Files
dj/integration-work/preflight_all_workflows.py
T

34 lines
2.3 KiB
Python

import subprocess,json,pathlib
code='''import asyncio,json,httpx,app
from workflow import compile_workflow,load_registry
workflows={'minimax_h3_t2v_official':0,'minimax_h3_i2v':1,'minimax_h3_r2v':1,'minimax_h3_hybrid_v0331_t2v':0,'minimax_h3_hybrid_v0331_i2v':1,'minimax_h3_r2v_4step':1,'ltx23_t2v':0,'ltx23_t2v_text_preserve':0,'wan22_simple':1,'qwen_image_2_1':0}
async def main():
registry=load_registry();report={}
async with httpx.AsyncClient(timeout=30) as c:
for p in app.providers().values():
r=await c.get(p.base_url+'/object_info',headers=app.provider_headers(p));r.raise_for_status();info=r.json();checks={}
for key,refs in list(workflows.items())+[('qwen_image_2_1',1)]:
spec=registry[key];req=app.JobRequest(workflow_key=key,prompt='A quiet mountain lake. No dialogue.',duration=4,width=512,height=512)
plan=app.request_audio_plan(spec,req)
if plan.get('supported'):req=req.model_copy(update={'prompt':plan['normalized_prompt']})
graph=compile_workflow(spec,req.model_dump(),['preflight.png']*refs,'huobao-check',preserve_requested_audio=bool(plan.get('supported')))
missing=[]
for node in graph.values():
typ=node['class_type']
if typ not in info:missing.append(typ);continue
ni=info[typ].get('input',{});fields={**ni.get('required',{}),**ni.get('optional',{})}
for field,val in node['inputs'].items():
opt=fields.get(field)
if not isinstance(val,str) or not opt or field=='image':continue
options=opt[0] if isinstance(opt[0],list) else opt[1].get('options') if len(opt)>1 and isinstance(opt[1],dict) else None
if options and val not in [v.get('key') if isinstance(v,dict) else v for v in options]:missing.append(typ+':'+field+':'+val)
checks[key+('-reference' if refs else '')]=missing
report[p.id]=checks
print(json.dumps(report))
asyncio.run(main())
'''
out=subprocess.check_output(['docker','exec','canvas-h3-prompt-normalizer-healthy-20261026','python','-c',code],text=True)
report=json.loads(out);pathlib.Path('/home/ps/huobao-gpu-selection/all-workflows-preflight.json').write_text(json.dumps(report,indent=2))
for provider,checks in report.items():print(provider,'checked',len(checks),'missing',{k:v for k,v in checks.items() if v})
assert all(not issues for checks in report.values() for issues in checks.values())