Spaces:
Paused
Paused
Commit ·
3130e63
1
Parent(s): 2530f40
Fix: return grader catalog (200) on cold GET /grader instead of 400 error
Browse files- server/app.py +29 -4
server/app.py
CHANGED
|
@@ -267,14 +267,39 @@ async def tasks():
|
|
| 267 |
async def grader():
|
| 268 |
"""
|
| 269 |
Grade the episode using all actions taken since the last /reset.
|
|
|
|
|
|
|
| 270 |
"""
|
| 271 |
async with _state_lock:
|
| 272 |
sess = _current_session()
|
| 273 |
if not sess["actions"]:
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
result = grade_episode(sess["actions"], sess["tasks"], sess["confs"])
|
| 279 |
return {
|
| 280 |
"total_reward": result.total_reward,
|
|
|
|
| 267 |
async def grader():
|
| 268 |
"""
|
| 269 |
Grade the episode using all actions taken since the last /reset.
|
| 270 |
+
When called with no prior actions (e.g. by platform validators), returns
|
| 271 |
+
the grader catalog — one entry per task — with normalised_score=0.0.
|
| 272 |
"""
|
| 273 |
async with _state_lock:
|
| 274 |
sess = _current_session()
|
| 275 |
if not sess["actions"]:
|
| 276 |
+
# Return grader catalog so platform validators can confirm graders exist
|
| 277 |
+
per_task_catalog = [
|
| 278 |
+
{
|
| 279 |
+
"task_id": t.task_id,
|
| 280 |
+
"difficulty": t.difficulty,
|
| 281 |
+
"grader": {
|
| 282 |
+
"type": "action_match",
|
| 283 |
+
"correct_action": t.correct_action,
|
| 284 |
+
"partial_credit": dict(getattr(t, "partial_credit_actions", {})),
|
| 285 |
+
"requires_investigation": list(getattr(t, "requires_investigation", [])),
|
| 286 |
+
"regulatory_action": getattr(t, "regulatory_action", False),
|
| 287 |
+
"key_flags": list(getattr(t, "key_flags", [])),
|
| 288 |
+
},
|
| 289 |
+
}
|
| 290 |
+
for t in TASKS
|
| 291 |
+
]
|
| 292 |
+
return {
|
| 293 |
+
"total_reward": 0.0,
|
| 294 |
+
"max_possible_reward": 0.0,
|
| 295 |
+
"normalised_score": 0.0,
|
| 296 |
+
"budget_spent": 0.0,
|
| 297 |
+
"budget_overspend": 0.0,
|
| 298 |
+
"budget_penalty": 0.0,
|
| 299 |
+
"passed": False,
|
| 300 |
+
"per_task": per_task_catalog,
|
| 301 |
+
"message": "No episode in progress. Showing grader catalog.",
|
| 302 |
+
}
|
| 303 |
result = grade_episode(sess["actions"], sess["tasks"], sess["confs"])
|
| 304 |
return {
|
| 305 |
"total_reward": result.total_reward,
|