-
Notifications
You must be signed in to change notification settings - Fork 50
feat: Add pagination buttons (prev/next) to anywidget mode for DataFrames #1841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
8125614
to
0f871a9
Compare
87958ac
to
3f87072
Compare
36f89e2
to
6f70a4a
Compare
e01a330
to
0586866
Compare
c4642e6
to
98eba30
Compare
bigframes/display/anywidget.py
Outdated
|
||
# Initialize data fetching attributes. | ||
self._batches = dataframe.to_pandas_batches(page_size=self.page_size) | ||
self._cached_data = pd.DataFrame(columns=self._dataframe.columns) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutating a DataFrame can be kinda slow (lots of potential for unnecessary memory copies). Perhaps we can use a list of DataFrame instead?
Or are you trying to support dynamic changing of the page size here? If so, perhaps leave a comment explaining that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use a list of DataFrame instead.
warnings.warn( | ||
"Anywidget mode is not available, falling back to deferred mode." | ||
) | ||
return formatter.repr_query_job(self._compute_dry_run()) | ||
|
||
self._cached() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We never make it to this code or the blob_display
code or the column width code that follows if they set anywidget as the mode. Are you sure that's what we want? At some point (maybe BigFrames 3.0 or maybe even earlier) we'll want to make anywidget
the default, so it would be disappointing to lose these features.
Maybe we need some TODOs and follow-up issues filed to consolidate these code paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my change:
(1) Move blob processing before mode check: The blob column processing from now happens before the anywidget mode check, ensuring blob URLs are generated regardless of display mode.
(2) Pass processed DataFrame to widget: Instead of passing self to TableWidget, we pass the processed df that already has blob URLs resolved.
(3) Maintain feature parity: The anywidget mode now inherits all the blob display capabilities that were previously only available in the default HTML mode.
This approach ensures that when anywidget becomes the default mode, users won't lose the multimodal data display capabilities that are critical for working with images, videos, and other blob content as shown in.
bigframes/display/anywidget.py
Outdated
self._all_data_loaded = True | ||
# update row count if we loaded all data | ||
if self.row_count == 0: | ||
self.row_count = len(self._cached_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused what the purpose of this is. Didn't we set row_count
already in the constructor?
Also, 0 is not a great placeholder for missing value, since 0 is a valid number of rows in a query result. If we do delay populating row_count
, let's use None
as the placeholder for missing value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fall back logic is removed.
c596dc9
to
2ce9709
Compare
Adding interactive pagination buttons controls (Previous/Next buttons) to the anywidget mode for BigFrames DataFrames, enabling users to navigate through large datasets page by page in Jupyter notebooks.
b/391599608