File size: 3,310 Bytes
58ffc16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Reproduce FineEnvs v3 membership: newly solved tasks and the remaining-unsolved archive.
python patch.py --out reproduced [--source /path/to/pinned/fineenvs_v2/archive.parquet]
Requires pyarrow and huggingface_hub; metadata/selection.json beside this script. Task payloads
are the evaluated fineenvs_v2 archive rows; only archive status and success-count columns change.
Does not rerun evaluation.
"""
from pathlib import Path
import argparse,json,hashlib
import pyarrow as pa,pyarrow.parquet as pq

REASON='No observed success in four Qwen/Qwen3-30B-A3B-Instruct-2507 attempts (v2) or two Qwen/Qwen3.8-27B thinking attempts (v3); terminal errors counted as unsolved.'

def main():
 p=argparse.ArgumentParser();p.add_argument('--out',type=Path,required=True);p.add_argument('--source',type=Path);a=p.parse_args()
 s=json.loads((Path(__file__).parent/'metadata/selection.json').read_text());tasks=s['tasks']
 if a.source is None:
  from huggingface_hub import hf_hub_download
  a.source=Path(hf_hub_download('FWeindel/validated-tasks',f"{s['source_folder']}/{s['source_file']}",repo_type='dataset',revision=s['source_revision']))
 assert hashlib.file_digest(a.source.open('rb'),'sha256').hexdigest()==s['source_sha256']
 pf=pq.ParquetFile(a.source);schema=pf.schema_arrow
 for c,typ in [('qwen38_successes',pa.int64()),('qwen38_attempts',pa.int64()),('kept_from_v2',pa.bool_())]:schema=schema.append(pa.field(c,typ))
 kept={t for t,v in tasks.items() if v['kept']};a.out.mkdir(parents=True,exist_ok=True);writers={}
 for name,chosen in [('tasks.parquet',kept),('archive.parquet',set(tasks)-kept)]:
  meta=dict(schema.metadata or {});im=json.loads(meta[b'ot.images.v1'])
  im['tasks']={t:v for t,v in im['tasks'].items() if t 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}
  if 'coverage' in im:im['coverage']={**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']))
  meta[b'ot.images.v1']=json.dumps(im).encode()
  meta[b'ot.release.v3']=json.dumps({'layout':'incremental','kept':len(kept),'rows':len(chosen),'baseline_folder':s['baseline_folder'],'baseline_revision':s['source_revision'],'source':f"{s['source_folder']}/{s['source_file']}",'source_sha256':s['source_sha256']}).encode()
  writers[name]=pq.ParquetWriter(a.out/name,schema.with_metadata(meta),compression='zstd')
 seen=set()
 try:
  for batch in pf.iter_batches(batch_size=4):
   groups={n:[] for n in writers}
   for row in batch.to_pylist():
    v=tasks[row['path']];assert v['content_sha256']==row['content_sha256'];seen.add(row['path'])
    if v['kept']:row.update(archive_stage=None,archive_reason=None,archive_labels=[]);n='tasks.parquet'
    else:row.update(archive_stage=6,archive_reason=REASON,archive_labels=['teacher:no-observed-success']);n='archive.parquet'
    row.update(qwen38_successes=v['qwen38_successes'],qwen38_attempts=v['qwen38_attempts'],kept_from_v2=False);groups[n].append(row)
   for n,rows in groups.items():
    if rows:writers[n].write_table(pa.Table.from_pylist(rows,schema=writers[n].schema))
 finally:
  for w in writers.values():w.close()
 assert seen==set(tasks)
if __name__=='__main__':main()