From c2e4b96f8562ed361a4591d19bbd1dd0d5417d1a Mon Sep 17 00:00:00 2001 From: younes127001 <37003408+younes127001@users.noreply.github.com> Date: Thu, 6 Feb 2025 02:28:51 +0100 Subject: [PATCH 1/2] Add support for including custom nodes via environment variable --- main.py | 12 ++++++++++++ nodes.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/main.py b/main.py index f6510c90a..0da854e0d 100644 --- a/main.py +++ b/main.py @@ -69,6 +69,13 @@ def execute_prestartup_script(): if args.disable_all_custom_nodes: return + # Get the environment variable and convert it to a list (if not empty) + included_custom_nodes = os.environ.get("INCLUDED_CUSTOM_NODES", "").strip() + included_custom_nodes = ( + [name.strip() for name in included_custom_nodes.split(",")] + if included_custom_nodes else None + ) + 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 +86,11 @@ def execute_prestartup_script(): if os.path.isfile(module_path) or module_path.endswith(".disabled") or module_path == "__pycache__": continue + # Skip modules that are not in INCLUDED_CUSTOM_NODES + if included_custom_nodes and possible_module not in included_custom_nodes: + logging.debug(f"Skipping {possible_module} (not in INCLUDED_CUSTOM_NODES)") + continue + script_path = os.path.join(module_path, "prestartup_script.py") if os.path.exists(script_path): time_before = time.perf_counter() diff --git a/nodes.py b/nodes.py index ba9c4e4bb..f0316463b 100644 --- a/nodes.py +++ b/nodes.py @@ -2144,6 +2144,13 @@ def init_external_custom_nodes(): Returns: None """ + # Get the environment variable and convert it to a list (if not empty) + included_custom_nodes = os.environ.get("INCLUDED_CUSTOM_NODES", "").strip() + included_custom_nodes = ( + [name.strip() for name in included_custom_nodes.split(",")] + if included_custom_nodes else None + ) + base_node_names = set(NODE_CLASS_MAPPINGS.keys()) node_paths = folder_paths.get_folder_paths("custom_nodes") node_import_times = [] @@ -2153,6 +2160,11 @@ def init_external_custom_nodes(): possible_modules.remove("__pycache__") for possible_module in possible_modules: + # Skip modules that are not in INCLUDED_CUSTOM_NODES + if included_custom_nodes and possible_module not in included_custom_nodes: + logging.debug(f"Skipping {possible_module} (not in INCLUDED_CUSTOM_NODES)") + continue + 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 From 9b608b6f92a833e130df18725daf8435a04de7b5 Mon Sep 17 00:00:00 2001 From: younes127001 <37003408+younes127001@users.noreply.github.com> Date: Thu, 6 Feb 2025 02:51:46 +0100 Subject: [PATCH 2/2] Remove debug logging for skipped custom nodes in prestartup script execution --- main.py | 1 - nodes.py | 1 - 2 files changed, 2 deletions(-) diff --git a/main.py b/main.py index 0da854e0d..23faa980b 100644 --- a/main.py +++ b/main.py @@ -88,7 +88,6 @@ def execute_prestartup_script(): # Skip modules that are not in INCLUDED_CUSTOM_NODES if included_custom_nodes and possible_module not in included_custom_nodes: - logging.debug(f"Skipping {possible_module} (not in INCLUDED_CUSTOM_NODES)") continue script_path = os.path.join(module_path, "prestartup_script.py") diff --git a/nodes.py b/nodes.py index f0316463b..9e84aa736 100644 --- a/nodes.py +++ b/nodes.py @@ -2162,7 +2162,6 @@ def init_external_custom_nodes(): for possible_module in possible_modules: # Skip modules that are not in INCLUDED_CUSTOM_NODES if included_custom_nodes and possible_module not in included_custom_nodes: - logging.debug(f"Skipping {possible_module} (not in INCLUDED_CUSTOM_NODES)") continue module_path = os.path.join(custom_node_path, possible_module)