"""Reproduce the frozen SETA v2 partial-result selection. Requires pyarrow and huggingface_hub.""" import argparse,copy,hashlib,json from pathlib import Path import pyarrow as pa import pyarrow.parquet as pq from huggingface_hub import hf_hub_download p=argparse.ArgumentParser(description=__doc__);p.add_argument('--out',type=Path,required=True);p.add_argument('--source',type=Path);a=p.parse_args() m=json.loads((Path(__file__).parent/'assets/selection.json').read_text());a.out.mkdir(parents=True,exist_ok=True) assert not (a.out/'tasks.parquet').exists(),'Choose an empty output directory' f=a.source or Path(hf_hub_download(m['repo_id'],m['source_folder']+'/tasks.parquet',revision=m['source_revision'],repo_type='dataset',cache_dir=a.out/'.source-cache')) assert hashlib.sha256(f.read_bytes()).hexdigest()==m['source_sha256'] t=pq.read_table(f);rows=[];schema=t.schema.remove_metadata() for prefix in ['instruct','thinking']: for suffix in ['successes','graded_attempts','missing_attempts']: schema=schema.append(pa.field(prefix+'_'+suffix,pa.int64())) schema=schema.append(pa.field('target_attempts_per_model',pa.int64())) for r in t.to_pylist(): s=m['tasks'][r['path']];assert r['content_sha256']==s['content_sha256'] if not s['kept']:continue for prefix,model in [('instruct','qwen3-30b-instruct-2507'),('thinking','qwen3-30b-thinking')]: v=s['models'][model];assert v['successful_attempts']==sum(x==1 for x in v['rewards']) assert v['graded_attempts']==sum(x is not None for x in v['rewards']) assert v['missing_attempts']==16-v['graded_attempts'] for suffix,key in [('successes','successful_attempts'),('graded_attempts','graded_attempts'),('missing_attempts','missing_attempts')]:r[prefix+'_'+suffix]=v[key] assert r['instruct_successes'] or r['thinking_successes'] r['target_attempts_per_model']=16;rows.append(r) assert len(rows)==2150 names={r['path'] for r in rows};images=json.loads(t.schema.metadata[b'ot.images.v1']);images['tasks']={k:v for k,v in images['tasks'].items() if k in names};assert set(images['tasks'])==names bundles={e['bundle'] for v in images['tasks'].values() for e in v['environments']};images['bundles']={k:v for k,v in images['bundles'].items() if k in bundles};images['missing']=[] meta={b'ot.images.v1':json.dumps(images).encode(),b'ot.release.v2':json.dumps({k:v for k,v in m.items() if k!='tasks'}).encode()} pq.write_table(pa.Table.from_pylist(rows,schema=schema).replace_schema_metadata(meta),a.out/'tasks.parquet',compression='zstd') print(json.dumps({'retained':len(rows),'images_reused':len(bundles)}))