Spaces:
Runtime error
Runtime error
Download scripts/deploy_train_space.sh from nishu08/sql-error-classifier-train: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/nishu08/sql-error-classifier-train/resolve/9b2cded1a14e96dfbb9d8501b16cb86e95465eba/scripts/deploy_train_space.sh
- Command line
-
hf download hf://spaces/nishu08/sql-error-classifier-train@9b2cded1a14e96dfbb9d8501b16cb86e95465eba/scripts/deploy_train_space.sh
-
curl -L -o deploy_train_space.sh https://huggingface.co/spaces/nishu08/sql-error-classifier-train/resolve/9b2cded1a14e96dfbb9d8501b16cb86e95465eba/scripts/deploy_train_space.sh
1.43 kB
| # Deploy training Space to Hugging Face. | |
| # Usage: ./scripts/deploy_train_space.sh YOUR_HF_USERNAME/sql-error-classifier-train | |
| set -euo pipefail | |
| SPACE_ID="${1:-}" | |
| if [[ -z "${SPACE_ID}" ]]; then | |
| echo "Usage: $0 YOUR_USERNAME/sql-error-classifier-train" | |
| exit 1 | |
| fi | |
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" | |
| TOKEN="${HF_TOKEN:-${HUGGING_FACE_HUB_TOKEN:-}}" | |
| if [[ -z "${TOKEN}" ]]; then | |
| echo "Set HF_TOKEN before deploying." | |
| exit 1 | |
| fi | |
| WORKDIR=$(mktemp -d) | |
| trap 'rm -rf "${WORKDIR}"' EXIT | |
| echo "==> Preparing Space files in ${WORKDIR}..." | |
| rsync -a \ | |
| --exclude '.venv' \ | |
| --exclude 'models' \ | |
| --exclude '__pycache__' \ | |
| --exclude '.git' \ | |
| "${ROOT}/" "${WORKDIR}/" | |
| cp "${ROOT}/README_TRAIN_SPACE.md" "${WORKDIR}/README.md" | |
| echo "==> Creating / updating Space ${SPACE_ID}..." | |
| python - <<PY | |
| from huggingface_hub import HfApi | |
| api = HfApi(token="${TOKEN}") | |
| api.create_repo("${SPACE_ID}", repo_type="space", space_sdk="gradio", exist_ok=True) | |
| PY | |
| echo "==> Uploading to Hugging Face Space..." | |
| python - <<PY | |
| from huggingface_hub import HfApi | |
| api = HfApi(token="${TOKEN}") | |
| api.upload_folder( | |
| folder_path="${WORKDIR}", | |
| repo_id="${SPACE_ID}", | |
| repo_type="space", | |
| commit_message="Deploy CodeBERT training Space", | |
| ) | |
| PY | |
| echo "==> Done: https://huggingface.co/spaces/${SPACE_ID}" | |
| echo "Next: Space Settings → Hardware → GPU t4-small" | |
| echo " Space Settings → Secrets → HF_TOKEN" | |