diff --git a/comfy/cli_args.py b/comfy/cli_args.py index de3e85c08..2e140f767 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -120,6 +120,12 @@ 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="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") + + 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.") @@ -163,6 +169,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" diff --git a/main.py b/main.py index 9b2a33011..22590ecd7 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,13 @@ from comfy_execution.progress import get_progress_state from comfy_execution.utils import get_executing_context from comfy_api import feature_flags +if not args.disable_manager: + try: + import comfyui_manager + except Exception: + logging.warning(f"\n\nUnable to run comfyui-manager, disabling it. To enable comfyui-manager, run the following command:\ncommand:\n\t{sys.executable} -m pip install --pre comfyui_manager\n") + args.disable_manager = True + if __name__ == "__main__": #NOTE: These do not do anything on core ComfyUI, they are for custom nodes. os.environ['HF_HUB_DISABLE_TELEMETRY'] = '1' @@ -79,6 +86,11 @@ def execute_prestartup_script(): for possible_module in possible_modules: module_path = os.path.join(custom_node_path, possible_module) + + 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,6 +113,10 @@ def execute_prestartup_script(): logging.info("") apply_custom_paths() + +if not args.disable_manager: + comfyui_manager.prestartup() + execute_prestartup_script() @@ -312,6 +328,9 @@ def start_comfyui(asyncio_loop=None): asyncio.set_event_loop(asyncio_loop) prompt_server = server.PromptServer(asyncio_loop) + if not args.disable_manager and not args.disable_manager_ui: + comfyui_manager.start() + hook_breaker_ac10a0.save_functions() asyncio_loop.run_until_complete(nodes.init_extra_nodes( init_custom_nodes=(not args.disable_all_custom_nodes) or len(args.whitelist_custom_nodes) > 0, diff --git a/nodes.py b/nodes.py index 0aff6b14a..a295edc96 100644 --- a/nodes.py +++ b/nodes.py @@ -43,6 +43,9 @@ import folder_paths import latent_preview import node_helpers +if not args.disable_manager: + import comfyui_manager + def before_node_execution(): comfy.model_management.throw_exception_if_processing_interrupted() @@ -2226,6 +2229,12 @@ async def init_external_custom_nodes(): if args.disable_all_custom_nodes and possible_module not in args.whitelist_custom_nodes: logging.info(f"Skipping {possible_module} due to disable_all_custom_nodes and whitelist_custom_nodes") 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 = await load_custom_node(module_path, base_node_names, module_parent="custom_nodes") node_import_times.append((time.perf_counter() - time_before, module_path, success)) diff --git a/requirements.txt b/requirements.txt index 131484ce8..8cdcaa75c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ comfyui-frontend-package==1.25.10 comfyui-workflow-templates==0.1.65 comfyui-embedded-docs==0.2.6 +comfyui_manager==4.0.0b13 torch torchsde torchvision diff --git a/server.py b/server.py index 8f9c88ebf..3b52b0f76 100644 --- a/server.py +++ b/server.py @@ -39,6 +39,9 @@ from typing import Optional, Union from api_server.routes.internal.internal_routes import InternalRoutes from protocol import BinaryEventTypes +if not args.disable_manager: + import comfyui_manager + async def send_socket_catch_exception(function, message): try: await function(message) @@ -173,6 +176,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()