Skip to content

Commit 1877e65

Browse files
committed
final touch up
1 parent e6d3bc1 commit 1877e65

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

bigframes/display/anywidget.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, dataframe: bigframes.dataframe.DataFrame):
7474
# Initialize data fetching attributes.
7575
self._batches = dataframe.to_pandas_batches(page_size=initial_page_size)
7676

77-
# Now it's safe to set traitlets properties that trigger observers
77+
# set traitlets properties that trigger observers
7878
self.page_size = initial_page_size
7979

8080
# len(dataframe) is expensive, since it will trigger a
@@ -102,12 +102,15 @@ def _css(self):
102102
table_html = traitlets.Unicode().tag(sync=True)
103103

104104
@traitlets.validate("page")
105-
def _validate_page(self, proposal: Dict[str, Any]):
105+
def _validate_page(self, proposal: Dict[str, Any]) -> int:
106106
"""Validate and clamp the page number to a valid range.
107107
108108
Args:
109109
proposal: A dictionary from the traitlets library containing the
110110
proposed change. The new value is in proposal["value"].
111+
112+
Returns:
113+
The validated and clamped page number as an integer.
111114
"""
112115

113116
value = proposal["value"]
@@ -121,11 +124,15 @@ def _validate_page(self, proposal: Dict[str, Any]):
121124
return max(0, min(value, max_page))
122125

123126
@traitlets.validate("page_size")
124-
def _validate_page_size(self, proposal: Dict[str, Any]):
127+
def _validate_page_size(self, proposal: Dict[str, Any]) -> int:
125128
"""Validate page size to ensure it's positive and reasonable.
129+
126130
Args:
127131
proposal: A dictionary from the traitlets library containing the
128132
proposed change. The new value is in proposal["value"].
133+
134+
Returns:
135+
The validated page size as an integer.
129136
"""
130137
value = proposal["value"]
131138

@@ -141,7 +148,7 @@ def _get_next_batch(self) -> bool:
141148
"""
142149
Gets the next batch of data from the generator and appends to cache.
143150
144-
Return:
151+
Returns:
145152
True if a batch was successfully loaded, False otherwise.
146153
"""
147154
if self._all_data_loaded:

notebooks/dataframes/anywidget_mode.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
{
7676
"data": {
7777
"text/html": [
78-
"Query job 0b22b0f5-b952-4546-a969-41a89e343e9b is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:0b22b0f5-b952-4546-a969-41a89e343e9b&page=queryresults\">Open Job</a>"
78+
"Query job c5fcfd5e-1617-49c8-afa3-86ca21019de4 is DONE. 0 Bytes processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:c5fcfd5e-1617-49c8-afa3-86ca21019de4&page=queryresults\">Open Job</a>"
7979
],
8080
"text/plain": [
8181
"<IPython.core.display.HTML object>"
@@ -141,7 +141,7 @@
141141
{
142142
"data": {
143143
"text/html": [
144-
"Query job 8e57da45-b6a7-44fb-8c4f-4b87058d94cb is DONE. 171.4 MB processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:8e57da45-b6a7-44fb-8c4f-4b87058d94cb&page=queryresults\">Open Job</a>"
144+
"Query job ab900a53-5011-4e80-85d5-0ef2958598db is DONE. 171.4 MB processed. <a target=\"_blank\" href=\"https://console.cloud.google.com/bigquery?project=bigframes-dev&j=bq:US:ab900a53-5011-4e80-85d5-0ef2958598db&page=queryresults\">Open Job</a>"
145145
],
146146
"text/plain": [
147147
"<IPython.core.display.HTML object>"
@@ -153,7 +153,7 @@
153153
{
154154
"data": {
155155
"application/vnd.jupyter.widget-view+json": {
156-
"model_id": "4d00aaf284984cbc97483c651b9c5110",
156+
"model_id": "bda63ba739dc4d5f83a5e18eb27b2686",
157157
"version_major": 2,
158158
"version_minor": 1
159159
},
@@ -204,7 +204,7 @@
204204
{
205205
"data": {
206206
"application/vnd.jupyter.widget-view+json": {
207-
"model_id": "d4af4cf7d24d4f1c8e9c9b5f237df32b",
207+
"model_id": "9bffeb73549e48419c3dd895edfe30e8",
208208
"version_major": 2,
209209
"version_minor": 1
210210
},
@@ -290,7 +290,7 @@
290290
{
291291
"data": {
292292
"application/vnd.jupyter.widget-view+json": {
293-
"model_id": "0f04ad3c464145ee9735eba09f5107a9",
293+
"model_id": "dfd4fa3a1c6f4b3eb1877cb0e9ba7e94",
294294
"version_major": 2,
295295
"version_minor": 1
296296
},

0 commit comments

Comments
 (0)