Skip to content

Commit 8ba60a1

Browse files
committed
fix: SQL cell output broken in Colab due to anywidget HTML conflict
1 parent 7e959b9 commit 8ba60a1

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

bigframes/dataframe.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -864,11 +864,7 @@ def _get_anywidget_bundle(self, include=None, exclude=None):
864864
else:
865865
widget_repr = dict(widget_repr_result)
866866

867-
# At this point, we have already executed the query as part of the
868-
# widget construction. Let's use the information available to render
869-
# the HTML and plain text versions.
870-
widget_repr["text/html"] = widget.table_html
871-
867+
# Plain text representations to avoid multiple queries.
872868
widget_repr["text/plain"] = self._create_text_representation(
873869
widget._cached_data, widget.row_count
874870
)

tests/system/small/test_anywidget.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,19 @@ def test_repr_in_anywidget_mode_should_not_be_deferred(
930930
assert "page_1_row_1" in representation
931931

932932

933+
def test_repr_mimebundle_anywidget_no_html(
934+
paginated_bf_df: bf.dataframe.DataFrame,
935+
):
936+
"""
937+
Verify that in 'anywidget' mode, the mimebundle does not contain 'text/html'.
938+
This is to prevent rendering conflicts in environments like Colab.
939+
"""
940+
with bf.option_context("display.repr_mode", "anywidget"):
941+
mimebundle = paginated_bf_df._repr_mimebundle_()
942+
assert "text/html" not in mimebundle
943+
assert "application/vnd.jupyter.widget-view+json" in mimebundle
944+
945+
933946
# TODO(b/332316283): Add tests for custom index and multiindex
934947
# This may not be necessary for the SQL Cell use case but should be
935948
# considered for completeness.

0 commit comments

Comments
 (0)