Spaces:
Sleeping
Sleeping
Commit ·
55bb0ce
1
Parent(s): c4a66be
add grader_fn to tasks endpoint
Browse files- sql_env/server.py +33 -7
sql_env/server.py
CHANGED
|
@@ -6,11 +6,10 @@ Exposes the OpenEnv-required endpoints: /reset, /step, /state + /tasks for valid
|
|
| 6 |
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
from typing import Optional
|
| 9 |
-
|
| 10 |
from fastapi import FastAPI, HTTPException
|
| 11 |
from fastapi.middleware.cors import CORSMiddleware
|
| 12 |
from pydantic import BaseModel
|
| 13 |
-
|
| 14 |
from sql_env import SQLAction, SQLCorrectionEnv
|
| 15 |
from sql_env.tasks import ALL_TASKS
|
| 16 |
|
|
@@ -99,12 +98,39 @@ async def health():
|
|
| 99 |
|
| 100 |
@app.get("/tasks")
|
| 101 |
async def list_tasks():
|
| 102 |
-
"""Return graded tasks
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
-
return graded_tasks # {"easy": [tasks], "medium": [tasks], "hard": [tasks]}
|
| 108 |
|
| 109 |
|
| 110 |
@app.get("/")
|
|
|
|
| 6 |
|
| 7 |
from contextlib import asynccontextmanager
|
| 8 |
from typing import Optional
|
|
|
|
| 9 |
from fastapi import FastAPI, HTTPException
|
| 10 |
from fastapi.middleware.cors import CORSMiddleware
|
| 11 |
from pydantic import BaseModel
|
| 12 |
+
from openenv.core.env_server import Environment
|
| 13 |
from sql_env import SQLAction, SQLCorrectionEnv
|
| 14 |
from sql_env.tasks import ALL_TASKS
|
| 15 |
|
|
|
|
| 98 |
|
| 99 |
@app.get("/tasks")
|
| 100 |
async def list_tasks():
|
| 101 |
+
"""Return graded tasks in openenv validator format."""
|
| 102 |
+
from sql_env.grader import grade
|
| 103 |
+
return {
|
| 104 |
+
"tasks": [
|
| 105 |
+
{
|
| 106 |
+
"name": "easy",
|
| 107 |
+
"difficulty": "easy",
|
| 108 |
+
"description": "Fix a single syntax error. Error hint provided.",
|
| 109 |
+
"max_steps": 5,
|
| 110 |
+
"has_grader": True,
|
| 111 |
+
"grader": "sql_env.grader.grade",
|
| 112 |
+
"grader_fn": grade.__module__ + "." + grade.__qualname__,
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"name": "medium",
|
| 116 |
+
"difficulty": "medium",
|
| 117 |
+
"description": "Fix multiple errors. No hint.",
|
| 118 |
+
"max_steps": 5,
|
| 119 |
+
"has_grader": True,
|
| 120 |
+
"grader": "sql_env.grader.grade",
|
| 121 |
+
"grader_fn": grade.__module__ + "." + grade.__qualname__,
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"name": "hard",
|
| 125 |
+
"difficulty": "hard",
|
| 126 |
+
"description": "Fix complex multi-join queries. Schema provided.",
|
| 127 |
+
"max_steps": 4,
|
| 128 |
+
"has_grader": True,
|
| 129 |
+
"grader": "sql_env.grader.grade",
|
| 130 |
+
"grader_fn": grade.__module__ + "." + grade.__qualname__,
|
| 131 |
+
},
|
| 132 |
+
]
|
| 133 |
}
|
|
|
|
| 134 |
|
| 135 |
|
| 136 |
@app.get("/")
|