Vscode / deploy_to_hf.py
Erinaldorodrigues's picture
Release Safe Bet AI v2.2 Precision
888ef7f
Raw
History Blame Contribute Delete
907 Bytes
#!/usr/bin/env python3
from __future__ import annotations
import os
from pathlib import Path
from huggingface_hub import HfApi
token = os.getenv("HF_TOKEN", "").strip()
repo = os.getenv("HF_SPACE_REPO", "").strip()
if not token or not repo:
raise SystemExit(
"Defina HF_TOKEN e HF_SPACE_REPO.\n"
"Exemplo:\n"
"export HF_TOKEN='hf_xxx'\n"
"export HF_SPACE_REPO='usuario/safe-bet-ai'\n"
"python deploy_to_hf.py"
)
api = HfApi(token=token)
api.upload_folder(
folder_path=str(Path(__file__).resolve().parent),
repo_id=repo,
repo_type="space",
ignore_patterns=[
".git/**",
".env",
"**/__pycache__/**",
"**/*.py[cod]",
"**/.pytest_cache/**",
".venv/**",
"data/**",
],
commit_message="Deploy Safe Bet AI",
)
print(f"OK: arquivos enviados para https://huggingface.co/spaces/{repo}")