Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- graders.py +57 -0
- openenv.yaml +10 -0
graders.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Root-level grader entry points for OpenEnv judge.
|
| 2 |
+
|
| 3 |
+
Each function receives the episode trajectory and returns a float in [0.0, 1.0].
|
| 4 |
+
These are referenced in openenv.yaml and must be importable from the repo root.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
from typing import Any, Dict, List
|
| 10 |
+
|
| 11 |
+
from server.graders import SchedulingGrader
|
| 12 |
+
from server.scheduling_env_environment import SchedulingEnvironment
|
| 13 |
+
|
| 14 |
+
_grader = SchedulingGrader()
|
| 15 |
+
_env = SchedulingEnvironment()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _grade_task(task_id: str, trajectory: Any = None) -> float:
|
| 19 |
+
"""Run a task with the environment's own state and grade it.
|
| 20 |
+
|
| 21 |
+
If a trajectory dict is provided with 'final_state' and 'final_observation',
|
| 22 |
+
those are used directly. Otherwise the grader returns 0.0.
|
| 23 |
+
"""
|
| 24 |
+
if trajectory is not None:
|
| 25 |
+
final_state = trajectory.get("final_state")
|
| 26 |
+
final_obs = trajectory.get("final_observation")
|
| 27 |
+
if final_state and final_obs:
|
| 28 |
+
return _grader.grade_episode(final_state, final_obs)
|
| 29 |
+
|
| 30 |
+
# Fallback: use the environment's current state
|
| 31 |
+
state = _env.state
|
| 32 |
+
if state.completed:
|
| 33 |
+
from models import SchedulingObservation
|
| 34 |
+
|
| 35 |
+
obs = SchedulingObservation(
|
| 36 |
+
success=True,
|
| 37 |
+
done=True,
|
| 38 |
+
reward=state.final_reward,
|
| 39 |
+
)
|
| 40 |
+
return _grader.grade_episode(state, obs)
|
| 41 |
+
|
| 42 |
+
return 0.0
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def task1_easy_grader(trajectory: Any = None) -> float:
|
| 46 |
+
"""Grader for task1_easy: 2 attendees, free slot exists. Expected: 0.8-1.0."""
|
| 47 |
+
return _grade_task("task1_easy", trajectory)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def task2_medium_grader(trajectory: Any = None) -> float:
|
| 51 |
+
"""Grader for task2_medium: 4 attendees, requires rescheduling. Expected: 0.5-0.8."""
|
| 52 |
+
return _grade_task("task2_medium", trajectory)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def task3_hard_grader(trajectory: Any = None) -> float:
|
| 56 |
+
"""Grader for task3_hard: 6 attendees, cascading conflicts. Expected: 0.2-0.6."""
|
| 57 |
+
return _grade_task("task3_hard", trajectory)
|
openenv.yaml
CHANGED
|
@@ -5,3 +5,13 @@ runtime: fastapi
|
|
| 5 |
app: server.app:app
|
| 6 |
port: 8000
|
| 7 |
description: "Intelligent Meeting Scheduling - Learn optimal scheduling through multi-stakeholder preference optimization"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
app: server.app:app
|
| 6 |
port: 8000
|
| 7 |
description: "Intelligent Meeting Scheduling - Learn optimal scheduling through multi-stakeholder preference optimization"
|
| 8 |
+
tasks:
|
| 9 |
+
- id: task1_easy
|
| 10 |
+
difficulty: easy
|
| 11 |
+
grader: graders.task1_easy_grader
|
| 12 |
+
- id: task2_medium
|
| 13 |
+
difficulty: medium
|
| 14 |
+
grader: graders.task2_medium_grader
|
| 15 |
+
- id: task3_hard
|
| 16 |
+
difficulty: hard
|
| 17 |
+
grader: graders.task3_hard_grader
|