Skip to content

Commit a16aea0

Browse files
committed
add error report, add cum cost to summary and ray backend by default
1 parent 2b4775b commit a16aea0

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

src/agentlab/analyze/agent_xray.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ def filter_agent_id(self, agent_id: list[tuple]):
142142
max-height: 400px;
143143
overflow-y: auto;
144144
}
145+
.error-report {
146+
max-height: 700px;
147+
overflow-y: auto;
148+
}
145149
.my-code-view {
146150
max-height: 300px;
147151
overflow-y: auto;
@@ -284,6 +288,8 @@ def run_gradio(results_dir: Path):
284288
with gr.Tab("Global Stats"):
285289
global_stats = gr.DataFrame(max_height=500, show_label=False, interactive=False)
286290

291+
with gr.Tab("Error Report"):
292+
error_report = gr.Markdown(elem_classes="error-report", show_copy_button=True)
287293
with gr.Row():
288294
episode_info = gr.Markdown(label="Episode Info", elem_classes="my-markdown")
289295
action_info = gr.Markdown(label="Action Info", elem_classes="my-markdown")
@@ -411,7 +417,7 @@ def run_gradio(results_dir: Path):
411417
exp_dir_choice.change(
412418
fn=new_exp_dir,
413419
inputs=exp_dir_choice,
414-
outputs=[agent_table, agent_id, constants, variables, global_stats],
420+
outputs=[agent_table, agent_id, constants, variables, global_stats, error_report],
415421
)
416422

417423
agent_table.select(fn=on_select_agent, inputs=agent_table, outputs=[agent_id])
@@ -918,19 +924,24 @@ def get_agent_report(result_df: pd.DataFrame):
918924

919925

920926
def update_global_stats():
921-
global info
922927
stats = inspect_results.global_report(info.result_df, reduce_fn=inspect_results.summarize_stats)
923928
stats.reset_index(inplace=True)
924929
return stats
925930

926931

932+
def update_error_report():
933+
report_files = list(info.exp_list_dir.glob("error_report*.md"))
934+
if len(report_files) == 0:
935+
return "No error report found"
936+
report_files = sorted(report_files, key=os.path.getctime, reverse=True)
937+
return report_files[0].read_text()
938+
927939
def new_exp_dir(exp_dir, progress=gr.Progress(), just_refresh=False):
928940

929941
if exp_dir == select_dir_instructions:
930942
return None, None
931943

932944
exp_dir = exp_dir.split(" - ")[0]
933-
global info
934945

935946
if len(exp_dir) == 0:
936947
info.exp_list_dir = None
@@ -951,7 +962,7 @@ def new_exp_dir(exp_dir, progress=gr.Progress(), just_refresh=False):
951962
agent_id = info.get_agent_id(agent_report.iloc[0])
952963

953964
constants, variables = format_constant_and_variables()
954-
return agent_report, agent_id, constants, variables, update_global_stats()
965+
return agent_report, agent_id, constants, variables, update_global_stats(), update_error_report()
955966

956967

957968
def new_agent_id(agent_id: list[tuple]):

src/agentlab/analyze/inspect_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def summarize(sub_df, use_bootstrap=False):
297297
n_err=err.sum(skipna=True),
298298
)
299299
if "stats.cum_cost" in sub_df:
300-
record["cum_cost"] = (sub_df["stats.cum_cost"].sum(skipna=True).round(4),)
300+
record["cum_cost"] = sub_df["stats.cum_cost"].sum(skipna=True).round(4)
301301

302302
return pd.Series(record)
303303

src/agentlab/experiments/launch_exp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def run_experiments(
4040
study_dir = Path(study_dir)
4141
study_dir.mkdir(parents=True, exist_ok=True)
4242

43-
if n_jobs == 1 and parallel_backend != "sequential":
44-
logging.warning("Only 1 job, switching to sequential backend.")
45-
parallel_backend = "sequential"
43+
# if n_jobs == 1 and parallel_backend != "sequential":
44+
# logging.warning("Only 1 job, switching to sequential backend.")
45+
# parallel_backend = "sequential"
4646

4747
logging.info(f"Saving experiments to {study_dir}")
4848
for exp_args in exp_args_list:

src/agentlab/experiments/study.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def set_reproducibility_info(self, strict_reproducibility=False, comment=None):
123123
def run(
124124
self,
125125
n_jobs=1,
126-
parallel_backend="joblib",
126+
parallel_backend="ray",
127127
strict_reproducibility=False,
128128
n_relaunch=3,
129129
relaunch_errors=True,

0 commit comments

Comments
 (0)