Skip to content

Commit b5b8254

Browse files
Fix loading exp_dir using row_index and add error handling. (#283)
Co-authored-by: Emiliano Penaloza <[email protected]>
1 parent f000d62 commit b5b8254

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/agentlab/analyze/agent_xray.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,16 @@ def update_exp_result(self, episode_id: EpisodeId):
103103

104104
# find unique row using idx
105105
result_df = self.agent_df.reset_index(inplace=False)
106-
exp_dir = result_df.iloc[episode_id.row_index]["exp_dir"]
106+
sub_df = result_df[result_df["_row_index"] == episode_id.row_index]
107+
if len(sub_df) == 0:
108+
self.exp_result = None
109+
raise ValueError(f"Could not find _row_index: {episode_id.row_index}")
110+
111+
if len(sub_df) > 1:
112+
warning(
113+
f"Found multiple rows with same row_index {episode_id.row_index} Using the first one."
114+
)
115+
exp_dir = sub_df.iloc[0]["exp_dir"]
107116
print(exp_dir)
108117
self.exp_result = ExpResult(exp_dir)
109118
self.step = 0

0 commit comments

Comments
 (0)