Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 4134750

Browse files
committed
feat: Disable progress bars in Anywidget mode to reduce notebook clutter
1 parent 51309df commit 4134750

File tree

3 files changed

+128
-250
lines changed

3 files changed

+128
-250
lines changed

bigframes/display/anywidget.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,26 @@ def _initial_load(self) -> None:
133133
# obtain the row counts
134134
# TODO(b/428238610): Start iterating over the result of `to_pandas_batches()`
135135
# before we get here so that the count might already be cached.
136-
self._reset_batches_for_new_page_size()
136+
with bigframes.option_context("display.progress_bar", None):
137+
self._reset_batches_for_new_page_size()
137138

138-
if self._batches is None:
139-
self._error_message = (
140-
"Could not retrieve data batches. Data might be unavailable or "
141-
"an error occurred."
142-
)
143-
self.row_count = None
144-
elif self._batches.total_rows is None:
145-
# Total rows is unknown, this is an expected state.
146-
# TODO(b/461536343): Cheaply discover if we have exactly 1 page.
147-
# There are cases where total rows is not set, but there are no additional
148-
# pages. We could disable the "next" button in these cases.
149-
self.row_count = None
150-
else:
151-
self.row_count = self._batches.total_rows
139+
if self._batches is None:
140+
self._error_message = (
141+
"Could not retrieve data batches. Data might be unavailable or "
142+
"an error occurred."
143+
)
144+
self.row_count = None
145+
elif self._batches.total_rows is None:
146+
# Total rows is unknown, this is an expected state.
147+
# TODO(b/461536343): Cheaply discover if we have exactly 1 page.
148+
# There are cases where total rows is not set, but there are no additional
149+
# pages. We could disable the "next" button in these cases.
150+
self.row_count = None
151+
else:
152+
self.row_count = self._batches.total_rows
152153

153-
# get the initial page
154-
self._set_table_html()
154+
# get the initial page
155+
self._set_table_html()
155156

156157
@traitlets.observe("_initial_load_complete")
157158
def _on_initial_load_complete(self, change: dict[str, Any]):
@@ -281,7 +282,9 @@ def _reset_batches_for_new_page_size(self) -> None:
281282
def _set_table_html(self) -> None:
282283
"""Sets the current html data based on the current page and page size."""
283284
new_page = None
284-
with self._setting_html_lock:
285+
with self._setting_html_lock, bigframes.option_context(
286+
"display.progress_bar", None
287+
):
285288
if self._error_message:
286289
self.table_html = (
287290
f"<div class='bigframes-error-message'>"

bigframes/display/html.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ def repr_mimebundle(
363363

364364
if opts.repr_mode == "anywidget":
365365
try:
366-
return get_anywidget_bundle(obj, include=include, exclude=exclude)
366+
with bigframes.option_context("display.progress_bar", None):
367+
return get_anywidget_bundle(obj, include=include, exclude=exclude)
367368
except ImportError:
368369
# Anywidget is an optional dependency, so warn rather than fail.
369370
# TODO(shuowei): When Anywidget becomes the default for all repr modes,

0 commit comments

Comments
 (0)