File size: 1,828 Bytes
8536af5
 
 
 
 
 
 
 
 
aa4e7ae
 
 
 
 
 
8536af5
 
 
 
 
 
 
 
 
 
 
aa4e7ae
8536af5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
from __future__ import annotations

import argparse
from pathlib import Path

from huggingface_hub import HfApi


def validate_dataset_file(repo_root: Path) -> None:
    dataset_file = repo_root / "data/questions.jsonl"
    if not dataset_file.exists():
        raise SystemExit(f"Missing {dataset_file}")
    if dataset_file.stat().st_size == 0:
        raise SystemExit(f"{dataset_file} is empty. Regenerate it before uploading.")


def main() -> int:
    parser = argparse.ArgumentParser(description="Upload the Croissant-friendly ESI-Bench table to Hugging Face.")
    parser.add_argument("--repo-id", default="ESI-Bench/esi-bench")
    parser.add_argument("--repo-root", type=Path, default=Path(__file__).resolve().parents[1])
    parser.add_argument("--private", action="store_true", help="Create the dataset repo as private if it does not exist.")
    parser.add_argument("--commit-message", default="Replace with Croissant-friendly questions table")
    args = parser.parse_args()

    repo_root = args.repo_root.resolve()
    validate_dataset_file(repo_root)

    api = HfApi()
    api.create_repo(repo_id=args.repo_id, repo_type="dataset", private=args.private, exist_ok=True)
    api.upload_folder(
        folder_path=repo_root,
        repo_id=args.repo_id,
        repo_type="dataset",
        allow_patterns=[
            "README.md",
            "data/questions.jsonl",
            "scripts/export_hf_questions.py",
            "scripts/upload_hf_dataset.py",
        ],
        delete_patterns=[
            "data/**",
            "dataset/**",
            "scripts/**",
        ],
        commit_message=args.commit_message,
    )
    print(f"Uploaded {repo_root} to https://huggingface.co/datasets/{args.repo_id}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())