Spaces:
Sleeping
Sleeping
File size: 2,173 Bytes
98a3af2 |
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 67 68 69 70 71 72 73 74 75 76 77 |
# azure-pipelines.yml
# CI/CD: Deploy entire repo to Hugging Face Space (Docker + PDM)
# Space will build from your Dockerfile and run `src/app.py`.
trigger:
branches:
include:
- development
pool:
vmImage: "ubuntu-latest"
variables:
- group: HF_TOKEN_NATSAR
- name: PYTHON_VERSION
value: "3.10"
- name: HF_SPACE_ID_DEV
value: "lucid-hf/lucid-natsar-dev"
steps:
- checkout: self
lfs: true
- script: |
git lfs install --local
git lfs pull
displayName: "Fetch Git LFS assets"
- task: UsePythonVersion@0
inputs:
versionSpec: "$(PYTHON_VERSION)"
- script: |
python -m pip install --upgrade pip
pip install huggingface_hub==0.25.*
python - <<'PY'
import os
from huggingface_hub import HfApi, upload_folder
token = os.environ["HF_TOKEN"] # provided via Pipeline variable (Secret)
space_id = os.environ["HF_SPACE_ID"] # from variables above
api = HfApi(token=token)
# Ensure Space exists and uses Docker
api.create_repo(
repo_id=space_id,
repo_type="space",
exist_ok=True,
space_sdk="docker"
)
# Upload repo contents (respect ignore patterns to speed builds)
upload_folder(
folder_path=".", # whole repo: Dockerfile, pyproject.toml, src/, models/, etc.
repo_id=space_id,
repo_type="space",
path_in_repo=".", # put at Space root
token=token,
commit_message="CI: deploy Docker/PDM Space",
ignore_patterns=[
".git/*",
"__pycache__/*",
"*.zip", "*.tar", "*.tar.gz",
"*.ipynb", "*.ipynb_checkpoints/*",
"venv/*", ".venv/*",
"dist/*", "build/*",
".mypy_cache/*", ".pytest_cache/*",
"annotated_video/*", "annotated_images/*",
"training_model/*"
]
)
displayName: "Deploy to Hugging Face Space (Docker/PDM)"
env:
HF_TOKEN: $(HF_TOKEN_DEV) # Add this as a secret variable in Pipeline settings
HF_SPACE_ID: $(HF_SPACE_ID_DEV)
|