Rithwik Ravi commited on
Commit
bfcdfad
·
1 Parent(s): 8b003d5

Fixed uv run server error

Browse files
pyproject.toml CHANGED
@@ -17,8 +17,9 @@ dependencies = [
17
  "pandas"
18
  ]
19
 
20
- [tool.setuptools]
21
- packages = ["."]
 
22
 
23
  [project.scripts]
24
  server = "server.app:main"
 
17
  "pandas"
18
  ]
19
 
20
+ [tool.setuptools.packages.find]
21
+ where = ["."]
22
+ include = ["server*"]
23
 
24
  [project.scripts]
25
  server = "server.app:main"
sql_data_engineer_env.egg-info/PKG-INFO ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: sql-data-engineer-env
3
+ Version: 0.1.0
4
+ Summary: A real-world SQL data engineering environment for agent evaluation.
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: openenv-core
8
+ Requires-Dist: fastapi
9
+ Requires-Dist: uvicorn
10
+ Requires-Dist: pydantic
11
+ Requires-Dist: openai
12
+ Requires-Dist: pandas
13
+
14
+ ---
15
+ title: SQL Data Engineer Environment
16
+ emoji: 🗄️
17
+ colorFrom: blue
18
+ colorTo: indigo
19
+ sdk: docker
20
+ pinned: false
21
+ app_port: 7860
22
+ ---
23
+ # OpenEnv: SQL Data Engineer Environment
24
+
25
+ Welcome to the **SQL Data Engineer Environment**—a robust, fully-compliant baseline environment built for the Meta OpenEnv Hackathon. This project tests an AI agent's ability to natively interact with a live SQL engine to perform pragmatic data extraction, cleansing, and complex schema normalization tasks.
26
+
27
+ ## Environment Description & Motivation
28
+
29
+ ### Why SQL Data Engineering?
30
+ The industry needs reliable agents that can act as backend developers, DB administrators, and data engineers. While many environments focus on web browsing or gaming, manipulating relational databases is a high-value, real-world task. This environment simulates authentic obstacles developers face:
31
+ - Analyzing undocumented database schemas.
32
+ - Cleansing noisy string data into strict scalar types.
33
+ - Restructuring and normalizing flat tables into relational architectures while rigorously preserving foreign-key constraints.
34
+
35
+ It presents an excellent metric to gauge an LLM's structured reasoning and precise SQL generation capabilities.
36
+
37
+ ---
38
+
39
+ ## Space Definitions
40
+
41
+ The environment adheres strictly to the OpenEnv Pydantic specification, enabling seamless API integration.
42
+
43
+ ### Observation Space
44
+ The observation space is tailored to provide dense context while remaining token-efficient:
45
+ - `goal` (string): The explicit task prompt/requirement dictating what the agent must achieve.
46
+ - `schema_dump` (string | null): The current DDL representing all tables and views in the DB (schema definition). Sent back only when the schema dynamically changes or the state is stable.
47
+ - `result` (string): The standard output of the previously executed query (capped to 10 rows for SELECTs) or a clear `rowcount` confirmation for INSERTs/UPDATEs.
48
+ - `last_action_error` (boolean): Flag indicating if the previous SQL Action threw a syntax or logic engine error.
49
+ - `step` (integer): The current episode step tally.
50
+
51
+ ### Action Space
52
+ - `action_str` (string): The agent must return a JSON dictionary containing a single, syntactically correct SQLite query to be executed against the backend state.
53
+
54
+ ---
55
+
56
+ ## Tasks & Graders
57
+
58
+ Each episode challenges the agent with one of 3 tasks featuring deterministic OpenEnv graders scoring between `0.0` and `1.0`.
59
+
60
+ #### 1. Easy: Data Extraction (View Creation)
61
+ - **Goal**: Read a `customers` table, filter out metrics > 1000.0, and construct a targeted `high_value_customers` SQL View.
62
+ - **Difficulty**: Easy. Tests basic SELECT syntax and DDL proficiency.
63
+ - **Grader**: Validates if the correct view exists in `sqlite_master`, assigns `0.5` points. Exact row and content matching grants the remaining `+0.5`.
64
+
65
+ #### 2. Medium: Data Cleaning
66
+ - **Goal**: Coerce a messy `products` table. The agent must standardize categorical string sizes (e.g., converting 'ELEC' to 'ELECTRONICS') and extract numeric floats from dirty string pricing (e.g., '$85.00' -> `85.0`) into a new generated float column.
67
+ - **Difficulty**: Medium. Tests native string pattern matching and targeted UPDATE pipelines.
68
+ - **Grader**: Adding the column yields `0.3` points. Correct categorical string mapping grants up to `0.3`, and correctly extracted float prices yield `0.4` respectively.
69
+
70
+ #### 3. Hard: Schema Normalization
71
+ - **Goal**: Normalize a completely flat `hospital_records` repository into a structured 3-table format (`patients`, `doctors`, `appointments`). Data must be completely migrated and bound by Primary/Foreign key constraints.
72
+ - **Difficulty**: Hard. Tests multi-step schema architectural reasoning and safe data-migration pipelines.
73
+ - **Grader**: Validating table signatures issues `0.1` per table. Proper data counts yield `0.1` each, and if a relational JOIN across the new DB perfectly rebuilds the original flat map, the final `0.3` is awarded.
74
+
75
+ ### The Dense Reward Function
76
+ Scores are completely dense over the episode lifecycle.
77
+ At `step(action)`, the grader executes. The mathematical reward signal is continuous:
78
+ `Reward = (Current_Score - Previous_Score)`.
79
+ *Note: A `-0.05` penalty is actively applied when `last_action_error` triggers, strongly discouraging hallucinated or malformed SQL loops.*
80
+
81
+ ---
82
+
83
+ ## Local Setup & Usage
84
+
85
+ To validate the OpenEnv schema, install the framework, and run the OpenAI-compatible baseline script locally:
86
+
87
+ ```bash
88
+ # 1. Clone the repository and navigate inside
89
+ git clone <your-repo-url>
90
+ cd OpenEnv-SQL-Data-Engineer
91
+
92
+ # 2. Setup standard Python virtual environment
93
+ python -m venv venv
94
+ source venv/bin/activate # Or `venv\Scripts\activate` on Windows
95
+
96
+ # 3. Install core dependencies (FastAPI, Pydantic, OpenAI, OpenEnv)
97
+ pip install openenv openenv-core openai pydantic fastapi uvicorn requests
98
+
99
+ # 4. Verify OpenEnv schema compliance locally
100
+ openenv validate
101
+
102
+ # 5. Execute the baseline AI Agent (make sure to set your key)
103
+ export OPENAI_API_KEY="your-api-key"
104
+ export MODEL_NAME="gpt-4o"
105
+ python inference.py
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Deployment Instructions
111
+
112
+ ### Docker Container Build
113
+ The environment provides a native Hugging Face structured `Dockerfile` configured to launch on port 7860 as an unprivileged user.
114
+
115
+ ```bash
116
+ docker build -t openenv-sql .
117
+ docker run -p 7860:7860 openenv-sql
118
+ ```
119
+
120
+ ### Deploying to Hugging Face Spaces
121
+ To finalize your Hackathon deployment and spin up the live inference API:
122
+ 1. First, create a new minimal **Docker Space** inside Hugging Face.
123
+ 2. Ensure you add `HF_TOKEN` globally inside your HF Space Repository secrets.
124
+ 3. Push this directory to the Space via git:
125
+ ```bash
126
+ git remote add space https://huggingface.co/spaces/<your-username>/<your-space-name>
127
+ git push space main
128
+ ```
129
+ 4. The environment URL will naturally respond to ping checks and `/reset` on HF endpoints.
130
+
131
+
132
+ ### Baseline Scores (Llama-3-8B-Instruct)
133
+ - **Easy Task:** 1.0 (Passed)
134
+ - **Medium Task:** 0.62 (Partial Success - struggled with complex string casting)
135
+ - **Hard Task:** 0.2 (Challenging - requires higher reasoning/longer context)
sql_data_engineer_env.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ README.md
2
+ pyproject.toml
3
+ server/__init__.py
4
+ server/app.py
5
+ server/models.py
6
+ server/tasks.py
7
+ sql_data_engineer_env.egg-info/PKG-INFO
8
+ sql_data_engineer_env.egg-info/SOURCES.txt
9
+ sql_data_engineer_env.egg-info/dependency_links.txt
10
+ sql_data_engineer_env.egg-info/entry_points.txt
11
+ sql_data_engineer_env.egg-info/requires.txt
12
+ sql_data_engineer_env.egg-info/top_level.txt
sql_data_engineer_env.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
sql_data_engineer_env.egg-info/entry_points.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [console_scripts]
2
+ server = server.app:main
sql_data_engineer_env.egg-info/requires.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ openenv-core
2
+ fastapi
3
+ uvicorn
4
+ pydantic
5
+ openai
6
+ pandas
sql_data_engineer_env.egg-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ server