Skip to content

Commit 9185cdd

Browse files
committed
test(bigframes): verify read_gbq_colab label preservation in anywidget display mode
1 parent c563483 commit 9185cdd

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

packages/bigframes/bigframes/session/_io/bigquery/__init__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,8 @@ def create_job_configs_labels(
6969

7070
if api_methods and "bigframes-api" not in job_configs_labels:
7171
api_methods = list(api_methods)
72-
colab_idx = next(
73-
(i for i, m in enumerate(api_methods) if "read_gbq_colab" in m), None
74-
)
75-
if colab_idx is not None:
76-
job_configs_labels["bigframes-api"] = api_methods.pop(colab_idx)
77-
else:
78-
job_configs_labels["bigframes-api"] = api_methods[0]
79-
del api_methods[0]
72+
job_configs_labels["bigframes-api"] = api_methods[0]
73+
del api_methods[0]
8074

8175
# Make sure we always populate bigframes-api with _something_, even if we
8276
# have a code path which doesn't populate the list of api_methods. See

packages/bigframes/tests/unit/session/test_io_bigquery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_add_and_trim_labels_length_limit_met():
172172
for _ in range(52):
173173
df.head()
174174

175-
io_bq.add_and_trim_labels(job_config=job_config)
175+
io_bq.add_and_trim_labels(job_config=job_config, session=df._session)
176176
assert job_config.labels is not None
177177
assert len(job_config.labels) == 56
178178
assert "dataframe-max" not in job_config.labels.values()
@@ -218,6 +218,7 @@ def test_start_query_with_job_labels_length_limit_met(
218218
timeout=timeout,
219219
metrics=None,
220220
publisher=bigframes.core.events.Publisher(),
221+
session=df._session,
221222
)
222223

223224
assert job_config.labels is not None

packages/bigframes/tests/unit/session/test_read_gbq_colab.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_read_gbq_colab_includes_label():
4848

4949

5050
def test_read_gbq_colab_includes_label_in_anywidget_mode():
51-
"""Make sure read_gbq_colab label is preserved as the primary bigframes-api label in anywidget mode."""
51+
"""Make sure read_gbq_colab label is preserved in recent-bigframes-api labels in anywidget mode."""
5252
pytest.importorskip("anywidget")
5353
pytest.importorskip("traitlets")
5454

@@ -64,7 +64,6 @@ def test_read_gbq_colab_includes_label_in_anywidget_mode():
6464
_ = bf_html.get_anywidget_bundle(df)
6565

6666
label_values = []
67-
bigframes_api_labels = []
6867
for kall in itertools.chain(
6968
bqclient.query_and_wait.call_args_list,
7069
bqclient._query_and_wait_bigframes.call_args_list,
@@ -74,11 +73,8 @@ def test_read_gbq_colab_includes_label_in_anywidget_mode():
7473
if job_config is None:
7574
continue
7675
label_values.extend(job_config.labels.values())
77-
if "bigframes-api" in job_config.labels:
78-
bigframes_api_labels.append(job_config.labels["bigframes-api"])
7976

8077
assert "session-read_gbq_colab" in label_values
81-
assert "session-read_gbq_colab" in bigframes_api_labels
8278

8379

8480
@pytest.mark.parametrize("dry_run", [True, False])

0 commit comments

Comments
 (0)