From 6897a1d077e06e8147e55932fc880a5cd6ef8f13 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Wed, 19 Mar 2025 22:24:04 +0900 Subject: [PATCH 1/8] support pip comfyui-manager --- main.py | 4 ++++ nodes.py | 1 + 2 files changed, 5 insertions(+) diff --git a/main.py b/main.py index 1b100fa8a..16a13cf97 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ from app.logger import setup_logger import itertools import utils.extra_config import logging +import comfyui_manager if __name__ == "__main__": #NOTE: These do not do anything on core ComfyUI which should already have no communication with the internet, they are for custom nodes. @@ -69,6 +70,8 @@ def execute_prestartup_script(): if args.disable_all_custom_nodes: return + comfyui_manager.prestartup() + node_paths = folder_paths.get_folder_paths("custom_nodes") for custom_node_path in node_paths: possible_modules = os.listdir(custom_node_path) @@ -261,6 +264,7 @@ def start_comfyui(asyncio_loop=None): prompt_server = server.PromptServer(asyncio_loop) q = execution.PromptQueue(prompt_server) + comfyui_manager.start() nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes) cuda_malloc_warning() diff --git a/nodes.py b/nodes.py index 71d1b8dd7..c06269525 100644 --- a/nodes.py +++ b/nodes.py @@ -37,6 +37,7 @@ import importlib import folder_paths import latent_preview import node_helpers +import comfyui_manager def before_node_execution(): comfy.model_management.throw_exception_if_processing_interrupted() From fb1b9c76b02442f89e97302499b627d122ffd1c4 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Thu, 10 Apr 2025 08:40:53 +0900 Subject: [PATCH 2/8] added: --disable-manager option --- comfy/cli_args.py | 1 + main.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/comfy/cli_args.py b/comfy/cli_args.py index 62079e6a7..52930652b 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -49,6 +49,7 @@ parser.add_argument("--temp-directory", type=str, default=None, help="Set the Co parser.add_argument("--input-directory", type=str, default=None, help="Set the ComfyUI input directory. Overrides --base-directory.") parser.add_argument("--auto-launch", action="store_true", help="Automatically launch ComfyUI in the default browser.") parser.add_argument("--disable-auto-launch", action="store_true", help="Disable auto launching the browser.") +parser.add_argument("--disable-manager", action="store_true", help="Disable ComfyUI-Manager feature.") parser.add_argument("--cuda-device", type=int, default=None, metavar="DEVICE_ID", help="Set the id of the cuda device this instance will use.") cm_group = parser.add_mutually_exclusive_group() cm_group.add_argument("--cuda-malloc", action="store_true", help="Enable cudaMallocAsync (enabled by default for torch 2.0 and up).") diff --git a/main.py b/main.py index 16a13cf97..3ab31f414 100644 --- a/main.py +++ b/main.py @@ -264,7 +264,9 @@ def start_comfyui(asyncio_loop=None): prompt_server = server.PromptServer(asyncio_loop) q = execution.PromptQueue(prompt_server) - comfyui_manager.start() + if not args.disable_manager: + comfyui_manager.start() + nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes) cuda_malloc_warning() From 8b9f31abdfed38b199db9ff9bcc33b55fb6d5958 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Thu, 10 Apr 2025 12:10:24 +0900 Subject: [PATCH 3/8] fixed: ruff check --- nodes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nodes.py b/nodes.py index 0b62a9f70..f63e8cb5e 100644 --- a/nodes.py +++ b/nodes.py @@ -37,7 +37,6 @@ import importlib import folder_paths import latent_preview import node_helpers -import comfyui_manager def before_node_execution(): comfy.model_management.throw_exception_if_processing_interrupted() From cc975e5f0b141fac0e3548d058d36260183a7814 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 12 Apr 2025 19:11:02 +0900 Subject: [PATCH 4/8] add comfyui_manager to requirements.txt It's still in the development stage, so the version is not pinned yet. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 851db23bd..310ab57ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ comfyui-frontend-package==1.15.13 +comfyui_manager torch torchsde torchvision From 418eaed42ca2d30d5e0c657f9c27b0b7c62f0b28 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 12 Apr 2025 20:55:27 +0900 Subject: [PATCH 5/8] fixed: Ensure that `comfyui_manager`'s prestartup always runs, even when `--disable-all-custom-nodes` is used. feat: Disable specific custom nodes according to the policy of `comfyui_manager`. --- main.py | 7 +++++-- nodes.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 7ca04f4b1..ff582ff22 100644 --- a/main.py +++ b/main.py @@ -70,8 +70,6 @@ def execute_prestartup_script(): if args.disable_all_custom_nodes: return - comfyui_manager.prestartup() - node_paths = folder_paths.get_folder_paths("custom_nodes") for custom_node_path in node_paths: possible_modules = os.listdir(custom_node_path) @@ -79,6 +77,10 @@ def execute_prestartup_script(): for possible_module in possible_modules: module_path = os.path.join(custom_node_path, possible_module) + + if comfyui_manager.should_be_disabled(module_path): + continue + if os.path.isfile(module_path) or module_path.endswith(".disabled") or module_path == "__pycache__": continue @@ -98,6 +100,7 @@ def execute_prestartup_script(): logging.info("") apply_custom_paths() +comfyui_manager.prestartup() execute_prestartup_script() diff --git a/nodes.py b/nodes.py index 8c1720c1a..5b8077ab7 100644 --- a/nodes.py +++ b/nodes.py @@ -37,6 +37,7 @@ import importlib import folder_paths import latent_preview import node_helpers +import comfyui_manager def before_node_execution(): comfy.model_management.throw_exception_if_processing_interrupted() @@ -2196,6 +2197,10 @@ def init_external_custom_nodes(): module_path = os.path.join(custom_node_path, possible_module) if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue if module_path.endswith(".disabled"): continue + if comfyui_manager.should_be_disabled(module_path): + logging.info(f"Blocked by policy: {module_path}") + continue + time_before = time.perf_counter() success = load_custom_node(module_path, base_node_names, module_parent="custom_nodes") node_import_times.append((time.perf_counter() - time_before, module_path, success)) From 94f61c63788f144d8c86db2d72aa22c6742e79d7 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Tue, 15 Apr 2025 01:36:17 +0900 Subject: [PATCH 6/8] add --enable-manager-legacy-ui --- comfy/cli_args.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/comfy/cli_args.py b/comfy/cli_args.py index 771fc1655..87b9a87b4 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -49,7 +49,6 @@ parser.add_argument("--temp-directory", type=str, default=None, help="Set the Co parser.add_argument("--input-directory", type=str, default=None, help="Set the ComfyUI input directory. Overrides --base-directory.") parser.add_argument("--auto-launch", action="store_true", help="Automatically launch ComfyUI in the default browser.") parser.add_argument("--disable-auto-launch", action="store_true", help="Disable auto launching the browser.") -parser.add_argument("--disable-manager", action="store_true", help="Disable ComfyUI-Manager feature.") parser.add_argument("--cuda-device", type=int, default=None, metavar="DEVICE_ID", help="Set the id of the cuda device this instance will use.") cm_group = parser.add_mutually_exclusive_group() cm_group.add_argument("--cuda-malloc", action="store_true", help="Enable cudaMallocAsync (enabled by default for torch 2.0 and up).") @@ -118,6 +117,11 @@ upcast.add_argument("--force-upcast-attention", action="store_true", help="Force upcast.add_argument("--dont-upcast-attention", action="store_true", help="Disable all upcasting of attention. Should be unnecessary except for debugging.") +manager_group = parser.add_mutually_exclusive_group() +manager_group.add_argument("--disable-manager", action="store_true", help="Disable ComfyUI-Manager feature.") +manager_group.add_argument("--enable-manager-legacy-ui", action="store_true", help="Enables the legacy UI of ComfyUI-Manager") + + vram_group = parser.add_mutually_exclusive_group() vram_group.add_argument("--gpu-only", action="store_true", help="Store and run everything (text encoders/CLIP models, etc... on the GPU).") vram_group.add_argument("--highvram", action="store_true", help="By default models will be unloaded to CPU memory after being used. This option keeps them in GPU memory.") @@ -152,6 +156,7 @@ parser.add_argument("--multi-user", action="store_true", help="Enables per-user parser.add_argument("--verbose", default='INFO', const='DEBUG', nargs="?", choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Set the logging level') parser.add_argument("--log-stdout", action="store_true", help="Send normal process output to stdout instead of stderr (default).") + # The default built-in provider hosted under web/ DEFAULT_VERSION_STRING = "comfyanonymous/ComfyUI@latest" From 57dae1469fbad2fdc2b44fd73739461886e9b7c3 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Mon, 28 Apr 2025 17:56:50 +0900 Subject: [PATCH 7/8] modified: --disable-manager will prevent importing comfyui-manager feat: --disable-manager-ui will disable the endpoints and ui of comfyui-manager --- comfy/cli_args.py | 3 ++- main.py | 16 +++++++++++----- nodes.py | 12 ++++++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/comfy/cli_args.py b/comfy/cli_args.py index 68c7285ee..af5016e64 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -119,7 +119,8 @@ upcast.add_argument("--dont-upcast-attention", action="store_true", help="Disabl manager_group = parser.add_mutually_exclusive_group() -manager_group.add_argument("--disable-manager", action="store_true", help="Disable ComfyUI-Manager feature.") +manager_group.add_argument("--disable-manager", action="store_true", help="Completely disable the ComfyUI-Manager feature.") +manager_group.add_argument("--disable-manager-ui", action="store_true", help="Disables only the ComfyUI-Manager UI and endpoints. Scheduled installations and similar background tasks will still operate.") manager_group.add_argument("--enable-manager-legacy-ui", action="store_true", help="Enables the legacy UI of ComfyUI-Manager") diff --git a/main.py b/main.py index 295d0f4e2..c1bfdaf57 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,9 @@ import itertools import utils.extra_config import logging import sys -import comfyui_manager + +if not args.disable_manager: + import comfyui_manager if __name__ == "__main__": #NOTE: These do not do anything on core ComfyUI which should already have no communication with the internet, they are for custom nodes. @@ -79,8 +81,9 @@ def execute_prestartup_script(): for possible_module in possible_modules: module_path = os.path.join(custom_node_path, possible_module) - if comfyui_manager.should_be_disabled(module_path): - continue + if not args.disable_manager: + if comfyui_manager.should_be_disabled(module_path): + continue if os.path.isfile(module_path) or module_path.endswith(".disabled") or module_path == "__pycache__": continue @@ -101,7 +104,10 @@ def execute_prestartup_script(): logging.info("") apply_custom_paths() -comfyui_manager.prestartup() + +if not args.disable_manager: + comfyui_manager.prestartup() + execute_prestartup_script() @@ -274,7 +280,7 @@ def start_comfyui(asyncio_loop=None): prompt_server = server.PromptServer(asyncio_loop) q = execution.PromptQueue(prompt_server) - if not args.disable_manager: + if not args.disable_manager and not args.disable_manager_ui: comfyui_manager.start() nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes) diff --git a/nodes.py b/nodes.py index f7bd54e46..188c67d16 100644 --- a/nodes.py +++ b/nodes.py @@ -37,7 +37,9 @@ import importlib import folder_paths import latent_preview import node_helpers -import comfyui_manager + +if not args.disable_manager: + import comfyui_manager def before_node_execution(): comfy.model_management.throw_exception_if_processing_interrupted() @@ -2173,9 +2175,11 @@ def init_external_custom_nodes(): module_path = os.path.join(custom_node_path, possible_module) if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue if module_path.endswith(".disabled"): continue - if comfyui_manager.should_be_disabled(module_path): - logging.info(f"Blocked by policy: {module_path}") - continue + + if not args.disable_manager: + if comfyui_manager.should_be_disabled(module_path): + logging.info(f"Blocked by policy: {module_path}") + continue time_before = time.perf_counter() success = load_custom_node(module_path, base_node_names, module_parent="custom_nodes") From 17cfabec7dd103ad9b56b508c393e36d8138f729 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Tue, 1 Jul 2025 12:55:53 +0900 Subject: [PATCH 8/8] added: Apply manager middleware --- server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server.py b/server.py index 878b5eeb1..993d52daf 100644 --- a/server.py +++ b/server.py @@ -36,6 +36,9 @@ from app.custom_node_manager import CustomNodeManager from typing import Optional, Union from api_server.routes.internal.internal_routes import InternalRoutes +if not args.disable_manager: + import comfyui_manager + class BinaryEventTypes: PREVIEW_IMAGE = 1 UNENCODED_PREVIEW_IMAGE = 2 @@ -175,6 +178,9 @@ class PromptServer(): else: middlewares.append(create_origin_only_middleware()) + if not args.disable_manager: + middlewares.append(comfyui_manager.create_middleware()) + max_upload_size = round(args.max_upload_size * 1024 * 1024) self.app = web.Application(client_max_size=max_upload_size, middlewares=middlewares) self.sockets = dict()