Spaces:
Sleeping
Sleeping
Upload main.py with huggingface_hub
Browse files
main.py
CHANGED
|
@@ -36,8 +36,7 @@ app.add_middleware(
|
|
| 36 |
VALID_TASKS = [
|
| 37 |
"easy_dedup_rename",
|
| 38 |
"medium_missing_dtype",
|
| 39 |
-
"hard_full_pipeline"
|
| 40 |
-
"expert_sales_pipeline"
|
| 41 |
]
|
| 42 |
|
| 43 |
envs: Dict[str, DataCleaningEnv] = {
|
|
@@ -125,21 +124,6 @@ def list_tasks():
|
|
| 125 |
"remove_duplicates", "fill_missing", "fix_dtype",
|
| 126 |
"remove_outliers", "validate_schema", "finish"
|
| 127 |
]
|
| 128 |
-
},
|
| 129 |
-
{
|
| 130 |
-
"task_id": "expert_sales_pipeline",
|
| 131 |
-
"difficulty": "expert",
|
| 132 |
-
"description": (
|
| 133 |
-
"Expert level: Full sales data cleaning pipeline "
|
| 134 |
-
"requiring correct order of operations including "
|
| 135 |
-
"case standardization, outlier removal, and schema validation."
|
| 136 |
-
),
|
| 137 |
-
"max_steps": 25,
|
| 138 |
-
"operations": [
|
| 139 |
-
"remove_duplicates", "fill_missing", "fix_dtype",
|
| 140 |
-
"remove_outliers", "rename_columns",
|
| 141 |
-
"validate_schema", "finish"
|
| 142 |
-
]
|
| 143 |
}
|
| 144 |
]
|
| 145 |
}
|
|
@@ -236,75 +220,3 @@ def validate():
|
|
| 236 |
"openenv_valid": all_passed,
|
| 237 |
"tasks": results
|
| 238 |
}
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
# In memory leaderboard
|
| 242 |
-
leaderboard_data = []
|
| 243 |
-
|
| 244 |
-
@app.post("/leaderboard/submit")
|
| 245 |
-
def submit_score(entry: Dict[str, Any]):
|
| 246 |
-
"""Submit a score to the leaderboard."""
|
| 247 |
-
required = ["model_name", "task_id", "score"]
|
| 248 |
-
for field in required:
|
| 249 |
-
if field not in entry:
|
| 250 |
-
raise HTTPException(
|
| 251 |
-
status_code=400,
|
| 252 |
-
detail=f"Missing field: {field}"
|
| 253 |
-
)
|
| 254 |
-
if not 0.0 <= float(entry["score"]) <= 1.0:
|
| 255 |
-
raise HTTPException(
|
| 256 |
-
status_code=400,
|
| 257 |
-
detail="Score must be between 0.0 and 1.0"
|
| 258 |
-
)
|
| 259 |
-
leaderboard_data.append({
|
| 260 |
-
"model_name": entry["model_name"],
|
| 261 |
-
"task_id": entry["task_id"],
|
| 262 |
-
"score": round(float(entry["score"]), 4),
|
| 263 |
-
"steps": entry.get("steps", 0),
|
| 264 |
-
"timestamp": __import__("datetime").datetime.utcnow().isoformat()
|
| 265 |
-
})
|
| 266 |
-
return {"status": "submitted", "entry": leaderboard_data[-1]}
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
@app.get("/leaderboard")
|
| 270 |
-
def get_leaderboard():
|
| 271 |
-
"""Get current leaderboard rankings."""
|
| 272 |
-
if not leaderboard_data:
|
| 273 |
-
# Return baseline scores
|
| 274 |
-
return {
|
| 275 |
-
"leaderboard": [
|
| 276 |
-
{
|
| 277 |
-
"rank": 1,
|
| 278 |
-
"model_name": "gpt-4o-mini (baseline)",
|
| 279 |
-
"easy_score": 1.0000,
|
| 280 |
-
"medium_score": 0.6643,
|
| 281 |
-
"hard_score": 0.8386,
|
| 282 |
-
"avg_score": 0.8343
|
| 283 |
-
}
|
| 284 |
-
],
|
| 285 |
-
"total_submissions": 1
|
| 286 |
-
}
|
| 287 |
-
|
| 288 |
-
# Group by model
|
| 289 |
-
from collections import defaultdict
|
| 290 |
-
model_scores = defaultdict(dict)
|
| 291 |
-
for entry in leaderboard_data:
|
| 292 |
-
model_scores[entry["model_name"]][entry["task_id"]] = entry["score"]
|
| 293 |
-
|
| 294 |
-
ranked = []
|
| 295 |
-
for model, scores in model_scores.items():
|
| 296 |
-
avg = sum(scores.values()) / len(scores) if scores else 0
|
| 297 |
-
ranked.append({
|
| 298 |
-
"model_name": model,
|
| 299 |
-
"scores": scores,
|
| 300 |
-
"avg_score": round(avg, 4)
|
| 301 |
-
})
|
| 302 |
-
|
| 303 |
-
ranked.sort(key=lambda x: x["avg_score"], reverse=True)
|
| 304 |
-
for i, r in enumerate(ranked):
|
| 305 |
-
r["rank"] = i + 1
|
| 306 |
-
|
| 307 |
-
return {
|
| 308 |
-
"leaderboard": ranked,
|
| 309 |
-
"total_submissions": len(leaderboard_data)
|
| 310 |
-
}
|
|
|
|
| 36 |
VALID_TASKS = [
|
| 37 |
"easy_dedup_rename",
|
| 38 |
"medium_missing_dtype",
|
| 39 |
+
"hard_full_pipeline"
|
|
|
|
| 40 |
]
|
| 41 |
|
| 42 |
envs: Dict[str, DataCleaningEnv] = {
|
|
|
|
| 124 |
"remove_duplicates", "fill_missing", "fix_dtype",
|
| 125 |
"remove_outliers", "validate_schema", "finish"
|
| 126 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
}
|
| 128 |
]
|
| 129 |
}
|
|
|
|
| 220 |
"openenv_valid": all_passed,
|
| 221 |
"tasks": results
|
| 222 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|