mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-19 19:13:02 +08:00
Support validation of inputs and outputs
This commit is contained in:
parent
676de9e618
commit
68153f6c04
@ -150,6 +150,9 @@ class _IO_V3:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def io_type(self):
|
def io_type(self):
|
||||||
return self.Parent.io_type
|
return self.Parent.io_type
|
||||||
@ -899,6 +902,12 @@ class DynamicCombo(ComfyTypeI):
|
|||||||
"options": [o.as_dict() for o in self.options],
|
"options": [o.as_dict() for o in self.options],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
# make sure all nested inputs are validated
|
||||||
|
for option in self.options:
|
||||||
|
for input in option.inputs:
|
||||||
|
input.validate()
|
||||||
|
|
||||||
@comfytype(io_type="COMFY_MATCHTYPE_V3")
|
@comfytype(io_type="COMFY_MATCHTYPE_V3")
|
||||||
class MatchType(ComfyTypeIO):
|
class MatchType(ComfyTypeIO):
|
||||||
class Template:
|
class Template:
|
||||||
@ -1105,6 +1114,11 @@ class Schema:
|
|||||||
issues.append(f"Ids must be unique between inputs and outputs, but {intersection} are not.")
|
issues.append(f"Ids must be unique between inputs and outputs, but {intersection} are not.")
|
||||||
if len(issues) > 0:
|
if len(issues) > 0:
|
||||||
raise ValueError("\n".join(issues))
|
raise ValueError("\n".join(issues))
|
||||||
|
# validate inputs and outputs
|
||||||
|
for input in self.inputs:
|
||||||
|
input.validate()
|
||||||
|
for output in self.outputs:
|
||||||
|
output.validate()
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
"""Add hidden based on selected schema options, and give outputs without ids default ids."""
|
"""Add hidden based on selected schema options, and give outputs without ids default ids."""
|
||||||
@ -1697,6 +1711,7 @@ __all__ = [
|
|||||||
"MultiType",
|
"MultiType",
|
||||||
# Dynamic Types
|
# Dynamic Types
|
||||||
"MatchType",
|
"MatchType",
|
||||||
|
"DynamicCombo",
|
||||||
# Other classes
|
# Other classes
|
||||||
"HiddenHolder",
|
"HiddenHolder",
|
||||||
"Hidden",
|
"Hidden",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user