"""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()