57 lines
2.2 KiB
Plaintext
57 lines
2.2 KiB
Plaintext
--- 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)
|