57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
"""Independent physical endpoint/slot and declared type inventory, no graph execution."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
OUT = Path(__file__).resolve().parent
|
|
PATH = "example_ComfyUI_workflows/6-动作迁移/Wan_Animate2_动作迁移_for循环长视频.json"
|
|
|
|
|
|
def main():
|
|
root = json.loads((ROOT / PATH).read_bytes())
|
|
results = []
|
|
for scope, graph in [("root", root)] + [
|
|
(definition["id"], definition) for definition in root["definitions"]["subgraphs"]
|
|
]:
|
|
nodes = {node["id"]: node for node in graph["nodes"]}
|
|
if scope != "root":
|
|
nodes[graph["inputNode"]["id"]] = {"outputs": graph["inputs"]}
|
|
nodes[graph["outputNode"]["id"]] = {"inputs": graph["outputs"]}
|
|
for edge in graph["links"]:
|
|
if isinstance(edge, list):
|
|
eid, origin, origin_slot, target, target_slot, edge_type = edge
|
|
else:
|
|
eid = edge["id"]
|
|
origin, origin_slot = edge["origin_id"], edge["origin_slot"]
|
|
target, target_slot = edge["target_id"], edge["target_slot"]
|
|
edge_type = edge["type"]
|
|
source_port = nodes[origin]["outputs"][origin_slot]
|
|
target_port = nodes[target]["inputs"][target_slot]
|
|
results.append(
|
|
dict(
|
|
scope=scope,
|
|
id=eid,
|
|
origin=[origin, origin_slot],
|
|
target=[target, target_slot],
|
|
edge_type=edge_type,
|
|
origin_type=source_port.get("type"),
|
|
target_type=target_port.get("type"),
|
|
both_endpoint_slots_exist=True,
|
|
)
|
|
)
|
|
assert len(results) == 221
|
|
(OUT / "endpoint-check.json").write_text(
|
|
json.dumps(
|
|
dict(records=221, endpoints=results, type_compatibility_executed=False, repaired=False),
|
|
ensure_ascii=False,
|
|
indent=2,
|
|
)
|
|
+ "\n"
|
|
)
|
|
print("PASS221 physical endpoint ids/slots; original types separate, no execution")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|