chore: snapshot in-progress question-gen work before preflight fixes

This commit is contained in:
2026-07-16 04:12:21 -04:00
parent 11a5545f57
commit a4c429b247
39 changed files with 738 additions and 283 deletions
+10 -15
View File
@@ -124,19 +124,6 @@ def stratified_sample(
return flatten_units(sampled)
def _unit_correct(unit: QuestionUnit, correctness: dict[str, bool]) -> bool:
"""单元级正确性:成员全部答对才算对(缺失按 False,宽松口径)。
参数:
unit: 目标单元(single 1 题,pair 2 题)。
correctness: question_id -> 基线是否答对。
返回:
pair 走双向 AND、single 即单题正确性;任一成员缺失或答错即 False。
"""
return all(correctness.get(q.question_id, False) for q in unit.questions)
def _ratio_stratified_sample(
pool: list[QuestionUnit],
correctness: dict[str, bool],
@@ -158,9 +145,17 @@ def _ratio_stratified_sample(
异常:
ValueError: 对单元或错单元层不足。
关键实现:
unit_correctness 采用函数内延迟导入:loader 属 question_gen
question_units 属 harness,模块级导入将触发循环依赖(沿用 build_units /
flatten_units 的既有做法)。以 strict=False 保持"缺基线对错即视为未答对"
原 loose 语义不变。
"""
correct = [u for u in pool if _unit_correct(u, correctness)]
wrong = [u for u in pool if not _unit_correct(u, correctness)]
from app.harness.question_units import unit_correctness
correct = [u for u in pool if unit_correctness(u, correctness, strict=False)]
wrong = [u for u in pool if not unit_correctness(u, correctness, strict=False)]
n_correct = round(size * correct_ratio)
n_wrong = size - n_correct
if len(correct) < n_correct or len(wrong) < n_wrong: