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

Commit 8b9a2cf

Browse files
committed
function polish
1 parent d53eea3 commit 8b9a2cf

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

bigframes/dataframe.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,7 @@ def _repr_html_fallback(self) -> str:
838838
if opts.repr_mode == "deferred":
839839
return formatter.repr_query_job(self._compute_dry_run())
840840

841-
# Process blob columns first for non-deferred modes
842-
df, blob_cols = self._process_blob_columns()
841+
df, blob_cols = self._get_display_df_and_blob_cols()
843842

844843
pandas_df, row_count, query_job = df._block.retrieve_repr_request_results(
845844
max_results
@@ -852,9 +851,8 @@ def _repr_html_fallback(self) -> str:
852851
pandas_df, row_count, column_count, blob_cols
853852
)
854853

855-
def _process_blob_columns(self) -> tuple[DataFrame, list[str]]:
854+
def _get_display_df_and_blob_cols(self) -> tuple[DataFrame, list[str]]:
856855
"""Process blob columns for display."""
857-
self._cached()
858856
df = self
859857
blob_cols = []
860858
if bigframes.options.display.blob_display:
@@ -866,6 +864,7 @@ def _process_blob_columns(self) -> tuple[DataFrame, list[str]]:
866864
if blob_cols:
867865
df = self.copy()
868866
for col in blob_cols:
867+
# TODO(garrettwu): Not necessary to get access urls for all the rows. Update when having a to get URLs from local data.
869868
df[col] = df[col].blob._get_runtime(mode="R", with_metadata=True)
870869
return df, blob_cols
871870

@@ -876,7 +875,8 @@ def _get_anywidget_bundle(self, include=None, exclude=None):
876875
"""
877876
from bigframes import display
878877

879-
df, _ = self._process_blob_columns()
878+
# TODO(shuowei): Keep blob_cols and pass them to TableWidget so that they can render properly.
879+
df, _ = self._get_display_df_and_blob_cols()
880880

881881
# Create and display the widget
882882
widget = display.TableWidget(df)
@@ -940,21 +940,21 @@ def _repr_mimebundle_(self, include=None, exclude=None):
940940
return self._get_anywidget_bundle(include=include, exclude=exclude)
941941

942942
except ImportError:
943-
# Fallback: let IPython use _repr_html_fallback() instead
943+
# Anywidget is an optional dependency, so warn rather than fail.
944+
# TODO(shuowei): When Anywidget becomes the default for all repr modes,
945+
# remove this warning.
944946
warnings.warn(
945947
"Anywidget mode is not available. "
946948
"Please `pip install anywidget traitlets` or `pip install 'bigframes[anywidget]'` to use interactive tables. "
947949
f"Falling back to static HTML. Error: {traceback.format_exc()}"
948950
)
949-
# Don't return anything - let IPython fall back to _repr_html_fallback()
950-
pass
951951

952952
# In non-anywidget mode, fetch data once and use it for both HTML
953953
# and plain text representations to avoid multiple queries.
954954
opts = bigframes.options.display
955955
max_results = opts.max_rows
956956

957-
df, blob_cols = self._process_blob_columns()
957+
df, blob_cols = self._get_display_df_and_blob_cols()
958958

959959
pandas_df, row_count, query_job = df._block.retrieve_repr_request_results(
960960
max_results

0 commit comments

Comments
 (0)