From 9cb0bf2e359235a79f0079094a5717d0ec067455 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 13 Oct 2026 11:28:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(bioflow):=20stage=5Fdone=20=E6=91=98?= =?UTF-8?q?=E8=A6=81=E4=BB=8E=20manifest.metrics=20=E6=8F=90=E5=8F=96?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E6=8C=87=E6=A0=87(=E5=91=BD=E4=B8=AD/?= =?UTF-8?q?=E6=AF=94=E5=AF=B9=E7=8E=87=E7=AD=89)=20(#010)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/bioflow/runner.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/bioflow_service/app/services/bioflow/runner.py b/bioflow_service/app/services/bioflow/runner.py index 4553a11..1de5e30 100644 --- a/bioflow_service/app/services/bioflow/runner.py +++ b/bioflow_service/app/services/bioflow/runner.py @@ -617,6 +617,30 @@ def parse_progress_marker(line: str) -> dict[str, Any] | None: return None +_METRIC_LABELS = { + "hits": "命中", "hit_count": "命中", "mapping_rate": "比对率", + "aligned": "比对", "mapped": "比对", "identified": "鉴定", + "members": "成员", "de_genes": "差异基因", "up": "上调", "down": "下调", + "enriched": "富集", "count": "数量", "total": "总数", + "records": "记录", "sequences": "序列", +} + + +def _metrics_summary(stage: str, metrics: dict) -> str: + """阶段完成摘要(G 关键指标自然语言转述);无指标时退化为「阶段已完成」。""" + if not isinstance(metrics, dict) or not metrics: + return f"阶段 {stage} 已完成" + parts = [] + for k, v in metrics.items(): + if not isinstance(v, (int, float, str, bool)): + continue + label = _METRIC_LABELS.get(str(k), str(k)) + parts.append(f"{label} {v}") + if parts: + return f"阶段 {stage} 完成:{','.join(parts)}" + return f"阶段 {stage} 已完成" + + @dataclass class JobRecord: """任务内存记录(DB 行 + 派生路径)。""" @@ -1071,7 +1095,7 @@ class Runner: "job_id": record.id, "stage": stage, "exit_code": exit_code, "manifest_ref": manifest.path, "metrics": manifest.metrics, - "summary": f"阶段 {stage} 已完成", + "summary": _metrics_summary(stage, manifest.metrics), }) return "done"