Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- env/tasks.py +29 -4
- tasks.py +1 -2
env/tasks.py
CHANGED
|
@@ -219,7 +219,7 @@ class TaskSpec:
|
|
| 219 |
return copy.deepcopy(self.schema)
|
| 220 |
|
| 221 |
|
| 222 |
-
|
| 223 |
"easy": TaskSpec(
|
| 224 |
name="easy",
|
| 225 |
difficulty="easy",
|
|
@@ -358,10 +358,10 @@ TASKS: Dict[str, TaskSpec] = {
|
|
| 358 |
|
| 359 |
def get_task(task_name: str) -> TaskSpec:
|
| 360 |
normalized = _normalize_text(task_name)
|
| 361 |
-
if normalized not in
|
| 362 |
-
valid = ", ".join(sorted(
|
| 363 |
raise ValueError(f"unknown task '{task_name}'. expected one of: {valid}")
|
| 364 |
-
return
|
| 365 |
|
| 366 |
|
| 367 |
def task_names() -> List[str]:
|
|
@@ -387,6 +387,31 @@ def hard_grader(candidate: Dict[str, Any]) -> float:
|
|
| 387 |
return score
|
| 388 |
|
| 389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
GRADERS = {
|
| 391 |
"easy": easy_grader,
|
| 392 |
"medium": medium_grader,
|
|
|
|
| 219 |
return copy.deepcopy(self.schema)
|
| 220 |
|
| 221 |
|
| 222 |
+
TASK_SPECS: Dict[str, TaskSpec] = {
|
| 223 |
"easy": TaskSpec(
|
| 224 |
name="easy",
|
| 225 |
difficulty="easy",
|
|
|
|
| 358 |
|
| 359 |
def get_task(task_name: str) -> TaskSpec:
|
| 360 |
normalized = _normalize_text(task_name)
|
| 361 |
+
if normalized not in TASK_SPECS:
|
| 362 |
+
valid = ", ".join(sorted(TASK_SPECS.keys()))
|
| 363 |
raise ValueError(f"unknown task '{task_name}'. expected one of: {valid}")
|
| 364 |
+
return TASK_SPECS[normalized]
|
| 365 |
|
| 366 |
|
| 367 |
def task_names() -> List[str]:
|
|
|
|
| 387 |
return score
|
| 388 |
|
| 389 |
|
| 390 |
+
# Canonical checker-friendly task list with explicit grader functions.
|
| 391 |
+
TASKS = [
|
| 392 |
+
{
|
| 393 |
+
"name": "easy",
|
| 394 |
+
"difficulty": "easy",
|
| 395 |
+
"grader": easy_grader,
|
| 396 |
+
"spec": TASK_SPECS["easy"],
|
| 397 |
+
},
|
| 398 |
+
{
|
| 399 |
+
"name": "medium",
|
| 400 |
+
"difficulty": "medium",
|
| 401 |
+
"grader": medium_grader,
|
| 402 |
+
"spec": TASK_SPECS["medium"],
|
| 403 |
+
},
|
| 404 |
+
{
|
| 405 |
+
"name": "hard",
|
| 406 |
+
"difficulty": "hard",
|
| 407 |
+
"grader": hard_grader,
|
| 408 |
+
"spec": TASK_SPECS["hard"],
|
| 409 |
+
},
|
| 410 |
+
]
|
| 411 |
+
|
| 412 |
+
# Compatibility alias for validators that look for this exact name.
|
| 413 |
+
TASKS_WITH_GRADERS = TASKS
|
| 414 |
+
|
| 415 |
GRADERS = {
|
| 416 |
"easy": easy_grader,
|
| 417 |
"medium": medium_grader,
|
tasks.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
| 2 |
|
| 3 |
from typing import Any, Dict
|
| 4 |
|
| 5 |
-
from env.tasks import GRADERS,
|
| 6 |
|
| 7 |
|
| 8 |
def easy_grader(candidate: Dict[str, Any]) -> float:
|
|
@@ -29,7 +29,6 @@ TASKS_WITH_GRADERS = TASKS
|
|
| 29 |
|
| 30 |
|
| 31 |
__all__ = [
|
| 32 |
-
"TASKS",
|
| 33 |
"TaskSpec",
|
| 34 |
"get_task",
|
| 35 |
"schema_json",
|
|
|
|
| 2 |
|
| 3 |
from typing import Any, Dict
|
| 4 |
|
| 5 |
+
from env.tasks import GRADERS, TASK_SPECS, TaskSpec, get_task, schema_json, task_names
|
| 6 |
|
| 7 |
|
| 8 |
def easy_grader(candidate: Dict[str, Any]) -> float:
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
__all__ = [
|
|
|
|
| 32 |
"TaskSpec",
|
| 33 |
"get_task",
|
| 34 |
"schema_json",
|