From 47128ee279b701dda93dcfb40b4e9ea4464fee38 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Tue, 18 Nov 2025 01:41:25 -0800 Subject: [PATCH] frontend will no longer namespace dynamic inputs widgets so reflect that in code, refactor build_nested_inputs --- comfy_api/latest/_io.py | 14 ++++++++------ execution.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/comfy_api/latest/_io.py b/comfy_api/latest/_io.py index 594831336..79d5e47e7 100644 --- a/comfy_api/latest/_io.py +++ b/comfy_api/latest/_io.py @@ -888,8 +888,7 @@ def add_dynamic_id_mapping(d: dict[str], inputs: list[Input], curr_prefix: str, dynamic[self.id] = f"{curr_prefix}{self.id}" for i in inputs: if not isinstance(i, DynamicInput): - # frontend keys should include the prefixes - dynamic[f"{curr_prefix}{i.id}"] = f"{curr_prefix}{i.id}" + dynamic[f"{i.id}"] = f"{curr_prefix}{i.id}" @comfytype(io_type="COMFY_DYNAMICCOMBO_V3") class DynamicCombo(ComfyTypeI): @@ -1279,9 +1278,9 @@ def add_to_input_dict_v1(d: dict[str], inputs: list[Input], live_inputs: dict[st if live_inputs is not None: i.add_to_dict_live_inputs(d, live_inputs, curr_prefix) else: - add_to_dict_v1(i, d, curr_prefix=curr_prefix) + add_to_dict_v1(i, d) -def add_to_dict_v1(i: Input, d: dict, dynamic_dict: dict=None, curr_prefix=''): +def add_to_dict_v1(i: Input, d: dict, dynamic_dict: dict=None): key = "optional" if i.optional else "required" as_dict = i.as_dict() # for v1, we don't want to include the optional key @@ -1290,12 +1289,15 @@ def add_to_dict_v1(i: Input, d: dict, dynamic_dict: dict=None, curr_prefix=''): value = (i.get_io_type(), as_dict) else: value = (i.get_io_type(), as_dict, dynamic_dict) - d.setdefault(key, {})[f"{curr_prefix}{i.id}"] = value + d.setdefault(key, {})[i.id] = value def add_to_dict_v3(io: Input | Output, d: dict): d[io.id] = (io.get_io_type(), io.as_dict()) -def build_nested_inputs(values: dict[str], paths: dict[str]): +def build_nested_inputs(values: dict[str], v3_data: V3Data): + paths = v3_data.get("dynamic_data", None) + if paths is None: + return values # NOTE: This was initially AI generated # Tries to account for arrays as well, will likely be changed once that's in values = values.copy() diff --git a/execution.py b/execution.py index 4faed5ded..c50ac39d3 100644 --- a/execution.py +++ b/execution.py @@ -269,8 +269,8 @@ async def _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, f class_clone = type_obj.PREPARE_CLASS_CLONE(v3_data) f = make_locked_method_func(type_obj, func, class_clone) # in case of dynamic inputs, restructure inputs to expected nested dict - if v3_data is not None and v3_data["dynamic_data"] is not None: - inputs = _io.build_nested_inputs(inputs, v3_data["dynamic_data"]) + if v3_data is not None: + inputs = _io.build_nested_inputs(inputs, v3_data) # V1 else: f = getattr(obj, func)