Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

“--whitelist-custom-nodes” args for comfy core to go with “--disable-all-custom-nodes” for development purposes (#8592)

xufengba9548f75637
diff --git a/comfy/cli_args.py b/comfy/cli_args.py
index 741ecac3f..7234a7ba0 100644
--- a/comfy/cli_args.py
+++ b/comfy/cli_args.py
@@ -151,6 +151,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("--whitelist-custom-nodes", type=str, nargs='+', default=[], help="Specify custom node folders to load even when --disable-all-custom-nodes is enabled.")
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 0d7c97dcb..5dd3c92d2 100644
--- a/main.py
+++ b/main.py
@@ -66,9 +66,6 @@ def execute_prestartup_script():
logging.error(f"Failed to execute startup-script: {script_path} / {e}")
return False
- if args.disable_all_custom_nodes:
- return
-
node_paths = folder_paths.get_folder_paths("custom_nodes")
for custom_node_path in node_paths:
possible_modules = os.listdir(custom_node_path)
@@ -81,6 +78,9 @@ def execute_prestartup_script():
script_path = os.path.join(module_path, "prestartup_script.py")
if os.path.exists(script_path):
+ if args.disable_all_custom_nodes and possible_module not in args.whitelist_custom_nodes:
+ logging.info(f"Prestartup Skipping {possible_module} due to disable_all_custom_nodes and whitelist_custom_nodes")
+ continue
time_before = time.perf_counter()
success = execute_script(script_path)
node_prestartup_times.append((time.perf_counter() - time_before, module_path, success))
@@ -276,7 +276,10 @@ def start_comfyui(asyncio_loop=None):
prompt_server = server.PromptServer(asyncio_loop)
hook_breaker_ac10a0.save_functions()
- nodes.init_extra_nodes(init_custom_nodes=not args.disable_all_custom_nodes, init_api_nodes=not args.disable_api_nodes)
+ nodes.init_extra_nodes(
+ init_custom_nodes=True,
+ 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 11aa50fce..99411a1fe 100644
--- a/nodes.py
+++ b/nodes.py
@@ -2187,6 +2187,9 @@ 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 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
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))