ritvik360/nl2sql-bench
0
1#!/usr/bin/env bash2# nl2sql-bench/scripts/run_local.sh3# ─────────────────────────────────────────────────────────────────────────────4# Quick local development server (no Docker needed).5# Prerequisites: Python 3.10+, pip or uv6#7# Usage:8# chmod +x scripts/run_local.sh9# ./scripts/run_local.sh10# ─────────────────────────────────────────────────────────────────────────────11set -euo pipefail12 13REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"14cd "$REPO_ROOT"15 16echo "═══════════════════════════════════════════════"17echo " NL2SQL-Bench — Local Dev Server"18echo "═══════════════════════════════════════════════"19 20# ── Check Python ────────────────────────────────────────────────────────────21if ! command -v python3 &>/dev/null; then22 echo "ERROR: python3 not found. Install Python 3.10+." && exit 123fi24PY_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')25echo "Python: $PY_VERSION"26 27# ── Virtual environment ──────────────────────────────────────────────────────28if [ ! -d ".venv" ]; then29 echo "Creating virtualenv..."30 python3 -m venv .venv31fi32source .venv/bin/activate33 34# ── Install deps ─────────────────────────────────────────────────────────────35echo "Installing dependencies..."36pip install -q --upgrade pip37pip install -q openenv-core fastapi "uvicorn[standard]" openai pydantic pytest pytest-asyncio38 39# ── Load .env if present ─────────────────────────────────────────────────────40if [ -f ".env" ]; then41 echo "Loading .env..."42 set -a43 source .env44 set +a45fi46 47# ── Export PYTHONPATH ─────────────────────────────────────────────────────────48export PYTHONPATH="$REPO_ROOT:$REPO_ROOT/server"49 50echo ""51echo "Starting server at http://localhost:8000"52echo " /reset → POST (start episode)"53echo " /step → POST (submit SQL)"54echo " /state → GET (episode metadata)"55echo " /health → GET (liveness probe)"56echo " /docs → GET (Swagger UI)"57echo ""58echo "Press Ctrl+C to stop."59echo "───────────────────────────────────────────────"60 61cd "$REPO_ROOT/server"62uvicorn app:app \63 --host 0.0.0.0 \64 --port 8000 \65 --reload \66 --reload-dir "$REPO_ROOT" \67 --log-level info68 