From efe4656caa0c6a8ab9048644303b4d64e8c0ad20 Mon Sep 17 00:00:00 2001 From: TSC <112517630+LucianoCirino@users.noreply.github.com> Date: Sat, 9 Sep 2023 11:49:23 -0500 Subject: [PATCH 1/2] Change how Web Extensions are Loaded This change comes from changes made to ComfyUI from commmit https://github.com/comfyanonymous/ComfyUI/pull/1273 --- __init__.py | 6 +++--- tsc_utils.py | 29 ++++++----------------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/__init__.py b/__init__.py index d8edad8..806f466 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,3 @@ -from .efficiency_nodes import NODE_CLASS_MAPPINGS - -__all__ = ['NODE_CLASS_MAPPINGS'] +from .efficiency_nodes import NODE_CLASS_MAPPINGS +WEB_DIRECTORY = "js" +__all__ = ['NODE_CLASS_MAPPINGS'] diff --git a/tsc_utils.py b/tsc_utils.py index 7d62f10..74e364f 100644 --- a/tsc_utils.py +++ b/tsc_utils.py @@ -521,33 +521,16 @@ def packages(python_exe=None, versions=False): install_packages(my_dir) #----------------------------------------------------------------------------------------------------------------------- -# Auto install efficiency nodes web extensions '\js\' to 'ComfyUI\web\extensions' +# Delete efficiency nodes web extensions from 'ComfyUI\web\extensions'. +# PR from https://github.com/comfyanonymous/ComfyUI/pull/1273 now allows defining web extensions through a dir path in import shutil -# Source and destination directories -source_dir = os.path.join(my_dir, 'js') +# Destination directory destination_dir = os.path.join(comfy_dir, 'web', 'extensions', 'efficiency-nodes-comfyui') -# Create the destination directory if it doesn't exist -os.makedirs(destination_dir, exist_ok=True) - -# Get a list of all .js files in the source directory -source_files = [f for f in os.listdir(source_dir) if f.endswith('.js')] - -# Clear files in the destination directory that aren't in the source directory -for file_name in os.listdir(destination_dir): - if file_name not in source_files and file_name.endswith('.js'): - file_path = os.path.join(destination_dir, file_name) - os.unlink(file_path) - -# Iterate over all files in the source directory for copying -for file_name in source_files: - # Full paths for source and destination - source_path = os.path.join(source_dir, file_name) - destination_path = os.path.join(destination_dir, file_name) - - # Directly copy the file (this will overwrite if the file already exists) - shutil.copy2(source_path, destination_path) +# Check if the directory exists and delete it +if os.path.exists(destination_dir): + shutil.rmtree(destination_dir) #----------------------------------------------------------------------------------------------------------------------- # Establish a websocket connection to communicate with "efficiency-nodes.js" under: From 8429544192a1ec65aaea5a760895c4283fed661d Mon Sep 17 00:00:00 2001 From: TSC <112517630+LucianoCirino@users.noreply.github.com> Date: Sat, 9 Sep 2023 11:51:12 -0500 Subject: [PATCH 2/2] Update tsc_utils.py --- tsc_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsc_utils.py b/tsc_utils.py index 74e364f..5eec0f4 100644 --- a/tsc_utils.py +++ b/tsc_utils.py @@ -522,7 +522,7 @@ install_packages(my_dir) #----------------------------------------------------------------------------------------------------------------------- # Delete efficiency nodes web extensions from 'ComfyUI\web\extensions'. -# PR from https://github.com/comfyanonymous/ComfyUI/pull/1273 now allows defining web extensions through a dir path in +# Pull https://github.com/comfyanonymous/ComfyUI/pull/1273 now allows defining web extensions through a dir path in init import shutil # Destination directory