Datasets:
Download facet_v2/patch.py from FWeindel/validated-tasks: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F30/facet_v2/patch.py
- Command line
-
hf download hf://datasets/FWeindel/validated-tasks@refs/pr/30/facet_v2/patch.py
-
curl -L -o patch.py https://huggingface.co/datasets/FWeindel/validated-tasks/resolve/refs%2Fpr%2F30/facet_v2/patch.py
1.35 kB
| """Reproduce partial FACET v2 membership; preserves source task payloads. | |
| Run: python patch.py --out reproduced | |
| Requires huggingface_hub and pyarrow; metadata/selection.json beside this file. | |
| """ | |
| from pathlib import Path | |
| import argparse,json | |
| import pyarrow as pa,pyarrow.parquet as pq | |
| from huggingface_hub import hf_hub_download | |
| def main(): | |
| ap=argparse.ArgumentParser();ap.add_argument('--out',type=Path,required=True);a=ap.parse_args() | |
| selection=json.loads((Path(__file__).parent/'metadata/selection.json').read_text()) | |
| a.out.mkdir(parents=True,exist_ok=True) | |
| source=pq.read_table(hf_hub_download('FWeindel/validated-tasks','facet_v1/tasks.parquet',repo_type='dataset',revision=selection['base_revision'])) | |
| groups={'tasks.parquet':[],'archive-new.parquet':[],'pending.parquet':[]} | |
| for i,r in enumerate(source.select(['path','content_sha256']).to_pylist()): | |
| info=selection['tasks'].get(r['path']) | |
| if info:assert info['content_sha256']==r['content_sha256'] | |
| name='pending.parquet' if info is None else 'tasks.parquet' if info['kept'] else 'archive-new.parquet' | |
| if info is None:assert r['path'] in selection['pending_task_ids'] | |
| groups[name].append(i) | |
| for name,indices in groups.items():pq.write_table(source.take(pa.array(indices)),a.out/name,compression='zstd') | |
| print({k:len(v) for k,v in groups.items()}) | |
| if __name__=='__main__':main() | |