| #!/bin/bash |
| |
|
|
| 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 "" |
|
|
| |
| if [ -f "${ENV_FILE}" ]; then |
| set -a |
| |
| 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 |
|
|
| |
| 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 |
|
|
| |
| 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 |
|
|