File size: 2,300 Bytes
d0c28fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159806e
d0c28fa
 
 
 
 
159806e
 
 
 
 
 
d0c28fa
 
 
 
 
 
 
 
b505bc4
d0c28fa
 
 
 
 
 
 
 
 
 
 
 
b505bc4
d0c28fa
 
 
 
b505bc4
159806e
 
 
 
d0c28fa
6795535
d0c28fa
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""Create and upload the standalone passive-single dataset repository."""

from __future__ import annotations

import argparse
from pathlib import Path

from huggingface_hub import HfApi


DEFAULT_REPO_ROOT = Path(__file__).resolve().parents[1]


def validate(repo_root: Path) -> None:
    required = [
        repo_root / "README.md",
        repo_root / "data/metadata.jsonl",
    ]
    missing = [str(path) for path in required if not path.is_file()]
    if missing:
        raise SystemExit("Missing required files:\n" + "\n".join(missing))

    metadata_rows = sum(1 for line in (repo_root / "data/metadata.jsonl").open(encoding="utf-8") if line.strip())
    image_count = sum(1 for path in (repo_root / "data").rglob("*.png") if path.is_file())
    if metadata_rows != 3423 or image_count != 3423:
        raise SystemExit(f"Expected 3423 metadata rows and images, got {metadata_rows} and {image_count}")
    if (repo_root / "reports").exists():
        raise SystemExit("reports/ must not be included")


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--repo-id", default="ESI-Bench/esi-bench-passive-single")
    parser.add_argument("--repo-root", type=Path, default=DEFAULT_REPO_ROOT)
    parser.add_argument("--private", action="store_true")
    parser.add_argument("--revision", default=None)
    parser.add_argument("--commit-message", default="Upload standalone passive-single dataset")
    args = parser.parse_args()

    repo_root = args.repo_root.resolve()
    validate(repo_root)

    api = HfApi()
    api.create_repo(
        repo_id=args.repo_id,
        repo_type="dataset",
        private=args.private,
        exist_ok=True,
    )
    api.upload_folder(
        repo_id=args.repo_id,
        repo_type="dataset",
        folder_path=repo_root,
        revision=args.revision,
        commit_message=args.commit_message,
        delete_patterns=[
            "data/**",
            "reports/**",
        ],
        ignore_patterns=[
            ".cache/**",
            "**/__pycache__/**",
            "**/*.pyc",
            ".git/**",
        ],
    )
    print(f"Uploaded to https://huggingface.co/datasets/{args.repo_id}")
    return 0


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