From 1fb1bad150167ab8111f02342f5b7f7c4913363e Mon Sep 17 00:00:00 2001 From: "kosinkadink1@gmail.com" Date: Wed, 4 Jun 2025 18:56:01 -0700 Subject: [PATCH] Some node changes to compare v1 and v3 --- comfy_api/v3/io.py | 2 +- comfy_extras/nodes_v1_test.py | 42 +++++++++++++++++++++++++++ comfy_extras/nodes_v3_test.py | 54 ++++++++++++++--------------------- nodes.py | 1 + 4 files changed, 66 insertions(+), 33 deletions(-) create mode 100644 comfy_extras/nodes_v1_test.py diff --git a/comfy_api/v3/io.py b/comfy_api/v3/io.py index 009ba51c0..0ab736891 100644 --- a/comfy_api/v3/io.py +++ b/comfy_api/v3/io.py @@ -17,7 +17,7 @@ class FolderType(str, Enum): temp = "temp" class RemoteOptions: - def __init__(self, route: str, refresh_button: bool, control_after_refresh: Literal["first", "last"]=None, + def __init__(self, route: str, refresh_button: bool, control_after_refresh: Literal["first", "last"]="first", timeout: int=None, max_retries: int=None, refresh: int=None): self.route = route """The route to the remote source.""" diff --git a/comfy_extras/nodes_v1_test.py b/comfy_extras/nodes_v1_test.py new file mode 100644 index 000000000..5ef31a3b7 --- /dev/null +++ b/comfy_extras/nodes_v1_test.py @@ -0,0 +1,42 @@ +import torch +from comfy.comfy_types.node_typing import ComfyNodeABC, IO + + +class TestNode(ComfyNodeABC): + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "image": (IO.IMAGE,), + "xyz": ("XYZ",), + "some_int": (IO.INT, {"display_name": "new_name", + "min": 0, "max": 127, "default": 42, + "tooltip": "My tooltip 😎", "display": "slider"}), + "combo": (IO.COMBO, {"options": ["a", "b", "c"], "tooltip": "This is a combo input"}), + }, + "optional": { + "mask": (IO.MASK,), + } + } + + RETURN_TYPES = (IO.INT, IO.IMAGE) + RETURN_NAMES = ("INT", "img🖼️") + OUTPUT_TOOLTIPS = (None, "This is an image") + FUNCTION = "do_thing" + + OUTPUT_NODE = True + + CATEGORY = "v3 nodes" + + def do_thing(self, image: torch.Tensor, xyz, some_int: int, combo: str, mask: torch.Tensor=None): + return (some_int, image) + + +NODE_CLASS_MAPPINGS = { + "V1TestNode1": TestNode, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "V1TestNode1": "V1 Test Node", +} diff --git a/comfy_extras/nodes_v3_test.py b/comfy_extras/nodes_v3_test.py index dfc4b130d..0a0c83f57 100644 --- a/comfy_extras/nodes_v3_test.py +++ b/comfy_extras/nodes_v3_test.py @@ -1,35 +1,33 @@ import torch - from comfy_api.v3.io import ( - ComfyNodeV3, SchemaV3, CustomType, CustomInput, CustomOutput, InputBehavior, NumberDisplay, - IntegerInput, MaskInput, ImageInput, ComboInput, NodeOutput, FolderType, RemoteOptions + ComfyNodeV3, SchemaV3, InputBehavior, NumberDisplay, + IntegerInput, MaskInput, ImageInput, ComboInput, CustomInput, + IntegerOutput, ImageOutput, + NodeOutput, ) - - - class V3TestNode(ComfyNodeV3): - - @classmethod def DEFINE_SCHEMA(cls): return SchemaV3( node_id="V3TestNode1", - display_name="V3 Test Node (1djekjd)", + display_name="V3 Test Node", description="This is a funky V3 node test.", category="v3 nodes", inputs=[ - IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display_mode=NumberDisplay.slider), - MaskInput("mask", behavior=InputBehavior.optional), ImageInput("image", display_name="new_image"), - ComboInput("combo", image_upload=True, image_folder=FolderType.output, - remote=RemoteOptions( - route="/internal/files/output", - refresh_button=True, - ), - tooltip="This is a combo input"), - # ComboInput("combo", options=["a", "b", "c"], tooltip="This is a combo input"), + CustomInput("xyz", "XYZ"), + MaskInput("mask", behavior=InputBehavior.optional), + IntegerInput("some_int", display_name="new_name", min=0, max=127, default=42, + tooltip="My tooltip 😎", display_mode=NumberDisplay.slider), + ComboInput("combo", options=["a", "b", "c"], tooltip="This is a combo input"), + # ComboInput("combo", image_upload=True, image_folder=FolderType.output, + # remote=RemoteOptions( + # route="/internal/files/output", + # refresh_button=True, + # ), + # tooltip="This is a combo input"), # IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider, ), # ComboDynamicInput("mask", behavior=InputBehavior.optional), # IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider, @@ -41,23 +39,15 @@ class V3TestNode(ComfyNodeV3): # CombyDynamicOptons("option2", []) # ]] ], + outputs=[ + IntegerOutput("int_output"), + ImageOutput("img_output", display_name="img🖼️", tooltip="This is an image"), + ], is_output_node=True, ) - def execute(self, some_int: int, image: torch.Tensor, mask: torch.Tensor=None, **kwargs): - a = NodeOutput(1) - aa = NodeOutput(1, "hellothere") - ab = NodeOutput(1, "hellothere", ui={"lol": "jk"}) - b = NodeOutput() - c = NodeOutput(ui={"lol": "jk"}) - return NodeOutput() - return NodeOutput(1) - return NodeOutput(1, block_execution="Kill yourself") - return () - - - - + def execute(image: torch.Tensor, xyz, some_int: int, combo: str, mask: torch.Tensor=None): + return NodeOutput(some_int, image) NODES_LIST: list[ComfyNodeV3] = [ diff --git a/nodes.py b/nodes.py index df52a62f9..6f2a1f252 100644 --- a/nodes.py +++ b/nodes.py @@ -2273,6 +2273,7 @@ def init_builtin_extra_nodes(): "nodes_string.py", "nodes_camera_trajectory.py", "nodes_v3_test.py", + "nodes_v1_test.py", ] import_failed = []