Mist-ic commited on
Commit
14cf714
·
1 Parent(s): a843678

Fix /reset to accept empty/null body for hackathon validator

Browse files

Validator sends POST /reset with no body or null body. Changed from
typed ResetRequest parameter to raw Request parsing, so any body
(empty, null, {}, or full JSON) works and defaults to task_id=easy.

Files changed (1) hide show
  1. server/app.py +16 -6
server/app.py CHANGED
@@ -15,7 +15,7 @@ from __future__ import annotations
15
 
16
  from typing import Any, Dict, List, Optional
17
 
18
- from fastapi import FastAPI
19
  from openenv.core.env_server import create_app
20
  from openenv.core.env_server.serialization import serialize_observation
21
  from pydantic import BaseModel
@@ -59,12 +59,22 @@ app.routes[:] = [r for r in app.routes if getattr(r, "path", None) not in _route
59
 
60
 
61
  @app.post("/reset")
62
- async def reset_env(request: ResetRequest) -> Dict[str, Any]:
63
- """Reset the environment and return initial observation."""
 
 
 
 
 
 
 
 
 
 
64
  obs = _env.reset(
65
- seed=request.seed,
66
- episode_id=request.episode_id,
67
- task_id=request.task_id,
68
  )
69
  return serialize_observation(obs)
70
 
 
15
 
16
  from typing import Any, Dict, List, Optional
17
 
18
+ from fastapi import FastAPI, Request
19
  from openenv.core.env_server import create_app
20
  from openenv.core.env_server.serialization import serialize_observation
21
  from pydantic import BaseModel
 
59
 
60
 
61
  @app.post("/reset")
62
+ async def reset_env(raw: Request) -> Dict[str, Any]:
63
+ """Reset the environment and return initial observation.
64
+
65
+ Accepts any body: {}, null, missing, or {"task_id": "hard", "seed": 42}.
66
+ """
67
+ try:
68
+ body = await raw.json()
69
+ except Exception:
70
+ body = {}
71
+ if not isinstance(body, dict):
72
+ body = {}
73
+ req = ResetRequest(**{k: v for k, v in body.items() if k in ResetRequest.model_fields})
74
  obs = _env.reset(
75
+ seed=req.seed,
76
+ episode_id=req.episode_id,
77
+ task_id=req.task_id,
78
  )
79
  return serialize_observation(obs)
80