mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-18 18:43:05 +08:00
Make sure Autogrow inputs are force_input = True when WidgetInput, fix runtime validation by removing original input from expected inputs, fix min/max bounds, change test nodes slightly
This commit is contained in:
parent
4881a9886d
commit
3b98df6984
@ -898,7 +898,9 @@ class Autogrow(ComfyTypeI):
|
|||||||
def __init__(self, input: Input):
|
def __init__(self, input: Input):
|
||||||
# dynamic inputs are not allowed as the template input
|
# dynamic inputs are not allowed as the template input
|
||||||
assert(not isinstance(input, DynamicInput))
|
assert(not isinstance(input, DynamicInput))
|
||||||
self.input = input
|
self.input = copy.copy(input)
|
||||||
|
if isinstance(self.input, WidgetInput):
|
||||||
|
self.input.force_input = True
|
||||||
self.names: list[str] = []
|
self.names: list[str] = []
|
||||||
self.cached_inputs = {}
|
self.cached_inputs = {}
|
||||||
|
|
||||||
@ -934,14 +936,14 @@ class Autogrow(ComfyTypeI):
|
|||||||
def __init__(self, input: Input, prefix: str, min: int=1, max: int=None):
|
def __init__(self, input: Input, prefix: str, min: int=1, max: int=None):
|
||||||
super().__init__(input)
|
super().__init__(input)
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
assert(min >= 1)
|
assert(min >= 0)
|
||||||
if not max:
|
if not max:
|
||||||
max = 10
|
max = 10
|
||||||
assert(max >= 1)
|
assert(max >= 2)
|
||||||
assert(max <= Autogrow._MaxNames)
|
assert(max <= Autogrow._MaxNames)
|
||||||
self.min = min
|
self.min = min
|
||||||
self.max = max
|
self.max = max
|
||||||
self.names = [f"{self.prefix}{i+1}" for i in range(self.max)]
|
self.names = [f"{self.prefix}{i}" for i in range(self.max)]
|
||||||
self._create_cached_inputs()
|
self._create_cached_inputs()
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
@ -955,7 +957,7 @@ class Autogrow(ComfyTypeI):
|
|||||||
def __init__(self, input: Input, names: list[str], min: int=1):
|
def __init__(self, input: Input, names: list[str], min: int=1):
|
||||||
super().__init__(input)
|
super().__init__(input)
|
||||||
self.names = names[:Autogrow._MaxNames]
|
self.names = names[:Autogrow._MaxNames]
|
||||||
assert(min >= 1)
|
assert(min >= 0)
|
||||||
self.min = min
|
self.min = min
|
||||||
self._create_cached_inputs()
|
self._create_cached_inputs()
|
||||||
|
|
||||||
@ -988,6 +990,10 @@ class Autogrow(ComfyTypeI):
|
|||||||
|
|
||||||
def add_to_dict_live_inputs(self, d: dict[str], live_inputs: dict[str], curr_prefix=''):
|
def add_to_dict_live_inputs(self, d: dict[str], live_inputs: dict[str], curr_prefix=''):
|
||||||
curr_prefix = f"{curr_prefix}{self.id}."
|
curr_prefix = f"{curr_prefix}{self.id}."
|
||||||
|
# need to remove self from expected inputs dictionary; replaced by template inputs in frontend
|
||||||
|
for inner_dict in d.values():
|
||||||
|
if self.id in inner_dict:
|
||||||
|
del inner_dict[self.id]
|
||||||
self.template.add_to_dict_live_inputs(d, live_inputs, curr_prefix)
|
self.template.add_to_dict_live_inputs(d, live_inputs, curr_prefix)
|
||||||
|
|
||||||
@comfytype(io_type="COMFY_DYNAMICCOMBO_V3")
|
@comfytype(io_type="COMFY_DYNAMICCOMBO_V3")
|
||||||
|
|||||||
@ -103,7 +103,7 @@ class DCTestNode(io.ComfyNode):
|
|||||||
class AutogrowNamesTestNode(io.ComfyNode):
|
class AutogrowNamesTestNode(io.ComfyNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
def define_schema(cls):
|
def define_schema(cls):
|
||||||
template = io.Autogrow.TemplateNames(input=io.String.Input("string"), names=["a", "b", "c"])
|
template = io.Autogrow.TemplateNames(input=io.Float.Input("float"), names=["a", "b", "c"])
|
||||||
return io.Schema(
|
return io.Schema(
|
||||||
node_id="AutogrowNamesTestNode",
|
node_id="AutogrowNamesTestNode",
|
||||||
display_name="AutogrowNamesTest",
|
display_name="AutogrowNamesTest",
|
||||||
@ -117,13 +117,13 @@ class AutogrowNamesTestNode(io.ComfyNode):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def execute(cls, autogrow: io.Autogrow.Type) -> io.NodeOutput:
|
def execute(cls, autogrow: io.Autogrow.Type) -> io.NodeOutput:
|
||||||
vals = list(autogrow.values())
|
vals = list(autogrow.values())
|
||||||
combined = "".join(vals)
|
combined = ",".join([str(x) for x in vals])
|
||||||
return io.NodeOutput(combined)
|
return io.NodeOutput(combined)
|
||||||
|
|
||||||
class AutogrowPrefixTestNode(io.ComfyNode):
|
class AutogrowPrefixTestNode(io.ComfyNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
def define_schema(cls):
|
def define_schema(cls):
|
||||||
template = io.Autogrow.TemplatePrefix(input=io.String.Input("string"), prefix="string", min=1, max=10)
|
template = io.Autogrow.TemplatePrefix(input=io.Float.Input("float"), prefix="float", min=1, max=10)
|
||||||
return io.Schema(
|
return io.Schema(
|
||||||
node_id="AutogrowPrefixTestNode",
|
node_id="AutogrowPrefixTestNode",
|
||||||
display_name="AutogrowPrefixTest",
|
display_name="AutogrowPrefixTest",
|
||||||
@ -137,7 +137,7 @@ class AutogrowPrefixTestNode(io.ComfyNode):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def execute(cls, autogrow: io.Autogrow.Type) -> io.NodeOutput:
|
def execute(cls, autogrow: io.Autogrow.Type) -> io.NodeOutput:
|
||||||
vals = list(autogrow.values())
|
vals = list(autogrow.values())
|
||||||
combined = "".join(vals)
|
combined = ",".join([str(x) for x in vals])
|
||||||
return io.NodeOutput(combined)
|
return io.NodeOutput(combined)
|
||||||
|
|
||||||
class LogicExtension(ComfyExtension):
|
class LogicExtension(ComfyExtension):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user