Datasets:
Download nl2bash_v2/patch.py from FWeindel/validated-tasks: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F30/nl2bash_v2/patch.py
- Command line
-
hf download hf://datasets/FWeindel/validated-tasks@refs/pr/30/nl2bash_v2/patch.py
-
curl -L -o patch.py https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F30/nl2bash_v2/patch.py
1.61 kB
| """Reproduce tasks.parquet from the pinned v1 source and saved success selection.""" | |
| import argparse,json | |
| from pathlib import Path | |
| import pyarrow as pa | |
| import pyarrow.parquet as pq | |
| from huggingface_hub import hf_hub_download | |
| def main(): | |
| p=argparse.ArgumentParser(description=__doc__);p.add_argument('--out',type=Path,default=Path('tasks.parquet'));a=p.parse_args() | |
| selection=json.loads((Path(__file__).parent/'metadata/selection.json').read_text()) | |
| source=hf_hub_download('FWeindel/validated-tasks','nl2bash_v1/tasks.parquet',repo_type='dataset',revision=selection['base_revision']) | |
| table=pq.read_table(source);rows=[] | |
| for r in table.to_pylist(): | |
| s=selection['tasks'][r['path']];assert r['content_sha256']==s['content_sha256'] | |
| if s['kept']: | |
| r.update(coder_successes=s['coder_successes'],coder_attempts=4,coder_graded_attempts=sum(v is not None for v in s['attempts'].values()));rows.append(r) | |
| meta=dict(table.schema.metadata);images=json.loads(meta[b'ot.images.v1']);kept={r['path'] for r in rows};images['tasks']={k:v for k,v in images['tasks'].items() if k in kept};used={e['bundle'] for t in images['tasks'].values() for e in t['environments']};images['bundles']={k:v for k,v in images['bundles'].items() if k in used};meta[b'ot.images.v1']=json.dumps(images).encode() | |
| schema=table.schema | |
| for k in ['coder_successes','coder_attempts','coder_graded_attempts']:schema=schema.append(pa.field(k,pa.int64())) | |
| pq.write_table(pa.Table.from_pylist(rows,schema=schema).replace_schema_metadata(meta),a.out,compression='zstd') | |
| print(f'{len(rows)} kept tasks -> {a.out}') | |
| if __name__=='__main__':main() | |