Spaces:
Sleeping
Sleeping
File size: 1,594 Bytes
98cbf67 4713899 4cc2f21 4713899 a6856e0 e877495 9fa751e e877495 a6856e0 231d560 a6856e0 231d560 a6856e0 231d560 4713899 a6856e0 4713899 a6856e0 4713899 231d560 a6856e0 4713899 | 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 | """Optional Hugging Face Space deploy helper.
This script is intentionally minimal because CI may call it directly. If the
optional HF_BUILD_SMALL_HACKATHON_TOKEN secret is missing, it exits cleanly.
"""
import os
TOKEN_ENV_VAR = "HF_BUILD_SMALL_HACKATHON_TOKEN"
DEFAULT_SPACE_ID = "byte-vortex/Myco"
IGNORE_PATTERNS_TEXT = """
.git/*
.github/*
__pycache__/*
**/__pycache__/*
*.pyc
.gradio/*
.cache/*
models/downloads/*
models/**/*.gguf
models/**/*.bin
models/**/*.safetensors
"""
def get_ignore_patterns():
"""Return upload ignore patterns as a list for huggingface_hub."""
return [str(pattern) for pattern in IGNORE_PATTERNS_TEXT.split()]
def get_hf_token():
"""Return the optional Hugging Face deploy token."""
return os.environ.get(TOKEN_ENV_VAR, "").strip()
def get_space_id():
"""Return the target Hugging Face Space id."""
return os.environ.get("HF_SPACE_ID", DEFAULT_SPACE_ID).strip() or DEFAULT_SPACE_ID
def main():
"""Deploy when a token is configured; otherwise skip without failing."""
token = get_hf_token()
if not token:
print(f"{TOKEN_ENV_VAR} is not configured; skipping Hugging Face Space deployment.")
return
from huggingface_hub import HfApi
repo_id = get_space_id()
HfApi().upload_folder(
folder_path=".",
repo_id=repo_id,
repo_type="space",
token=token,
ignore_patterns=get_ignore_patterns(),
commit_message="Deploy Myco from CI",
)
print(f"Deployed Myco to https://huggingface.co/spaces/{repo_id}")
if __name__ == "__main__":
main()
|