File size: 1,531 Bytes
0828c2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32f26e4
 
0828c2c
32f26e4
 
 
 
0828c2c
32f26e4
0828c2c
32f26e4
 
 
 
 
 
 
 
 
0828c2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Upload ProfillyBot to Hugging Face Space MinhDS/ProfillyBot."""

from __future__ import annotations

import os
import sys
from pathlib import Path

from huggingface_hub import HfApi, login


ROOT = Path(__file__).resolve().parents[1]
REPO_ID = "MinhDS/ProfillyBot"

IGNORE = [
    ".venv/**",
    ".git/**",
    ".env",
    ".pytest_cache/**",
    ".ruff_cache/**",
    "htmlcov/**",
    "**/__pycache__/**",
    "_cv_preview.txt",
    ".cursor/**",
    "*.pyc",
    ".mypy_cache/**",
    "uv.lock",
    "requirements-lock.txt",
    # Avoid Docker SDK confusion on Gradio ZeroGPU Spaces
    "Dockerfile",
    "Dockerfile.app",
    "docker-compose.yml",
    ".github/**",
    "tests/**",
]


def main() -> int:
    token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_HUB_TOKEN")
    if not token:
        print(
            "ERROR: Set HF_TOKEN (https://huggingface.co/settings/tokens) then re-run:\n"
            "  $env:HF_TOKEN = 'hf_xxx'\n"
            "  python scripts/deploy_hf_space.py",
            file=sys.stderr,
        )
        return 1

    login(token=token)
    api = HfApi(token=token)

    print(f"Uploading {ROOT} → spaces/{REPO_ID} ...")
    api.upload_folder(
        folder_path=str(ROOT),
        repo_id=REPO_ID,
        repo_type="space",
        commit_message="Deploy ProfillyBot: Gradio ZeroGPU + CV RAG (Qwen2.5-3B)",
        ignore_patterns=IGNORE,
    )
    print(f"Done. Open https://huggingface.co/spaces/{REPO_ID}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())