File size: 796 Bytes
e23172f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""Deploy Trifecta-Bro HF Space."""

from __future__ import annotations

import os
from pathlib import Path

from huggingface_hub import HfApi, upload_folder


SPACE_ID = "Brettapps/trifecta-bro"
LOCAL_DIR = Path(__file__).resolve().parents[0]


def deploy() -> None:
    token = os.environ.get("HF_ACCESS_TOKEN") or os.environ.get("HF_TOKEN")
    if not token:
        raise EnvironmentError("HF_ACCESS_TOKEN/HF_TOKEN is required")

    api = HfApi(token=token)
    print(f"Deploying {LOCAL_DIR} -> {SPACE_ID}")
    upload_folder(
        folder_path=str(LOCAL_DIR),
        repo_id=SPACE_ID,
        repo_type="space",
        commit_message="Update Trifecta-Bro booklet",
        token=token,
    )
    print("Upload complete")


if __name__ == "__main__":
    deploy()