From 094e9ef126fb60a6f5eeb7e1e30669b9328e7349 Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Tue, 6 May 2025 01:53:53 -0700 Subject: [PATCH] Add a way to disable api nodes: --disable-api-nodes (#7960) --- comfy/cli_args.py | 1 + main.py | 2 +- nodes.py | 30 +++++++++++++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/comfy/cli_args.py b/comfy/cli_args.py index ef5ab627..97b348f0 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -148,6 +148,7 @@ parser.add_argument("--windows-standalone-build", action="store_true", help="Win parser.add_argument("--disable-metadata", action="store_true", help="Disable saving prompt metadata in files.") parser.add_argument("--disable-all-custom-nodes", action="store_true", help="Disable loading all custom nodes.") +parser.add_argument("--disable-api-nodes", action="store_true", help="Disable loading all api nodes.") parser.add_argument("--multi-user", action="store_true", help="Enables per-user storage.") diff --git a/main.py b/main.py index 5c21542b..221e48e4 100644 --- a/main.py +++ b/main.py @@ -270,7 +270,7 @@ def start_comfyui(asyncio_loop=None): q = execution.PromptQueue(prompt_server) hook_breaker_ac10a0.save_functions() - nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes) + nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes, init_api_nodes=not args.disable_api_nodes) hook_breaker_ac10a0.restore_functions() cuda_malloc_warning() diff --git a/nodes.py b/nodes.py index d31e0774..3c361756 100644 --- a/nodes.py +++ b/nodes.py @@ -2261,6 +2261,15 @@ def init_builtin_extra_nodes(): "nodes_preview_any.py", ] + import_failed = [] + for node_file in extras_files: + if not load_custom_node(os.path.join(extras_dir, node_file), module_parent="comfy_extras"): + import_failed.append(node_file) + + return import_failed + + +def init_builtin_api_nodes(): api_nodes_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy_api_nodes") api_nodes_files = [ "nodes_ideogram.py", @@ -2277,10 +2286,6 @@ def init_builtin_extra_nodes(): ] import_failed = [] - for node_file in extras_files: - if not load_custom_node(os.path.join(extras_dir, node_file), module_parent="comfy_extras"): - import_failed.append(node_file) - for node_file in api_nodes_files: if not load_custom_node(os.path.join(api_nodes_dir, node_file), module_parent="comfy_api_nodes"): import_failed.append(node_file) @@ -2288,14 +2293,29 @@ def init_builtin_extra_nodes(): return import_failed -def init_extra_nodes(init_custom_nodes=True): +def init_extra_nodes(init_custom_nodes=True, init_api_nodes=True): import_failed = init_builtin_extra_nodes() + import_failed_api = [] + if init_api_nodes: + import_failed_api = init_builtin_api_nodes() + if init_custom_nodes: init_external_custom_nodes() else: logging.info("Skipping loading of custom nodes") + if len(import_failed_api) > 0: + logging.warning("WARNING: some comfy_api_nodes/ nodes did not import correctly. This may be because they are missing some dependencies.\n") + for node in import_failed_api: + logging.warning("IMPORT FAILED: {}".format(node)) + logging.warning("\nThis issue might be caused by new missing dependencies added the last time you updated ComfyUI.") + if args.windows_standalone_build: + logging.warning("Please run the update script: update/update_comfyui.bat") + else: + logging.warning("Please do a: pip install -r requirements.txt") + logging.warning("") + if len(import_failed) > 0: logging.warning("WARNING: some comfy_extras/ nodes did not import correctly. This may be because they are missing some dependencies.\n") for node in import_failed: