"""Resume undispatched work and preserve infrastructure-interrupted attempts.""" import json,shutil,concurrent.futures,sys import run_suite as s # The original batch keeps its original limits and its own50USD allocation. s.R=s.B/'execution';s.ledger_path=s.R/'ledger.json';s.limit=s.Decimal('50') R=s.R;jobs=[];retry_runs=set() for rep in [1,2]: for task in range(1,7): names=list(s.MODELS);shift=(task-1+(rep-1)*2)%5 for model in names[shift:]+names[:shift]: tag={'Qwen 4':'qwen4','Astra':'astra','Sol':'sol','Opus':'opus','Fable':'fable'}[model];rid=f'T{task:02}-R{rep}-{tag}';p=R/'runs'/rid if not p.exists():jobs.append((model,task,rep));continue result=json.loads((p/'result.json').read_text())if(p/'result.json').exists()else None status=result.get('stages',{}).get('initial',{}).get('status','')if result else'' if status=='stopped: Global accounting halt': dest=R/'attempts'/'batch-halt'/rid;dest.parent.mkdir(parents=True,exist_ok=True);shutil.move(str(p),dest);jobs.append((model,task,rep));retry_runs.add(rid) original=s.call def call(model,messages,ident): rid=ident.split('-initial-')[0].split('-revision-')[0] if rid in retry_runs:ident=ident.replace(rid+'-',rid+'-retry1-',1) return original(model,messages,ident) s.call=call s.save(R/'resume-note.json',{'reason':'Qwen task04revision connection reset halted batch. Unsent jobs resume; partial SolT04andFableT05infrastructure-interrupted attempts preserved and rerun once. Qwen partial revision not silently replaced.','jobs':len(jobs),'retry_runs':sorted(retry_runs),'time':s.now(),'allocation_usd':50}) with concurrent.futures.ThreadPoolExecutor(max_workers=3)as pool: fs=[pool.submit(s.run,*j)for j in jobs] for f in concurrent.futures.as_completed(fs): try:f.result() except Exception as e:print('RESUME ERROR',str(e),flush=True)