Skip to content

Commit

Permalink
Replace usage of google.api.core with google.api_core (#4221)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Jon Wayne Parrott authored Oct 18, 2017
1 parent 961c70c commit 8040bc4
Show file tree
Hide file tree
Showing 99 changed files with 188 additions and 5,791 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
python3.6 test_utils/scripts/get_target_packages.py > ~/target_packages
cat ~/target_packages
- run:
name: Run tests - google.api.core
name: Run tests - google.api_core
command: |
if [[ -n $(grep api_core ~/target_packages) ]]; then
nox -f api_core/nox.py
Expand Down
6 changes: 2 additions & 4 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
core/* @dhermes
test_utils/* @dhermes

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

# Tres Seaver and Tim Swast share responsibility for BigQuery.
bigquery/* @tswast @tseaver
Expand Down
7 changes: 4 additions & 3 deletions api_core/google/api_core/future/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def result(self, timeout=None):
google.protobuf.Message: The Operation's result.
Raises:
google.gax.GaxError: If the operation errors or if the timeout is
reached before the operation completes.
google.api_core.GoogleAPICallError: If the operation errors or if
the timeout is reached before the operation completes.
"""
self._blocking_poll(timeout=timeout)

Expand All @@ -120,7 +120,8 @@ def exception(self, timeout=None):
If None, wait indefinitely.
Returns:
Optional[google.gax.GaxError]: The operation's error.
Optional[google.api_core.GoogleAPICallError]: The operation's
error.
"""
self._blocking_poll()
return self._exception
Expand Down
1 change: 0 additions & 1 deletion api_core/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def unit_tests(session, python_version):
session.run(
'py.test',
'--quiet',
'--cov=google.cloud',
'--cov=google.api_core',
'--cov=tests.unit',
'--cov-append',
Expand Down
6 changes: 3 additions & 3 deletions bigquery/google/cloud/bigquery/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ def _item_to_row(iterator, resource):
added to the iterator after being created, which
should be done by the caller.
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
Expand All @@ -834,10 +834,10 @@ def _item_to_row(iterator, resource):
def _rows_page_start(iterator, page, response):
"""Grab total rows when :class:`~google.cloud.iterator.Page` starts.
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type page: :class:`~google.cloud.iterator.Page`
:type page: :class:`~google.api_core.page_iterator.Page`
:param page: The page that was just created.
:type response: dict
Expand Down
14 changes: 7 additions & 7 deletions bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

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

from google.api.core import page_iterator
from google.api_core import page_iterator
from google.cloud.client import ClientWithProject
from google.cloud.bigquery._http import Connection
from google.cloud.bigquery.dataset import Dataset
Expand Down Expand Up @@ -97,7 +97,7 @@ def list_projects(self, max_results=None, page_token=None):
not passed, the API will return the first page of
projects.
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:rtype: :class:`~google.api_core.page_iterator.Iterator`
:returns: Iterator of :class:`~google.cloud.bigquery.client.Project`
accessible to the current client.
"""
Expand Down Expand Up @@ -129,7 +129,7 @@ def list_datasets(self, include_all=False, max_results=None,
not passed, the API will return the first page of
datasets.
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:rtype: :class:`~google.api_core.page_iterator.Iterator`
:returns: Iterator of :class:`~google.cloud.bigquery.dataset.Dataset`.
accessible to the current client.
"""
Expand Down Expand Up @@ -250,7 +250,7 @@ def list_jobs(self, max_results=None, page_token=None, all_users=None,
* ``"pending"``
* ``"running"``
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:rtype: :class:`~google.api_core.page_iterator.Iterator`
:returns: Iterable of job instances.
"""
extra_params = {'projection': 'full'}
Expand Down Expand Up @@ -397,7 +397,7 @@ def run_sync_query(self, query, udf_resources=(), query_parameters=()):
def _item_to_project(iterator, resource):
"""Convert a JSON project to the native object.
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
Expand All @@ -413,7 +413,7 @@ def _item_to_project(iterator, resource):
def _item_to_dataset(iterator, resource):
"""Convert a JSON dataset to the native object.
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
Expand All @@ -428,7 +428,7 @@ def _item_to_dataset(iterator, resource):
def _item_to_job(iterator, resource):
"""Convert a JSON job to the native object.
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
Expand Down
6 changes: 3 additions & 3 deletions bigquery/google/cloud/bigquery/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Define API Datasets."""
import six

from google.api.core import page_iterator
from google.api_core import page_iterator
from google.cloud._helpers import _datetime_from_microseconds
from google.cloud.exceptions import NotFound
from google.cloud.bigquery.table import Table
Expand Down Expand Up @@ -561,7 +561,7 @@ def list_tables(self, max_results=None, page_token=None):
datasets. If not passed, the API will return the
first page of datasets.
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:rtype: :class:`~google.api_core.page_iterator.Iterator`
:returns: Iterator of :class:`~google.cloud.bigquery.table.Table`
contained within the current dataset.
"""
Expand Down Expand Up @@ -595,7 +595,7 @@ def table(self, name, schema=()):
def _item_to_table(iterator, resource):
"""Convert a JSON table to the native object.
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type resource: dict
Expand Down
8 changes: 4 additions & 4 deletions bigquery/google/cloud/bigquery/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import six
from six.moves import http_client

import google.api.core.future.polling
import google.api_core.future.polling
from google.cloud import exceptions
from google.cloud.exceptions import NotFound
from google.cloud._helpers import _datetime_from_microseconds
Expand Down Expand Up @@ -140,7 +140,7 @@ class WriteDisposition(_EnumProperty):
WRITE_EMPTY = 'WRITE_EMPTY'


class _AsyncJob(google.api.core.future.polling.PollingFuture):
class _AsyncJob(google.api_core.future.polling.PollingFuture):
"""Base class for asynchronous jobs.
:type name: str
Expand Down Expand Up @@ -496,7 +496,7 @@ def cancelled(self):
This always returns False. It's not possible to check if a job was
cancelled in the API. This method is here to satisfy the interface
for :class:`google.api.core.future.Future`.
for :class:`google.api_core.future.Future`.
:rtype: bool
:returns: False
Expand Down Expand Up @@ -1316,7 +1316,7 @@ def result(self, timeout=None):
How long to wait for job to complete before raising a
:class:`TimeoutError`.
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:rtype: :class:`~google.api_core.page_iterator.Iterator`
:returns:
Iterator of row data :class:`tuple`s. During each page, the
iterator will have the ``total_rows`` attribute set, which counts
Expand Down
8 changes: 4 additions & 4 deletions bigquery/google/cloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import six

from google.api.core import page_iterator
from google.api_core import page_iterator
from google.cloud.bigquery._helpers import _TypedProperty
from google.cloud.bigquery._helpers import _rows_from_json
from google.cloud.bigquery.dataset import Dataset
Expand Down Expand Up @@ -420,7 +420,7 @@ def fetch_data(self, max_results=None, page_token=None, start_index=None,
:param client: the client to use. If not passed, falls back to the
``client`` stored on the current dataset.
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:rtype: :class:`~google.api_core.page_iterator.Iterator`
:returns: Iterator of row data :class:`tuple`s. During each page, the
iterator will have the ``total_rows`` attribute set,
which counts the total number of rows **in the result
Expand Down Expand Up @@ -467,10 +467,10 @@ def _rows_page_start_query(iterator, page, response):
added to the iterator after being created, which
should be done by the caller.
:type iterator: :class:`~google.api.core.page_iterator.Iterator`
:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that is currently in use.
:type page: :class:`~google.cloud.iterator.Page`
:type page: :class:`~google.api_core.page_iterator.Page`
:param page: The page that was just created.
:type response: dict
Expand Down
4 changes: 2 additions & 2 deletions bigquery/google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from google.resumable_media.requests import MultipartUpload
from google.resumable_media.requests import ResumableUpload

from google.api.core import page_iterator
from google.api_core import page_iterator
from google.cloud import exceptions
from google.cloud._helpers import _datetime_from_microseconds
from google.cloud._helpers import _millis_from_datetime
Expand Down Expand Up @@ -712,7 +712,7 @@ def fetch_data(self, max_results=None, page_token=None, client=None):
:param client: (Optional) The client to use. If not passed, falls
back to the ``client`` stored on the current dataset.
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:rtype: :class:`~google.api_core.page_iterator.Iterator`
:returns: Iterator of row data :class:`tuple`s. During each page, the
iterator will have the ``total_rows`` attribute set,
which counts the total number of rows **in the table**
Expand Down
1 change: 1 addition & 0 deletions bigquery/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


LOCAL_DEPS = (
os.path.join('..', 'api_core'),
os.path.join('..', 'core'),
)

Expand Down
2 changes: 1 addition & 1 deletion bigtable/google/cloud/bigtable/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import re

from google.api.core import operation
from google.api_core import operation
from google.cloud.bigtable._generated import (
instance_pb2 as data_v2_pb2)
from google.cloud.bigtable._generated import (
Expand Down
2 changes: 1 addition & 1 deletion bigtable/google/cloud/bigtable/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import re

from google.api.core import operation
from google.api_core import operation
from google.cloud.bigtable._generated import (
instance_pb2 as data_v2_pb2)
from google.cloud.bigtable._generated import (
Expand Down
5 changes: 4 additions & 1 deletion bigtable/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import nox


LOCAL_DEPS = ('../core/',)
LOCAL_DEPS = (
os.path.join('..', 'api_core'),
os.path.join('..', 'core'),
)


@nox.session
Expand Down
4 changes: 2 additions & 2 deletions bigtable/tests/unit/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_reload(self):
self.assertEqual(cluster.location, LOCATION)

def test_create(self):
from google.api.core import operation
from google.api_core import operation
from google.longrunning import operations_pb2
from google.cloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
Expand Down Expand Up @@ -275,7 +275,7 @@ def test_create(self):

def test_update(self):
import datetime
from google.api.core import operation
from google.api_core import operation
from google.longrunning import operations_pb2
from google.protobuf.any_pb2 import Any
from google.cloud._helpers import _datetime_to_pb_timestamp
Expand Down
4 changes: 2 additions & 2 deletions bigtable/tests/unit/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_reload(self):

def test_create(self):
import datetime
from google.api.core import operation
from google.api_core import operation
from google.longrunning import operations_pb2
from google.protobuf.any_pb2 import Any
from google.cloud.bigtable._generated import (
Expand Down Expand Up @@ -285,7 +285,7 @@ def test_create(self):
self.assertEqual(kwargs, {})

def test_create_w_explicit_serve_nodes(self):
from google.api.core import operation
from google.api_core import operation
from google.longrunning import operations_pb2
from google.cloud.bigtable._generated import (
bigtable_instance_admin_pb2 as messages_v2_pb2)
Expand Down
22 changes: 0 additions & 22 deletions core/google/api/__init__.py

This file was deleted.

18 changes: 0 additions & 18 deletions core/google/api/core/__init__.py

This file was deleted.

22 changes: 0 additions & 22 deletions core/google/api/core/datetime_helpers.py

This file was deleted.

Loading

0 comments on commit 8040bc4

Please sign in to comment.