Spaces:
Sleeping
Sleeping
| # | |
| # Deploy the whole project (Dockerfile + sources) to a Hugging Face Space | |
| # (SDK: docker). HF builds the image on its side from the uploaded files. | |
| # | |
| # Usage: | |
| # ./scripts/deploy-space.sh <space-id> | |
| # | |
| # Example: | |
| # ./scripts/deploy-space.sh tfrere/hf-model-viewer | |
| # | |
| # Prerequisites: | |
| # - You have created the Space at https://huggingface.co/spaces/<space-id> | |
| # with SDK = "docker". | |
| # - You are logged in: `hf auth login` (or HF_TOKEN env var set). | |
| # - (Optional but recommended) Add HF_TOKEN as a Space secret so the backend | |
| # can push traced graphs to the `tfrere/model-graphs` cache dataset. | |
| # | |
| set -euo pipefail | |
| SPACE_ID="${1:-}" | |
| if [ -z "$SPACE_ID" ]; then | |
| echo "Usage: $0 <space-id> (e.g. tfrere/hf-model-viewer)" | |
| exit 1 | |
| fi | |
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" | |
| cd "$ROOT" | |
| echo "==> Uploading sources to space: $SPACE_ID" | |
| echo " (HF will build the Docker image on its side)" | |
| # Use the new `hf upload` CLI. We upload the repo root but exclude heavy or | |
| # irrelevant directories via repeated --exclude flags. node_modules / dist / | |
| # .venv / __pycache__ / hf-cache must not ship. | |
| hf upload \ | |
| --repo-type=space \ | |
| --commit-message "Deploy hf-model-viewer $(date -u +%Y-%m-%dT%H:%M:%SZ)" \ | |
| --exclude "node_modules/**" \ | |
| --exclude "**/node_modules/**" \ | |
| --exclude "dist/**" \ | |
| --exclude "**/dist/**" \ | |
| --exclude ".venv/**" \ | |
| --exclude "**/.venv/**" \ | |
| --exclude "**/__pycache__/**" \ | |
| --exclude "*.pyc" \ | |
| --exclude ".cache/**" \ | |
| --exclude "hf-cache/**" \ | |
| --exclude ".DS_Store" \ | |
| --exclude ".git/**" \ | |
| "$SPACE_ID" \ | |
| . \ | |
| . | |
| echo "==> Done. Open https://huggingface.co/spaces/$SPACE_ID" | |
| echo " First build may take a few minutes (torch CPU is ~200MB)." | |