Skip to content

Commit 4e2689a

Browse files
authored
feat: Disable progress bars in Anywidget mode (#2444)
This PR improves the user experience of the interactive Anywidget display mode by automatically disabling progress bars and job logging during widget operations. Changes: Wrapped the get_anywidget_bundle call in repr_mimebundle with option_context("display.progress_bar", None) to silence the initial widget load. Wrapped TableWidget._initial_load and TableWidget._set_table_html methods to silence subsequent interactions like pagination and sorting. Motivation: When interacting with the TableWidget (paging, sorting), the repeated appearance of progress bars creates visual noise and clutter in the notebook output cell, distracting from the interactive data exploration experience. This change ensures a clean and seamless interface. Verified at: vs code notebook: screen/B7hCnXdLeTiFshr colab notebook: screen/4d8Kpo5ZbbfZUBb Fixes #< 482120359 > 🦕
1 parent 3cb57b1 commit 4e2689a

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

bigframes/display/anywidget.py

Lines changed: 23 additions & 19 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]):
@@ -274,14 +275,17 @@ def _reset_batch_cache(self) -> None:
274275

275276
def _reset_batches_for_new_page_size(self) -> None:
276277
"""Reset the batch iterator when page size changes."""
277-
self._batches = self._dataframe.to_pandas_batches(page_size=self.page_size)
278+
with bigframes.option_context("display.progress_bar", None):
279+
self._batches = self._dataframe.to_pandas_batches(page_size=self.page_size)
278280

279281
self._reset_batch_cache()
280282

281283
def _set_table_html(self) -> None:
282284
"""Sets the current html data based on the current page and page size."""
283285
new_page = None
284-
with self._setting_html_lock:
286+
with self._setting_html_lock, bigframes.option_context(
287+
"display.progress_bar", None
288+
):
285289
if self._error_message:
286290
self.table_html = (
287291
f"<div class='bigframes-error-message'>"

0 commit comments

Comments
 (0)