File size: 1,733 Bytes
fc01079
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
#
# 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)."