| title | SQL Cost Optimizer Env v2 | |||
|---|---|---|---|---|
| emoji | 🚀 | |||
| colorFrom | blue | |||
| colorTo | green | |||
| sdk | docker | |||
| pinned | false | |||
| app_port | 8000 | |||
| tags |
|
This repository provides an OpenEnv-compatible SQL optimization benchmark with three tasks:
index-advisorquery-rewriterschema-normalizer
The environment simulates a real task people actually do: improving SQL performance and schema quality while preserving correctness.
Agents receive a slow SQL query, schema, sample data, and an EXPLAIN plan. They must propose an optimization action such as an index, rewritten SQL, or normalized schema migration.
MyAction includes:
optimized_query: SQL or DDL to executeexplanation: short rationalesuggested_changes: list of changes madeconfidence: float in[0.0, 1.0]metadata: extra fields
MyObservation includes:
task_typequerydatabase_schemacurrent_execution_time_msexplain_plansample_data_previewhintmetadata
Install dependencies and run validation:
uv sync
openenv validate
python inference.pySet these in your Hugging Face Space or local environment:
API_BASE_URLMODEL_NAMEHF_TOKEN
Run the demo script to exercise one environment step:
python demo.pyBuild locally:
docker build -f Dockerfile -t sql-cost-optimizer-env-v2 .Deploy to Hugging Face Spaces by pushing the repo root with Dockerfile, openenv.yaml, inference.py, requirements.txt, and README.md present.
my_env/
├── .dockerignore # Docker build exclusions
├── __init__.py # Module exports
├── README.md # This file
├── openenv.yaml # OpenEnv manifest
├── pyproject.toml # Project metadata and dependencies
├── uv.lock # Locked dependencies (generated)
├── client.py # MyEnv client
├── models.py # Action and Observation models
└── server/
├── __init__.py # Server module exports
├── my_env_environment.py # Core environment logic
├── app.py # FastAPI application (HTTP + WebSocket endpoints)
└── Dockerfile # Container image definition