| #!/usr/bin/env bash |
| |
| |
| set -euo pipefail |
| HOST="${1:?host}"; PORT="${2:?port}"; MODEL="${3:?model}"; RUN_NAME="${4:?run_name}" |
|
|
| KEY="$HOME/.runpod/ssh/RunPod-Key-Go" |
| SSH_OPTS=(-i "$KEY" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=20) |
| TARBALL=/tmp/pj.tar.gz |
| REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" |
|
|
| echo "[deploy] $HOST:$PORT model=$MODEL run=$RUN_NAME" |
|
|
| if [ ! -f "$TARBALL" ] || find "$REPO_DIR/src" -newer "$TARBALL" 2>/dev/null | grep -q .; then |
| echo "[deploy] (re)building tarball" |
| tar -czf "$TARBALL" \ |
| --no-xattrs \ |
| --exclude PhysioJEPA/.venv --exclude PhysioJEPA/.git \ |
| --exclude PhysioJEPA/.agents --exclude PhysioJEPA/.claude \ |
| --exclude PhysioJEPA/__pycache__ --exclude PhysioJEPA/runs \ |
| --exclude PhysioJEPA/cache --exclude PhysioJEPA/docs/figures \ |
| --exclude PhysioJEPA/docs/paperes \ |
| --exclude '*/__pycache__' --exclude '*.pyc' \ |
| -C "$(dirname "$REPO_DIR")" "$(basename "$REPO_DIR")" |
| fi |
|
|
| scp "${SSH_OPTS[@]}" -P "$PORT" "$TARBALL" "root@$HOST:/workspace/pj.tar.gz" |
| scp "${SSH_OPTS[@]}" -P "$PORT" "$REPO_DIR/.env" "root@$HOST:/workspace/.env" |
| ssh "${SSH_OPTS[@]}" -p "$PORT" "root@$HOST" \ |
| 'set -e; cd /workspace; if [ -d PhysioJEPA ]; then mv PhysioJEPA "PhysioJEPA.old.$$" && (rm -rf "PhysioJEPA.old.$$" 2>/dev/null &); fi; tar --no-same-owner -xzf pj.tar.gz && rm pj.tar.gz && ls PhysioJEPA | head' |
| ssh "${SSH_OPTS[@]}" -p "$PORT" "root@$HOST" \ |
| "mkdir -p /workspace/runs && cd /workspace/PhysioJEPA && chmod +x scripts/pod_bootstrap.sh && \ |
| nohup bash scripts/pod_bootstrap.sh $MODEL $RUN_NAME \ |
| > /workspace/runs/$RUN_NAME.bootstrap.log 2>&1 & disown; \ |
| echo BOOTSTRAP_STARTED; sleep 1" |
| echo "[deploy] launched, log at /workspace/runs/$RUN_NAME.bootstrap.log on pod" |
|
|