mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-03 11:07:06 +08:00
allow loading V1 and V3 nodes from the same module
This commit is contained in:
parent
aff5271291
commit
f11f097ade
15
nodes.py
15
nodes.py
@ -26,7 +26,7 @@ import comfy.sd
|
|||||||
import comfy.utils
|
import comfy.utils
|
||||||
import comfy.controlnet
|
import comfy.controlnet
|
||||||
from comfy.comfy_types import IO, ComfyNodeABC, InputTypeDict, FileLocator
|
from comfy.comfy_types import IO, ComfyNodeABC, InputTypeDict, FileLocator
|
||||||
from comfy_api.v3.io import ComfyNodeV3
|
from comfy_api.v3 import io
|
||||||
|
|
||||||
import comfy.clip_vision
|
import comfy.clip_vision
|
||||||
|
|
||||||
@ -2151,6 +2151,7 @@ def load_custom_node(module_path: str, ignore=set(), module_parent="custom_nodes
|
|||||||
EXTENSION_WEB_DIRS[module_name] = web_dir
|
EXTENSION_WEB_DIRS[module_name] = web_dir
|
||||||
|
|
||||||
# V1 node definition
|
# V1 node definition
|
||||||
|
v = False
|
||||||
if hasattr(module, "NODE_CLASS_MAPPINGS") and getattr(module, "NODE_CLASS_MAPPINGS") is not None:
|
if hasattr(module, "NODE_CLASS_MAPPINGS") and getattr(module, "NODE_CLASS_MAPPINGS") is not None:
|
||||||
for name, node_cls in module.NODE_CLASS_MAPPINGS.items():
|
for name, node_cls in module.NODE_CLASS_MAPPINGS.items():
|
||||||
if name not in ignore:
|
if name not in ignore:
|
||||||
@ -2158,21 +2159,21 @@ def load_custom_node(module_path: str, ignore=set(), module_parent="custom_nodes
|
|||||||
node_cls.RELATIVE_PYTHON_MODULE = "{}.{}".format(module_parent, get_module_name(module_path))
|
node_cls.RELATIVE_PYTHON_MODULE = "{}.{}".format(module_parent, get_module_name(module_path))
|
||||||
if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS") and getattr(module, "NODE_DISPLAY_NAME_MAPPINGS") is not None:
|
if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS") and getattr(module, "NODE_DISPLAY_NAME_MAPPINGS") is not None:
|
||||||
NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
|
NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
|
||||||
return True
|
v = True
|
||||||
# V3 node definition
|
# V3 node definition
|
||||||
elif getattr(module, "NODES_LIST", None) is not None:
|
if getattr(module, "NODES_LIST", None) is not None:
|
||||||
for node_cls in module.NODES_LIST:
|
for node_cls in module.NODES_LIST:
|
||||||
node_cls: ComfyNodeV3
|
node_cls: io.ComfyNodeV3
|
||||||
schema = node_cls.GET_SCHEMA()
|
schema = node_cls.GET_SCHEMA()
|
||||||
if schema.node_id not in ignore:
|
if schema.node_id not in ignore:
|
||||||
NODE_CLASS_MAPPINGS[schema.node_id] = node_cls
|
NODE_CLASS_MAPPINGS[schema.node_id] = node_cls
|
||||||
node_cls.RELATIVE_PYTHON_MODULE = "{}.{}".format(module_parent, get_module_name(module_path))
|
node_cls.RELATIVE_PYTHON_MODULE = "{}.{}".format(module_parent, get_module_name(module_path))
|
||||||
if schema.display_name is not None:
|
if schema.display_name is not None:
|
||||||
NODE_DISPLAY_NAME_MAPPINGS[schema.node_id] = schema.display_name
|
NODE_DISPLAY_NAME_MAPPINGS[schema.node_id] = schema.display_name
|
||||||
return True
|
v = True
|
||||||
else:
|
if not v:
|
||||||
logging.warning(f"Skip {module_path} module for custom nodes due to the lack of NODE_CLASS_MAPPINGS or NODES_LIST (need one).")
|
logging.warning(f"Skip {module_path} module for custom nodes due to the lack of NODE_CLASS_MAPPINGS or NODES_LIST (need one).")
|
||||||
return False
|
return v
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(traceback.format_exc())
|
logging.warning(traceback.format_exc())
|
||||||
logging.warning(f"Cannot import {module_path} module for custom nodes: {e}")
|
logging.warning(f"Cannot import {module_path} module for custom nodes: {e}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user