docs(hel-892): bind primary 8010 engine bytes and audit AIO branches
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
--- 0.17.0:_async_map_node_over_list
|
||||
+++ 8010:_async_map_node_over_list
|
||||
@@ -43,7 +43,7 @@
|
||||
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:
|
||||
- inputs = _io.build_nested_inputs(inputs, v3_data)
|
||||
+ inputs = _io.build_nested_inputs(inputs, v3_data, input_is_list=input_is_list)
|
||||
# V1
|
||||
else:
|
||||
f = getattr(obj, func)
|
||||
@@ -74,4 +74,4 @@
|
||||
for i in range(max_len_input):
|
||||
input_dict = slice_dict(input_data_all, i)
|
||||
await process_inputs(input_dict, i)
|
||||
- return results+ return results
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
--- 0.17.0:cache_update
|
||||
+++ 8010:cache_update
|
||||
@@ -1,5 +1,7 @@
|
||||
def cache_update(self, node_id, value):
|
||||
if node_id in self.execution_cache_listeners:
|
||||
- for to_node_id in self.execution_cache_listeners[node_id]:
|
||||
+ for to_node_id, from_socket in self.execution_cache_listeners[node_id]:
|
||||
if to_node_id in self.execution_cache:
|
||||
- self.execution_cache[to_node_id][node_id] = value+ self.execution_cache[to_node_id][node_id] = value
|
||||
+ if from_socket is not None and self.output_link_callback is not None:
|
||||
+ self.output_link_callback(value.outputs[from_socket])
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
--- 0.17.0:execute
|
||||
+++ 8010:execute
|
||||
@@ -1,4 +1,4 @@
|
||||
-async def execute(server, dynprompt, caches, current_item, extra_data, executed, prompt_id, execution_list, pending_subgraph_results, pending_async_nodes, ui_outputs):
|
||||
+async def execute(server: "ExecutionServer", dynprompt, caches, current_item, extra_data, executed, prompt_id, execution_list, pending_subgraph_results, pending_async_nodes, ui_outputs, asset_manager: AssetManager):
|
||||
unique_id = current_item
|
||||
real_node_id = dynprompt.get_real_node_id(unique_id)
|
||||
display_node_id = dynprompt.get_display_node_id(unique_id)
|
||||
@@ -6,13 +6,9 @@
|
||||
inputs = dynprompt.get_node(unique_id)['inputs']
|
||||
class_type = dynprompt.get_node(unique_id)['class_type']
|
||||
class_def = nodes.NODE_CLASS_MAPPINGS[class_type]
|
||||
- cached = caches.outputs.get(unique_id)
|
||||
+ cached = await caches.outputs.get(unique_id)
|
||||
if cached is not None:
|
||||
- if server.client_id is not None:
|
||||
- cached_ui = cached.ui or {}
|
||||
- server.send_sync("executed", { "node": unique_id, "display_node": display_node_id, "output": cached_ui.get("output",None), "prompt_id": prompt_id }, server.client_id)
|
||||
- if cached.ui is not None:
|
||||
- ui_outputs[unique_id] = cached.ui
|
||||
+ emit_cached_output(server, unique_id, display_node_id, cached, prompt_id, ui_outputs, asset_manager)
|
||||
get_progress_state().finish_progress(unique_id)
|
||||
execution_list.cache_update(unique_id, cached)
|
||||
return (ExecutionResult.SUCCESS, None, None)
|
||||
@@ -62,10 +58,10 @@
|
||||
server.last_node_id = display_node_id
|
||||
server.send_sync("executing", { "node": unique_id, "display_node": display_node_id, "prompt_id": prompt_id }, server.client_id)
|
||||
|
||||
- obj = caches.objects.get(unique_id)
|
||||
+ obj = await caches.objects.get(unique_id)
|
||||
if obj is None:
|
||||
obj = class_def()
|
||||
- caches.objects.set(unique_id, obj)
|
||||
+ await caches.objects.set(unique_id, obj)
|
||||
|
||||
if issubclass(class_def, _ComfyNodeInternal):
|
||||
lazy_status_present = first_real_override(class_def, "check_lazy_status") is not None
|
||||
@@ -85,6 +81,8 @@
|
||||
for i in required_inputs:
|
||||
execution_list.make_input_strong_link(unique_id, i)
|
||||
return (ExecutionResult.PENDING, None, None)
|
||||
+ if execution_list.is_staged_node_blocked():
|
||||
+ return (ExecutionResult.PENDING, None, None)
|
||||
|
||||
def execution_block_cb(block):
|
||||
if block.message is not None:
|
||||
@@ -112,8 +110,9 @@
|
||||
output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
|
||||
finally:
|
||||
if comfy.memory_management.aimdo_enabled:
|
||||
- if args.verbose == "DEBUG":
|
||||
+ if get_console_log_level(args.verbose) == "DEBUG":
|
||||
comfy_aimdo.control.analyze()
|
||||
+ comfy.model_prefetch.cleanup_prefetch_queues()
|
||||
comfy.model_management.reset_cast_buffers()
|
||||
comfy_aimdo.model_vbar.vbars_reset_watermark_limits()
|
||||
|
||||
@@ -126,18 +125,20 @@
|
||||
unblock()
|
||||
asyncio.create_task(await_completion())
|
||||
return (ExecutionResult.PENDING, None, None)
|
||||
+ cache_ui_value = ui_outputs.get(unique_id)
|
||||
if len(output_ui) > 0:
|
||||
- ui_outputs[unique_id] = {
|
||||
- "meta": {
|
||||
- "node_id": unique_id,
|
||||
- "display_node": display_node_id,
|
||||
- "parent_node": parent_node_id,
|
||||
- "real_node_id": real_node_id,
|
||||
- },
|
||||
- "output": output_ui
|
||||
+ output_ui = enrich_output_with_media_metadata(output_ui)
|
||||
+ meta = {
|
||||
+ "node_id": unique_id,
|
||||
+ "display_node": display_node_id,
|
||||
+ "parent_node": parent_node_id,
|
||||
+ "real_node_id": real_node_id,
|
||||
}
|
||||
+ enriched_output_ui = register_executed_outputs(output_ui, prompt_id, asset_manager)
|
||||
+ ui_outputs[unique_id] = {"meta": meta, "output": enriched_output_ui}
|
||||
+ cache_ui_value = {"meta": meta, "output": output_ui}
|
||||
if server.client_id is not None:
|
||||
- server.send_sync("executed", { "node": unique_id, "display_node": display_node_id, "output": output_ui, "prompt_id": prompt_id }, server.client_id)
|
||||
+ server.send_sync("executed", { "node": unique_id, "display_node": display_node_id, "output": enriched_output_ui, "prompt_id": prompt_id }, server.client_id)
|
||||
if has_subgraph:
|
||||
cached_outputs = []
|
||||
new_node_ids = []
|
||||
@@ -174,9 +175,9 @@
|
||||
pending_subgraph_results[unique_id] = cached_outputs
|
||||
return (ExecutionResult.PENDING, None, None)
|
||||
|
||||
- cache_entry = CacheEntry(ui=ui_outputs.get(unique_id), outputs=output_data)
|
||||
+ cache_entry = CacheEntry(ui=cache_ui_value, outputs=output_data)
|
||||
execution_list.cache_update(unique_id, cache_entry)
|
||||
- caches.outputs.set(unique_id, cache_entry)
|
||||
+ await caches.outputs.set(unique_id, cache_entry)
|
||||
|
||||
except comfy.model_management.InterruptProcessingException as iex:
|
||||
logging.info("Processing interrupted")
|
||||
@@ -202,7 +203,7 @@
|
||||
|
||||
if comfy.model_management.is_oom(ex):
|
||||
tips = "This error means you ran out of memory on your GPU.\n\nTIPS: If the workflow worked before you might have accidentally set the batch_size to a large number."
|
||||
- logging.info("Memory summary: {}".format(comfy.model_management.debug_memory_summary()))
|
||||
+ logging.info("Memory summary:\n{}".format(comfy.model_management.debug_memory_summary()))
|
||||
logging.error("Got an OOM, unloading all loaded models.")
|
||||
comfy.model_management.unload_all_models()
|
||||
elif isinstance(ex, RuntimeError) and ("mat1 and mat2 shapes" in str(ex)) and "Sampler" in class_type:
|
||||
@@ -221,4 +222,4 @@
|
||||
get_progress_state().finish_progress(unique_id)
|
||||
executed.add(unique_id)
|
||||
|
||||
- return (ExecutionResult.SUCCESS, None, None)+ return (ExecutionResult.SUCCESS, None, None)
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
--- 0.17.0:get_cache
|
||||
+++ 8010:get_cache
|
||||
@@ -5,5 +5,5 @@
|
||||
if value is None:
|
||||
return None
|
||||
#Write back to the main cache on touch.
|
||||
- self.output_cache.set(from_node_id, value)
|
||||
- return value+ self.output_cache.set_local(from_node_id, value)
|
||||
+ return value
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
--- 0.17.0:get_input_data
|
||||
+++ 8010:get_input_data
|
||||
@@ -45,6 +45,10 @@
|
||||
hidden_inputs_v3[io.Hidden.auth_token_comfy_org] = extra_data.get("auth_token_comfy_org", None)
|
||||
if io.Hidden.api_key_comfy_org.name in hidden:
|
||||
hidden_inputs_v3[io.Hidden.api_key_comfy_org] = extra_data.get("api_key_comfy_org", None)
|
||||
+ if io.Hidden.comfy_usage_source.name in hidden:
|
||||
+ hidden_inputs_v3[io.Hidden.comfy_usage_source] = extra_data.get("comfy_usage_source", None)
|
||||
+ if io.Hidden.execution_list.name in hidden:
|
||||
+ hidden_inputs_v3[io.Hidden.execution_list] = execution_list
|
||||
else:
|
||||
if "hidden" in valid_inputs:
|
||||
h = valid_inputs["hidden"]
|
||||
@@ -53,6 +57,8 @@
|
||||
input_data_all[x] = [dynprompt.get_original_prompt() if dynprompt is not None else {}]
|
||||
if h[x] == "DYNPROMPT":
|
||||
input_data_all[x] = [dynprompt]
|
||||
+ if h[x] == "EXECUTION_LIST":
|
||||
+ input_data_all[x] = [execution_list]
|
||||
if h[x] == "EXTRA_PNGINFO":
|
||||
input_data_all[x] = [extra_data.get('extra_pnginfo', None)]
|
||||
if h[x] == "UNIQUE_ID":
|
||||
@@ -61,5 +67,7 @@
|
||||
input_data_all[x] = [extra_data.get("auth_token_comfy_org", None)]
|
||||
if h[x] == "API_KEY_COMFY_ORG":
|
||||
input_data_all[x] = [extra_data.get("api_key_comfy_org", None)]
|
||||
+ if h[x] == "COMFY_USAGE_SOURCE":
|
||||
+ input_data_all[x] = [extra_data.get("comfy_usage_source", None)]
|
||||
v3_data["hidden_inputs"] = hidden_inputs_v3
|
||||
- return input_data_all, missing_keys, v3_data+ return input_data_all, missing_keys, v3_data
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.17.0:get_input_info
|
||||
+++ 8010:get_input_info
|
||||
@@ -38,4 +38,4 @@
|
||||
# if isinstance(input_type, list):
|
||||
# extra_info["options"] = input_type
|
||||
# input_type = IO.Combo.io_type
|
||||
- return input_type, input_category, extra_info+ return input_type, input_category, extra_info
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.17.0:get_output_data
|
||||
+++ 8010:get_output_data
|
||||
@@ -4,4 +4,4 @@
|
||||
if has_pending_task:
|
||||
return return_values, {}, False, has_pending_task
|
||||
output, ui, has_subgraph = get_output_from_returns(return_values, obj)
|
||||
- return output, ui, has_subgraph, False+ return output, ui, has_subgraph, False
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.17.0:get_output_from_returns
|
||||
+++ 8010:get_output_from_returns
|
||||
@@ -61,4 +61,4 @@
|
||||
# any nodes that use both subgraph expansion and custom UI outputs, but might be a problem in the future.
|
||||
if len(uis) > 0:
|
||||
ui = {k: [y for x in uis for y in x[k]] for k in uis[0].keys()}
|
||||
- return output, ui, has_subgraph+ return output, ui, has_subgraph
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.17.0:is_link
|
||||
+++ 8010:is_link
|
||||
@@ -7,4 +7,4 @@
|
||||
return False
|
||||
if not isinstance(obj[1], int) and not isinstance(obj[1], float):
|
||||
return False
|
||||
- return True+ return True
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.17.0:merge_result_data
|
||||
+++ 8010:merge_result_data
|
||||
@@ -17,4 +17,4 @@
|
||||
output.append(value)
|
||||
else:
|
||||
output.append([o[i] for o in results])
|
||||
- return output+ return output
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
--- 0.17.0:validate_inputs
|
||||
+++ 8010:validate_inputs
|
||||
@@ -1,6 +1,25 @@
|
||||
-async def validate_inputs(prompt_id, prompt, item, validated):
|
||||
+async def validate_inputs(prompt_id, prompt, item, validated, visiting=None):
|
||||
+ if visiting is None:
|
||||
+ visiting = []
|
||||
+
|
||||
unique_id = item
|
||||
if unique_id in validated:
|
||||
+ return validated[unique_id]
|
||||
+
|
||||
+ if unique_id in visiting:
|
||||
+ cycle_path_nodes = visiting[visiting.index(unique_id):] + [unique_id]
|
||||
+ cycle_nodes = list(dict.fromkeys(cycle_path_nodes))
|
||||
+ cycle_path = " -> ".join(f"{node_id} ({prompt[node_id]['class_type']})" for node_id in cycle_path_nodes)
|
||||
+ for node_id in cycle_nodes:
|
||||
+ validated[node_id] = (False, [{
|
||||
+ "type": "dependency_cycle",
|
||||
+ "message": "Dependency cycle detected",
|
||||
+ "details": cycle_path,
|
||||
+ "extra_info": {
|
||||
+ "node_id": node_id,
|
||||
+ "cycle_nodes": cycle_nodes,
|
||||
+ }
|
||||
+ }], node_id)
|
||||
return validated[unique_id]
|
||||
|
||||
inputs = prompt[unique_id]['inputs']
|
||||
@@ -16,7 +35,17 @@
|
||||
if issubclass(obj_class, _ComfyNodeInternal):
|
||||
obj_class: _io._ComfyNodeBaseInternal
|
||||
class_inputs = obj_class.INPUT_TYPES()
|
||||
- class_inputs, _, v3_data = _io.get_finalized_class_inputs(class_inputs, inputs)
|
||||
+ try:
|
||||
+ class_inputs, _, v3_data = _io.get_finalized_class_inputs(class_inputs, inputs)
|
||||
+ except _io.DynamicInputError as ex:
|
||||
+ errors.append({
|
||||
+ "type": "invalid_dynamic_input",
|
||||
+ "message": "Invalid dynamic input",
|
||||
+ "details": str(ex),
|
||||
+ "extra_info": {"input_name": ex.input_name},
|
||||
+ })
|
||||
+ validated[unique_id] = (False, errors, unique_id)
|
||||
+ return validated[unique_id]
|
||||
validate_function_name = "validate_inputs"
|
||||
validate_function = first_real_override(obj_class, validate_function_name)
|
||||
else:
|
||||
@@ -86,7 +115,11 @@
|
||||
errors.append(error)
|
||||
continue
|
||||
try:
|
||||
- r = await validate_inputs(prompt_id, prompt, o_id, validated)
|
||||
+ visiting.append(unique_id)
|
||||
+ try:
|
||||
+ r = await validate_inputs(prompt_id, prompt, o_id, validated, visiting)
|
||||
+ finally:
|
||||
+ visiting.pop()
|
||||
if r[0] is False:
|
||||
# `r` will be set in `validated[o_id]` already
|
||||
valid = False
|
||||
@@ -181,7 +214,12 @@
|
||||
combo_options = extra_info.get("options", [])
|
||||
else:
|
||||
combo_options = input_type
|
||||
- if val not in combo_options:
|
||||
+ is_multiselect = extra_info.get("multiselect", False)
|
||||
+ if is_multiselect and isinstance(val, list):
|
||||
+ invalid_vals = [v for v in val if v not in combo_options]
|
||||
+ else:
|
||||
+ invalid_vals = [val] if val not in combo_options else []
|
||||
+ if invalid_vals:
|
||||
input_config = info
|
||||
list_info = ""
|
||||
|
||||
@@ -196,7 +234,7 @@
|
||||
error = {
|
||||
"type": "value_not_in_list",
|
||||
"message": "Value not in list",
|
||||
- "details": f"{x}: '{val}' not in {list_info}",
|
||||
+ "details": f"{x}: {', '.join(repr(v) for v in invalid_vals)} not in {list_info}",
|
||||
"extra_info": {
|
||||
"input_name": x,
|
||||
"input_config": input_config,
|
||||
@@ -208,37 +246,46 @@
|
||||
|
||||
if len(validate_function_inputs) > 0 or validate_has_kwargs:
|
||||
input_data_all, _, v3_data = get_input_data(inputs, obj_class, unique_id)
|
||||
+ dynamic_paths = v3_data.get("dynamic_paths", {})
|
||||
+ if not validate_has_kwargs:
|
||||
+ dynamic_paths = {key: path for key, path in dynamic_paths.items() if path.split(".")[0] in validate_function_inputs}
|
||||
+ v3_data = v3_data | {
|
||||
+ "dynamic_paths": dynamic_paths,
|
||||
+ "list_paths": {path for path in v3_data.get("list_paths", set()) if path.split(".")[0] in validate_function_inputs},
|
||||
+ }
|
||||
input_filtered = {}
|
||||
for x in input_data_all:
|
||||
- if x in validate_function_inputs or validate_has_kwargs:
|
||||
+ input_name = dynamic_paths[x].split(".")[0] if x in dynamic_paths else x
|
||||
+ if input_name in validate_function_inputs or validate_has_kwargs:
|
||||
input_filtered[x] = input_data_all[x]
|
||||
if 'input_types' in validate_function_inputs:
|
||||
input_filtered['input_types'] = [received_types]
|
||||
|
||||
ret = await _async_map_node_over_list(prompt_id, unique_id, obj_class, input_filtered, validate_function_name, v3_data=v3_data)
|
||||
ret = await resolve_map_node_over_list_results(ret)
|
||||
- for x in input_filtered:
|
||||
+ for x in input_filtered or (None,):
|
||||
for i, r in enumerate(ret):
|
||||
if r is not True and not isinstance(r, ExecutionBlocker):
|
||||
- details = f"{x}"
|
||||
+ details = x if x is not None else ""
|
||||
if r is not False:
|
||||
- details += f" - {str(r)}"
|
||||
+ details = f"{x} - {r}" if x is not None else str(r)
|
||||
|
||||
error = {
|
||||
"type": "custom_validation_failed",
|
||||
"message": "Custom validation failed for node",
|
||||
"details": details,
|
||||
- "extra_info": {
|
||||
- "input_name": x,
|
||||
- }
|
||||
+ "extra_info": {"input_name": x} if x is not None else {},
|
||||
}
|
||||
errors.append(error)
|
||||
continue
|
||||
|
||||
- if len(errors) > 0 or valid is not True:
|
||||
- ret = (False, errors, unique_id)
|
||||
- else:
|
||||
- ret = (True, [], unique_id)
|
||||
+ ret = validated.get(unique_id, (True, [], unique_id))
|
||||
+ # Recursive cycle detection may have already populated an error on us. Join it.
|
||||
+ ret = (
|
||||
+ ret[0] and valid is True and not errors,
|
||||
+ ret[1] + [error for error in errors if error not in ret[1]],
|
||||
+ unique_id,
|
||||
+ )
|
||||
|
||||
validated[unique_id] = ret
|
||||
- return ret+ return ret
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.17.0:validate_node_input
|
||||
+++ 8010:validate_node_input
|
||||
@@ -52,4 +52,4 @@
|
||||
return received_types.issubset(input_types)
|
||||
else:
|
||||
# In non-strict mode, there must be at least one type in common
|
||||
- return len(received_types.intersection(input_types)) > 0+ return len(received_types.intersection(input_types)) > 0
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
--- 0.17.0:validate_prompt
|
||||
+++ 8010:validate_prompt
|
||||
@@ -45,6 +45,16 @@
|
||||
"extra_info": {}
|
||||
}
|
||||
return (False, error, [], {})
|
||||
+
|
||||
+ start_nodes = set()
|
||||
+ end_nodes = set()
|
||||
+ for node_id, node in prompt.items():
|
||||
+ class_def = nodes.NODE_CLASS_MAPPINGS[node["class_type"]]
|
||||
+ boundary = class_def.GET_SCHEMA().loop_boundary if issubclass(class_def, _ComfyNodeInternal) else None
|
||||
+ if boundary == "start":
|
||||
+ start_nodes.add(node_id)
|
||||
+ elif boundary == "end":
|
||||
+ end_nodes.add(node_id)
|
||||
|
||||
good_outputs = set()
|
||||
errors = []
|
||||
@@ -101,6 +111,31 @@
|
||||
node_errors[node_id]["dependent_outputs"].append(o)
|
||||
logging.error("Output will be ignored")
|
||||
|
||||
+ has_dependency_cycle = any(
|
||||
+ reason["type"] == "dependency_cycle"
|
||||
+ for valid, reasons, _ in validated.values()
|
||||
+ for reason in reasons
|
||||
+ )
|
||||
+ if not has_dependency_cycle:
|
||||
+ try:
|
||||
+ validate_loops(prompt, outputs, validated, start_nodes, end_nodes)
|
||||
+ except LoopValidationError as ex:
|
||||
+ dependent_outputs = ex.error["extra_info"]["output_ids"]
|
||||
+ for node_id in ex.error["extra_info"]["node_ids"]:
|
||||
+ if node_id not in node_errors:
|
||||
+ node_errors[node_id] = {
|
||||
+ "errors": [],
|
||||
+ "dependent_outputs": [],
|
||||
+ "class_type": prompt[node_id]["class_type"],
|
||||
+ }
|
||||
+ node_errors[node_id]["errors"].append(ex.error)
|
||||
+ node_errors[node_id]["dependent_outputs"] = sorted(
|
||||
+ set(node_errors[node_id]["dependent_outputs"]).union(dependent_outputs)
|
||||
+ )
|
||||
+ for output_id in dependent_outputs:
|
||||
+ good_outputs.discard(output_id)
|
||||
+ errors.append((dependent_outputs[0], [ex.error]))
|
||||
+
|
||||
if len(good_outputs) == 0:
|
||||
errors_list = []
|
||||
for o, errors in errors:
|
||||
@@ -117,4 +152,4 @@
|
||||
|
||||
return (False, error, list(good_outputs), node_errors)
|
||||
|
||||
- return (True, None, list(good_outputs), node_errors)+ return (True, None, list(good_outputs), node_errors)
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
--- 0.21.1:_async_map_node_over_list
|
||||
+++ 8010:_async_map_node_over_list
|
||||
@@ -43,7 +43,7 @@
|
||||
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:
|
||||
- inputs = _io.build_nested_inputs(inputs, v3_data)
|
||||
+ inputs = _io.build_nested_inputs(inputs, v3_data, input_is_list=input_is_list)
|
||||
# V1
|
||||
else:
|
||||
f = getattr(obj, func)
|
||||
@@ -74,4 +74,4 @@
|
||||
for i in range(max_len_input):
|
||||
input_dict = slice_dict(input_data_all, i)
|
||||
await process_inputs(input_dict, i)
|
||||
- return results+ return results
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
--- 0.21.1:cache_update
|
||||
+++ 8010:cache_update
|
||||
@@ -1,5 +1,7 @@
|
||||
def cache_update(self, node_id, value):
|
||||
if node_id in self.execution_cache_listeners:
|
||||
- for to_node_id in self.execution_cache_listeners[node_id]:
|
||||
+ for to_node_id, from_socket in self.execution_cache_listeners[node_id]:
|
||||
if to_node_id in self.execution_cache:
|
||||
- self.execution_cache[to_node_id][node_id] = value+ self.execution_cache[to_node_id][node_id] = value
|
||||
+ if from_socket is not None and self.output_link_callback is not None:
|
||||
+ self.output_link_callback(value.outputs[from_socket])
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
--- 0.21.1:execute
|
||||
+++ 8010:execute
|
||||
@@ -1,4 +1,4 @@
|
||||
-async def execute(server, dynprompt, caches, current_item, extra_data, executed, prompt_id, execution_list, pending_subgraph_results, pending_async_nodes, ui_outputs):
|
||||
+async def execute(server: "ExecutionServer", dynprompt, caches, current_item, extra_data, executed, prompt_id, execution_list, pending_subgraph_results, pending_async_nodes, ui_outputs, asset_manager: AssetManager):
|
||||
unique_id = current_item
|
||||
real_node_id = dynprompt.get_real_node_id(unique_id)
|
||||
display_node_id = dynprompt.get_display_node_id(unique_id)
|
||||
@@ -8,7 +8,7 @@
|
||||
class_def = nodes.NODE_CLASS_MAPPINGS[class_type]
|
||||
cached = await caches.outputs.get(unique_id)
|
||||
if cached is not None:
|
||||
- _send_cached_ui(server, unique_id, display_node_id, cached, prompt_id, ui_outputs)
|
||||
+ emit_cached_output(server, unique_id, display_node_id, cached, prompt_id, ui_outputs, asset_manager)
|
||||
get_progress_state().finish_progress(unique_id)
|
||||
execution_list.cache_update(unique_id, cached)
|
||||
return (ExecutionResult.SUCCESS, None, None)
|
||||
@@ -81,6 +81,8 @@
|
||||
for i in required_inputs:
|
||||
execution_list.make_input_strong_link(unique_id, i)
|
||||
return (ExecutionResult.PENDING, None, None)
|
||||
+ if execution_list.is_staged_node_blocked():
|
||||
+ return (ExecutionResult.PENDING, None, None)
|
||||
|
||||
def execution_block_cb(block):
|
||||
if block.message is not None:
|
||||
@@ -108,10 +110,10 @@
|
||||
output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
|
||||
finally:
|
||||
if comfy.memory_management.aimdo_enabled:
|
||||
- if args.verbose == "DEBUG":
|
||||
+ if get_console_log_level(args.verbose) == "DEBUG":
|
||||
comfy_aimdo.control.analyze()
|
||||
+ comfy.model_prefetch.cleanup_prefetch_queues()
|
||||
comfy.model_management.reset_cast_buffers()
|
||||
- comfy.model_prefetch.cleanup_prefetch_queues()
|
||||
comfy_aimdo.model_vbar.vbars_reset_watermark_limits()
|
||||
|
||||
if has_pending_tasks:
|
||||
@@ -123,18 +125,20 @@
|
||||
unblock()
|
||||
asyncio.create_task(await_completion())
|
||||
return (ExecutionResult.PENDING, None, None)
|
||||
+ cache_ui_value = ui_outputs.get(unique_id)
|
||||
if len(output_ui) > 0:
|
||||
- ui_outputs[unique_id] = {
|
||||
- "meta": {
|
||||
- "node_id": unique_id,
|
||||
- "display_node": display_node_id,
|
||||
- "parent_node": parent_node_id,
|
||||
- "real_node_id": real_node_id,
|
||||
- },
|
||||
- "output": output_ui
|
||||
+ output_ui = enrich_output_with_media_metadata(output_ui)
|
||||
+ meta = {
|
||||
+ "node_id": unique_id,
|
||||
+ "display_node": display_node_id,
|
||||
+ "parent_node": parent_node_id,
|
||||
+ "real_node_id": real_node_id,
|
||||
}
|
||||
+ enriched_output_ui = register_executed_outputs(output_ui, prompt_id, asset_manager)
|
||||
+ ui_outputs[unique_id] = {"meta": meta, "output": enriched_output_ui}
|
||||
+ cache_ui_value = {"meta": meta, "output": output_ui}
|
||||
if server.client_id is not None:
|
||||
- server.send_sync("executed", { "node": unique_id, "display_node": display_node_id, "output": output_ui, "prompt_id": prompt_id }, server.client_id)
|
||||
+ server.send_sync("executed", { "node": unique_id, "display_node": display_node_id, "output": enriched_output_ui, "prompt_id": prompt_id }, server.client_id)
|
||||
if has_subgraph:
|
||||
cached_outputs = []
|
||||
new_node_ids = []
|
||||
@@ -171,7 +175,7 @@
|
||||
pending_subgraph_results[unique_id] = cached_outputs
|
||||
return (ExecutionResult.PENDING, None, None)
|
||||
|
||||
- cache_entry = CacheEntry(ui=ui_outputs.get(unique_id), outputs=output_data)
|
||||
+ cache_entry = CacheEntry(ui=cache_ui_value, outputs=output_data)
|
||||
execution_list.cache_update(unique_id, cache_entry)
|
||||
await caches.outputs.set(unique_id, cache_entry)
|
||||
|
||||
@@ -199,7 +203,7 @@
|
||||
|
||||
if comfy.model_management.is_oom(ex):
|
||||
tips = "This error means you ran out of memory on your GPU.\n\nTIPS: If the workflow worked before you might have accidentally set the batch_size to a large number."
|
||||
- logging.info("Memory summary: {}".format(comfy.model_management.debug_memory_summary()))
|
||||
+ logging.info("Memory summary:\n{}".format(comfy.model_management.debug_memory_summary()))
|
||||
logging.error("Got an OOM, unloading all loaded models.")
|
||||
comfy.model_management.unload_all_models()
|
||||
elif isinstance(ex, RuntimeError) and ("mat1 and mat2 shapes" in str(ex)) and "Sampler" in class_type:
|
||||
@@ -218,4 +222,4 @@
|
||||
get_progress_state().finish_progress(unique_id)
|
||||
executed.add(unique_id)
|
||||
|
||||
- return (ExecutionResult.SUCCESS, None, None)+ return (ExecutionResult.SUCCESS, None, None)
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.21.1:get_cache
|
||||
+++ 8010:get_cache
|
||||
@@ -6,4 +6,4 @@
|
||||
return None
|
||||
#Write back to the main cache on touch.
|
||||
self.output_cache.set_local(from_node_id, value)
|
||||
- return value+ return value
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
--- 0.21.1:get_input_data
|
||||
+++ 8010:get_input_data
|
||||
@@ -45,6 +45,10 @@
|
||||
hidden_inputs_v3[io.Hidden.auth_token_comfy_org] = extra_data.get("auth_token_comfy_org", None)
|
||||
if io.Hidden.api_key_comfy_org.name in hidden:
|
||||
hidden_inputs_v3[io.Hidden.api_key_comfy_org] = extra_data.get("api_key_comfy_org", None)
|
||||
+ if io.Hidden.comfy_usage_source.name in hidden:
|
||||
+ hidden_inputs_v3[io.Hidden.comfy_usage_source] = extra_data.get("comfy_usage_source", None)
|
||||
+ if io.Hidden.execution_list.name in hidden:
|
||||
+ hidden_inputs_v3[io.Hidden.execution_list] = execution_list
|
||||
else:
|
||||
if "hidden" in valid_inputs:
|
||||
h = valid_inputs["hidden"]
|
||||
@@ -53,6 +57,8 @@
|
||||
input_data_all[x] = [dynprompt.get_original_prompt() if dynprompt is not None else {}]
|
||||
if h[x] == "DYNPROMPT":
|
||||
input_data_all[x] = [dynprompt]
|
||||
+ if h[x] == "EXECUTION_LIST":
|
||||
+ input_data_all[x] = [execution_list]
|
||||
if h[x] == "EXTRA_PNGINFO":
|
||||
input_data_all[x] = [extra_data.get('extra_pnginfo', None)]
|
||||
if h[x] == "UNIQUE_ID":
|
||||
@@ -61,5 +67,7 @@
|
||||
input_data_all[x] = [extra_data.get("auth_token_comfy_org", None)]
|
||||
if h[x] == "API_KEY_COMFY_ORG":
|
||||
input_data_all[x] = [extra_data.get("api_key_comfy_org", None)]
|
||||
+ if h[x] == "COMFY_USAGE_SOURCE":
|
||||
+ input_data_all[x] = [extra_data.get("comfy_usage_source", None)]
|
||||
v3_data["hidden_inputs"] = hidden_inputs_v3
|
||||
- return input_data_all, missing_keys, v3_data+ return input_data_all, missing_keys, v3_data
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.21.1:get_input_info
|
||||
+++ 8010:get_input_info
|
||||
@@ -38,4 +38,4 @@
|
||||
# if isinstance(input_type, list):
|
||||
# extra_info["options"] = input_type
|
||||
# input_type = IO.Combo.io_type
|
||||
- return input_type, input_category, extra_info+ return input_type, input_category, extra_info
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.21.1:get_output_data
|
||||
+++ 8010:get_output_data
|
||||
@@ -4,4 +4,4 @@
|
||||
if has_pending_task:
|
||||
return return_values, {}, False, has_pending_task
|
||||
output, ui, has_subgraph = get_output_from_returns(return_values, obj)
|
||||
- return output, ui, has_subgraph, False+ return output, ui, has_subgraph, False
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.21.1:get_output_from_returns
|
||||
+++ 8010:get_output_from_returns
|
||||
@@ -61,4 +61,4 @@
|
||||
# any nodes that use both subgraph expansion and custom UI outputs, but might be a problem in the future.
|
||||
if len(uis) > 0:
|
||||
ui = {k: [y for x in uis for y in x[k]] for k in uis[0].keys()}
|
||||
- return output, ui, has_subgraph+ return output, ui, has_subgraph
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.21.1:is_link
|
||||
+++ 8010:is_link
|
||||
@@ -7,4 +7,4 @@
|
||||
return False
|
||||
if not isinstance(obj[1], int) and not isinstance(obj[1], float):
|
||||
return False
|
||||
- return True+ return True
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.21.1:merge_result_data
|
||||
+++ 8010:merge_result_data
|
||||
@@ -17,4 +17,4 @@
|
||||
output.append(value)
|
||||
else:
|
||||
output.append([o[i] for o in results])
|
||||
- return output+ return output
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
--- 0.21.1:validate_inputs
|
||||
+++ 8010:validate_inputs
|
||||
@@ -35,7 +35,17 @@
|
||||
if issubclass(obj_class, _ComfyNodeInternal):
|
||||
obj_class: _io._ComfyNodeBaseInternal
|
||||
class_inputs = obj_class.INPUT_TYPES()
|
||||
- class_inputs, _, v3_data = _io.get_finalized_class_inputs(class_inputs, inputs)
|
||||
+ try:
|
||||
+ class_inputs, _, v3_data = _io.get_finalized_class_inputs(class_inputs, inputs)
|
||||
+ except _io.DynamicInputError as ex:
|
||||
+ errors.append({
|
||||
+ "type": "invalid_dynamic_input",
|
||||
+ "message": "Invalid dynamic input",
|
||||
+ "details": str(ex),
|
||||
+ "extra_info": {"input_name": ex.input_name},
|
||||
+ })
|
||||
+ validated[unique_id] = (False, errors, unique_id)
|
||||
+ return validated[unique_id]
|
||||
validate_function_name = "validate_inputs"
|
||||
validate_function = first_real_override(obj_class, validate_function_name)
|
||||
else:
|
||||
@@ -236,29 +246,35 @@
|
||||
|
||||
if len(validate_function_inputs) > 0 or validate_has_kwargs:
|
||||
input_data_all, _, v3_data = get_input_data(inputs, obj_class, unique_id)
|
||||
+ dynamic_paths = v3_data.get("dynamic_paths", {})
|
||||
+ if not validate_has_kwargs:
|
||||
+ dynamic_paths = {key: path for key, path in dynamic_paths.items() if path.split(".")[0] in validate_function_inputs}
|
||||
+ v3_data = v3_data | {
|
||||
+ "dynamic_paths": dynamic_paths,
|
||||
+ "list_paths": {path for path in v3_data.get("list_paths", set()) if path.split(".")[0] in validate_function_inputs},
|
||||
+ }
|
||||
input_filtered = {}
|
||||
for x in input_data_all:
|
||||
- if x in validate_function_inputs or validate_has_kwargs:
|
||||
+ input_name = dynamic_paths[x].split(".")[0] if x in dynamic_paths else x
|
||||
+ if input_name in validate_function_inputs or validate_has_kwargs:
|
||||
input_filtered[x] = input_data_all[x]
|
||||
if 'input_types' in validate_function_inputs:
|
||||
input_filtered['input_types'] = [received_types]
|
||||
|
||||
ret = await _async_map_node_over_list(prompt_id, unique_id, obj_class, input_filtered, validate_function_name, v3_data=v3_data)
|
||||
ret = await resolve_map_node_over_list_results(ret)
|
||||
- for x in input_filtered:
|
||||
+ for x in input_filtered or (None,):
|
||||
for i, r in enumerate(ret):
|
||||
if r is not True and not isinstance(r, ExecutionBlocker):
|
||||
- details = f"{x}"
|
||||
+ details = x if x is not None else ""
|
||||
if r is not False:
|
||||
- details += f" - {str(r)}"
|
||||
+ details = f"{x} - {r}" if x is not None else str(r)
|
||||
|
||||
error = {
|
||||
"type": "custom_validation_failed",
|
||||
"message": "Custom validation failed for node",
|
||||
"details": details,
|
||||
- "extra_info": {
|
||||
- "input_name": x,
|
||||
- }
|
||||
+ "extra_info": {"input_name": x} if x is not None else {},
|
||||
}
|
||||
errors.append(error)
|
||||
continue
|
||||
@@ -272,4 +288,4 @@
|
||||
)
|
||||
|
||||
validated[unique_id] = ret
|
||||
- return ret+ return ret
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
--- 0.21.1:validate_node_input
|
||||
+++ 8010:validate_node_input
|
||||
@@ -52,4 +52,4 @@
|
||||
return received_types.issubset(input_types)
|
||||
else:
|
||||
# In non-strict mode, there must be at least one type in common
|
||||
- return len(received_types.intersection(input_types)) > 0+ return len(received_types.intersection(input_types)) > 0
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
--- 0.21.1:validate_prompt
|
||||
+++ 8010:validate_prompt
|
||||
@@ -45,6 +45,16 @@
|
||||
"extra_info": {}
|
||||
}
|
||||
return (False, error, [], {})
|
||||
+
|
||||
+ start_nodes = set()
|
||||
+ end_nodes = set()
|
||||
+ for node_id, node in prompt.items():
|
||||
+ class_def = nodes.NODE_CLASS_MAPPINGS[node["class_type"]]
|
||||
+ boundary = class_def.GET_SCHEMA().loop_boundary if issubclass(class_def, _ComfyNodeInternal) else None
|
||||
+ if boundary == "start":
|
||||
+ start_nodes.add(node_id)
|
||||
+ elif boundary == "end":
|
||||
+ end_nodes.add(node_id)
|
||||
|
||||
good_outputs = set()
|
||||
errors = []
|
||||
@@ -101,6 +111,31 @@
|
||||
node_errors[node_id]["dependent_outputs"].append(o)
|
||||
logging.error("Output will be ignored")
|
||||
|
||||
+ has_dependency_cycle = any(
|
||||
+ reason["type"] == "dependency_cycle"
|
||||
+ for valid, reasons, _ in validated.values()
|
||||
+ for reason in reasons
|
||||
+ )
|
||||
+ if not has_dependency_cycle:
|
||||
+ try:
|
||||
+ validate_loops(prompt, outputs, validated, start_nodes, end_nodes)
|
||||
+ except LoopValidationError as ex:
|
||||
+ dependent_outputs = ex.error["extra_info"]["output_ids"]
|
||||
+ for node_id in ex.error["extra_info"]["node_ids"]:
|
||||
+ if node_id not in node_errors:
|
||||
+ node_errors[node_id] = {
|
||||
+ "errors": [],
|
||||
+ "dependent_outputs": [],
|
||||
+ "class_type": prompt[node_id]["class_type"],
|
||||
+ }
|
||||
+ node_errors[node_id]["errors"].append(ex.error)
|
||||
+ node_errors[node_id]["dependent_outputs"] = sorted(
|
||||
+ set(node_errors[node_id]["dependent_outputs"]).union(dependent_outputs)
|
||||
+ )
|
||||
+ for output_id in dependent_outputs:
|
||||
+ good_outputs.discard(output_id)
|
||||
+ errors.append((dependent_outputs[0], [ex.error]))
|
||||
+
|
||||
if len(good_outputs) == 0:
|
||||
errors_list = []
|
||||
for o, errors in errors:
|
||||
@@ -117,4 +152,4 @@
|
||||
|
||||
return (False, error, list(good_outputs), node_errors)
|
||||
|
||||
- return (True, None, list(good_outputs), node_errors)+ return (True, None, list(good_outputs), node_errors)
|
||||
Reference in New Issue
Block a user