chore: lint and format per-category pool strategy implementation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,9 +7,10 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
from collections import Counter
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
from app.harness.pools import (
|
||||
PerCategoryPoolStrategy,
|
||||
@@ -22,10 +23,14 @@ from core.types import GeneratedQuestion, PoolConfig
|
||||
def _make_question(qid: str, task_type: str) -> GeneratedQuestion:
|
||||
"""构造测试用 GeneratedQuestion。"""
|
||||
return GeneratedQuestion(
|
||||
question_id=qid, video_id="v1", task_type=task_type,
|
||||
question_id=qid,
|
||||
video_id="v1",
|
||||
task_type=task_type,
|
||||
question=f"Q {qid}?",
|
||||
options=("A. a", "B. b", "C. c", "D. d"),
|
||||
answer="A", source_nodes=("n1",), difficulty="medium",
|
||||
answer="A",
|
||||
source_nodes=("n1",),
|
||||
difficulty="medium",
|
||||
)
|
||||
|
||||
|
||||
@@ -35,10 +40,18 @@ class TestPerCategoryE2E:
|
||||
def test_full_flow(self, tmp_path: Path) -> None:
|
||||
"""完整流程:12 类各 30 题 → 策略构建 → 冻结 → 加载 → 三池校验。"""
|
||||
task_types = [
|
||||
"Action Prediction", "Action Reasoning", "Action Recognition",
|
||||
"Action Sequence", "Causal Reasoning", "Event Reasoning",
|
||||
"Object Interaction", "Object Reasoning", "Object Recognition",
|
||||
"Scene Understanding", "Spatial Reasoning", "Temporal Reasoning",
|
||||
"Action Prediction",
|
||||
"Action Reasoning",
|
||||
"Action Recognition",
|
||||
"Action Sequence",
|
||||
"Causal Reasoning",
|
||||
"Event Reasoning",
|
||||
"Object Interaction",
|
||||
"Object Reasoning",
|
||||
"Object Recognition",
|
||||
"Scene Understanding",
|
||||
"Spatial Reasoning",
|
||||
"Temporal Reasoning",
|
||||
]
|
||||
questions = []
|
||||
for tt in task_types:
|
||||
@@ -52,11 +65,17 @@ class TestPerCategoryE2E:
|
||||
correctness[q.question_id] = idx < 18
|
||||
|
||||
config = PoolConfig(
|
||||
task_types=None, seed=42, baseline_run_id="baseline_v2",
|
||||
diag_size=0, diag_correct_ratio=0.0,
|
||||
val_size=0, val_correct_ratio=0.0,
|
||||
test_size=0, eval_min_per_class=0,
|
||||
train_ratio=20 / 30, test_questions_dir=None,
|
||||
task_types=None,
|
||||
seed=42,
|
||||
baseline_run_id="baseline_v2",
|
||||
diag_size=0,
|
||||
diag_correct_ratio=0.0,
|
||||
val_size=0,
|
||||
val_correct_ratio=0.0,
|
||||
test_size=0,
|
||||
eval_min_per_class=0,
|
||||
train_ratio=20 / 30,
|
||||
test_questions_dir=None,
|
||||
)
|
||||
|
||||
strategy = PerCategoryPoolStrategy()
|
||||
@@ -107,11 +126,17 @@ class TestPerCategoryE2E:
|
||||
correctness = {q.question_id: (i < 20) for i, q in enumerate(questions)}
|
||||
|
||||
config = PoolConfig(
|
||||
task_types=("Object Recognition",), seed=42, baseline_run_id="bl",
|
||||
diag_size=0, diag_correct_ratio=0.0,
|
||||
val_size=0, val_correct_ratio=0.0,
|
||||
test_size=0, eval_min_per_class=0,
|
||||
train_ratio=20 / 30, test_questions_dir=None,
|
||||
task_types=("Object Recognition",),
|
||||
seed=42,
|
||||
baseline_run_id="bl",
|
||||
diag_size=0,
|
||||
diag_correct_ratio=0.0,
|
||||
val_size=0,
|
||||
val_correct_ratio=0.0,
|
||||
test_size=0,
|
||||
eval_min_per_class=0,
|
||||
train_ratio=20 / 30,
|
||||
test_questions_dir=None,
|
||||
)
|
||||
|
||||
strategy = PerCategoryPoolStrategy()
|
||||
|
||||
Reference in New Issue
Block a user