Skip to content

Commit 1e1fb7c

Browse files
shrutipatel31facebook-github-bot
authored andcommitted
Add NotApplicableStateAnalysisCard class (facebook#5035)
Summary: Add a new NotApplicableStateAnalysisCard class to distinguish transient 'not applicable ' states from true errors. This card is used for analyses that cannot be computed due to the current experiment state (e.g., 'Experiment has no data yet') but will become available as the experiment progresses. Differential Revision: D96248249
1 parent 038c9cd commit 1e1fb7c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ax/core/analysis_card.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,17 @@ def _body_html(self, depth: int) -> str:
431431
"""
432432

433433
return f"<div class='content'>{self.blob}</div>"
434+
435+
436+
class NotApplicableStateAnalysisCard(AnalysisCard):
437+
"""Card for analyses that are not applicable to the current experiment state.
438+
439+
This card represents a transient state where an analysis cannot be computed
440+
due to the current experiment state (e.g., when the experiment doesn't have enough
441+
data, when no model has been fit yet, or when required trials have not completed),
442+
but may become available as the experiment progresses.
443+
"""
444+
445+
def _body_html(self, depth: int) -> str:
446+
"""Return the HTML body containing the not-applicable explanation text."""
447+
return f"<div class='content'>{self.blob}</div>"

ax/core/tests/test_analysis_card.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ax.analysis.analysis import AnalysisCard
1010
from ax.analysis.markdown.markdown_analysis import MarkdownAnalysisCard
1111
from ax.analysis.plotly.plotly_analysis import PlotlyAnalysisCard
12-
from ax.core.analysis_card import AnalysisCardGroup
12+
from ax.core.analysis_card import AnalysisCardGroup, NotApplicableStateAnalysisCard
1313
from ax.utils.common.testutils import TestCase
1414
from plotly import graph_objects as go, io as pio
1515

@@ -67,3 +67,14 @@ def test_hierarchy_str(self) -> None:
6767
test_markdown_analysis_card_title"""
6868

6969
self.assertEqual(big_group.hierarchy_str(), expected)
70+
71+
def test_not_applicable_card(self) -> None:
72+
"""Test NotApplicableStateAnalysisCard._body_html renders blob content."""
73+
card = NotApplicableStateAnalysisCard(
74+
name="Test",
75+
title="Test",
76+
subtitle="",
77+
df=pd.DataFrame(),
78+
blob="Explanation text.",
79+
)
80+
self.assertIn("Explanation text.", card._body_html(depth=0))

0 commit comments

Comments
 (0)