File size: 1,214 Bytes
230508d 32e98ab 230508d ee17720 230508d d6d0f4e 32e98ab bae016f 230508d a217e81 bae016f a217e81 | 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 | #!/bin/bash
# Entrypoint for auto-stop runner target.
# Starts Runpod's SSH/Jupyter in the background, runs the command, then exits.
set -e
cd /opt/pawn
export PYTHONPATH=/opt/pawn
export PATH="/opt/pawn/.venv/bin:$PATH"
# Persist HF_TOKEN to huggingface-hub's token cache so it survives env changes
if [ -n "$HF_TOKEN" ]; then
mkdir -p /root/.cache/huggingface
echo -n "$HF_TOKEN" > /root/.cache/huggingface/token
fi
# Let Runpod's own start script handle SSH, Jupyter, key injection, etc.
if [ -f /start.sh ]; then
/start.sh &
sleep 2 # give sshd a moment to bind
fi
# Pull checkpoint from HuggingFace if PAWN_MODEL is set
if [ -n "$PAWN_MODEL" ]; then
echo "Pulling model: $PAWN_MODEL"
python3 -c "
from huggingface_hub import snapshot_download
snapshot_download('$PAWN_MODEL', local_dir='checkpoints/model')
print('Model downloaded to checkpoints/model/')
"
fi
# Run the command: Docker CMD args, or PAWN_CMD env var
# When it finishes, the container exits and the pod auto-stops.
if [ $# -gt 0 ]; then
exec "$@"
elif [ -n "$PAWN_CMD" ]; then
exec bash -c "$PAWN_CMD"
else
echo "ERROR: No command provided. Set PAWN_CMD env var or pass Docker CMD args."
exit 1
fi
|