Harden summary_metrics parsing for None rows

This commit is contained in:
2026-01-28 23:05:48 +08:00
parent f6be8a6ecb
commit 7232b6d1ca

View File

@@ -16,14 +16,19 @@ def parse_last_row(history_path: Path):
rows = history_path.read_text(encoding="utf-8").strip().splitlines() rows = history_path.read_text(encoding="utf-8").strip().splitlines()
if len(rows) < 2: if len(rows) < 2:
return None return None
last = rows[-1].split(",") for line in reversed(rows[1:]):
if len(last) < 4: parts = line.split(",")
return None if len(parts) < 4:
return { continue
"avg_ks": float(last[1]), try:
"avg_jsd": float(last[2]), return {
"avg_lag1_diff": float(last[3]), "avg_ks": float(parts[1]),
} "avg_jsd": float(parts[2]),
"avg_lag1_diff": float(parts[3]),
}
except Exception:
continue
return None
def main(): def main():