Spaces:
Running
Running
File size: 1,081 Bytes
00a67f9 | 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 | #!/usr/bin/env python3
"""Deploy Brettapps/email-assistant Static HF Space."""
from __future__ import annotations
import os
from pathlib import Path
from huggingface_hub import HfApi, create_repo, upload_folder
SPACE_ID = "Brettapps/email-assistant"
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 required")
api = HfApi(token=token)
try:
api.whoami()
except Exception as exc:
print(f"HF auth failed: {exc}")
raise SystemExit(1)
create_repo(repo_id=SPACE_ID, repo_type="space", token=token, exist_ok=True, space_sdk="static")
print(f"Deploying {LOCAL_DIR} -> {SPACE_ID}")
upload_folder(folder_path=str(LOCAL_DIR), repo_id=SPACE_ID, repo_type="space",
commit_message="Email assistant static demo + Obsidian vault workflow", token=token)
print(f"Done: https://huggingface.co/spaces/{SPACE_ID}")
if __name__ == "__main__":
deploy()
|