import pathlib,datetime,json,hashlib,shutil,subprocess root=pathlib.Path('/home/ps/huobao-gpu-selection');folder=root/('task-tracking-'+datetime.datetime.now().strftime('%Y%m%d-%H%M%S'));folder.mkdir(mode=0o700) addition=''' @app.get("/v1/huobao/jobs/{job_id}", dependencies=[Depends(require_token)]) async def huobao_job_status(job_id: str) -> dict[str, Any]: # Keep the general API contract unchanged; Huobao needs actual queue state. result = await get_job(job_id) if result.get("status") != "running": return {**result, "worker_state": result.get("status")} if result.get("pollDeferred"): return {**result, "worker_state": "checking"} provider, prompt_id = decode_job(job_id) async with httpx.AsyncClient(timeout=10) as client: response = await client.get(f"{provider.base_url}/queue", headers=provider_headers(provider)) response.raise_for_status() queue = response.json() running = [row[1] for row in queue.get("queue_running", [])] pending = [row[1] for row in queue.get("queue_pending", [])] if prompt_id in running: return {**result, "worker_state": "running"} if prompt_id in pending: return {**result, "worker_state": "queued", "queue_position": pending.index(prompt_id) + 1} # A task may finish between the first history read and the queue read. fresh = await get_job(job_id) if fresh.get("status") != "running": return {**fresh, "worker_state": fresh.get("status")} if fresh.get("pollDeferred"): return {**fresh, "worker_state": "checking"} # Do not invent success/failure or submit again when a worker has lost history. return {**fresh, "worker_state": "missing"} ''' manifest={} for short,name in [('general','canvas-h3-prompt-normalizer-healthy-20261026'),('vdn','huobao-vdn-normalizer')]: p=root/(name+'.candidate.py');source=p.read_text();assert '/v1/huobao/jobs/{job_id}' not in source shutil.copy2(p,folder/(short+'.before.py')) candidate=folder/(short+'.after.py');candidate.write_text(source+addition);compile(candidate.read_text(),str(candidate),'exec') manifest[short]={'name':name,'path':str(p),'candidate':str(candidate),'before':hashlib.sha256(p.read_bytes()).hexdigest(),'after':hashlib.sha256(candidate.read_bytes()).hexdigest()} for short,foldername in [('main','huobao-model-bridge'),('hd','huobao-vdn/bridge')]: p=pathlib.Path('/home/ps')/foldername/'bridge.py';shutil.copy2(p,folder/(short+'-bridge.before.py')) manifest[short+'-bridge']={'path':str(p),'before':hashlib.sha256(p.read_bytes()).hexdigest()} (folder/'manifest.json').write_text(json.dumps(manifest,indent=2));(root/'task-tracking-current.json').write_text(json.dumps({'directory':str(folder)})) print('Prepared',str(folder)) names=subprocess.check_output(['docker','ps','-a','--format','{{.Names}}'],text=True).splitlines() print('MANJU_CONTAINERS',[n for n in names if 'manju' in n])