Datasets:
Download fineenvs_v3/patch.py from FWeindel/validated-tasks: direct link, hf CLI and curl.
- Browser
- Download file 3.31 kB
-
https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/main/fineenvs_v3/patch.py
- Command line
-
hf download hf://datasets/FWeindel/validated-tasks/fineenvs_v3/patch.py
-
curl -L -o patch.py https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/main/fineenvs_v3/patch.py
3.31 kB
| """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() | |