Spaces:
Sleeping
Sleeping
File size: 1,686 Bytes
2e3e9b8 cf4af3c |
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 43 44 45 46 47 48 49 50 51 52 53 |
set -euo pipefail
API_BASE=${API_BASE:-"http://127.0.0.1:8000"}
API_KEY=${API_KEY:-"dev-key"}
PROM=${PROMETHEUS_URL:-"http://127.0.0.1:9090"}
TMP_DB="/tmp/nl2sql_dbs/smoke_demo.sqlite"
echo "π§ͺ Running NL2SQL smoke metrics validation..."
echo "API_BASE=$API_BASE"
echo "PROMETHEUS_URL=$PROM"
echo "TMP_DB=$TMP_DB"
# --- 1. Make sure the DB exists ---
if [ ! -f "$TMP_DB" ]; then
echo "βοΈ Creating demo database via smoke_run.py..."
python scripts/smoke_run.py || {
echo "β smoke_run.py failed to create demo DB."
exit 1
}
else
echo "β
Found existing DB at $TMP_DB"
fi
# --- 2. Upload DB and capture db_id ---
echo "β¬οΈ Uploading demo DB..."
DB_ID=$(curl -s -X POST "$API_BASE/api/v1/nl2sql/upload_db" \
-H "X-API-Key: $API_KEY" \
-F "file=@${TMP_DB}" | jq -r '.db_id')
if [ "$DB_ID" = "null" ] || [ -z "$DB_ID" ]; then
echo "β Failed to upload DB or get db_id."
exit 1
fi
echo "β
Uploaded DB_ID: $DB_ID"
# --- 3. Run a few API smoke queries ---
echo "π Sending test queries..."
curl -s -X POST "$API_BASE/api/v1/nl2sql" \
-H "Content-Type: application/json" -H "X-API-Key: $API_KEY" \
-d "{\"db_id\":\"$DB_ID\",\"query\":\"How many artists are there?\"}" | jq .
curl -s -X POST "$API_BASE/api/v1/nl2sql" \
-H "Content-Type: application/json" -H "X-API-Key: $API_KEY" \
-d "{\"db_id\":\"$DB_ID\",\"query\":\"Which customer spent the most?\"}" | jq .
# --- 4. Collect metrics snapshot from Prometheus ---
echo "π Checking Prometheus metrics..."
curl -s "$PROM/api/v1/query?query=nl2sql:pipeline_success_ratio" | jq .
curl -s "$PROM/api/v1/query?query=nl2sql:stage_p95_ms" | jq .
echo "β
Smoke metrics check completed."
|