fix: restore sub_pattern when loading benchmark JSON
This commit is contained in:
@@ -51,6 +51,7 @@ def load_benchmark(questions_dir: Path) -> list[GeneratedQuestion]:
|
|||||||
family=qa.get("family"),
|
family=qa.get("family"),
|
||||||
skill_target=qa.get("skill_target"),
|
skill_target=qa.get("skill_target"),
|
||||||
difficulty_steps=qa.get("difficulty_steps"),
|
difficulty_steps=qa.get("difficulty_steps"),
|
||||||
|
sub_pattern=qa.get("sub_pattern"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -90,3 +90,33 @@ def test_append_to_json_writes_sub_pattern(tmp_path):
|
|||||||
|
|
||||||
data = json.loads((tmp_path / "v1.json").read_text(encoding="utf-8"))
|
data = json.loads((tmp_path / "v1.json").read_text(encoding="utf-8"))
|
||||||
assert data[0]["sub_pattern"] == "temporal_reasoning_failure"
|
assert data[0]["sub_pattern"] == "temporal_reasoning_failure"
|
||||||
|
|
||||||
|
|
||||||
|
def test_load_benchmark_restores_sub_pattern(tmp_path):
|
||||||
|
from app.question_gen.loader import load_benchmark
|
||||||
|
import json
|
||||||
|
entry = {
|
||||||
|
"question_id": "v1_Action Recognition_0001", "video_id": "v1",
|
||||||
|
"task_type": "Action Recognition", "question": "?",
|
||||||
|
"options": ["A. 蒸", "B. 炒", "C. 煮", "D. 炸"], "answer": "A",
|
||||||
|
"source_nodes": ["n1"], "difficulty": "hard",
|
||||||
|
"family": "ACTION_RECOGNITION", "skill_target": "M1_AR",
|
||||||
|
"sub_pattern": "temporal_reasoning_failure",
|
||||||
|
}
|
||||||
|
(tmp_path / "v1.json").write_text(json.dumps([entry]), encoding="utf-8")
|
||||||
|
loaded = load_benchmark(tmp_path)
|
||||||
|
assert loaded[0].sub_pattern == "temporal_reasoning_failure"
|
||||||
|
|
||||||
|
|
||||||
|
def test_load_benchmark_sub_pattern_defaults_none_when_absent(tmp_path):
|
||||||
|
from app.question_gen.loader import load_benchmark
|
||||||
|
import json
|
||||||
|
entry = {
|
||||||
|
"question_id": "v1_Object Recognition_0001", "video_id": "v1",
|
||||||
|
"task_type": "Object Recognition", "question": "?",
|
||||||
|
"options": ["A. a", "B. b", "C. c", "D. d"], "answer": "A",
|
||||||
|
"source_nodes": ["n1"], "difficulty": "medium",
|
||||||
|
}
|
||||||
|
(tmp_path / "v1.json").write_text(json.dumps([entry]), encoding="utf-8")
|
||||||
|
loaded = load_benchmark(tmp_path)
|
||||||
|
assert loaded[0].sub_pattern is None
|
||||||
|
|||||||
Reference in New Issue
Block a user