Merserk's picture
Add files using upload-large-folder tool
d895b3e verified
Raw
History Blame Contribute Delete
1.67 kB
from __future__ import annotations
import argparse
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))
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/**", "**/__pycache__/**", "*.pyc"],
num_workers=4,
print_report_every=30,
)
print(f"https://huggingface.co/datasets/{args.repo_id}")
return 0
if __name__ == "__main__":
raise SystemExit(main())