"""Checks every ComfyUI workflow template against a running ComfyUI (CPU is enough): the nodes must exist and the inputs must be accepted by /prompt. It does not generate anything. Model files must exist, even empty ones, in the ComfyUI models folders, and the input files must exist in its input folder. python tests/modules/validate_workflows.py [http://127.0.0.1:18188] """ import glob, json, os, sys, urllib.request, urllib.error base = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:18188" vals = { "prompt": "a cat", "width": 832, "height": 480, "count": 1, "seed": 1, "prefix": "wxch/test/out", "length": 73, "fps": 24, "image": "in.png", "steps": 4, "cfg": 1.0, "lora_strength": 1.0, "video": "in.mp4", "down": 0.5, "multiplier": 2, } def fill(x): if isinstance(x, dict): return {k: fill(v) for k, v in x.items()} if isinstance(x, list): return [fill(v) for v in x] if isinstance(x, str) and x.startswith("@") and len(x) > 1: return vals[x[1:]] return x bad = 0 here = os.path.dirname(os.path.abspath(__file__)) for path in sorted(glob.glob(os.path.join(here, "..", "..", "catalog", "workflows", "*.json"))): wf = fill(json.load(open(path, encoding="utf-8"))) req = urllib.request.Request(base + "/prompt", json.dumps({"prompt": wf}).encode(), {"Content-Type": "application/json"}) name = os.path.basename(path) try: r = json.load(urllib.request.urlopen(req, timeout=60)) print("ok ", name, r.get("prompt_id")) except urllib.error.HTTPError as e: bad += 1 print("FAIL", name) print(" ", e.read().decode()[:1500]) sys.exit(1 if bad else 0)