Kalletlamadhav/sql_optimized_env_new
0
1# Live Endpoint Testing Instructions2 3## Your HuggingFace Space is Currently Not Responding4 5**URL:** https://kalletlamadhav-sql-optimized-env-new.hf.space6 7All curl/HTTP requests are timing out after 30 seconds. This indicates the Space is either:8- ๐ด **Sleeping** (free tier Spaces sleep after inactivity)9- ๐จ **Building** (still deploying your latest changes)10- ๐ฅ **Crashed** (runtime error preventing startup)11- โ **Wrong URL** (Space name might be different)12 13## STEP 1: Wake Up Your Space14 151. **Visit the Space URL in your browser:**16 ```17 https://kalletlamadhav-sql-optimized-env-new.hf.space18 ```19 202. **Check the Space status page:**21 ```22 https://huggingface.co/spaces/kalletlamadhav/sql-optimized-env-new23 ```24 - Look for "Building", "Running", or "Runtime error" status25 - Check the logs for any error messages26 273. **Wait 30-60 seconds** for the Space to fully wake up28 29## STEP 2: Test Endpoints Using curl30 31Once the Space is accessible, run these commands:32 33### Test 1: Health Check34```bash35curl -s https://kalletlamadhav-sql-optimized-env-new.hf.space/health | python -m json.tool36```37 38**Expected:** JSON with `"status": "ok"`39 40### Test 2: List Tasks41```bash42curl -s https://kalletlamadhav-sql-optimized-env-new.hf.space/tasks | python -m json.tool43```44 45**Expected:** Array with 3+ task objects46 47### Test 3: Reset Environment48```bash49curl -s -X POST "https://kalletlamadhav-sql-optimized-env-new.hf.space/reset?task_id=gst_missing_index" | python -m json.tool50```51 52**Expected:** Observation object with fields:53- `task_id`: "gst_missing_index"54- `step_number`: 055- `goal`: string56- `schema_ddl`: string57- `slow_query`: string58- `expected_pattern`: string59 60### Test 4: Get State61```bash62curl -s https://kalletlamadhav-sql-optimized-env-new.hf.space/state | python -m json.tool63```64 65**Expected:** State object with `current_task_id` and `episode_count`66 67### Test 5: Submit Step (CRITICAL - Reward Validation)68```bash69curl -s -X POST "https://kalletlamadhav-sql-optimized-env-new.hf.space/step" \70 -H "Content-Type: application/json" \71 -d '{72 "optimized_query": "SELECT gstin_supplier, invoice_date FROM gst_invoice_records WHERE invoice_date >= '\''2025-01-01'\''",73 "identified_pattern": "MISSING_INDEX",74 "explanation": "Added index on invoice_date to avoid full table scan",75 "index_statements": ["CREATE INDEX idx_invoice_date ON gst_invoice_records(invoice_date)"],76 "schema_analysis": "No index on invoice_date"77 }' | python -m json.tool78```79 80**Expected:** Step result with:81- `reward`: **MUST be strictly between 0.01 and 0.99** (NOT 0.0, NOT 1.0)82- `done`: boolean83- `observation`: object with task details84 85## STEP 3: Verify Reward Values86 87**CRITICAL CHECK:** The `reward` field (or `reward.total` if it's an object) must be:88- โ
Greater than 0.0189- โ
Less than 0.9990- โ NOT exactly 0.091- โ NOT exactly 1.092 93### Example Valid Responses:94```json95{96 "reward": 0.45, // โ
VALID97 "done": false,98 "observation": {...}99}100```101 102```json103{104 "reward": {105 "total": 0.67, // โ
VALID106 "speedup_score": 0.25,107 ...108 },109 "done": false,110 "observation": {...}111}112```113 114### Example INVALID Responses:115```json116{117 "reward": 0.0, // โ FAIL - exactly 0.0118 ...119}120```121 122```json123{124 "reward": 1.0, // โ FAIL - exactly 1.0125 ...126}127```128 129## STEP 4: If Tests Fail130 131### If /health times out or returns error:132- Space is not running properly133- Check HuggingFace Space logs134- Verify Dockerfile and requirements are correct135 136### If /tasks returns empty array:137- Check `tasks/` directory has task files138- Verify `task_registry.py` is loading tasks correctly139 140### If /reset returns error or empty:141- Check `server/main.py` reset endpoint142- Verify `server/environment.py` reset method143 144### If /step reward is 0.0 or 1.0:145- **This is the main Phase 2 validation issue**146- All graders must clamp scores to (0.01, 0.99)147- Check files already fixed in this repo148 149## All Fixes Already Applied150 151The following files have been fixed to ensure rewards are strictly between 0.01 and 0.99:152 153โ
`server/graders/speedup_grader.py`154โ
`server/graders/equivalence_grader.py`155โ
`server/graders/antipattern_grader.py`156โ
`server/graders/index_grader.py`157โ
`server/reward.py`158โ
`server/app.py`159โ
`pyproject.toml`160 161**If your Space is using old code**, you need to:1621. Push the fixed files to your HuggingFace Space repository1632. Wait for the Space to rebuild1643. Test again165 166## Quick Python Test Script167 168If curl is not available, use this Python script:169 170```python171import requests172import json173 174BASE_URL = "https://kalletlamadhav-sql-optimized-env-new.hf.space"175 176# Test health177print("Testing /health...")178r = requests.get(f"{BASE_URL}/health", timeout=10)179print(json.dumps(r.json(), indent=2))180 181# Test reset182print("\nTesting /reset...")183r = requests.post(f"{BASE_URL}/reset?task_id=gst_missing_index", timeout=10)184print(json.dumps(r.json(), indent=2))185 186# Test step187print("\nTesting /step...")188action = {189 "optimized_query": "SELECT gstin_supplier FROM gst_invoice_records WHERE invoice_date >= '2025-01-01'",190 "identified_pattern": "MISSING_INDEX",191 "explanation": "Added index",192 "index_statements": ["CREATE INDEX idx_date ON gst_invoice_records(invoice_date)"],193 "schema_analysis": "No index"194}195r = requests.post(f"{BASE_URL}/step", json=action, timeout=10)196result = r.json()197print(json.dumps(result, indent=2))198 199# Validate reward200reward = result.get("reward")201if isinstance(reward, dict):202 reward = reward.get("total", 0)203 204print(f"\n{'='*50}")205if 0.01 < reward < 0.99:206 print(f"โ
PASS: Reward {reward} is valid!")207else:208 print(f"โ FAIL: Reward {reward} is NOT in (0.01, 0.99)")209print(f"{'='*50}")210```211 212## Summary213 214Your local code has been fixed and is ready for Phase 2 validation. The issue is that your HuggingFace Space is not responding to HTTP requests. You need to:215 2161. โ
Visit the Space URL to wake it up2172. โ
Verify it's running (not building/crashed)2183. โ
Push the fixed code if Space is using old version2194. โ
Run the tests above to verify all endpoints work2205. โ
Confirm reward values are strictly between 0.01 and 0.99221 