feat: 手术视频消耗、待确认与持久化改造

- 新增 Alembic 初始迁移、领域明细模型及归档持久化与重试链路\n- 拆分视频会话注册表、分类处理、推理时间窗聚合与流处理\n- 消耗日志:TSV/Markdown 含 top2/top3;item_id 优先产品编码;待确认记「待确认」行,语音确认后落正式行并更新汇总\n- 待确认时内存/DB 明细为占位行,确认后替换;拒绝时移除占位\n- 分类 probs 先 detach/cpu 再转 NumPy,修复 MPS/CUDA 上推理被静默跳过\n- 补充集成测试、归档与设备张量等单测

Made-with: Cursor
This commit is contained in:
Kevin
2026-04-23 20:42:21 +08:00
parent 69980d8073
commit 3d7bd70355
55 changed files with 4544 additions and 2050 deletions

View File

@@ -47,7 +47,7 @@ def test_build_tsv_line_matches_sample_shape(monkeypatch: pytest.MonkeyPatch) ->
wall_end_epoch=w0 + 45.0,
)
parts = line.rstrip("\n").split("\t")
assert len(parts) == 5
assert len(parts) == 9
assert parts[0] == "2237844"
assert parts[1] == "一次性医用灭菌棉签"
assert parts[2] == "1"
@@ -58,6 +58,10 @@ def test_build_tsv_line_matches_sample_shape(monkeypatch: pytest.MonkeyPatch) ->
+ _RANGE_SEP
+ "2024-01-01T00:00:45.000+00:00"
)
assert parts[5] == "cls2"
assert parts[6] == "0.0003"
assert parts[7] == "cls3"
assert parts[8] == "0.0002"
def test_resolve_consumption_item_id_uses_normalized_catalog_key() -> None:
@@ -67,7 +71,17 @@ def test_resolve_consumption_item_id_uses_normalized_catalog_key() -> None:
def test_header_columns() -> None:
cols = HEADER.strip().split("\t")
assert cols == ["item_id", "item_name", "qty", "doctor_id", "timestamp"]
assert cols == [
"item_id",
"item_name",
"qty",
"doctor_id",
"timestamp",
"top2_name",
"top2_conf",
"top3_name",
"top3_conf",
]
def test_per_surgery_file_init_and_append(
@@ -137,8 +151,10 @@ def test_build_consumption_markdown_top123_columns(monkeypatch: pytest.MonkeyPat
wall_end_epoch=w0 + 45.0,
)
assert "| item_id |" in md and "| item_name |" in md and "| qty |" in md
assert "| top2 |" in md and "| top3 |" in md
assert "2237844" in md
assert "一次性医用灭菌棉签" in md
assert "cls2" in md and "cls3" in md
assert "DOCTOR_PLACEHOLDER" in md
assert "| 1 |" in md
# 终端为可读时间戳,非落盘用 ISO@cam