Add get_subgraphs_dir to ComfyExtension and PUBLISHED_SUBGRAPH_DIRS to nodes.py

This commit is contained in:
Jedrzej Kosinski 2025-10-16 22:38:18 -07:00
parent d8d60b5609
commit b73e0547ca
2 changed files with 12 additions and 0 deletions

View File

@ -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]]:
"""

View File

@ -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.")