File size: 2,589 Bytes
df01731
 
 
 
6d453e3
df01731
 
 
6d453e3
 
df01731
 
 
 
 
 
 
 
 
 
 
 
 
6d453e3
 
 
 
 
56f5645
 
296b327
 
 
 
56f5645
 
6d453e3
 
 
 
 
df01731
 
 
6d453e3
df01731
 
 
 
 
6d453e3
 
 
 
 
 
df01731
 
 
 
 
56f5645
6d453e3
 
 
 
 
 
 
df01731
 
 
 
 
 
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
75
76
#!/usr/bin/env python3
from __future__ import annotations

import argparse
import json
import sys
from pathlib import Path

from huggingface_hub import HfApi
from huggingface_hub.utils import RepositoryNotFoundError


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("--repo-id", default="skyzhou06/LifeStreamingCoT")
    parser.add_argument("--folder", default="life_streaming_cot_dataset")
    args = parser.parse_args()

    folder = Path(args.folder)
    if not folder.exists():
        print(f"Dataset folder does not exist: {folder}", file=sys.stderr)
        sys.exit(1)

    info_path = folder / "dataset_info.json"
    if not info_path.exists():
        print(f"Missing dataset_info.json in {folder}", file=sys.stderr)
        sys.exit(1)
    info = json.loads(info_path.read_text(encoding="utf-8"))
    if info.get("version") != "v0.4.1":
        print("Refusing upload: dataset_info.json is not version v0.4.1.", file=sys.stderr)
        sys.exit(1)
    if info.get("repo_id") != "skyzhou06/LifeStreamingCoT":
        print("Refusing upload: dataset_info.json repo_id is not skyzhou06/LifeStreamingCoT.", file=sys.stderr)
        sys.exit(1)
    if "v0.4.1" not in str(info.get("generation_method", "")):
        print("Refusing upload: generation_method does not contain v0.4.1.", file=sys.stderr)
        sys.exit(1)
    if args.repo_id != "skyzhou06/LifeStreamingCoT":
        print("Refusing upload: use the existing repo skyzhou06/LifeStreamingCoT.", file=sys.stderr)
        sys.exit(1)

    api = HfApi()
    try:
        api.whoami()
    except Exception:  # noqa: BLE001 - do not print auth internals or tokens
        print("Hugging Face authentication is missing or invalid.")
        print("Run this command, then rerun the upload:")
        print("huggingface-cli login")
        sys.exit(2)

    try:
        api.repo_info(repo_id=args.repo_id, repo_type="dataset")
    except RepositoryNotFoundError:
        print(f"Refusing upload: dataset repo does not exist: {args.repo_id}", file=sys.stderr)
        sys.exit(1)

    api.upload_folder(
        repo_id=args.repo_id,
        repo_type="dataset",
        folder_path=str(folder),
        path_in_repo=".",
        commit_message="Update LifeStreamingCoT to v0.4.1 loading config and HQ subset patch",
        ignore_patterns=[
            ".DS_Store",
            "*/.DS_Store",
            "__pycache__",
            "*/__pycache__/*",
            "*.pyc",
        ],
    )
    print(f"https://huggingface.co/datasets/{args.repo_id}")


if __name__ == "__main__":
    main()