Spaces:
Sleeping
Sleeping
| # Stage the prologue codebase (sibling directory) into a temp dir, swap in | |
| # the Space-specific README / requirements, and push the whole thing to an | |
| # HF Space. | |
| # | |
| # Directory layout this script assumes: | |
| # <parent>/prologue/ <- the open-source code repo | |
| # <parent>/prologue-space/ <- this folder (deploy.sh + Space README/requirements) | |
| # | |
| # Override the code path with PROLOGUE_REPO=/some/other/prologue if needed. | |
| # | |
| # Usage: | |
| # bash deploy.sh # default repo Zyriix/prologue-demo | |
| # PROLOGUE_SPACE=Zyriix/foo bash deploy.sh | |
| # | |
| # Requires the `hf` CLI to be authenticated (`hf auth login`). | |
| set -euo pipefail | |
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| ROOT_DIR="${PROLOGUE_REPO:-$( cd "${SCRIPT_DIR}/../prologue" && pwd )}" | |
| SPACE_REPO="${PROLOGUE_SPACE:-Zyriix/prologue-demo}" | |
| STAGE_DIR="$(mktemp -d --suffix=.prologue-space)" | |
| echo "[deploy] code repo -> ${ROOT_DIR}" | |
| echo "[deploy] staging codebase -> ${STAGE_DIR}" | |
| echo "[deploy] target Space repo -> ${SPACE_REPO}" | |
| # rsync is faster than cp and respects --exclude predictably. | |
| rsync -a \ | |
| --exclude '.git/' \ | |
| --exclude 'ckpts/' \ | |
| --exclude 'ckpts_test/' \ | |
| --exclude 'logs/' \ | |
| --exclude 'wandb/' \ | |
| --exclude 'wandb_runs/' \ | |
| --exclude 'experiments/' \ | |
| --exclude 'experiments_ar/' \ | |
| --exclude 'eval/' \ | |
| --exclude 'eval_ar/' \ | |
| --exclude 'data/' \ | |
| --exclude 'pretoken/' \ | |
| --exclude 'tmp/' \ | |
| --exclude '__pycache__/' \ | |
| --exclude '*.pyc' \ | |
| --exclude '_smoke_*' \ | |
| --exclude 'assets/' \ | |
| --exclude 'README.md' \ | |
| --exclude 'MODEL_CARD.md' \ | |
| --exclude 'requirements.txt' \ | |
| "${ROOT_DIR}/" "${STAGE_DIR}/" | |
| cp "${SCRIPT_DIR}/README.md" "${STAGE_DIR}/README.md" | |
| cp "${SCRIPT_DIR}/requirements.txt" "${STAGE_DIR}/requirements.txt" | |
| echo "[deploy] staged file tree:" | |
| ( cd "${STAGE_DIR}" && find . -maxdepth 2 -type f | sort ) | |
| echo "[deploy] uploading to hf://${SPACE_REPO} ..." | |
| hf upload "${SPACE_REPO}" "${STAGE_DIR}" . \ | |
| --repo-type space \ | |
| --commit-message "Deploy Prologue demo $(date -u +%Y-%m-%dT%H:%M:%SZ)" | |
| echo "[deploy] done -> https://huggingface.co/spaces/${SPACE_REPO}" | |
| echo "[deploy] cleaning up ${STAGE_DIR}" | |
| rm -rf "${STAGE_DIR}" | |