Skip to content

Commit 1f83b1c

Browse files
committed
Improve error handling and calculation in global stats and summarization functions
1 parent c5ea716 commit 1f83b1c

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/agentlab/analyze/agent_xray.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,16 @@ def get_agent_report(result_df: pd.DataFrame):
10011001

10021002

10031003
def update_global_stats():
1004-
stats = inspect_results.global_report(info.result_df, reduce_fn=inspect_results.summarize_stats)
1005-
stats.reset_index(inplace=True)
1006-
return stats
1004+
try:
1005+
stats = inspect_results.global_report(
1006+
info.result_df, reduce_fn=inspect_results.summarize_stats
1007+
)
1008+
stats.reset_index(inplace=True)
1009+
return stats
1010+
1011+
except Exception as e:
1012+
warning(f"Error while updating global stats: {e}")
1013+
return None
10071014

10081015

10091016
def update_error_report():

src/agentlab/analyze/inspect_results.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ def summarize(sub_df):
251251
)
252252
else:
253253
err = sub_df["err_msg"].notnull()
254-
n_completed = (err | sub_df["truncated"] | sub_df["terminated"]).sum()
254+
n_completed = err.copy()
255+
for col in ["truncated", "terminated"]:
256+
if col in sub_df:
257+
n_completed = n_completed | sub_df[col]
258+
n_completed = n_completed.sum()
255259

256260
if n_completed == 0:
257261
return None
@@ -280,7 +284,12 @@ def summarize_stats(sub_df):
280284

281285
# make sure there are completed runs
282286
err = sub_df["err_msg"].notnull()
283-
n_completed = (err | sub_df["truncated"] | sub_df["terminated"]).sum()
287+
n_completed = err.copy()
288+
for col in ["truncated", "terminated"]:
289+
if col in sub_df:
290+
n_completed = n_completed | sub_df[col]
291+
n_completed = n_completed.sum()
292+
284293
if n_completed == 0:
285294
return None
286295

0 commit comments

Comments
 (0)