mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-19 02:53:05 +08:00
frontend will no longer namespace dynamic inputs widgets so reflect that in code, refactor build_nested_inputs
This commit is contained in:
parent
122c9d5362
commit
47128ee279
@ -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}"
|
dynamic[self.id] = f"{curr_prefix}{self.id}"
|
||||||
for i in inputs:
|
for i in inputs:
|
||||||
if not isinstance(i, DynamicInput):
|
if not isinstance(i, DynamicInput):
|
||||||
# frontend keys should include the prefixes
|
dynamic[f"{i.id}"] = f"{curr_prefix}{i.id}"
|
||||||
dynamic[f"{curr_prefix}{i.id}"] = f"{curr_prefix}{i.id}"
|
|
||||||
|
|
||||||
@comfytype(io_type="COMFY_DYNAMICCOMBO_V3")
|
@comfytype(io_type="COMFY_DYNAMICCOMBO_V3")
|
||||||
class DynamicCombo(ComfyTypeI):
|
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:
|
if live_inputs is not None:
|
||||||
i.add_to_dict_live_inputs(d, live_inputs, curr_prefix)
|
i.add_to_dict_live_inputs(d, live_inputs, curr_prefix)
|
||||||
else:
|
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"
|
key = "optional" if i.optional else "required"
|
||||||
as_dict = i.as_dict()
|
as_dict = i.as_dict()
|
||||||
# for v1, we don't want to include the optional key
|
# 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)
|
value = (i.get_io_type(), as_dict)
|
||||||
else:
|
else:
|
||||||
value = (i.get_io_type(), as_dict, dynamic_dict)
|
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):
|
def add_to_dict_v3(io: Input | Output, d: dict):
|
||||||
d[io.id] = (io.get_io_type(), io.as_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
|
# NOTE: This was initially AI generated
|
||||||
# Tries to account for arrays as well, will likely be changed once that's in
|
# Tries to account for arrays as well, will likely be changed once that's in
|
||||||
values = values.copy()
|
values = values.copy()
|
||||||
|
|||||||
@ -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)
|
class_clone = type_obj.PREPARE_CLASS_CLONE(v3_data)
|
||||||
f = make_locked_method_func(type_obj, func, class_clone)
|
f = make_locked_method_func(type_obj, func, class_clone)
|
||||||
# in case of dynamic inputs, restructure inputs to expected nested dict
|
# 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:
|
if v3_data is not None:
|
||||||
inputs = _io.build_nested_inputs(inputs, v3_data["dynamic_data"])
|
inputs = _io.build_nested_inputs(inputs, v3_data)
|
||||||
# V1
|
# V1
|
||||||
else:
|
else:
|
||||||
f = getattr(obj, func)
|
f = getattr(obj, func)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user