From b73e0547ca20faa966972650b3321a3d0df573ca Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Thu, 16 Oct 2025 22:38:18 -0700 Subject: [PATCH] Add get_subgraphs_dir to ComfyExtension and PUBLISHED_SUBGRAPH_DIRS to nodes.py --- comfy_api/latest/__init__.py | 6 ++++++ nodes.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/comfy_api/latest/__init__.py b/comfy_api/latest/__init__.py index b7a3fa9c1..0e007045a 100644 --- a/comfy_api/latest/__init__.py +++ b/comfy_api/latest/__init__.py @@ -83,6 +83,12 @@ class ComfyExtension(ABC): This should be used to initialize any global resources neeeded by the extension. """ + async def get_subgraphs_dir(self) -> str | None: + """ + Returns the directory containing the published subgraphs for this extension. + """ + return None + @abstractmethod async def get_node_list(self) -> list[type[io.ComfyNode]]: """ diff --git a/nodes.py b/nodes.py index 7cfa8ca14..183a91896 100644 --- a/nodes.py +++ b/nodes.py @@ -2081,6 +2081,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { } EXTENSION_WEB_DIRS = {} +PUBLISHED_SUBGRAPH_DIRS = {} # Dictionary of successfully loaded module names and associated directories. LOADED_MODULE_DIRS = {} @@ -2179,6 +2180,11 @@ async def load_custom_node(module_path: str, ignore=set(), module_parent="custom if not isinstance(extension, ComfyExtension): logging.warning(f"comfy_entrypoint in {module_path} did not return a ComfyExtension, skipping.") return False + subgraphs_dir = await extension.get_subgraphs_dir() + if subgraphs_dir is not None: + subgraphs_dir = os.path.abspath(os.path.join(module_dir, subgraphs_dir)) + if os.path.isdir(subgraphs_dir): + PUBLISHED_SUBGRAPH_DIRS[module_name] = subgraphs_dir node_list = await extension.get_node_list() if not isinstance(node_list, list): logging.warning(f"comfy_entrypoint in {module_path} did not return a list of nodes, skipping.")