mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-13 15:02:37 +08:00
robust patch
* cut execution path instead of crash if result is empty list
This commit is contained in:
parent
efbdeee460
commit
5162b7807e
23
execution.py
23
execution.py
@ -58,8 +58,12 @@ def map_node_over_list(obj, input_data_all, func, allow_interrupt=False):
|
|||||||
# get a slice of inputs, repeat last input when list isn't long enough
|
# get a slice of inputs, repeat last input when list isn't long enough
|
||||||
def slice_dict(d, i):
|
def slice_dict(d, i):
|
||||||
d_new = dict()
|
d_new = dict()
|
||||||
for k,v in d.items():
|
|
||||||
d_new[k] = v[i if len(v) > i else -1]
|
for k, v in d.items():
|
||||||
|
if not v:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
d_new[k] = v[i if len(v) > i else -1]
|
||||||
return d_new
|
return d_new
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
@ -71,15 +75,24 @@ def map_node_over_list(obj, input_data_all, func, allow_interrupt=False):
|
|||||||
for i in range(max_len_input):
|
for i in range(max_len_input):
|
||||||
if allow_interrupt:
|
if allow_interrupt:
|
||||||
nodes.before_node_execution()
|
nodes.before_node_execution()
|
||||||
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
|
|
||||||
|
params = slice_dict(input_data_all, i)
|
||||||
|
|
||||||
|
if params is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
results.append(getattr(obj, func)(**params))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def get_output_data(obj, input_data_all):
|
def get_output_data(obj, input_data_all):
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
uis = []
|
uis = []
|
||||||
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
|
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
|
||||||
|
|
||||||
|
if return_values is None:
|
||||||
|
return None, None
|
||||||
|
|
||||||
for r in return_values:
|
for r in return_values:
|
||||||
if isinstance(r, dict):
|
if isinstance(r, dict):
|
||||||
if 'ui' in r:
|
if 'ui' in r:
|
||||||
@ -103,7 +116,7 @@ def get_output_data(obj, input_data_all):
|
|||||||
else:
|
else:
|
||||||
output.append([o[i] for o in results])
|
output.append([o[i] for o in results])
|
||||||
|
|
||||||
ui = dict()
|
ui = dict()
|
||||||
if len(uis) > 0:
|
if len(uis) > 0:
|
||||||
ui = {k: [y for x in uis for y in x[k]] for k in uis[0].keys()}
|
ui = {k: [y for x in uis for y in x[k]] for k in uis[0].keys()}
|
||||||
return output, ui
|
return output, ui
|
||||||
|
|||||||
@ -242,12 +242,16 @@ def worklist_execute(server, prompt, outputs, extra_data, prompt_id, outputs_ui,
|
|||||||
|
|
||||||
output_data, output_ui = get_output_data(obj, input_data_all)
|
output_data, output_ui = get_output_data(obj, input_data_all)
|
||||||
|
|
||||||
outputs[unique_id] = output_data
|
if output_ui is not None and len(output_ui) > 0:
|
||||||
if len(output_ui) > 0:
|
|
||||||
outputs_ui[unique_id] = output_ui
|
outputs_ui[unique_id] = output_ui
|
||||||
if server.client_id is not None:
|
if server.client_id is not None:
|
||||||
server.send_sync("executed", {"node": unique_id, "output": output_ui, "prompt_id": prompt_id},
|
server.send_sync("executed", {"node": unique_id, "output": output_ui, "prompt_id": prompt_id},
|
||||||
server.client_id)
|
server.client_id)
|
||||||
|
|
||||||
|
if output_data is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
outputs[unique_id] = output_data
|
||||||
executed.add(unique_id)
|
executed.add(unique_id)
|
||||||
|
|
||||||
result = exception_helper(unique_id, input_data_all, executed, outputs, task)
|
result = exception_helper(unique_id, input_data_all, executed, outputs, task)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user