| from __future__ import annotations
|
|
|
| import argparse |
| import subprocess |
| import sys |
| from pathlib import Path |
|
|
| from huggingface_hub import HfApi
|
|
|
|
|
| def main() -> int:
|
| parser = argparse.ArgumentParser(description="Upload the validated benchmark release to Hugging Face")
|
| parser.add_argument("repo_id", metavar="OWNER/DATASET")
|
| parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1])
|
| parser.add_argument("--private", action="store_true")
|
| parser.add_argument("--dry-run", action="store_true")
|
| args = parser.parse_args()
|
| root = args.root.resolve()
|
| required = [root / "README.md", root / "data" / "train" / "metadata.jsonl", root / "checksums" / "SHA256SUMS"]
|
| missing = [str(path) for path in required if not path.is_file()]
|
| if missing: |
| raise RuntimeError("Release is incomplete: " + ", ".join(missing)) |
| if (root / "viewer_data").exists() or (root / "data" / "train-00000-of-00001.parquet").exists(): |
| raise RuntimeError("Obsolete Dataset Viewer Parquet artifacts are present") |
| subprocess.run( |
| [sys.executable, str(root / "scripts" / "validate_release.py"), "--root", str(root)], |
| check=True, |
| ) |
| files = [path for path in root.rglob("*") if path.is_file()]
|
| total = sum(path.stat().st_size for path in files)
|
| print(f"ready: {len(files)} files, {total / 1024**3:.3f} GiB -> datasets/{args.repo_id}")
|
| if args.dry_run:
|
| return 0
|
| api = HfApi()
|
| api.create_repo(repo_id=args.repo_id, repo_type="dataset", private=args.private, exist_ok=True)
|
| api.upload_large_folder(
|
| repo_id=args.repo_id,
|
| repo_type="dataset",
|
| folder_path=str(root),
|
| private=args.private,
|
| ignore_patterns=[ |
| ".cache/**", |
| ".viewer_fix_venv/**", |
| "viewer_data/**", |
| "viewer_fix_output/**", |
| "**/__pycache__/**", |
| "*.pyc", |
| "viewer_fix_*.log", |
| ], |
| num_workers=4,
|
| print_report_every=30,
|
| )
|
| print(f"https://huggingface.co/datasets/{args.repo_id}")
|
| return 0
|
|
|
|
|
| if __name__ == "__main__":
|
| raise SystemExit(main())
|
|
|