Spaces:
Sleeping
Sleeping
Commit ·
88c262b
1
Parent(s): 6d75c2b
debugged the task validation error
Browse files- app/__pycache__/grader.cpython-313.pyc +0 -0
- app/__pycache__/main.cpython-313.pyc +0 -0
- app/grader.py +4 -1
- app/main.py +1 -0
- openenv.yaml +12 -0
- validate_submission.py +32 -4
app/__pycache__/grader.cpython-313.pyc
CHANGED
|
Binary files a/app/__pycache__/grader.cpython-313.pyc and b/app/__pycache__/grader.cpython-313.pyc differ
|
|
|
app/__pycache__/main.cpython-313.pyc
CHANGED
|
Binary files a/app/__pycache__/main.cpython-313.pyc and b/app/__pycache__/main.cpython-313.pyc differ
|
|
|
app/grader.py
CHANGED
|
@@ -62,6 +62,9 @@ def grade_review(task: TaskDefinition, review: str) -> GradeResult:
|
|
| 62 |
raw_score = coverage_score - total_penalty
|
| 63 |
# Keep scores strictly within (0, 1) for evaluator compatibility.
|
| 64 |
final_score = max(_MIN_SCORE, min(_MAX_SCORE, raw_score))
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
rationale = (
|
| 67 |
f"Coverage={coverage_score:.2f}; Penalty={total_penalty:.2f}; "
|
|
@@ -69,7 +72,7 @@ def grade_review(task: TaskDefinition, review: str) -> GradeResult:
|
|
| 69 |
)
|
| 70 |
|
| 71 |
return GradeResult(
|
| 72 |
-
score=
|
| 73 |
matched_criteria=matched_criteria,
|
| 74 |
missed_criteria=missed_criteria,
|
| 75 |
penalties=penalties,
|
|
|
|
| 62 |
raw_score = coverage_score - total_penalty
|
| 63 |
# Keep scores strictly within (0, 1) for evaluator compatibility.
|
| 64 |
final_score = max(_MIN_SCORE, min(_MAX_SCORE, raw_score))
|
| 65 |
+
rounded = round(final_score, 4)
|
| 66 |
+
# Guard float edge cases so reward never equals exactly 0.0 or 1.0 after rounding.
|
| 67 |
+
score = max(_MIN_SCORE, min(_MAX_SCORE, rounded))
|
| 68 |
|
| 69 |
rationale = (
|
| 70 |
f"Coverage={coverage_score:.2f}; Penalty={total_penalty:.2f}; "
|
|
|
|
| 72 |
)
|
| 73 |
|
| 74 |
return GradeResult(
|
| 75 |
+
score=score,
|
| 76 |
matched_criteria=matched_criteria,
|
| 77 |
missed_criteria=missed_criteria,
|
| 78 |
penalties=penalties,
|
app/main.py
CHANGED
|
@@ -52,6 +52,7 @@ def metadata() -> dict[str, Any]:
|
|
| 52 |
"task_id": task.id,
|
| 53 |
"task_type": task.task_type,
|
| 54 |
"has_grader": True,
|
|
|
|
| 55 |
"criteria_count": len(task.criteria),
|
| 56 |
}
|
| 57 |
for task in TASKS.values()
|
|
|
|
| 52 |
"task_id": task.id,
|
| 53 |
"task_type": task.task_type,
|
| 54 |
"has_grader": True,
|
| 55 |
+
"grader_enabled": True,
|
| 56 |
"criteria_count": len(task.criteria),
|
| 57 |
}
|
| 58 |
for task in TASKS.values()
|
openenv.yaml
CHANGED
|
@@ -29,6 +29,18 @@ tasks:
|
|
| 29 |
grader: true
|
| 30 |
score_range: [0.01, 0.99]
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
grading:
|
| 33 |
type: automated
|
| 34 |
deterministic: true
|
|
|
|
| 29 |
grader: true
|
| 30 |
score_range: [0.01, 0.99]
|
| 31 |
|
| 32 |
+
# Top-level graders (some validators scan for this key and `task:` aliases).
|
| 33 |
+
graders:
|
| 34 |
+
- task: easy
|
| 35 |
+
enabled: true
|
| 36 |
+
type: deterministic
|
| 37 |
+
- task: medium
|
| 38 |
+
enabled: true
|
| 39 |
+
type: deterministic
|
| 40 |
+
- task: hard
|
| 41 |
+
enabled: true
|
| 42 |
+
type: deterministic
|
| 43 |
+
|
| 44 |
grading:
|
| 45 |
type: automated
|
| 46 |
deterministic: true
|
validate_submission.py
CHANGED
|
@@ -37,19 +37,38 @@ def _check_openenv_yaml(path: Path) -> None:
|
|
| 37 |
1 for t in tasks if isinstance(t, dict) and t.get("grader") is True
|
| 38 |
)
|
| 39 |
grading = data.get("grading")
|
| 40 |
-
|
| 41 |
if isinstance(grading, dict):
|
| 42 |
g = grading.get("graders")
|
| 43 |
if isinstance(g, list):
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
raise AssertionError(
|
| 48 |
"openenv.yaml must declare graders for at least 3 tasks "
|
| 49 |
-
"(each task: grader: true, and/or grading.graders
|
| 50 |
)
|
| 51 |
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
def _check_api_contracts() -> None:
|
| 54 |
client = TestClient(app)
|
| 55 |
|
|
@@ -141,11 +160,20 @@ def _run_inference_dry_run(root: Path) -> None:
|
|
| 141 |
assert sum(1 for line in lines if line.startswith("[STEP]")) >= 3, "Expected >=3 [STEP] logs"
|
| 142 |
assert any(line.startswith("[END]") for line in lines), "Missing [END] log"
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
def main() -> None:
|
| 146 |
root = Path(__file__).resolve().parent
|
| 147 |
|
| 148 |
_check_openenv_yaml(root / "openenv.yaml")
|
|
|
|
| 149 |
_check_api_contracts()
|
| 150 |
_check_tasks_and_graders()
|
| 151 |
_check_inference_script(root / "inference.py")
|
|
|
|
| 37 |
1 for t in tasks if isinstance(t, dict) and t.get("grader") is True
|
| 38 |
)
|
| 39 |
grading = data.get("grading")
|
| 40 |
+
nested_graders: list = []
|
| 41 |
if isinstance(grading, dict):
|
| 42 |
g = grading.get("graders")
|
| 43 |
if isinstance(g, list):
|
| 44 |
+
nested_graders = g
|
| 45 |
|
| 46 |
+
root_graders = data.get("graders")
|
| 47 |
+
root_graders_len = len(root_graders) if isinstance(root_graders, list) else 0
|
| 48 |
+
|
| 49 |
+
grader_slots = max(tasks_with_grader, len(nested_graders), root_graders_len)
|
| 50 |
+
if grader_slots < 3:
|
| 51 |
raise AssertionError(
|
| 52 |
"openenv.yaml must declare graders for at least 3 tasks "
|
| 53 |
+
"(each task: grader: true, top-level graders:, and/or grading.graders)"
|
| 54 |
)
|
| 55 |
|
| 56 |
|
| 57 |
+
def _check_metadata_graders() -> None:
|
| 58 |
+
client = TestClient(app)
|
| 59 |
+
response = client.get("/metadata")
|
| 60 |
+
assert response.status_code == 200, f"/metadata returned {response.status_code}"
|
| 61 |
+
payload = response.json()
|
| 62 |
+
tasks = payload.get("tasks")
|
| 63 |
+
assert isinstance(tasks, list) and len(tasks) >= 3, "metadata.tasks must list at least 3 tasks"
|
| 64 |
+
graded = sum(
|
| 65 |
+
1
|
| 66 |
+
for t in tasks
|
| 67 |
+
if isinstance(t, dict) and (t.get("has_grader") is True or t.get("grader_enabled") is True)
|
| 68 |
+
)
|
| 69 |
+
assert graded >= 3, "metadata must expose at least 3 tasks with graders enabled"
|
| 70 |
+
|
| 71 |
+
|
| 72 |
def _check_api_contracts() -> None:
|
| 73 |
client = TestClient(app)
|
| 74 |
|
|
|
|
| 160 |
assert sum(1 for line in lines if line.startswith("[STEP]")) >= 3, "Expected >=3 [STEP] logs"
|
| 161 |
assert any(line.startswith("[END]") for line in lines), "Missing [END] log"
|
| 162 |
|
| 163 |
+
for line in lines:
|
| 164 |
+
if not line.startswith("[STEP]"):
|
| 165 |
+
continue
|
| 166 |
+
payload_text = line.split("]", 1)[1].strip()
|
| 167 |
+
step_payload = json.loads(payload_text)
|
| 168 |
+
score = float(step_payload["score"])
|
| 169 |
+
assert 0.0 < score < 1.0, f"inference STEP score must be strictly in (0, 1), got {score}"
|
| 170 |
+
|
| 171 |
|
| 172 |
def main() -> None:
|
| 173 |
root = Path(__file__).resolve().parent
|
| 174 |
|
| 175 |
_check_openenv_yaml(root / "openenv.yaml")
|
| 176 |
+
_check_metadata_graders()
|
| 177 |
_check_api_contracts()
|
| 178 |
_check_tasks_and_graders()
|
| 179 |
_check_inference_script(root / "inference.py")
|