Harden summary_metrics parsing for None rows
This commit is contained in:
@@ -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
|
||||
for line in reversed(rows[1:]):
|
||||
parts = line.split(",")
|
||||
if len(parts) < 4:
|
||||
continue
|
||||
try:
|
||||
return {
|
||||
"avg_ks": float(last[1]),
|
||||
"avg_jsd": float(last[2]),
|
||||
"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():
|
||||
|
||||
Reference in New Issue
Block a user