From 3dcf04e32425fdd83d4ee5a3cc2f2b8681bba248 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sun, 23 Jul 2023 13:02:00 +0900 Subject: [PATCH] support disable.py/enable.py scripts --- README.md | 30 +++++++++----- __init__.py | 11 ++++- custom-node-list.json | 2 +- extension-node-map.json | 90 ++++++++++++++++++++--------------------- prestartup_script.py | 11 +++-- 5 files changed, 82 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 1aa3f84..800256a 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ You can execute ComfyUI by running either `./run_gpu.sh` or `./run_cpu.sh` depen * Please submit a pull request to update either the custom-node-list.json or model-list.json file. * The scanner currently provides a detection function for missing nodes, which is capable of detecting nodes described by the following two patterns. + * Or you can provide manually `node_list.js` file. ``` NODE_CLASS_MAPPINGS = { @@ -88,6 +89,16 @@ NODE_CLASS_MAPPINGS.update({ }) ``` +* **Special purpose files** (optional) + * `node_list.js` - When your custom nodes pattern of NODE_CLASS_MAPPINGS is not conventional, it is used to manually provide a list of nodes for reference. ([example](https://github.com/melMass/comfy_mtb/raw/main/node_list.json)) + * `requirements.txt` - When installing, this pip requirements will be installed automatically + * `install.py` - When installing, it is automatically called + * `uninstall.py` - When uninstalling, it is automatically called + * `disable.py` - When disabled, it is automatically called + * When installing a custom node setup `.js` file, it is recommended to write this script for disabling. + * `enable.py` - When enabled, it is automatically called + + # Support of missing nodes installation ![missing-menu](misc/missing-menu.png) @@ -115,15 +126,16 @@ NODE_CLASS_MAPPINGS.update({ # Roadmap -* installation from git url -* 3rd party repository -* category/keyword filter -* Specification of custom nodes -* Specification scanner -* Search extension by node name -* Automatic recognition of missing custom nodes -* Automatic installation suggestion of missing custom nodes -* workflow downloader +- [x] category/keyword filter +- [x] Automatic recognition of missing custom nodes +- [x] Automatic installation suggestion of missing custom nodes +- [ ] installation from git url +- [ ] 3rd party repository +- [ ] Specification of custom nodes +- [ ] Specification scanner +- [ ] Search extension by node name +- [ ] workflow downloader + # Disclaimer diff --git a/__init__.py b/__init__.py index 0099418..8cc1173 100644 --- a/__init__.py +++ b/__init__.py @@ -32,7 +32,7 @@ sys.path.append('../..') from torchvision.datasets.utils import download_url # ensure .js -print("### Loading: ComfyUI-Manager (V0.13)") +print("### Loading: ComfyUI-Manager (V0.14)") comfy_ui_revision = "Unknown" @@ -656,6 +656,15 @@ def gitclone_set_active(files, is_disable): os.rename(current_path, new_path) + if is_disable: + if os.path.exists(os.path.join(new_path, "disable.py")): + disable_script = [sys.executable, "disable.py"] + try_install_script(url, new_path, disable_script) + else: + if os.path.exists(os.path.join(new_path, "enable.py")): + enable_script = [sys.executable, "enable.py"] + try_install_script(url, new_path, enable_script) + except Exception as e: print(f"{action_name}(git-clone) error: {url} / {e}") return False diff --git a/custom-node-list.json b/custom-node-list.json index 05ce0b2..e3ee2ed 100644 --- a/custom-node-list.json +++ b/custom-node-list.json @@ -756,7 +756,7 @@ "https://github.com/ArtVentureX/comfyui-animatediff" ], "install_type": "git-clone", - "description": "AnimateDiff integration for ComfyUI, adapts from sd-webui-animatediff." + "description": "AnimateDiff integration for ComfyUI, adapts from sd-webui-animatediff.

You only need to download one of mm_sd_v14.ckpt | mm_sd_v15.ckpt. Put the model weights under comfyui-animatediff/models/. DO NOT change model filename.

" }, { "author": "twri", diff --git a/extension-node-map.json b/extension-node-map.json index ae5e3c4..6d79078 100644 --- a/extension-node-map.json +++ b/extension-node-map.json @@ -725,51 +725,51 @@ "Swap Color Mode" ], "https://github.com/evanspearman/ComfyMath": [ - "BreakoutVec2", - "BreakoutVec3", - "BreakoutVec4", - "ComposeVec2", - "ComposeVec3", - "ComposeVec4", - "FloatToInt", - "FloatToNumber", - "IntToFloat", - "IntToNumber", - "NumberToFloat", - "NumberToInt", - "Vec2Add", - "Vec2Cross", - "Vec2Distance", - "Vec2Dot", - "Vec2Eq", - "Vec2Ne", - "Vec2Neg", - "Vec2Norm", - "Vec2Normalize", - "Vec2ScalarMul", - "Vec2Sub", - "Vec3Add", - "Vec3Cross", - "Vec3Distance", - "Vec3Dot", - "Vec3Eq", - "Vec3Ne", - "Vec3Neg", - "Vec3Norm", - "Vec3Normalize", - "Vec3ScalarMul", - "Vec3Sub", - "Vec4Add", - "Vec4Cross", - "Vec4Distance", - "Vec4Dot", - "Vec4Eq", - "Vec4Ne", - "Vec4Neg", - "Vec4Norm", - "Vec4Normalize", - "Vec4ScalarMul", - "Vec4Sub" + "CM_BreakoutVec2", + "CM_BreakoutVec3", + "CM_BreakoutVec4", + "CM_ComposeVec2", + "CM_ComposeVec3", + "CM_ComposeVec4", + "CM_FloatBinaryCondition", + "CM_FloatBinaryOperation", + "CM_FloatToInt", + "CM_FloatToNumber", + "CM_FloatUnaryCondition", + "CM_FloatUnaryOperation", + "CM_IntBinaryCondition", + "CM_IntBinaryOperation", + "CM_IntToFloat", + "CM_IntToNumber", + "CM_IntUnaryCondition", + "CM_IntUnaryOperation", + "CM_NumberBinaryCondition", + "CM_NumberBinaryOperation", + "CM_NumberToFloat", + "CM_NumberToInt", + "CM_NumberUnaryCondition", + "CM_NumberUnaryOperation", + "CM_Vec2BinaryCondition", + "CM_Vec2BinaryOperation", + "CM_Vec2ScalarOperation", + "CM_Vec2ToScalarBinaryOperation", + "CM_Vec2ToScalarUnaryOperation", + "CM_Vec2UnaryCondition", + "CM_Vec2UnaryOperation", + "CM_Vec3BinaryCondition", + "CM_Vec3BinaryOperation", + "CM_Vec3ScalarOperation", + "CM_Vec3ToScalarBinaryOperation", + "CM_Vec3ToScalarUnaryOperation", + "CM_Vec3UnaryCondition", + "CM_Vec3UnaryOperation", + "CM_Vec4BinaryCondition", + "CM_Vec4BinaryOperation", + "CM_Vec4ScalarOperation", + "CM_Vec4ToScalarBinaryOperation", + "CM_Vec4ToScalarUnaryOperation", + "CM_Vec4UnaryCondition", + "CM_Vec4UnaryOperation" ], "https://github.com/filipemeneses/comfy_pixelization": [ "Pixelization" diff --git a/prestartup_script.py b/prestartup_script.py index 13b32c6..7f4dcc4 100644 --- a/prestartup_script.py +++ b/prestartup_script.py @@ -6,7 +6,7 @@ script_list_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "st # Check if script_list_path exists if os.path.exists(script_list_path): print("\n#######################################################################") - print("[ComfyUI-Manager] Starting dependency installation for the extension\n") + print("[ComfyUI-Manager] Starting dependency installation/(de)activation for the extension\n") executed = set() # Read each line from the file and convert it to a list using eval @@ -19,19 +19,18 @@ if os.path.exists(script_list_path): try: script = eval(line) - print(f"\n## Install dependency for '{script[0]}'") + print(f"\n## Execute install/(de)activation script for '{script[0]}'") code = subprocess.run(script[1:], cwd=script[0]) if code.returncode != 0: - print(f"install script failed: {script[0]}") + print(f"install/(de)activation script failed: {script[0]}") except Exception as e: - print(f"[ERROR] Failed to install: {line} / {e}") - + print(f"[ERROR] Failed to execute install/(de)activation script: {line} / {e}") # Remove the script_list_path file if os.path.exists(script_list_path): os.remove(script_list_path) - print("\n[ComfyUI-Manager] Dependency installation completed.") + print("\n[ComfyUI-Manager] Startup script completed.") print("#######################################################################\n")