mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-09-14 13:35:05 +00:00
Refactored v3 code so that v3_01 becomes v3, v3_01 is deleted since no longer necessary
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
import torch
|
||||
from comfy_api.v3_01 import io
|
||||
import logging
|
||||
|
||||
|
||||
@io.comfytype(io_type="XYZ")
|
||||
class XYZ:
|
||||
Type = tuple[int,str]
|
||||
class Input(io.InputV3):
|
||||
...
|
||||
class Output(io.OutputV3):
|
||||
...
|
||||
|
||||
class MyState(io.NodeState):
|
||||
my_str: str
|
||||
my_int: int
|
||||
|
||||
|
||||
class V3TestNode(io.ComfyNodeV3):
|
||||
|
||||
state: MyState
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.hahajkunless = ";)"
|
||||
|
||||
@classmethod
|
||||
def DEFINE_SCHEMA(cls):
|
||||
return io.SchemaV3(
|
||||
node_id="V3_01_TestNode1",
|
||||
display_name="V3_01 Test Node",
|
||||
description="This is a funky V3_01 node test.",
|
||||
category="v3 nodes",
|
||||
inputs=[
|
||||
io.Image.Input("image", display_name="new_image"),
|
||||
XYZ.Input("xyz", optional=True),
|
||||
io.Custom("JKL").Input("jkl", optional=True),
|
||||
#JKL.Input("jkl", optional=True),
|
||||
#CustomInput("xyz", "XYZ", optional=True),
|
||||
io.Mask.Input("mask", optional=True),
|
||||
io.Int.Input("some_int", display_name="new_name", min=0, max=127, default=42,
|
||||
tooltip="My tooltip 😎", display_mode=io.NumberDisplay.slider),
|
||||
io.Combo.Input("combo", options=["a", "b", "c"], tooltip="This is a combo input"),
|
||||
io.MultiCombo.Input("combo2", options=["a","b","c"]),
|
||||
# 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,
|
||||
# dependent_inputs=[ComboDynamicInput("mask", behavior=InputBehavior.optional)],
|
||||
# dependent_values=[lambda my_value: IO.STRING if my_value < 5 else IO.NUMBER],
|
||||
# ),
|
||||
# ["option1", "option2". "option3"]
|
||||
# ComboDynamicInput["sdfgjhl", [ComboDynamicOptions("option1", [IntegerInput("some_int", display_name="new_name", min=0, tooltip="My tooltip 😎", display=NumberDisplay.slider, ImageInput(), MaskInput(), String()]),
|
||||
# CombyDynamicOptons("option2", [])
|
||||
# ]]
|
||||
],
|
||||
outputs=[
|
||||
io.Int.Output("int_output"),
|
||||
io.Image.Output("img_output", display_name="img🖼️", tooltip="This is an image"),
|
||||
],
|
||||
hidden=[
|
||||
|
||||
],
|
||||
is_output_node=True,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, image: io.Image.Type, some_int: int, combo: io.Combo.Type, combo2: io.MultiCombo.Type, xyz: XYZ.Type=None, mask: io.Mask.Type=None, **kwargs):
|
||||
zzz = cls.hidden.prompt
|
||||
cls.state.my_str = "LOLJK"
|
||||
expected_int = 123
|
||||
cls.state.my_int = expected_int
|
||||
if cls.state.my_int is None:
|
||||
cls.state.my_int = expected_int
|
||||
else:
|
||||
if cls.state.my_int != expected_int:
|
||||
raise Exception(f"Explicit state object did not maintain expected value: {cls.state.my_int} != {expected_int}")
|
||||
#some_int
|
||||
if hasattr(cls, "hahajkunless"):
|
||||
raise Exception("The 'cls' variable leaked instance state between runs!")
|
||||
if hasattr(cls, "doohickey"):
|
||||
raise Exception("The 'cls' variable leaked state on class properties between runs!")
|
||||
cls.doohickey = "LOLJK"
|
||||
return io.NodeOutput(some_int, image)
|
||||
|
||||
|
||||
NODES_LIST: list[io.ComfyNodeV3] = [
|
||||
V3TestNode,
|
||||
]
|
@@ -1,40 +1,47 @@
|
||||
import torch
|
||||
from comfy_api.v3.io import (
|
||||
ComfyNodeV3, SchemaV3, NumberDisplay,
|
||||
IntegerInput, MaskInput, ImageInput, ComboInput, CustomInput, StringInput, CustomType,
|
||||
IntegerOutput, ImageOutput, MultitypedInput, InputV3, OutputV3,
|
||||
NodeOutput
|
||||
)
|
||||
from comfy_api.v3 import io
|
||||
import logging
|
||||
|
||||
|
||||
class XYZInput(InputV3, io_type="XYZ"):
|
||||
@io.comfytype(io_type="XYZ")
|
||||
class XYZ:
|
||||
Type = tuple[int,str]
|
||||
class Input(io.InputV3):
|
||||
...
|
||||
class Output(io.OutputV3):
|
||||
...
|
||||
|
||||
class XYZOutput(OutputV3, io_type="XYZ"):
|
||||
...
|
||||
class MyState(io.NodeState):
|
||||
my_str: str
|
||||
my_int: int
|
||||
|
||||
|
||||
class V3TestNode(ComfyNodeV3):
|
||||
class V3TestNode(io.ComfyNodeV3):
|
||||
|
||||
state: MyState
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.hahajkunless = ";)"
|
||||
|
||||
@classmethod
|
||||
def DEFINE_SCHEMA(cls):
|
||||
return SchemaV3(
|
||||
node_id="V3TestNode1",
|
||||
return io.SchemaV3(
|
||||
node_id="V3_01_TestNode1",
|
||||
display_name="V3 Test Node",
|
||||
description="This is a funky V3 node test.",
|
||||
category="v3 nodes",
|
||||
inputs=[
|
||||
ImageInput("image", display_name="new_image"),
|
||||
XYZInput("xyz", optional=True),
|
||||
io.Image.Input("image", display_name="new_image"),
|
||||
XYZ.Input("xyz", optional=True),
|
||||
io.Custom("JKL").Input("jkl", optional=True),
|
||||
#JKL.Input("jkl", optional=True),
|
||||
#CustomInput("xyz", "XYZ", optional=True),
|
||||
MaskInput("mask", optional=True),
|
||||
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"),
|
||||
io.Mask.Input("mask", optional=True),
|
||||
io.Int.Input("some_int", display_name="new_name", min=0, max=127, default=42,
|
||||
tooltip="My tooltip 😎", display_mode=io.NumberDisplay.slider),
|
||||
io.Combo.Input("combo", options=["a", "b", "c"], tooltip="This is a combo input"),
|
||||
io.MultiCombo.Input("combo2", options=["a","b","c"]),
|
||||
# ComboInput("combo", image_upload=True, image_folder=FolderType.output,
|
||||
# remote=RemoteOptions(
|
||||
# route="/internal/files/output",
|
||||
@@ -53,8 +60,8 @@ class V3TestNode(ComfyNodeV3):
|
||||
# ]]
|
||||
],
|
||||
outputs=[
|
||||
IntegerOutput("int_output"),
|
||||
ImageOutput("img_output", display_name="img🖼️", tooltip="This is an image"),
|
||||
io.Int.Output("int_output"),
|
||||
io.Image.Output("img_output", display_name="img🖼️", tooltip="This is an image"),
|
||||
],
|
||||
hidden=[
|
||||
|
||||
@@ -63,15 +70,25 @@ class V3TestNode(ComfyNodeV3):
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, image: ImageInput.Type, some_int: IntegerInput.Type, combo: ComboInput.Type, xyz: XYZInput.Type=None, mask: MaskInput.Type=None):
|
||||
def execute(cls, image: io.Image.Type, some_int: int, combo: io.Combo.Type, combo2: io.MultiCombo.Type, xyz: XYZ.Type=None, mask: io.Mask.Type=None, **kwargs):
|
||||
zzz = cls.hidden.prompt
|
||||
cls.state.my_str = "LOLJK"
|
||||
expected_int = 123
|
||||
cls.state.my_int = expected_int
|
||||
if cls.state.my_int is None:
|
||||
cls.state.my_int = expected_int
|
||||
else:
|
||||
if cls.state.my_int != expected_int:
|
||||
raise Exception(f"Explicit state object did not maintain expected value: {cls.state.my_int} != {expected_int}")
|
||||
#some_int
|
||||
if hasattr(cls, "hahajkunless"):
|
||||
raise Exception("The 'cls' variable leaked instance state between runs!")
|
||||
if hasattr(cls, "doohickey"):
|
||||
raise Exception("The 'cls' variable leaked state on class properties between runs!")
|
||||
cls.doohickey = "LOLJK"
|
||||
return NodeOutput(some_int, image)
|
||||
return io.NodeOutput(some_int, image)
|
||||
|
||||
|
||||
NODES_LIST: list[ComfyNodeV3] = [
|
||||
NODES_LIST: list[io.ComfyNodeV3] = [
|
||||
V3TestNode,
|
||||
]
|
||||
|
Reference in New Issue
Block a user