Datasets:
Download fineenvs_v2/patch.py from FWeindel/validated-tasks: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/main/fineenvs_v2/patch.py
- Command line
-
hf download hf://datasets/FWeindel/validated-tasks/fineenvs_v2/patch.py
-
curl -L -o patch.py https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/main/fineenvs_v2/patch.py
1.81 kB
| """Reproduce FineEnvs v2 membership, preserving task payloads. | |
| python patch.py --out reproduced [--source /path/to/pinned/v1/tasks.parquet] | |
| Requires pyarrow and huggingface_hub; metadata/selection.json beside this script. | |
| """ | |
| from pathlib import Path | |
| import argparse,json,hashlib | |
| import pyarrow as pa,pyarrow.parquet as pq | |
| def main(): | |
| p=argparse.ArgumentParser();p.add_argument('--out',type=Path,required=True);p.add_argument('--source',type=Path);a=p.parse_args() | |
| root=Path(__file__).parent;s=json.loads((root/'metadata/selection.json').read_text()) | |
| if a.source is None: | |
| from huggingface_hub import hf_hub_download | |
| a.source=Path(hf_hub_download('FWeindel/validated-tasks','fineenvs_v1/tasks.parquet',repo_type='dataset',revision=s['base_revision'])) | |
| expected=json.loads((root/'metadata/contract.json').read_text())['dataset']['source_files'][0]['sha256'] | |
| assert hashlib.file_digest(a.source.open('rb'),'sha256').hexdigest()==expected | |
| a.out.mkdir(parents=True,exist_ok=True);pf=pq.ParquetFile(a.source) | |
| writers={n:pq.ParquetWriter(a.out/n,pf.schema_arrow,compression='zstd') for n in ['tasks.parquet','archive.parquet']} | |
| try: | |
| for batch in pf.iter_batches(batch_size=1): | |
| groups={n:[] for n in writers} | |
| for row in batch.to_pylist(): | |
| v=s['tasks'][row['path']];assert v['content_sha256']==row['content_sha256'] | |
| n='tasks.parquet' if v['kept'] else 'archive.parquet' | |
| if not v['kept']:row.update(archive_stage=6,archive_reason='No observed success in four teacher attempts; terminal errors counted as unsolved.',archive_labels=['teacher:no-observed-success']) | |
| groups[n].append(row) | |
| for n,rows in groups.items(): | |
| if rows:writers[n].write_table(pa.Table.from_pylist(rows,schema=pf.schema_arrow)) | |
| finally: | |
| for w in writers.values():w.close() | |
| if __name__=='__main__':main() | |