"""Resume remaining jobs, retaining every failed transport's full reserve.""" import sys,json,shutil,concurrent.futures,uuid from pathlib import Path extra='--added' in sys.argv if extra:sys.argv.append('--added-tasks') import run_suite as s s.R=s.B/('execution-added'if extra else'execution');s.ledger_path=s.R/'ledger.json';s.limit=s.Decimal('50') root=s.R;batch=uuid.uuid4().hex[:8];jobs=[] for rep in [1,2]: for task in (range(7,11)if extra else 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=root/'runs'/rid if not p.exists():jobs.append((model,task,rep));continue if not(p/'result.json').exists():continue result=json.loads((p/'result.json').read_text());status=result['stages']['initial']['status'] if status=='stopped: Global accounting halt' or ('Connection reset' in status and not any((root/'attempts').glob('*/'+rid))): dest=root/'attempts'/('resume-'+batch)/rid;dest.parent.mkdir(parents=True,exist_ok=True);shutil.move(str(p),dest);jobs.append((model,task,rep)) original=s.call def call(model,messages,ident):return original(model,messages,ident+'-resume'+batch) s.call=call s.save(root/('resume-'+batch+'.json'),{'reason':'Preserve unknown reserves; continue independent jobs without global cancellation. All earlier attempts retained.','jobs':len(jobs),'time':s.now(),'allocation_usd':50}) with concurrent.futures.ThreadPoolExecutor(max_workers=3)as pool: futures=[pool.submit(s.run,*j)for j in jobs] for f in concurrent.futures.as_completed(futures): try:f.result() except Exception as e:print('REMAINING ERROR',str(e),flush=True)