Made V3 NODES_LIST work properly

This commit is contained in:
Jedrzej Kosinski 2025-05-31 15:32:11 -07:00
parent de86d8e32b
commit 8642757971
2 changed files with 13 additions and 11 deletions

View File

@ -20,7 +20,7 @@ class V3TestNode(ComfyNodeV3):
description="This is a funky V3 node test.", description="This is a funky V3 node test.",
category="v3 nodes", category="v3 nodes",
inputs=[ inputs=[
IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎"), IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display_mode=NumberDisplay.slider),
MaskInput("mask", behavior=InputBehavior.optional), MaskInput("mask", behavior=InputBehavior.optional),
ImageInput("image", display_name="new_image"), ImageInput("image", display_name="new_image"),
# IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider, ), # IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider, ),

View File

@ -2129,8 +2129,18 @@ def load_custom_node(module_path: str, ignore=set(), module_parent="custom_nodes
if os.path.isdir(web_dir): if os.path.isdir(web_dir):
EXTENSION_WEB_DIRS[module_name] = web_dir EXTENSION_WEB_DIRS[module_name] = web_dir
if getattr(module, "NODES_LIST", None) is not None: # V1 node definition
for node_cls in module.NODES: 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():
if name not in ignore:
NODE_CLASS_MAPPINGS[name] = node_cls
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:
NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
return True
# V3 node definition
elif getattr(module, "NODES_LIST", None) is not None:
for node_cls in module.NODES_LIST:
node_cls: ComfyNodeV3 node_cls: 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:
@ -2139,14 +2149,6 @@ def load_custom_node(module_path: str, ignore=set(), module_parent="custom_nodes
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 return True
elif hasattr(module, "NODE_CLASS_MAPPINGS") and getattr(module, "NODE_CLASS_MAPPINGS") is not None:
for name, node_cls in module.NODE_CLASS_MAPPINGS.items():
if name not in ignore:
NODE_CLASS_MAPPINGS[name] = node_cls
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:
NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
return True
else: else:
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 False