From fa6932cab3d426a2dc7d7bb9724d19a2290ea863 Mon Sep 17 00:00:00 2001 From: Shruti Patel Date: Tue, 21 Apr 2026 18:20:54 -0700 Subject: [PATCH] Add toggle_label field to AnalysisCardBase for custom subtitle expansion text (#5124) Summary: Pull Request resolved: https://github.com/facebook/Ax/pull/5124 Adds a serializable `toggle_label: str` field to `AnalysisCardBase` that allows analyses to customize the subtitle expand/collapse toggle button text. When non-empty, `toggle_label` replaces the default "See more" text with a context-specific label (e.g., "Expand to see annotated parameters."). The field is persisted to both SQA and JSON storage backends, and used by the notebook HTML template for rendering. Changes: - Add `toggle_label` field + constructor param (default "") to AnalysisCardBase - Update notebook `_to_html()` to use `self.toggle_label or "See more"` - Add `toggle_label` nullable column to SQAAnalysisCard - Update SQA encoder/decoder (all 8 card-type callsites) - Update JSON encoder for both card and group dicts - Unit tests Reviewed By: bernardbeckerman Differential Revision: D98738752 --- ax/core/analysis_card.py | 36 ++++++++- ax/core/tests/test_analysis_card.py | 73 +++++++++++++++---- ax/storage/json_store/encoders.py | 2 + .../json_store/tests/test_json_store.py | 61 ++++++++++++++++ ax/storage/sqa_store/decoder.py | 11 +++ ax/storage/sqa_store/encoder.py | 2 + ax/storage/sqa_store/sqa_classes.py | 3 + ax/storage/sqa_store/tests/test_sqa_store.py | 60 ++++++++++++++- 8 files changed, 229 insertions(+), 19 deletions(-) diff --git a/ax/core/analysis_card.py b/ax/core/analysis_card.py index 2819eb59163..6f1679e01c5 100644 --- a/ax/core/analysis_card.py +++ b/ax/core/analysis_card.py @@ -18,6 +18,8 @@ from IPython.display import display, HTML, Markdown from plotly.offline import get_plotlyjs +DEFAULT_SUBTITLE_TOGGLE_LABEL: str = "See more" + # Simple HTML template for rendering a card with a title, subtitle, and body with # scrollable overflow. Subtitles are rendered in a
with max-height overflow # so that any HTML content (tables, lists, etc.) is valid and clipped correctly @@ -54,11 +56,11 @@ display: none; }} -
+
{title_str}
{subtitle_str}
- +
{body_html} @@ -66,10 +68,12 @@