feat: add selector_scores observation column to question_gen_items
This commit is contained in:
@@ -125,6 +125,7 @@ CREATE TABLE IF NOT EXISTS question_gen_items (
|
||||
gate_reject_reason TEXT,
|
||||
final_status TEXT NOT NULL DEFAULT 'pending',
|
||||
difficulty_steps INTEGER,
|
||||
selector_scores TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
"""
|
||||
@@ -177,11 +178,14 @@ class QuestionGenStore:
|
||||
self._conn.execute(idx_sql)
|
||||
self._conn.commit()
|
||||
|
||||
# 幂等迁移:为已有表加 sub_pattern 列
|
||||
# 幂等迁移:为已有表加 sub_pattern / selector_scores 列
|
||||
cols = {r[1] for r in self._conn.execute("PRAGMA table_info(question_gen_items)")}
|
||||
if "sub_pattern" not in cols:
|
||||
self._conn.execute("ALTER TABLE question_gen_items ADD COLUMN sub_pattern TEXT")
|
||||
self._conn.commit()
|
||||
if "selector_scores" not in cols:
|
||||
self._conn.execute("ALTER TABLE question_gen_items ADD COLUMN selector_scores TEXT")
|
||||
self._conn.commit()
|
||||
|
||||
def record_run_start(self, run_id: str, git_sha: str, config_snapshot: str) -> None:
|
||||
"""记录批次开始。
|
||||
@@ -378,6 +382,29 @@ class QuestionGenStore:
|
||||
if cursor.rowcount == 0:
|
||||
raise ValueError(f"item_id 不存在: {item_id}")
|
||||
|
||||
def update_selector_scores(self, item_id: str, selector_scores_json: str) -> None:
|
||||
"""写入 grounded selector 打分观测(JSON 字符串)。
|
||||
|
||||
Parameters
|
||||
----------
|
||||
item_id : str
|
||||
题目唯一 ID。
|
||||
selector_scores_json : str
|
||||
观测 JSON:correct_score / chosen / pool_size / anneal_rounds / hard_fail。
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
item_id 不存在时抛出。
|
||||
"""
|
||||
cursor = self._conn.execute(
|
||||
"UPDATE question_gen_items SET selector_scores=? WHERE item_id=?",
|
||||
(selector_scores_json, item_id),
|
||||
)
|
||||
self._conn.commit()
|
||||
if cursor.rowcount == 0:
|
||||
raise ValueError(f"item_id 不存在: {item_id}")
|
||||
|
||||
def get_run_stats(self, run_id: str) -> RunStats:
|
||||
"""查询批次统计摘要。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user