Skip to content

Commit 6d78978

Browse files
shrutipatel31facebook-github-bot
authored andcommitted
Include exception message in ErrorAnalysisCard subtitle (#4982)
Summary: Currently, the subtitle only shows a generic message like "AnalysisNotApplicableStateError encountered while computing ParallelCoordinatesPlot." Show the actual exception message, such as "AnalysisNotApplicableStateError: Experiment has no trials", providing immediate context. The exception message can now be displayed in the ErrorAnalysisCard subtitle, allowing users to immediately see the reasoning (e.g., why an analysis is not applicable). Differential Revision: D94617700
1 parent 3e8e4e7 commit 6d78978

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

ax/analysis/analysis.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,18 @@ def error_card_from_analysis_e(
206206
analysis_name = analysis_e.analysis.__class__.__name__
207207
exception_name = analysis_e.exception.__class__.__name__
208208

209+
# Include the exception message in the subtitle if available, so users can
210+
# see the reasoning in the error card.
211+
exception_message = str(analysis_e.exception)
212+
if exception_message:
213+
subtitle = f"{exception_name}: {exception_message}"
214+
else:
215+
subtitle = f"{exception_name} encountered while computing {analysis_name}."
216+
209217
return ErrorAnalysisCard(
210218
name=analysis_name,
211219
title=f"{analysis_name} Error",
212-
subtitle=f"{exception_name} encountered while computing {analysis_name}.",
220+
subtitle=subtitle,
213221
df=pd.DataFrame(),
214222
blob=analysis_e.tb_str() or "",
215223
)

ax/api/tests/test_client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from ax.api.protocols.metric import IMetric
2424
from ax.api.protocols.runner import IRunner
2525
from ax.api.types import TParameterization
26-
from ax.core.analysis_card import AnalysisCard
2726
from ax.core.data import Data
2827
from ax.core.experiment import Experiment
2928
from ax.core.map_metric import MapMetric
@@ -1278,14 +1277,13 @@ def test_compute_analyses(self) -> None:
12781277
self.assertEqual(len(cards), 1)
12791278
self.assertEqual(cards[0].name, "ParallelCoordinatesPlot")
12801279
self.assertEqual(cards[0].title, "ParallelCoordinatesPlot Error")
1281-
self.assertEqual(
1280+
self.assertIn(
1281+
"AnalysisNotApplicableStateError",
12821282
cards[0].subtitle,
1283-
"AnalysisNotApplicableStateError encountered while computing "
1284-
"ParallelCoordinatesPlot.",
12851283
)
12861284
self.assertIn(
12871285
"Experiment has no trials",
1288-
assert_is_instance(cards[0], AnalysisCard).blob,
1286+
cards[0].subtitle,
12891287
)
12901288

12911289
for trial_index, _ in client.get_next_trials(max_trials=1).items():

0 commit comments

Comments
 (0)