Added hidden and state to passed-in clone of node class

This commit is contained in:
Jedrzej Kosinski
2025-06-17 20:35:32 -05:00
parent 1ef0693e65
commit 38721fdb64
5 changed files with 143 additions and 37 deletions

View File

@@ -11,10 +11,17 @@ class XYZ:
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
@@ -64,6 +71,15 @@ class V3TestNode(io.ComfyNodeV3):
@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!")

View File

@@ -3,7 +3,7 @@ from comfy_api.v3.io import (
ComfyNodeV3, SchemaV3, NumberDisplay,
IntegerInput, MaskInput, ImageInput, ComboInput, CustomInput, StringInput, CustomType,
IntegerOutput, ImageOutput, MultitypedInput, InputV3, OutputV3,
NodeOutput, Hidden
NodeOutput
)
import logging