Skip to content

Commit 2c0a65a

Browse files
shrutipatel31facebook-github-bot
authored andcommitted
Include exception message in ErrorAnalysisCard subtitle
Summary: The exception message is now displayed in the ErrorAnalysisCard subtitle, allowing users to immediately see the reasoning (e.g., why an analysis is not applicable) without needing to expand the error card. Previously, the subtitle only showed a generic message like "AnalysisNotApplicableStateError encountered while computing ParallelCoordinatesPlot." Now it shows the actual exception message, such as "AnalysisNotApplicableStateError: Experiment has no trials", providing immediate context. Differential Revision: D94617700
1 parent 3df1600 commit 2c0a65a

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

ax/analysis/analysis.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,19 @@ 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 (e.g., why an analysis is not applicable) without
211+
# needing to expand the error card.
212+
exception_message = str(analysis_e.exception)
213+
if exception_message:
214+
subtitle = f"{exception_name}: {exception_message}"
215+
else:
216+
subtitle = f"{exception_name} encountered while computing {analysis_name}."
217+
209218
return ErrorAnalysisCard(
210219
name=analysis_name,
211220
title=f"{analysis_name} Error",
212-
subtitle=f"{exception_name} encountered while computing {analysis_name}.",
221+
subtitle=subtitle,
213222
df=pd.DataFrame(),
214223
blob=analysis_e.tb_str() or "",
215224
)

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)