File size: 1,567 Bytes
41f037f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""Upload the dataset to the Hugging Face Hub.

Uploads only README.md and data/** (raw/ and scripts/ stay local).
The repository is created private and gated; make it public when you are happy
with how it looks:  python scripts/upload.py --public

Before the first run:  hf auth login   (token with "Write" permission)
"""
import argparse
from pathlib import Path

from huggingface_hub import HfApi

ROOT = Path(__file__).resolve().parent.parent


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("--repo-id", default="aizana1/tuvan-vk-corpus")
    parser.add_argument("--public", action="store_true",
                        help="make the repository public (it stays gated)")
    parser.add_argument("--message", default="Upload dataset")
    args = parser.parse_args()

    api = HfApi()
    print("Logged in as:", api.whoami()["name"])

    api.create_repo(args.repo_id, repo_type="dataset", private=True, exist_ok=True)
    # Gated: users fill in the form from README.md before they can download files.
    api.update_repo_settings(args.repo_id, repo_type="dataset", gated="auto")

    api.upload_folder(
        repo_id=args.repo_id,
        repo_type="dataset",
        folder_path=ROOT,
        allow_patterns=["README.md", "data/**/*.parquet"],
        commit_message=args.message,
    )

    if args.public:
        api.update_repo_settings(args.repo_id, repo_type="dataset", private=False)

    print(f"Done: https://huggingface.co/datasets/{args.repo_id}")


if __name__ == "__main__":
    main()