"""Reproduce CalibForge v3 incremental tasks and remaining-unsolved archive. Requires huggingface_hub and pyarrow. Does not rerun evaluation. """ import argparse,hashlib,json from pathlib import Path import pyarrow as pa,pyarrow.parquet as pq from huggingface_hub import hf_hub_download def build(out): s=json.loads((Path(__file__).parent/'metadata/selection.json').read_text()) p=hf_hub_download('FWeindel/validated-tasks',s['source_folder']+'/tasks.parquet',repo_type='dataset',revision=s['source_revision']) assert hashlib.sha256(Path(p).read_bytes()).hexdigest()==s['source_sha256'] t=pq.read_table(p,columns=['path','task_binary','content_sha256']);t=t.filter(pa.array([x in s['tasks'] for x in t['path'].to_pylist()]));ids=t['path'].to_pylist() for x,h in zip(ids,t['content_sha256'].to_pylist()):assert h==s['tasks'][x]['content_sha256'] for c,typ in [('qwen38_successes',pa.int64()),('qwen38_attempts',pa.int64()),('kept_from_v2',pa.bool_())]:t=t.append_column(c,pa.array([s['tasks'][x][c] for x in ids],type=typ)) out.mkdir(parents=True,exist_ok=True) for name,keep in [('tasks.parquet',True),('archive.parquet',False)]: a=t.filter(pa.array([s['tasks'][x]['kept']==keep for x in ids]));chosen=set(a['path'].to_pylist());m=dict(a.schema.metadata or {}) if b'ot.images.v1' in m: im=json.loads(m[b'ot.images.v1']);im['tasks']={k:v for k,v in im['tasks'].items() if k in chosen};used={e['bundle'] for v in im['tasks'].values() for e in v['environments']};im['bundles']={k:v for k,v in im['bundles'].items() if k in used};im['coverage']={'cached_tasks':len(im['tasks']),'total_tasks':len(chosen)} if 'uncached_task_ids' in im:im['uncached_task_ids']=sorted(chosen-set(im['tasks'])) m[b'ot.images.v1']=json.dumps(im).encode() m[b'ot.release.v3']=json.dumps({'layout':'incremental','kept':len(chosen),'baseline_folder':'calibforge_v2','baseline_revision':'a8acfde13cc1be1672da3d17ee70bc4d842b4c19'}).encode() pq.write_table(a.replace_schema_metadata(m),out/name,compression='zstd') if __name__=='__main__': p=argparse.ArgumentParser();p.add_argument('--out',type=Path,required=True);a=p.parse_args();build(a.out)