Skip to content

Commit 8040bc4

Browse files
author
Jon Wayne Parrott
authored
Replace usage of google.api.core with google.api_core (googleapis#4221)
* Remove api.core packages from google.cloud.core, make google.cloud.core depend on api_core. * s/google.api.core/google.api_core/g and nox updates * Fixing core tests, addressing review feedback * Fix bigquery
1 parent 961c70c commit 8040bc4

File tree

99 files changed

+188
-5791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+188
-5791
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
python3.6 test_utils/scripts/get_target_packages.py > ~/target_packages
4242
cat ~/target_packages
4343
- run:
44-
name: Run tests - google.api.core
44+
name: Run tests - google.api_core
4545
command: |
4646
if [[ -n $(grep api_core ~/target_packages) ]]; then
4747
nox -f api_core/nox.py

.github/CODEOWNERS

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
core/* @dhermes
1111
test_utils/* @dhermes
1212

13-
# Jon Wayne Parrott is the author of the new google.api.core library.
14-
# NOTE: This trumps the previous core/* directive, since the last match is
15-
# what matters.
16-
core/google/api/core/* @jonparrott
13+
# Jon Wayne Parrott is the author of the new google.api_core library.
14+
api_core/* @jonparrott
1715

1816
# Tres Seaver and Tim Swast share responsibility for BigQuery.
1917
bigquery/* @tswast @tseaver

api_core/google/api_core/future/polling.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def result(self, timeout=None):
100100
google.protobuf.Message: The Operation's result.
101101
102102
Raises:
103-
google.gax.GaxError: If the operation errors or if the timeout is
104-
reached before the operation completes.
103+
google.api_core.GoogleAPICallError: If the operation errors or if
104+
the timeout is reached before the operation completes.
105105
"""
106106
self._blocking_poll(timeout=timeout)
107107

@@ -120,7 +120,8 @@ def exception(self, timeout=None):
120120
If None, wait indefinitely.
121121
122122
Returns:
123-
Optional[google.gax.GaxError]: The operation's error.
123+
Optional[google.api_core.GoogleAPICallError]: The operation's
124+
error.
124125
"""
125126
self._blocking_poll()
126127
return self._exception

api_core/nox.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def unit_tests(session, python_version):
4242
session.run(
4343
'py.test',
4444
'--quiet',
45-
'--cov=google.cloud',
4645
'--cov=google.api_core',
4746
'--cov=tests.unit',
4847
'--cov-append',

bigquery/google/cloud/bigquery/_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ def _item_to_row(iterator, resource):
818818
added to the iterator after being created, which
819819
should be done by the caller.
820820
821-
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
821+
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
822822
:param iterator: The iterator that is currently in use.
823823
824824
:type resource: dict
@@ -834,10 +834,10 @@ def _item_to_row(iterator, resource):
834834
def _rows_page_start(iterator, page, response):
835835
"""Grab total rows when :class:`~google.cloud.iterator.Page` starts.
836836
837-
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
837+
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
838838
:param iterator: The iterator that is currently in use.
839839
840-
:type page: :class:`~google.cloud.iterator.Page`
840+
:type page: :class:`~google.api_core.page_iterator.Page`
841841
:param page: The page that was just created.
842842
843843
:type response: dict

bigquery/google/cloud/bigquery/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"""Client for interacting with the Google BigQuery API."""
1616

17-
from google.api.core import page_iterator
17+
from google.api_core import page_iterator
1818
from google.cloud.client import ClientWithProject
1919
from google.cloud.bigquery._http import Connection
2020
from google.cloud.bigquery.dataset import Dataset
@@ -97,7 +97,7 @@ def list_projects(self, max_results=None, page_token=None):
9797
not passed, the API will return the first page of
9898
projects.
9999
100-
:rtype: :class:`~google.api.core.page_iterator.Iterator`
100+
:rtype: :class:`~google.api_core.page_iterator.Iterator`
101101
:returns: Iterator of :class:`~google.cloud.bigquery.client.Project`
102102
accessible to the current client.
103103
"""
@@ -129,7 +129,7 @@ def list_datasets(self, include_all=False, max_results=None,
129129
not passed, the API will return the first page of
130130
datasets.
131131
132-
:rtype: :class:`~google.api.core.page_iterator.Iterator`
132+
:rtype: :class:`~google.api_core.page_iterator.Iterator`
133133
:returns: Iterator of :class:`~google.cloud.bigquery.dataset.Dataset`.
134134
accessible to the current client.
135135
"""
@@ -250,7 +250,7 @@ def list_jobs(self, max_results=None, page_token=None, all_users=None,
250250
* ``"pending"``
251251
* ``"running"``
252252
253-
:rtype: :class:`~google.api.core.page_iterator.Iterator`
253+
:rtype: :class:`~google.api_core.page_iterator.Iterator`
254254
:returns: Iterable of job instances.
255255
"""
256256
extra_params = {'projection': 'full'}
@@ -397,7 +397,7 @@ def run_sync_query(self, query, udf_resources=(), query_parameters=()):
397397
def _item_to_project(iterator, resource):
398398
"""Convert a JSON project to the native object.
399399
400-
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
400+
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
401401
:param iterator: The iterator that is currently in use.
402402
403403
:type resource: dict
@@ -413,7 +413,7 @@ def _item_to_project(iterator, resource):
413413
def _item_to_dataset(iterator, resource):
414414
"""Convert a JSON dataset to the native object.
415415
416-
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
416+
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
417417
:param iterator: The iterator that is currently in use.
418418
419419
:type resource: dict
@@ -428,7 +428,7 @@ def _item_to_dataset(iterator, resource):
428428
def _item_to_job(iterator, resource):
429429
"""Convert a JSON job to the native object.
430430
431-
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
431+
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
432432
:param iterator: The iterator that is currently in use.
433433
434434
:type resource: dict

bigquery/google/cloud/bigquery/dataset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Define API Datasets."""
1616
import six
1717

18-
from google.api.core import page_iterator
18+
from google.api_core import page_iterator
1919
from google.cloud._helpers import _datetime_from_microseconds
2020
from google.cloud.exceptions import NotFound
2121
from google.cloud.bigquery.table import Table
@@ -561,7 +561,7 @@ def list_tables(self, max_results=None, page_token=None):
561561
datasets. If not passed, the API will return the
562562
first page of datasets.
563563
564-
:rtype: :class:`~google.api.core.page_iterator.Iterator`
564+
:rtype: :class:`~google.api_core.page_iterator.Iterator`
565565
:returns: Iterator of :class:`~google.cloud.bigquery.table.Table`
566566
contained within the current dataset.
567567
"""
@@ -595,7 +595,7 @@ def table(self, name, schema=()):
595595
def _item_to_table(iterator, resource):
596596
"""Convert a JSON table to the native object.
597597
598-
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
598+
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
599599
:param iterator: The iterator that is currently in use.
600600
601601
:type resource: dict

bigquery/google/cloud/bigquery/job.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import six
2020
from six.moves import http_client
2121

22-
import google.api.core.future.polling
22+
import google.api_core.future.polling
2323
from google.cloud import exceptions
2424
from google.cloud.exceptions import NotFound
2525
from google.cloud._helpers import _datetime_from_microseconds
@@ -140,7 +140,7 @@ class WriteDisposition(_EnumProperty):
140140
WRITE_EMPTY = 'WRITE_EMPTY'
141141

142142

143-
class _AsyncJob(google.api.core.future.polling.PollingFuture):
143+
class _AsyncJob(google.api_core.future.polling.PollingFuture):
144144
"""Base class for asynchronous jobs.
145145
146146
:type name: str
@@ -496,7 +496,7 @@ def cancelled(self):
496496
497497
This always returns False. It's not possible to check if a job was
498498
cancelled in the API. This method is here to satisfy the interface
499-
for :class:`google.api.core.future.Future`.
499+
for :class:`google.api_core.future.Future`.
500500
501501
:rtype: bool
502502
:returns: False
@@ -1316,7 +1316,7 @@ def result(self, timeout=None):
13161316
How long to wait for job to complete before raising a
13171317
:class:`TimeoutError`.
13181318
1319-
:rtype: :class:`~google.api.core.page_iterator.Iterator`
1319+
:rtype: :class:`~google.api_core.page_iterator.Iterator`
13201320
:returns:
13211321
Iterator of row data :class:`tuple`s. During each page, the
13221322
iterator will have the ``total_rows`` attribute set, which counts

bigquery/google/cloud/bigquery/query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import six
1818

19-
from google.api.core import page_iterator
19+
from google.api_core import page_iterator
2020
from google.cloud.bigquery._helpers import _TypedProperty
2121
from google.cloud.bigquery._helpers import _rows_from_json
2222
from google.cloud.bigquery.dataset import Dataset
@@ -420,7 +420,7 @@ def fetch_data(self, max_results=None, page_token=None, start_index=None,
420420
:param client: the client to use. If not passed, falls back to the
421421
``client`` stored on the current dataset.
422422
423-
:rtype: :class:`~google.api.core.page_iterator.Iterator`
423+
:rtype: :class:`~google.api_core.page_iterator.Iterator`
424424
:returns: Iterator of row data :class:`tuple`s. During each page, the
425425
iterator will have the ``total_rows`` attribute set,
426426
which counts the total number of rows **in the result
@@ -467,10 +467,10 @@ def _rows_page_start_query(iterator, page, response):
467467
added to the iterator after being created, which
468468
should be done by the caller.
469469
470-
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
470+
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
471471
:param iterator: The iterator that is currently in use.
472472
473-
:type page: :class:`~google.cloud.iterator.Page`
473+
:type page: :class:`~google.api_core.page_iterator.Page`
474474
:param page: The page that was just created.
475475
476476
:type response: dict

bigquery/google/cloud/bigquery/table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from google.resumable_media.requests import MultipartUpload
2424
from google.resumable_media.requests import ResumableUpload
2525

26-
from google.api.core import page_iterator
26+
from google.api_core import page_iterator
2727
from google.cloud import exceptions
2828
from google.cloud._helpers import _datetime_from_microseconds
2929
from google.cloud._helpers import _millis_from_datetime
@@ -712,7 +712,7 @@ def fetch_data(self, max_results=None, page_token=None, client=None):
712712
:param client: (Optional) The client to use. If not passed, falls
713713
back to the ``client`` stored on the current dataset.
714714
715-
:rtype: :class:`~google.api.core.page_iterator.Iterator`
715+
:rtype: :class:`~google.api_core.page_iterator.Iterator`
716716
:returns: Iterator of row data :class:`tuple`s. During each page, the
717717
iterator will have the ``total_rows`` attribute set,
718718
which counts the total number of rows **in the table**

0 commit comments

Comments
 (0)