Files
dj/integration-work/verify_and_remove_reference_probe.py
T

26 lines
1.6 KiB
Python

import subprocess
# This exact test job was submitted by verify_reference_image_live.py; never touch project jobs.
code='''import asyncio,json,httpx,app
jid='Z3B1MV84MTg5Ojc1NTgyYWE1LWMxNzgtNGFmMi1iMjJkLTNjMzE5ZTFjZmNhNg'
async def main():
p,pid=app.decode_job(jid)
assert p.id=='gpu1_8189' and pid=='75582aa5-c178-4af2-b22d-3c319e1cfca6'
async with httpx.AsyncClient(timeout=15) as c:
q=(await c.get(p.base_url+'/queue',headers=app.provider_headers(p))).json()
found=next((x for x in q.get('queue_pending',[]) if x[1]==pid),None)
assert found is not None,'Probe no longer pending; leave unchanged for inspection'
graph=found[2]
refs=[n['inputs']['image'] for n in graph.values() if n.get('class_type')=='LoadImage']
assert len(refs)==1,[(n.get('class_type'),list(n.get('inputs',{}))) for n in graph.values()]
print(json.dumps({'probe':pid,'provider':p.id,'reference_uploads':refs,'node_types':sorted({n['class_type'] for n in graph.values()})}))
before={x[1] for x in q.get('queue_pending',[])+q.get('queue_running',[]) if x[1]!=pid}
result=await app.cancel_job(jid)
assert result['status']=='cancelled',result
q2=(await c.get(p.base_url+'/queue',headers=app.provider_headers(p))).json()
after={x[1] for x in q2.get('queue_pending',[])+q2.get('queue_running',[])}
assert before<=after and pid not in after
print(json.dumps({'cancelled_only_probe':True,'other_queued_or_running_tasks_preserved':len(before)}))
asyncio.run(main())'''
r=subprocess.run(['docker','exec','canvas-h3-prompt-normalizer-healthy-20261026','python','-c',code],capture_output=True,text=True)
print(r.stdout);print(r.stderr);raise SystemExit(r.returncode)