"""Publish the generated dataset to the Hugging Face Hub (the one manual step). hf auth login # once, paste a write token python scripts/push_to_huggingface.py --repo / # add --private if you like The whole project folder becomes the dataset repository: the Parquet shards in data/ (with config.json and manifest.json), the README.md dataset card whose `configs:` block makes every table browsable in the Dataset Viewer, and the generator source, so the dataset is reproducible from the repository alone. The upload is resumable: re-run the same command after any interruption and it continues where it stopped (its bookkeeping lives in .cache/, ignored by git). """ import argparse import os from pathlib import Path from huggingface_hub import HfApi ROOT = Path(__file__).resolve().parents[1] IGNORE = ["__pycache__/**", "*.pyc", "*.tmp", ".git/**", ".gitignore", ".cache/**", ".DS_Store", "data_*/**", "*.log"] def main() -> None: parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument("--repo", required=True, help="dataset repository id, e.g. alexander/semantic-potential-routing") parser.add_argument("--private", action="store_true", help="create the repository as private") parser.add_argument("--token", default=os.environ.get("HF_TOKEN"), help="write token (default: HF_TOKEN or cached login)") parser.add_argument("--workers", type=int, default=None, help="parallel upload workers (default: library choice)") args = parser.parse_args() shards = sorted((ROOT / "data").glob("*/part-*.parquet")) if not shards or not (ROOT / "data" / "manifest.json").exists(): raise SystemExit("No finished dataset in data/ - run scripts/run_local_sweep.py first.") print(f"Uploading {len(shards)} Parquet shards " f"({sum(f.stat().st_size for f in shards) / 1e9:.2f} GB) plus README and source to {args.repo} ...") api = HfApi(token=args.token) api.create_repo(args.repo, repo_type="dataset", private=args.private, exist_ok=True) api.upload_large_folder(repo_id=args.repo, folder_path=ROOT, repo_type="dataset", ignore_patterns=IGNORE, num_workers=args.workers) print(f"Done: https://huggingface.co/datasets/{args.repo}") if __name__ == "__main__": main()