From 7232b6d1cadda4005ca4f852ae574bb8309e5997 Mon Sep 17 00:00:00 2001 From: MingzheYang Date: Wed, 28 Jan 2026 23:05:48 +0800 Subject: [PATCH] Harden summary_metrics parsing for None rows --- example/summary_metrics.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/example/summary_metrics.py b/example/summary_metrics.py index 1cc5f7b..75d0502 100644 --- a/example/summary_metrics.py +++ b/example/summary_metrics.py @@ -16,14 +16,19 @@ def parse_last_row(history_path: Path): rows = history_path.read_text(encoding="utf-8").strip().splitlines() if len(rows) < 2: return None - last = rows[-1].split(",") - if len(last) < 4: - return None - return { - "avg_ks": float(last[1]), - "avg_jsd": float(last[2]), - "avg_lag1_diff": float(last[3]), - } + for line in reversed(rows[1:]): + parts = line.split(",") + if len(parts) < 4: + continue + try: + return { + "avg_ks": float(parts[1]), + "avg_jsd": float(parts[2]), + "avg_lag1_diff": float(parts[3]), + } + except Exception: + continue + return None def main():