Datasets:
Download nl2bash_v3/patch.py from FWeindel/validated-tasks: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F32/nl2bash_v3/patch.py
- Command line
-
hf download hf://datasets/FWeindel/validated-tasks@refs/pr/32/nl2bash_v3/patch.py
-
curl -L -o patch.py https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F32/nl2bash_v3/patch.py
1.72 kB
| """Reproduce the incremental v3 task set from the pinned pre-migration release. | |
| Requires pyarrow and huggingface_hub. Does not rerun evaluation. | |
| """ | |
| import argparse,hashlib,json | |
| from pathlib import Path | |
| import pyarrow as pa,pyarrow.parquet as pq | |
| from huggingface_hub import hf_hub_download | |
| def build(out): | |
| root=Path(__file__).parent;m=json.loads((root/'metadata/layout.json').read_text()) | |
| p=hf_hub_download('FWeindel/validated-tasks','nl2bash_v3/tasks.parquet',repo_type='dataset',revision=m['previous_cumulative_revision']) | |
| assert hashlib.sha256(Path(p).read_bytes()).hexdigest()==m['previous_tasks_sha256'] | |
| t=pq.read_table(p);ids=set(m['task_ids']);t=t.filter(pa.array([x in ids for x in t['path'].to_pylist()]));assert set(t['path'].to_pylist())==ids | |
| meta=dict(t.schema.metadata or {}) | |
| if b'ot.images.v1' in meta: | |
| im=json.loads(meta[b'ot.images.v1']);im['tasks']={k:v for k,v in im['tasks'].items() if k in ids};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};im['coverage']={'cached_tasks':len(im['tasks']),'total_tasks':len(ids)} | |
| if 'uncached_task_ids' in im:im['uncached_task_ids']=sorted(ids-set(im['tasks'])) | |
| meta[b'ot.images.v1']=json.dumps(im).encode() | |
| release=json.loads(meta.get(b'ot.release.v3',b'{}'));release.update({k:m[k] for k in ['layout','kept','baseline_kept','combined_kept','baseline_folder','baseline_revision','carried_from_v2']});meta[b'ot.release.v3']=json.dumps(release).encode() | |
| pq.write_table(t.replace_schema_metadata(meta),out,compression='zstd') | |
| if __name__=='__main__': | |
| p=argparse.ArgumentParser();p.add_argument('--out',type=Path,required=True);a=p.parse_args();build(a.out) | |