File size: 805 Bytes
c3db5da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from pathlib import Path

from huggingface_hub import HfApi


REPO_ID = "tranvanhung203/apivietchu"
ROOT = Path(__file__).resolve().parents[1]


def main() -> None:
    token = os.environ.get("HF_TOKEN")
    if not token:
        raise SystemExit("HF_TOKEN is not set")

    api = HfApi(token=token)
    api.upload_folder(
        repo_id=REPO_ID,
        repo_type="space",
        folder_path=str(ROOT),
        ignore_patterns=[
            ".git/*",
            ".venv/*",
            "__pycache__/*",
            ".cache/huggingface/*",
            "app/models/*",
            "app/math_symbol_data/*",
        ],
        delete_patterns="*",
        commit_message="Deploy Docker Space",
    )

    print(f"https://huggingface.co/spaces/{REPO_ID}")


if __name__ == "__main__":
    main()