ProfillyBot / scripts /deploy_hf_space.py
MinhDS's picture
Deploy ProfillyBot: Gradio ZeroGPU + CV RAG (Qwen2.5-3B)
32f26e4 verified
Raw
History Blame Contribute Delete
1.53 kB
"""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())