Support empty inputs in NODE helper

This commit is contained in:
asagi4
2026-08-14 18:09:05 +03:00
parent 71a7ae5ca6
commit 4c9cc9e44c
3 changed files with 14 additions and 5 deletions
+7
View File
@@ -212,10 +212,17 @@ def build_scheduled_prompts(graph, schedules, clip):
magic_spec.replace(r"\;", "__ESCAPED_SEMICOLON__")
extra_inputs = magic_spec.split(";") if magic_spec.strip() else []
for e in extra_inputs:
e = e.strip()
if not e:
continue
e = e.replace("__ESCAPED_SEMICOLON__", ";")
name, jsondata = e.split(maxsplit=1)
jsondata = jsondata.strip()
if not jsondata.strip():
continue
# From helper node:
if jsondata == "__EMPTY__":
continue
try:
node.set_input(name.strip(), json.loads(jsondata.strip()))
except ValueError as e:
+5 -2
View File
@@ -202,8 +202,11 @@ class PCLinkHelper(io.ComfyNode):
@classmethod
def execute(cls, text, **vars) -> io.NodeOutput:
for k, v in vars.items():
text = substitute_var(text, k, json.dumps(v))
for k in "abcdefghijklmn":
v = "__EMPTY__"
if k in vars:
v = json.dumps(vars[k])
text = substitute_var(text, k, v)
return io.NodeOutput(text)
+2 -3
View File
@@ -503,7 +503,7 @@ def test_textencode_custom():
def test_textencode_custom_extra():
r = te(
'NODE(CustomTextEncode, prompt, image ["1", 0]; option "test"; float [10.0:5.0:0.5])simple [test:0.1,0.5] prompt'
'NODE(CustomTextEncode, prompt, image ["1", 0]; option "test"; float [10.0:__EMPTY__:0.5])simple [test:0.1,0.5] prompt'
)
assert r == {
"result": (["UID.0.0.8", 0],),
@@ -542,8 +542,7 @@ def test_textencode_custom_extra():
"clip": [0, 0],
"prompt": "simple prompt",
"image": ["1", 0],
"option": "test",
"float": 5.0,
"option": "test"
},
},
"UID.0.0.6": {