Skip to content

Commit 6588e9c

Browse files
committed
remove references to global _api_methods
1 parent e3e7b17 commit 6588e9c

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

owlbot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@
5858
".kokoro/build.sh",
5959
".kokoro/continuous/common.cfg",
6060
".kokoro/presubmit/common.cfg",
61-
# Temporary workaround to update docs job to use python 3.10
6261
".github/workflows/docs.yml",
62+
".github/workflows/lint.yml",
63+
".github/workflows/unittest.yml",
6364
],
6465
)
6566

tests/unit/session/test_io_bigquery.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
from unittest import mock
1919

2020
import google.cloud.bigquery as bigquery
21+
import google.cloud.bigquery.job
22+
import google.cloud.bigquery.table
2123
import pytest
2224

2325
import bigframes
2426
from bigframes.core import log_adapter
2527
import bigframes.core.events
2628
import bigframes.pandas as bpd
29+
import bigframes.session._io.bigquery
2730
import bigframes.session._io.bigquery as io_bq
2831
from bigframes.testing import mocks
2932

@@ -32,7 +35,7 @@
3235
def mock_bq_client():
3336
mock_client = mock.create_autospec(bigquery.Client)
3437
mock_query_job = mock.create_autospec(bigquery.QueryJob)
35-
mock_row_iterator = mock.create_autospec(bigquery.table.RowIterator)
38+
mock_row_iterator = mock.create_autospec(google.cloud.bigquery.table.RowIterator)
3639

3740
mock_query_job.result.return_value = mock_row_iterator
3841

@@ -98,14 +101,12 @@ def test_create_job_configs_labels_log_adaptor_call_method_under_length_limit():
98101
cur_labels = {
99102
"source": "bigquery-dataframes-temp",
100103
}
101-
df = bpd.DataFrame(
102-
{"col1": [1, 2], "col2": [3, 4]}, session=mocks.create_bigquery_session()
103-
)
104-
# Test running two methods
105-
df.head()
106-
df.max()
107-
df.columns
108-
api_methods = log_adapter._api_methods
104+
api_methods = [
105+
"dataframe-columns",
106+
"dataframe-max",
107+
"dataframe-head",
108+
"dataframe-__init__",
109+
]
109110

110111
labels = io_bq.create_job_configs_labels(
111112
job_configs_labels=cur_labels, api_methods=api_methods
@@ -123,13 +124,8 @@ def test_create_job_configs_labels_log_adaptor_call_method_under_length_limit():
123124

124125
def test_create_job_configs_labels_length_limit_met_and_labels_is_none():
125126
log_adapter.get_and_reset_api_methods()
126-
df = bpd.DataFrame(
127-
{"col1": [1, 2], "col2": [3, 4]}, session=mocks.create_bigquery_session()
128-
)
129127
# Test running methods more than the labels' length limit
130-
for i in range(100):
131-
df.head()
132-
api_methods = log_adapter._api_methods
128+
api_methods = list(["dataframe-head"] * 100)
133129

134130
with bpd.option_context("compute.extra_query_labels", {}):
135131
labels = io_bq.create_job_configs_labels(
@@ -151,13 +147,8 @@ def test_create_job_configs_labels_length_limit_met():
151147
value = f"test{i}"
152148
cur_labels[key] = value
153149
# If cur_labels length is 62, we can only add one label from api_methods
154-
df = bpd.DataFrame(
155-
{"col1": [1, 2], "col2": [3, 4]}, session=mocks.create_bigquery_session()
156-
)
157150
# Test running two methods
158-
df.head()
159-
df.max()
160-
api_methods = log_adapter._api_methods
151+
api_methods = ["dataframe-max", "dataframe-head"]
161152

162153
with bpd.option_context("compute.extra_query_labels", {}):
163154
labels = io_bq.create_job_configs_labels(
@@ -187,7 +178,7 @@ def test_add_and_trim_labels_length_limit_met():
187178
{"col1": [1, 2], "col2": [3, 4]}, session=mocks.create_bigquery_session()
188179
)
189180

190-
job_config = bigquery.job.QueryJobConfig()
181+
job_config = google.cloud.bigquery.job.QueryJobConfig()
191182
job_config.labels = cur_labels
192183

193184
df.max()
@@ -224,7 +215,7 @@ def test_start_query_with_client_labels_length_limit_met(
224215
{"col1": [1, 2], "col2": [3, 4]}, session=mocks.create_bigquery_session()
225216
)
226217

227-
job_config = bigquery.job.QueryJobConfig()
218+
job_config = google.cloud.bigquery.job.QueryJobConfig()
228219
job_config.labels = cur_labels
229220

230221
df.max()

0 commit comments

Comments
 (0)