File size: 2,194 Bytes
ef222b5
 
bfc7935
 
 
 
ef222b5
 
 
 
 
 
 
 
 
 
 
 
 
 
bfc7935
 
 
 
 
 
 
 
ef222b5
 
 
 
 
 
 
d895b3e
 
 
 
 
bfc7935
 
 
 
 
 
 
 
 
d895b3e
 
 
ef222b5
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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())