nl2sql-bench / scripts /run_local.sh
ritvik360's picture
Upload folder using huggingface_hub
a39d8ef verified
#!/usr/bin/env bash
# nl2sql-bench/scripts/run_local.sh
# ─────────────────────────────────────────────────────────────────────────────
# Quick local development server (no Docker needed).
# Prerequisites: Python 3.10+, pip or uv
#
# Usage:
# chmod +x scripts/run_local.sh
# ./scripts/run_local.sh
# ─────────────────────────────────────────────────────────────────────────────
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_ROOT"
echo "═══════════════════════════════════════════════"
echo " NL2SQL-Bench β€” Local Dev Server"
echo "═══════════════════════════════════════════════"
# ── Check Python ────────────────────────────────────────────────────────────
if ! command -v python3 &>/dev/null; then
echo "ERROR: python3 not found. Install Python 3.10+." && exit 1
fi
PY_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
echo "Python: $PY_VERSION"
# ── Virtual environment ──────────────────────────────────────────────────────
if [ ! -d ".venv" ]; then
echo "Creating virtualenv..."
python3 -m venv .venv
fi
source .venv/bin/activate
# ── Install deps ─────────────────────────────────────────────────────────────
echo "Installing dependencies..."
pip install -q --upgrade pip
pip install -q openenv-core fastapi "uvicorn[standard]" openai pydantic pytest pytest-asyncio
# ── Load .env if present ─────────────────────────────────────────────────────
if [ -f ".env" ]; then
echo "Loading .env..."
set -a
source .env
set +a
fi
# ── Export PYTHONPATH ─────────────────────────────────────────────────────────
export PYTHONPATH="$REPO_ROOT:$REPO_ROOT/server"
echo ""
echo "Starting server at http://localhost:8000"
echo " /reset β†’ POST (start episode)"
echo " /step β†’ POST (submit SQL)"
echo " /state β†’ GET (episode metadata)"
echo " /health β†’ GET (liveness probe)"
echo " /docs β†’ GET (Swagger UI)"
echo ""
echo "Press Ctrl+C to stop."
echo "───────────────────────────────────────────────"
cd "$REPO_ROOT/server"
uvicorn app:app \
--host 0.0.0.0 \
--port 8000 \
--reload \
--reload-dir "$REPO_ROOT" \
--log-level info