File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+ subtitle = (
212+ f"{ exception_name } : { exception_message } "
213+ if (exception_message := str (analysis_e .exception ))
214+ else f"{ exception_name } encountered while computing { analysis_name } ."
215+ )
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 )
Original file line number Diff line number Diff line change 1+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2+ #
3+ # This source code is licensed under the MIT license found in the
4+ # LICENSE file in the root directory of this source tree.
5+
6+ # pyre-strict
7+
8+ from ax .analysis .analysis import AnalysisE , error_card_from_analysis_e
9+ from ax .analysis .plotly .parallel_coordinates import ParallelCoordinatesPlot
10+ from ax .utils .common .testutils import TestCase
11+
12+
13+ class AnalysisTest (TestCase ):
14+ def test_error_card_from_analysis_e (self ) -> None :
15+ for exception , expected_subtitle in (
16+ (
17+ ValueError ("something went wrong" ),
18+ "ValueError: something went wrong" ,
19+ ),
20+ (
21+ ValueError (),
22+ "ValueError encountered while computing ParallelCoordinatesPlot." ,
23+ ),
24+ ):
25+ with self .subTest (exception = exception ):
26+ analysis_e = AnalysisE (
27+ message = "test" ,
28+ exception = exception ,
29+ analysis = ParallelCoordinatesPlot (),
30+ )
31+
32+ card = error_card_from_analysis_e (analysis_e )
33+
34+ self .assertEqual (card .name , "ParallelCoordinatesPlot" )
35+ self .assertEqual (card .title , "ParallelCoordinatesPlot Error" )
36+ self .assertEqual (card .subtitle , expected_subtitle )
37+ self .assertIn (expected_subtitle , card .blob )
Original file line number Diff line number Diff line change 2323from ax .api .protocols .metric import IMetric
2424from ax .api .protocols .runner import IRunner
2525from ax .api .types import TParameterization
26- from ax .core .analysis_card import AnalysisCard
2726from ax .core .data import Data
2827from ax .core .experiment import Experiment
2928from 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 ():
You can’t perform that action at this time.
0 commit comments