File size: 1,367 Bytes
8f8fb44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""Create or update a Hugging Face Dataset repository from hf_release."""

from __future__ import annotations

import argparse
from pathlib import Path

from huggingface_hub import HfApi


def main() -> None:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("repo_id", help="Hugging Face repository, for example org/quantinvbench")
    parser.add_argument("--private", action="store_true")
    parser.add_argument("--revision", default="main")
    args = parser.parse_args()

    release_root = Path(__file__).resolve().parents[1]
    required = [release_root / "README.md", release_root / "LICENSE", release_root / "data" / "manifest.json"]
    missing = [str(path) for path in required if not path.exists()]
    if missing:
        raise FileNotFoundError(f"Release is incomplete: {missing}")

    api = HfApi()
    api.create_repo(args.repo_id, repo_type="dataset", private=args.private, exist_ok=True)
    api.upload_folder(
        repo_id=args.repo_id,
        repo_type="dataset",
        revision=args.revision,
        folder_path=release_root,
        ignore_patterns=["__pycache__/**", "*.pyc", ".pytest_cache/**", "cache/**"],
        commit_message="Publish QuantInvBench dataset",
    )
    print(f"Uploaded https://huggingface.co/datasets/{args.repo_id}")


if __name__ == "__main__":
    main()