#!/usr/bin/env bash # Deploy CodeBERT training Space to Hugging Face. # Usage: ./scripts/deploy_train_space.sh [YOUR_USERNAME/space-name] set -euo pipefail SPACE_SUFFIX="${1:-sql-error-classifier-train}" TOKEN="${HF_TOKEN:-${HUGGING_FACE_HUB_TOKEN:-}}" if [[ -z "${TOKEN}" ]]; then echo "Set HF_TOKEN before deploying." exit 1 fi # Resolve full space id — must use an account you own if [[ "${SPACE_SUFFIX}" == */* ]]; then SPACE_ID="${SPACE_SUFFIX}" else USERNAME=$(python - < Preparing Space files..." rsync -a \ --exclude '.venv' \ --exclude 'models' \ --exclude '__pycache__' \ --exclude '.git' \ --exclude '*.joblib' \ "${ROOT}/" "${WORKDIR}/" cp "${ROOT}/README_TRAIN_SPACE.md" "${WORKDIR}/README.md" echo "==> Creating Space: ${SPACE_ID}" python - < Uploading..." python - <