Skip to content

Commit 7813eaa

Browse files
authored
feat: add display.render_mode to control DataFrame/Series visualization (#2413)
This PR introduces the display.render_mode configuration option, providing a clearer and more flexible way to control how BigFrames objects are visualized in notebooks and other interactive environments. Key Changes: * New Configuration Option: Added bpd.options.display.render_mode which supports three modes: * html (Default): Standard HTML table rendering. * plaintext: Forces plain text output by removing the HTML component from the mimebundle. * anywidget: Enables the interactive anywidget-based table component. * Migration Path: Maintained backward compatibility for display.repr_mode = "anywidget". The rendering logic now checks both the new render_mode and the legacy repr_mode flags. * Notebook & Test Updates: Updated existing notebooks and system tests to prefer the new render_mode option while verifying that existing behaviors remain intact. * New Unit Tests: Added tests/unit/display/test_render_mode.py to specifically verify the mimebundle selection logic and priority across different configuration states. While repr_mode was previously used to toggle the interactive widget, "representation mode" is a broad term. render_mode specifically addresses the format of the output (HTML vs. Text vs. Widget), allowing for better support for text-only environments and a more intuitive API for users. Also verified at colab notebook: [screen/AHNz4o5Mhb9UHrh](https://screenshot.googleplex.com/AHNz4o5Mhb9UHrh) Fixes #<479282023> 🦕
1 parent bf68d0c commit 7813eaa

File tree

8 files changed

+282
-332
lines changed

8 files changed

+282
-332
lines changed

bigframes/display/html.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def repr_mimebundle(
361361
if opts.repr_mode == "deferred":
362362
return repr_mimebundle_deferred(obj)
363363

364-
if opts.repr_mode == "anywidget":
364+
if opts.render_mode == "anywidget" or opts.repr_mode == "anywidget":
365365
try:
366366
with bigframes.option_context("display.progress_bar", None):
367367
with warnings.catch_warnings():
@@ -380,4 +380,8 @@ def repr_mimebundle(
380380
f"Falling back to static HTML. Error: {traceback.format_exc()}"
381381
)
382382

383-
return repr_mimebundle_head(obj)
383+
bundle = repr_mimebundle_head(obj)
384+
if opts.render_mode == "plaintext":
385+
bundle.pop("text/html", None)
386+
387+
return bundle

0 commit comments

Comments
 (0)