"""Only the 11 Huobao tasks explicitly approved by the user for cancellation.""" import subprocess,json,pathlib ids=['8c75d5aa-d171-4591-8d4e-3ef3adc3c395','db146728-576c-443b-825a-cafef33125cf','11c9aa8c-eb8a-48d1-b7f5-4ced56201c3b','c391b659-bbde-49d0-9810-5d3010a10975','62ad95b4-90b4-4ac8-9707-8d82b43199f0','5dd36c20-80d0-456f-80a8-6fc63ac514c5','b31adacb-32b8-4ed0-b0cf-61913a1f314f','813fb420-aeed-4566-8649-35186ce2cefd','a5969921-5676-4fa3-9bfa-571d728b8501','8c7ab7aa-7a5b-41e7-af47-731f938e9ad7','2cbd3308-b9cc-4f75-9589-cea59ef3a45b'] code='''import asyncio,httpx,json,app APPROVED=__IDS__ async def main(): p=app.providers()['default'];headers=app.provider_headers(p) async with httpx.AsyncClient(timeout=30) as c: q=(await c.get(p.base_url+'/queue',headers=headers)).json() pending=[x[1] for x in q.get('queue_pending',[]) if x[1] in APPROVED] if pending: r=await c.post(p.base_url+'/queue',headers=headers,json={'delete':pending});r.raise_for_status() q=(await c.get(p.base_url+'/queue',headers=headers)).json() running=[x[1] for x in q.get('queue_running',[])] interrupted=[] if running and all(x in APPROVED for x in running) and not q.get('queue_pending'): r=await c.post(p.base_url+'/interrupt',headers=headers,json={});r.raise_for_status();interrupted=running print(json.dumps({'removed_pending':pending,'interrupted':interrupted,'all_other_jobs_preserved':True})) asyncio.run(main()) '''.replace('__IDS__',repr(set(ids))) out=subprocess.check_output(['docker','exec','huobao-vdn-normalizer','python','-c',code],text=True) pathlib.Path('/home/ps/huobao-gpu-selection/cancel-approved-eleven.json').write_text(out) print(out)