data-cleaning-openenv / PROJECT_COMPLETE_GUIDE.md
01ammu's picture
Sync from GitHub via hub-sync
fee2f22 verified
|
Raw History Blame Contribute Delete
25.1 kB
# πŸ“˜ Data Cleaning OpenEnv β€” Complete Project Guide
> **Everything you need to understand, run, teach, and extend this project.**
> Written for the Meta OpenEnv Hackathon, April 2026.
---
## πŸ“Œ Table of Contents
1. [What is this project?](#1-what-is-this-project)
2. [What is Reinforcement Learning?](#2-what-is-reinforcement-learning)
3. [What is OpenEnv?](#3-what-is-openenv)
4. [Project File Structure](#4-project-file-structure)
5. [What Each File Does](#5-what-each-file-does)
6. [System Flowchart β€” How Everything Works Together](#6-system-flowchart--how-everything-works-together)
7. [The RL Loop in This Project](#7-the-rl-loop-in-this-project)
8. [Reward System Explained](#8-reward-system-explained)
9. [The 3 Tasks Explained](#9-the-3-tasks-explained)
10. [All Commands to Run the Project](#10-all-commands-to-run-the-project)
11. [How to Deploy to HuggingFace](#11-how-to-deploy-to-huggingface)
12. [Live URLs](#12-live-urls)
13. [Baseline Scores](#13-baseline-scores)
14. [Tech Stack](#14-tech-stack)
15. [Quick Glossary](#15-quick-glossary)
---
## 1. What is this project?
This project is a **Reinforcement Learning (RL) environment** where an AI agent learns to **clean messy datasets**.
In the real world, data scientists spend 60–80% of their time cleaning data β€” fixing missing values, removing duplicates, correcting wrong data types, standardizing categories, and handling outliers.
We built an environment where an AI agent can **practice and learn** this skill automatically, row by row, getting rewarded for good cleaning decisions and penalized for bad ones.
**Think of it like this:**
- The environment is a "gym" for the AI
- The dataset is the "obstacle course"
- Each dirty row is a challenge
- The agent picks an action (fill, fix, skip, etc.)
- It gets a reward or penalty based on the quality of its decision
- Over thousands of episodes, it learns to clean data like an expert
---
## 2. What is Reinforcement Learning?
Reinforcement Learning (RL) is a type of machine learning where an agent learns by **trial and error** β€” interacting with an environment and learning from rewards.
**The RL Loop:**
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚
β”‚ ENVIRONMENT ──observation──▢ AGENT β”‚
β”‚ β”‚
β”‚ ENVIRONMENT ◀──action────── AGENT β”‚
β”‚ β”‚
β”‚ ENVIRONMENT ──reward───────▢ AGENT β”‚
β”‚ β”‚
β”‚ (repeat until episode ends) β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
**In plain English:**
1. Environment shows agent the current situation (observation)
2. Agent decides what to do (action)
3. Environment evaluates the action and gives feedback (reward)
4. Agent learns from the reward and improves over time
**In our project:**
1. Environment shows agent a dirty data row
2. Agent picks a cleaning action (fill_missing, fix_type, etc.)
3. Environment gives +0.3 for good action, -0.2 for bad
4. Agent learns which actions to take for which types of issues
---
## 3. What is OpenEnv?
OpenEnv is a framework by Meta that standardizes how RL environments are built and deployed.
**Key idea:** RL environments should work like REST APIs β€” type-safe, containerized, and deployable anywhere.
**Why OpenEnv over traditional Gym?**
| Feature | Traditional (OpenAI Gym) | OpenEnv |
|---|---|---|
| Type Safety | ❌ Raw arrays/dicts | βœ… Typed Pydantic models |
| Isolation | ❌ Same process | βœ… Docker containers |
| Deployment | ❌ "Works on my machine" | βœ… Same everywhere |
| Language | ❌ Python only | βœ… Any language (HTTP API) |
| Scaling | ❌ Hard | βœ… Kubernetes-ready |
**The 3 mandatory endpoints:**
```
POST /reset β†’ Start a new episode
POST /step β†’ Take an action
GET /state β†’ Get episode metadata
```
---
## 4. Project File Structure
```
data-cleaning-openenv/
β”‚
β”œβ”€β”€ Dockerfile ← Containerizes the whole app
β”œβ”€β”€ inference.py ← Baseline agent using OpenAI API
β”œβ”€β”€ test_env.py ← Local testing script
β”œβ”€β”€ README.md ← HuggingFace/GitHub readme
β”œβ”€β”€ pyproject.toml ← Makes env pip-installable
β”œβ”€β”€ PROJECT_COMPLETE_GUIDE.md ← This file!
β”‚
└── envs/
└── data_cleaning_env/
β”‚
β”œβ”€β”€ models.py ← Typed contracts (Action, Observation, State)
β”œβ”€β”€ client.py ← HTTP client for agents to use
β”œβ”€β”€ openenv.yaml ← OpenEnv metadata/spec file
β”œβ”€β”€ __init__.py
β”‚
β”œβ”€β”€ server/
β”‚ β”œβ”€β”€ app.py ← FastAPI server (all endpoints)
β”‚ β”œβ”€β”€ environment.py ← Core RL logic
β”‚ └── __init__.py
β”‚
└── tasks/
β”œβ”€β”€ graders.py ← Task definitions + scoring logic
└── __init__.py
```
---
## 5. What Each File Does
### `models.py` β€” The Language
Defines the **typed data structures** that the agent and environment use to communicate.
```python
# What the agent SENDS to the environment
class DataCleaningAction:
action_type: str # "fill_missing", "fix_type", "skip", etc.
column: str # Which column to act on ("age", "salary", etc.)
value: Any # New value if needed (e.g., 30 for age)
# What the agent RECEIVES from the environment
class DataCleaningObservation:
current_row: int # Which row we're on (0, 1, 2...)
total_rows: int # Total rows in dataset
current_data: dict # The actual dirty data {'age': None, 'score': '85'}
issues_detected: list # ['missing:age', 'wrong_type:score']
legal_actions: list # ['fill_missing', 'fix_type', 'skip']
progress: float # 0.0 to 1.0
reward: float # Last reward received
done: bool # Is episode over?
# Episode metadata
class DataCleaningState:
episode_id: str
task_name: str
step_count: int
total_reward: float
rows_cleaned: int
score: float # Final grader score (0.0 to 1.0)
```
---
### `environment.py` β€” The Brain
The **core RL logic**. This is where the environment lives.
**Key methods:**
`reset(task_name)` β†’ Starts a new episode
- Loads a dirty dataset for the chosen task
- Resets all counters
- Returns the first observation
`step(action_type, column, value)` β†’ Processes one action
- Applies the cleaning action to the current row
- Calculates reward (+/- based on action quality)
- Moves to next row
- Returns new observation
`_detect_issues(row)` β†’ Finds problems in a row
- Checks for None values β†’ "missing:age"
- Checks for wrong types β†’ "wrong_type:score"
- Checks for formatting β†’ "formatting:email"
`_get_legal_actions(row, issues)` β†’ What can agent do right now?
- If missing values exist β†’ add "fill_missing"
- If wrong types exist β†’ add "fix_type"
- Always includes "skip", "remove_duplicate", etc.
---
### `graders.py` β€” The Judge
Defines the **3 tasks** and **scores** the cleaned dataset after an episode.
**Task generation:**
- `generate_easy_dataset()` β†’ 10 rows with missing values + wrong types
- `generate_medium_dataset()` β†’ 8 rows with duplicates + formatting issues
- `generate_hard_dataset()` β†’ 8 rows with all issues combined
**Grading:**
- `grade_easy(cleaned_data)` β†’ Checks all values filled + score is numeric
- `grade_medium(cleaned_data)` β†’ Checks no duplicates + emails lowercase
- `grade_hard(cleaned_data)` β†’ Checks depts standardized + salaries in range
All graders return `(score, message)` where score is 0.0–1.0.
---
### `app.py` β€” The Server
Exposes the environment over **HTTP and WebSocket** so any agent can interact with it.
**HTTP Endpoints:**
```
POST /reset β†’ env.reset(task_name)
POST /step β†’ env.step(action_type, column, value)
GET /state β†’ env.get_state()
GET /health β†’ {"status": "ok"}
GET /tasks β†’ list all tasks
GET /docs β†’ Swagger API documentation
```
**WebSocket Endpoint:**
```
WS /ws β†’ Persistent connection for efficient RL training
Each connection gets its own environment instance
Much faster than HTTP for thousands of steps
```
---
### `client.py` β€” The Agent's Interface
How your **training code** talks to the environment. Wraps all HTTP calls into clean Python methods.
```python
# Usage example
env = DataCleaningEnv(base_url="https://01ammu-data-cleaning-openenv.hf.space")
result = env.reset(task_name="easy")
# Returns StepResult(observation=..., reward=0.0, done=False, info={...})
result = env.step(action_type="fill_missing", column="age", value=30)
# Returns StepResult(observation=..., reward=0.3, done=False, info={...})
state = env.state()
# Returns episode metadata dict
```
---
### `inference.py` β€” The Baseline Agent
Uses the **OpenAI API** to run a language model against the environment. Produces reproducible baseline scores to show in the README.
---
### `Dockerfile` β€” The Container
Packages everything so it runs **identically everywhere**.
```dockerfile
FROM python:3.11-slim
WORKDIR /app
RUN pip install fastapi uvicorn requests openai pydantic
COPY envs/data_cleaning_env/server/ ./server/
COPY envs/data_cleaning_env/tasks/ ./tasks/
EXPOSE 7860
CMD ["python", "-m", "uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]
```
---
### `openenv.yaml` β€” The Spec File
Tells the OpenEnv framework everything about your environment β€” name, version, tasks, action space, observation space, endpoints.
---
### `pyproject.toml` β€” pip Installable
Makes your environment installable directly from HuggingFace:
```bash
pip install git+https://huggingface.co/spaces/01ammu/data-cleaning-openenv
```
---
## 6. System Flowchart β€” How Everything Works Together
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ AGENT (Your Code) β”‚
β”‚ β”‚
β”‚ from client import DataCleaningEnv β”‚
β”‚ env = DataCleaningEnv(base_url="https://...hf.space") β”‚
β”‚ result = env.reset(task_name="easy") β”‚
β”‚ result = env.step("fill_missing", "age", 30) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ HTTP POST /reset
β”‚ HTTP POST /step
β”‚ (or WebSocket /ws)
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ DOCKER CONTAINER (HF Space) β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ app.py (FastAPI Server) β”‚ β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ POST /reset ──────────────────────────────────────────┐ β”‚ β”‚
β”‚ β”‚ POST /step ──────────────────────────────────────┐ β”‚ β”‚ β”‚
β”‚ β”‚ GET /state ──────────────────────┐ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ WS /ws ──────────────────┐ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”˜ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β” β”‚ β”‚
β”‚ β”‚ environment.py (Core RL Logic) β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ reset() ──▢ loads dataset ──▢ returns observation β”‚ β”‚ β”‚
β”‚ β”‚ step() ──▢ applies action ──▢ calculates reward β”‚ β”‚ β”‚
β”‚ β”‚ ──▢ moves to next row ──▢ returns obs β”‚ β”‚ β”‚
β”‚ β”‚ get_state() ──▢ returns episode metadata β”‚ β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
β”‚ β”‚ graders.py (Tasks + Scoring) β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ generate_easy_dataset() β†’ 10 rows, missing+types β”‚ β”‚ β”‚
β”‚ β”‚ generate_medium_dataset() β†’ 8 rows, +duplicates β”‚ β”‚ β”‚
β”‚ β”‚ generate_hard_dataset() β†’ 8 rows, +outliers β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ grade_easy(data) β†’ score 0.0–1.0 β”‚ β”‚ β”‚
β”‚ β”‚ grade_medium(data) β†’ score 0.0–1.0 β”‚ β”‚ β”‚
β”‚ β”‚ grade_hard(data) β†’ score 0.0–1.0 β”‚ β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β–Ό
Observation + Reward returned to Agent
```
---
## 7. The RL Loop in This Project
Here is exactly what happens during one full episode:
```
START: Agent calls reset(task_name="easy")
β”‚
β”œβ”€β”€ Environment loads dirty dataset (10 rows)
β”œβ”€β”€ Returns first row: {'age': None, 'salary': 50000, 'score': '85'}
β”‚ Issues: ['missing:age', 'wrong_type:score']
β”‚ Legal actions: ['fill_missing', 'fix_type', 'skip', ...]
β”‚
β”œβ”€β”€ Agent sees the row and issues
β”œβ”€β”€ Agent picks action: fill_missing on column 'age', value=30
β”‚
β”œβ”€β”€ Environment applies: row['age'] = 30
β”œβ”€β”€ Reward: +0.3 (correct action for a missing value)
β”œβ”€β”€ Returns next row
β”‚
β”œβ”€β”€ Agent picks action: fix_type on column 'score'
β”œβ”€β”€ Environment applies: row['score'] = float('85') = 85.0
β”œβ”€β”€ Reward: +0.2
β”‚
β”œβ”€β”€ ... (repeat for all 10 rows) ...
β”‚
END: All rows processed β†’ done = True
β”‚
└── Grader scores final cleaned dataset β†’ 0.88
"Passed 31/35 checks"
```
---
## 8. Reward System Explained
| Action | When to use | Reward |
|---|---|---|
| `fill_missing` | Column value is None | **+0.3** |
| `fix_type` | Value is wrong type (e.g. "85" instead of 85) | **+0.2** |
| `remove_duplicate` | Row is a duplicate of previous row | **+0.4** |
| `fix_category` | Category is inconsistent (e.g. "eng" β†’ "Engineering") | **+0.3** |
| `remove_outlier` | Value is out of normal range (e.g. salary = 999999) | **+0.4** |
| `fix_formatting` | Text needs formatting (e.g. "ALICE@GMAIL.COM" β†’ lowercase) | **+0.2** |
| `skip` | Do nothing | **-0.2** (penalty) |
| Wrong action | e.g. fill_missing when value already exists | **-0.1** |
| Unknown action | Not in the action space | **-0.3** |
**Why penalties matter:**
The agent can't just always pick "fill_missing" and get rewards. If the value already exists and you try to fill it, you get -0.1. This forces the agent to actually read the observation and pick the right action.
---
## 9. The 3 Tasks Explained
### Task 1 β€” Easy: Fix Missing Values & Type Errors
**Dataset:** 10-row employee dataset with age, salary, score
**Issues:**
- `age` or `salary` is None β†’ needs `fill_missing`
- `score` is "85" (string) instead of 85.0 (float) β†’ needs `fix_type`
**Grader checks:**
- All age, salary, score fields are non-null
- score is numeric (float)
**Baseline score: 0.88**
---
### Task 2 β€” Medium: Remove Duplicates & Fix Formatting
**Dataset:** 8-row contacts dataset with name, email, age
**Issues:**
- Rows 2 and 4 are exact duplicates (Bob, bob@gmail.com, 30)
- Rows 3 and 7 are exact duplicates (charlie)
- `email` is uppercase ("ALICE@GMAIL.COM") β†’ needs `fix_formatting`
- `name` or `age` is None β†’ needs `fill_missing`
**Grader checks:**
- No duplicate emails
- All names filled
- All emails lowercase
- All ages filled
**Baseline score: 0.88**
---
### Task 3 β€” Hard: Full Data Cleaning
**Dataset:** 8-row HR dataset with name, dept, salary, age
**Issues:**
- Inconsistent departments: "eng", "h.r.", "ENGINEERING", "Finance" all need standardizing to "Engineering", "HR", "Finance"
- Outlier salary: 999999 (way too high) β†’ replace with median
- Negative salary: -5000 β†’ invalid
- Missing name, age, salary
- Duplicate rows (alice appears twice)
**Grader checks:**
- No duplicate names
- All fields filled
- All depts in {"Engineering", "HR", "Finance"}
- All salaries between 0 and 200,000
**Baseline score: 0.83**
---
## 10. All Commands to Run the Project
### Prerequisites
```bash
# Make sure you have Python 3.10+ and Git installed
python --version
git --version
```
---
### Clone the project
```bash
git clone https://github.com/AnubhavKiroula/data-cleaning-openenv
cd data-cleaning-openenv
```
---
### Install dependencies
```bash
pip install fastapi uvicorn pydantic requests openai
```
---
### Run the server locally
```bash
# From the project root: D:\META-HACKATHON\data-cleaning-openenv\
cd D:\META-HACKATHON\data-cleaning-openenv
python -m uvicorn server.app:app --host 0.0.0.0 --port 7860
```
Server will be live at: http://localhost:7860
---
### Test all 3 tasks locally
```bash
# From project root
cd D:\META-HACKATHON\data-cleaning-openenv
python test_env.py
```
Expected output:
```
easy : 0.88
medium : 0.88
hard : 0.83
average: 0.86
```
---
### Run with Docker locally
```bash
# From project root
cd D:\META-HACKATHON\data-cleaning-openenv
# Build the Docker image
docker build -t data-cleaning-openenv .
# Run the container
docker run -p 7860:7860 data-cleaning-openenv
```
---
### Run the baseline inference script
```bash
# Set environment variables first
$env:OPENAI_API_KEY = "your_openai_key_here"
$env:API_BASE_URL = "http://localhost:7860"
$env:MODEL_NAME = "gpt-4o-mini"
# Run inference
python inference.py
```
---
### Test the API manually (curl)
```bash
# Health check
curl.exe http://localhost:7860/health
# Reset to easy task
curl.exe -X POST http://localhost:7860/reset -H "Content-Type: application/json" -d '{\"task_name\": \"easy\"}'
# Take a step
curl.exe -X POST http://localhost:7860/step -H "Content-Type: application/json" -d '{\"action_type\": \"fill_missing\", \"column\": \"age\", \"value\": 30}'
# Check state
curl.exe http://localhost:7860/state
# List tasks
curl.exe http://localhost:7860/tasks
```
---
### Push changes to GitHub
```bash
cd D:\META-HACKATHON\data-cleaning-openenv
git add .
git commit -m "your commit message here"
git push origin main
```
---
### Push changes to HuggingFace Space
```bash
cd D:\META-HACKATHON\data-cleaning-openenv
git push hf main
```
If hf remote doesn't exist yet:
```bash
git remote add hf https://huggingface.co/spaces/01ammu/data-cleaning-openenv
git push hf main --force
```
---
### Use the client in your own code
```python
from envs.data_cleaning_env.client import DataCleaningEnv
# Connect to local server
env = DataCleaningEnv(base_url="http://localhost:7860")
# Or connect to live HF Space
env = DataCleaningEnv(base_url="https://01ammu-data-cleaning-openenv.hf.space")
# Run an episode
result = env.reset(task_name="easy")
print(result.observation)
while not result.done:
result = env.step(
action_type="fill_missing",
column="age",
value=30
)
print(f"Reward: {result.reward}, Done: {result.done}")
state = env.state()
print(f"Final score: {state['score']}")
```
---
## 11. How to Deploy to HuggingFace
### One-time setup (already done)
```bash
# Add HF as a git remote
git remote add hf https://huggingface.co/spaces/01ammu/data-cleaning-openenv
```
### Every time you want to redeploy
```bash
cd D:\META-HACKATHON\data-cleaning-openenv
git add .
git commit -m "update: describe what you changed"
git push hf main
git push origin main # also keep GitHub in sync
```
### Check deployment
- Go to: https://huggingface.co/spaces/01ammu/data-cleaning-openenv
- Click App tab β†’ watch Container logs
- Look for: "Application startup complete" and green Running dot
---
## 12. Live URLs
| What | URL |
|---|---|
| HF Space | https://01ammu-data-cleaning-openenv.hf.space |
| Health Check | https://01ammu-data-cleaning-openenv.hf.space/health |
| API Docs (Swagger) | https://01ammu-data-cleaning-openenv.hf.space/docs |
| List Tasks | https://01ammu-data-cleaning-openenv.hf.space/tasks |
| GitHub Repo | https://github.com/AnubhavKiroula/data-cleaning-openenv |
---
## 13. Baseline Scores
These scores were produced by running `inference.py` with a rule-based agent:
| Task | Score | What was tested |
|---|---|---|
| Easy | **1.00** | 31/35 checks passed |
| Medium | **0.88** | Duplicates removed, formatting fixed |
| Hard | **0.85** | All issues including outliers + categories |
| **Average** | **0.91** | Across all 3 tasks |
---
## 14. Tech Stack
| Technology | Role |
|---|---|
| **Python 3.11** | Core language |
| **FastAPI** | HTTP server framework |
| **Uvicorn** | ASGI server to run FastAPI |
| **Pydantic** | Typed data models (Action, Observation, State) |
| **Docker** | Containerization for deployment |
| **HuggingFace Spaces** | Cloud hosting platform |
| **OpenAI API** | Baseline inference agent |
| **Git** | Version control |
| **OpenEnv** | RL environment framework by Meta |
---
## 15. Quick Glossary
| Term | Meaning |
|---|---|
| **Agent** | The AI that makes decisions (what to do with each row) |
| **Environment** | The system the agent interacts with (our data cleaning env) |
| **Observation** | What the agent sees (current row, issues, legal actions) |
| **Action** | What the agent does (fill_missing, fix_type, skip, etc.) |
| **Reward** | Feedback the agent gets (+0.3, -0.2, etc.) |
| **Episode** | One full run through a dataset (all rows processed) |
| **Grader** | Function that scores the cleaned dataset (0.0–1.0) |
| **OpenEnv** | Meta's framework for standardizing RL environments |
| **HF Space** | HuggingFace hosting β€” where our environment runs live |
| **Docker** | Container technology β€” packages app + dependencies together |
| **FastAPI** | Python web framework β€” handles HTTP requests |
| **WebSocket** | Persistent connection β€” faster than HTTP for many RL steps |
| **Pydantic** | Python library for typed, validated data models |
| **Baseline** | A simple agent's score used as a reference point |
| **GRPO** | Group Relative Policy Optimization β€” an RL training algorithm |
---
*Built for the Meta OpenEnv Hackathon, April 2026.*
*Team: AnubhavKiroula*
*HF Space: https://01ammu-data-cleaning-openenv.hf.space*
*GitHub: https://github.com/AnubhavKiroula/data-cleaning-openenv*