File size: 1,928 Bytes
c9ee848
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Nova-Sim deployment script (HuggingFace Spaces)

set -e

if [ -z "${BASH_VERSION:-}" ]; then
    exec /bin/bash "$0" "$@"
fi

HF_SPACE="gpue/nova-sim"
ENV_FILE="${ENV_FILE:-.env.local}"

exec > >(tee -a deploy.logs) 2>&1

echo "==================================="
echo "Nova-Sim Deployment"
echo "==================================="
echo ""

# Load tokens from env file
if [ -f "${ENV_FILE}" ]; then
    set -a
    # shellcheck disable=SC1090
    source "${ENV_FILE}"
    set +a
else
    echo "Warning: ${ENV_FILE} not found"
fi

HF_TOKEN="${HF_TOKEN:-${HUGGINGFACE_TOKEN:-}}"
if [ -z "${HF_TOKEN}" ]; then
    echo "Error: missing HF token (set HF_TOKEN or HUGGINGFACE_TOKEN)"
    exit 1
fi

# Ensure huggingface_hub (and hf CLI) are available via local venv
VENV_DIR=".deploy-venv"
PY_BIN="${VENV_DIR}/bin/python3"
HF_BIN="${VENV_DIR}/bin/hf"

if [ ! -x "${PY_BIN}" ]; then
    echo "Creating deploy venv at ${VENV_DIR}..."
    python3 -m venv "${VENV_DIR}"
fi

if ! "${PY_BIN}" -c "import huggingface_hub" >/dev/null 2>&1; then
    echo "Installing huggingface_hub in deploy venv..."
    "${PY_BIN}" -m pip install --quiet huggingface_hub
fi

# Commit local changes before push so Spaces builds the right ref
if [[ -n $(git status -s) ]]; then
    echo "Committing changes for Space build context..."
    git add Dockerfile requirements.txt mujoco_server.py frontend/index.html README.md .dockerignore
    if git diff --cached --quiet; then
        echo "No staged changes for Space build context"
    else
        git commit -m "Prepare HF Space deployment"
        echo "✓ Space build context committed"
    fi
fi

PUSH_URL="https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE}"

echo "Pushing to ${HF_SPACE}..."
git push "${PUSH_URL}" HEAD:main --force
echo "✓ Push complete"
echo ""

if [ -x "${HF_BIN}" ]; then
    echo "Space status:"
    "${HF_BIN}" repo info "spaces/${HF_SPACE}" || true
fi