From 0fddd531961aa5b3d3d36bbad6c80d711465a755 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 09:55:22 -0800 Subject: [PATCH 1/9] Annotator lib_name and lib_version --- vision/google/cloud/vision/_gax.py | 9 +++++++-- vision/google/cloud/vision/client.py | 3 ++- vision/setup.py | 4 ++-- vision/unit_tests/test__gax.py | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/vision/google/cloud/vision/_gax.py b/vision/google/cloud/vision/_gax.py index 55f3dfd4adf2..36f013ea46cb 100644 --- a/vision/google/cloud/vision/_gax.py +++ b/vision/google/cloud/vision/_gax.py @@ -17,6 +17,7 @@ from google.cloud.gapic.vision.v1 import image_annotator_client from google.cloud.grpc.vision.v1 import image_annotator_pb2 +from google.cloud.vision import __version__ from google.cloud.vision.annotations import Annotations @@ -25,10 +26,14 @@ class _GAPICVisionAPI(object): :type client: :class:`~google.cloud.vision.client.Client` :param client: Instance of ``Client`` object. + + :type kwargs: dict + :param kwargs: Additional keyword arguments are sent to the GAPIC client. """ - def __init__(self, client=None): + def __init__(self, client=None, credentials=None): self._client = client - self._annotator_client = image_annotator_client.ImageAnnotatorClient() + self._annotator_client = image_annotator_client.ImageAnnotatorClient( + credentials=credentials, lib_name='gccl', lib_version=__version__) def annotate(self, images): """Annotate images through GAX. diff --git a/vision/google/cloud/vision/client.py b/vision/google/cloud/vision/client.py index 99a7664953ee..ff0d504b93ea 100644 --- a/vision/google/cloud/vision/client.py +++ b/vision/google/cloud/vision/client.py @@ -109,7 +109,8 @@ def _vision_api(self): """ if self._vision_api_internal is None: if self._use_gax: - self._vision_api_internal = _GAPICVisionAPI(self) + self._vision_api_internal = _GAPICVisionAPI(self, + credentials=None) else: self._vision_api_internal = _HTTPVisionAPI(self) return self._vision_api_internal diff --git a/vision/setup.py b/vision/setup.py index 7764d29668d2..cbd5dd4bad1c 100644 --- a/vision/setup.py +++ b/vision/setup.py @@ -52,12 +52,12 @@ REQUIREMENTS = [ 'enum34', 'google-cloud-core >= 0.23.0, < 0.24dev', - 'gapic-google-cloud-vision-v1 >= 0.14.0, < 0.15dev', + 'gapic-google-cloud-vision-v1 >= 0.15.0, < 0.16dev', ] setup( name='google-cloud-vision', - version='0.22.0', + version='0.23.0', description='Python Client for Google Cloud Vision', long_description=README, namespace_packages=[ diff --git a/vision/unit_tests/test__gax.py b/vision/unit_tests/test__gax.py index 31383936d0df..413896e6c3da 100644 --- a/vision/unit_tests/test__gax.py +++ b/vision/unit_tests/test__gax.py @@ -32,6 +32,28 @@ def test_ctor(self): api = self._make_one(client) self.assertIs(api._client, client) + def test_kwarg_lib_name(self): + from google.cloud.gapic.vision.v1.image_annotator_client import ( + ImageAnnotatorClient) + from google.cloud.vision import __version__ + + from .test_client import _make_credentials + + # Mock the GAPIC ImageAnnotatorClient, whose arguments we + # want to check. + with mock.patch.object(ImageAnnotatorClient, '__init__') as iac: + iac.return_value = None + + # Create the GAX client. + client = object() + self._make_one(client, credentials=_make_credentials()) + + # Assert that the GAPIC constructor was called once, and + # that lib_name and lib_version were sent. + iac.assert_called_once() + self.assertEqual(iac.mock_calls[0][2]['lib_name'], 'gccl') + self.assertEqual(iac.mock_calls[0][2]['lib_version'], __version__) + def test_annotation(self): from google.cloud.vision.feature import Feature from google.cloud.vision.feature import FeatureTypes From 1b230787e3a7f0fbfffa15adc68bbf073282ea67 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 10:21:40 -0800 Subject: [PATCH 2/9] Add a test for credential passthrough. --- vision/unit_tests/test__gax.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/vision/unit_tests/test__gax.py b/vision/unit_tests/test__gax.py index 413896e6c3da..66d0ba57de21 100644 --- a/vision/unit_tests/test__gax.py +++ b/vision/unit_tests/test__gax.py @@ -32,6 +32,26 @@ def test_ctor(self): api = self._make_one(client) self.assertIs(api._client, client) + def test_gapic_credentials(self): + from google.cloud.gapic.vision.v1.image_annotator_client import ( + ImageAnnotatorClient) + + from .test_client import _make_credentials + + # Mock the GAPIC ImageAnnotatorClient, whose arguments we + # want to check. + with mock.patch.object(ImageAnnotatorClient, '__init__') as iac: + iac.return_value = None + + # Create the GAX client. + credentials = _make_credentials() + self._make_one(client=object(), credentials=credentials) + + # Assert that the GAPIC constructor was called once, and + # that the credentials were sent. + iac.assert_called_once() + self.assertIs(iac.mock_calls[0][2]['credentials'], credentials) + def test_kwarg_lib_name(self): from google.cloud.gapic.vision.v1.image_annotator_client import ( ImageAnnotatorClient) @@ -45,8 +65,7 @@ def test_kwarg_lib_name(self): iac.return_value = None # Create the GAX client. - client = object() - self._make_one(client, credentials=_make_credentials()) + self._make_one(client=object(), credentials=_make_credentials()) # Assert that the GAPIC constructor was called once, and # that lib_name and lib_version were sent. From dafb0db6bdb972193ad6b9612becf9a3ebc62fa3 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 10:46:41 -0800 Subject: [PATCH 3/9] Style tweaks and using client._credentials. --- vision/google/cloud/vision/_gax.py | 5 +++-- vision/google/cloud/vision/client.py | 4 ++-- vision/unit_tests/test__gax.py | 31 +++++++++++++++++----------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/vision/google/cloud/vision/_gax.py b/vision/google/cloud/vision/_gax.py index 36f013ea46cb..3f041759fa9f 100644 --- a/vision/google/cloud/vision/_gax.py +++ b/vision/google/cloud/vision/_gax.py @@ -30,10 +30,11 @@ class _GAPICVisionAPI(object): :type kwargs: dict :param kwargs: Additional keyword arguments are sent to the GAPIC client. """ - def __init__(self, client=None, credentials=None): + def __init__(self, client=None): self._client = client self._annotator_client = image_annotator_client.ImageAnnotatorClient( - credentials=credentials, lib_name='gccl', lib_version=__version__) + credentials=client._credentials, lib_name='gccl', + lib_version=__version__) def annotate(self, images): """Annotate images through GAX. diff --git a/vision/google/cloud/vision/client.py b/vision/google/cloud/vision/client.py index ff0d504b93ea..9447682fce09 100644 --- a/vision/google/cloud/vision/client.py +++ b/vision/google/cloud/vision/client.py @@ -109,8 +109,8 @@ def _vision_api(self): """ if self._vision_api_internal is None: if self._use_gax: - self._vision_api_internal = _GAPICVisionAPI(self, - credentials=None) + self._vision_api_internal = _GAPICVisionAPI( + self, credentials=None) else: self._vision_api_internal = _HTTPVisionAPI(self) return self._vision_api_internal diff --git a/vision/unit_tests/test__gax.py b/vision/unit_tests/test__gax.py index 66d0ba57de21..2f02bcd90d20 100644 --- a/vision/unit_tests/test__gax.py +++ b/vision/unit_tests/test__gax.py @@ -17,6 +17,11 @@ import mock +def _make_credentials(): + import google.auth.credentials + return mock.Mock(spec=google.auth.credentials.Credentials) + + class TestGAXClient(unittest.TestCase): def _get_target_class(self): from google.cloud.vision._gax import _GAPICVisionAPI @@ -35,8 +40,7 @@ def test_ctor(self): def test_gapic_credentials(self): from google.cloud.gapic.vision.v1.image_annotator_client import ( ImageAnnotatorClient) - - from .test_client import _make_credentials + from google.cloud.vision import Client # Mock the GAPIC ImageAnnotatorClient, whose arguments we # want to check. @@ -45,19 +49,20 @@ def test_gapic_credentials(self): # Create the GAX client. credentials = _make_credentials() - self._make_one(client=object(), credentials=credentials) + client = Client(credentials=credentials) + self._make_one(client=client) # Assert that the GAPIC constructor was called once, and # that the credentials were sent. iac.assert_called_once() - self.assertIs(iac.mock_calls[0][2]['credentials'], credentials) + _, _, kwargs = iac.mock_calls[0] + self.assertIs(kwargs['credentials'], credentials) def test_kwarg_lib_name(self): from google.cloud.gapic.vision.v1.image_annotator_client import ( ImageAnnotatorClient) from google.cloud.vision import __version__ - - from .test_client import _make_credentials + from google.cloud.vision import Client # Mock the GAPIC ImageAnnotatorClient, whose arguments we # want to check. @@ -65,20 +70,22 @@ def test_kwarg_lib_name(self): iac.return_value = None # Create the GAX client. - self._make_one(client=object(), credentials=_make_credentials()) + client = Client(credentials=_make_credentials()) + self._make_one(client=client) # Assert that the GAPIC constructor was called once, and # that lib_name and lib_version were sent. iac.assert_called_once() - self.assertEqual(iac.mock_calls[0][2]['lib_name'], 'gccl') - self.assertEqual(iac.mock_calls[0][2]['lib_version'], __version__) + _, _, kwargs = iac.mock_calls[0] + self.assertEqual(kwargs['lib_name'], 'gccl') + self.assertEqual(kwargs['lib_version'], __version__) def test_annotation(self): from google.cloud.vision.feature import Feature from google.cloud.vision.feature import FeatureTypes from google.cloud.vision.image import Image - client = mock.Mock(spec_set=[]) + client = mock.Mock(spec_set=['_credentials']) feature = Feature(FeatureTypes.LABEL_DETECTION, 5) image_content = b'abc 1 2 3' image = Image(client, content=image_content) @@ -105,7 +112,7 @@ def test_annotate_no_results(self): from google.cloud.vision.feature import FeatureTypes from google.cloud.vision.image import Image - client = mock.Mock(spec_set=[]) + client = mock.Mock(spec_set=['_credentials']) feature = Feature(FeatureTypes.LABEL_DETECTION, 5) image_content = b'abc 1 2 3' image = Image(client, content=image_content) @@ -134,7 +141,7 @@ def test_annotate_multiple_results(self): from google.cloud.vision.feature import FeatureTypes from google.cloud.vision.image import Image - client = mock.Mock(spec_set=[]) + client = mock.Mock(spec_set=['_credentials']) feature = Feature(FeatureTypes.LABEL_DETECTION, 5) image_content = b'abc 1 2 3' image = Image(client, content=image_content) From 128d1c5a52d31b69caf97c97ee834fff820b5997 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 10:48:59 -0800 Subject: [PATCH 4/9] Change .grpc. to .proto. --- vision/google/cloud/vision/_gax.py | 6 +++--- vision/google/cloud/vision/annotations.py | 12 ++++++------ vision/google/cloud/vision/color.py | 4 ++-- vision/google/cloud/vision/entity.py | 2 +- vision/google/cloud/vision/face.py | 10 +++++----- vision/google/cloud/vision/geometry.py | 2 +- vision/google/cloud/vision/likelihood.py | 2 +- vision/google/cloud/vision/safe_search.py | 2 +- vision/unit_tests/test__gax.py | 8 ++++---- vision/unit_tests/test_annotations.py | 12 ++++++------ vision/unit_tests/test_color.py | 4 ++-- vision/unit_tests/test_entity.py | 2 +- vision/unit_tests/test_face.py | 6 +++--- vision/unit_tests/test_safe_search.py | 6 +++--- 14 files changed, 39 insertions(+), 39 deletions(-) diff --git a/vision/google/cloud/vision/_gax.py b/vision/google/cloud/vision/_gax.py index 3f041759fa9f..8246906412f5 100644 --- a/vision/google/cloud/vision/_gax.py +++ b/vision/google/cloud/vision/_gax.py @@ -15,7 +15,7 @@ """GAX Client for interacting with the Google Cloud Vision API.""" from google.cloud.gapic.vision.v1 import image_annotator_client -from google.cloud.grpc.vision.v1 import image_annotator_pb2 +from google.cloud.proto.vision.v1 import image_annotator_pb2 from google.cloud.vision import __version__ from google.cloud.vision.annotations import Annotations @@ -70,7 +70,7 @@ def _to_gapic_feature(feature): :param feature: Local ``Feature`` class to be converted to gRPC ``Feature`` instance. - :rtype: :class:`~google.cloud.grpc.vision.v1.image_annotator_pb2.Feature` + :rtype: :class:`~google.cloudvision.v1.image_annotator_pb2.Feature` :returns: gRPC ``Feature`` converted from :class:`~google.cloud.vision.feature.Feature`. """ @@ -85,7 +85,7 @@ def _to_gapic_image(image): :type image: :class:`~google.cloud.vision.image.Image` :param image: Local ``Image`` class to be converted to gRPC ``Image``. - :rtype: :class:`~google.cloud.grpc.vision.v1.image_annotator_pb2.Image` + :rtype: :class:`~google.cloudvision.v1.image_annotator_pb2.Image` :returns: gRPC ``Image`` converted from :class:`~google.cloud.vision.image.Image`. """ diff --git a/vision/google/cloud/vision/annotations.py b/vision/google/cloud/vision/annotations.py index 2348d2361731..eb32230b6f3c 100644 --- a/vision/google/cloud/vision/annotations.py +++ b/vision/google/cloud/vision/annotations.py @@ -99,7 +99,7 @@ def from_api_repr(cls, response): def from_pb(cls, response): """Factory: construct an instance of ``Annotations`` from protobuf. - :type response: :class:`~google.cloud.grpc.vision.v1.\ + :type response: :class:`~google.cloudvision.v1.\ image_annotator_pb2.AnnotateImageResponse` :param response: ``AnnotateImageResponse`` from protobuf call. @@ -113,7 +113,7 @@ def from_pb(cls, response): def _process_image_annotations(image): """Helper for processing annotation types from protobuf. - :type image: :class:`~google.cloud.grpc.vision.v1.image_annotator_pb2.\ + :type image: :class:`~google.cloudvision.v1.image_annotator_pb2.\ AnnotateImageResponse` :param image: ``AnnotateImageResponse`` from protobuf. @@ -137,7 +137,7 @@ def _make_entity_from_pb(annotations): """Create an entity from a protobuf response. :type annotations: - :class:`~google.cloud.grpc.vision.v1.image_annotator_pb2.EntityAnnotation` + :class:`~google.cloudvision.v1.image_annotator_pb2.EntityAnnotation` :param annotations: protobuf instance of ``EntityAnnotation``. :rtype: list @@ -150,7 +150,7 @@ def _make_faces_from_pb(faces): """Create face objects from a protobuf response. :type faces: - :class:`~google.cloud.grpc.vision.v1.image_annotator_pb2.FaceAnnotation` + :class:`~google.cloudvision.v1.image_annotator_pb2.FaceAnnotation` :param faces: Protobuf instance of ``FaceAnnotation``. :rtype: list @@ -162,7 +162,7 @@ def _make_faces_from_pb(faces): def _make_image_properties_from_pb(image_properties): """Create ``ImageProperties`` object from a protobuf response. - :type image_properties: :class:`~google.cloud.grpc.vision.v1.\ + :type image_properties: :class:`~google.cloudvision.v1.\ image_annotator_pb2.ImagePropertiesAnnotation` :param image_properties: Protobuf instance of ``ImagePropertiesAnnotation``. @@ -176,7 +176,7 @@ def _make_image_properties_from_pb(image_properties): def _make_safe_search_from_pb(safe_search): """Create ``SafeSearchAnnotation`` object from a protobuf response. - :type safe_search: :class:`~google.cloud.grpc.vision.v1.\ + :type safe_search: :class:`~google.cloudvision.v1.\ image_annotator_pb2.SafeSearchAnnotation` :param safe_search: Protobuf instance of ``SafeSearchAnnotation``. diff --git a/vision/google/cloud/vision/color.py b/vision/google/cloud/vision/color.py index 634842567525..b5f4acff0b9b 100644 --- a/vision/google/cloud/vision/color.py +++ b/vision/google/cloud/vision/color.py @@ -45,7 +45,7 @@ def from_api_repr(cls, image_properties): def from_pb(cls, image_properties): """Factory: construct ``ImagePropertiesAnnotation`` from a response. - :type image_properties: :class:`~google.cloud.grpc.vision.v1.\ + :type image_properties: :class:`~google.cloudvision.v1.\ image_annotator_pb2.ImageProperties` :param image_properties: Protobuf response from Vision API with image properties data. @@ -196,7 +196,7 @@ def from_api_repr(cls, color_information): def from_pb(cls, color_information): """Factory: construct ``ColorInformation`` for a color. - :type color_information: :class:`~google.cloud.grpc.vision.v1.\ + :type color_information: :class:`~google.cloudvision.v1.\ image_annotator_pb2.ColorInfo` :param color_information: Color data with extra meta information. diff --git a/vision/google/cloud/vision/entity.py b/vision/google/cloud/vision/entity.py index 774c220732d6..1b465f71ef09 100644 --- a/vision/google/cloud/vision/entity.py +++ b/vision/google/cloud/vision/entity.py @@ -74,7 +74,7 @@ def from_api_repr(cls, response): def from_pb(cls, response): """Factory: construct entity from Vision gRPC response. - :type response: :class:`~google.cloud.grpc.vision.v1.\ + :type response: :class:`~google.cloudvision.v1.\ image_annotator_pb2.AnnotateImageResponse` :param response: gRPC response from Vision API with entity data. diff --git a/vision/google/cloud/vision/face.py b/vision/google/cloud/vision/face.py index 354ff08d59ce..193291e34679 100644 --- a/vision/google/cloud/vision/face.py +++ b/vision/google/cloud/vision/face.py @@ -50,7 +50,7 @@ def from_api_repr(cls, angle): def from_pb(cls, angle): """Factory: convert protobuf Angle object to local Angle object. - :type angle: :class:`~google.cloud.grpc.vision.v1.\ + :type angle: :class:`~google.cloudvision.v1.\ image_annotator_pb2.FaceAnnotation` :param angle: Protobuf ``FaceAnnotation`` response with angle data. @@ -126,7 +126,7 @@ def from_api_repr(cls, emotions): def from_pb(cls, emotions): """Factory: construct ``Emotions`` from Vision API response. - :type emotions: :class:`~google.cloud.grpc.vision.v1.\ + :type emotions: :class:`~google.cloudvision.v1.\ image_annotator_pb2.FaceAnnotation` :param emotions: Response dictionary representing a face with emotions. @@ -225,7 +225,7 @@ def from_api_repr(cls, face): def from_pb(cls, face): """Factory: construct an instance of a Face from an protobuf response - :type face: :class:`~google.cloud.grpc.vision.v1.\ + :type face: :class:`~google.cloudvision.v1.\ image_annotator_pb2.AnnotateImageResponse` :param face: ``AnnotateImageResponse`` from gRPC call. @@ -397,7 +397,7 @@ def from_api_repr(cls, face): def from_pb(cls, face): """Factory: construct image properties from image. - :type face: :class:`~google.cloud.grpc.vision.v1.image_annotator_pb2.\ + :type face: :class:`~google.cloudvision.v1.image_annotator_pb2.\ FaceAnnotation` :param face: Protobuf instace of `Face`. @@ -508,7 +508,7 @@ def from_api_repr(cls, landmark): def from_pb(cls, landmark): """Factory: construct an instance of a Landmark from a response. - :type landmark: :class:`~google.cloud.grpc.vision.v1.\ + :type landmark: :class:`~google.cloudvision.v1.\ image_annotator_pb.FaceAnnotation.Landmark` :param landmark: Landmark representation from Vision API. diff --git a/vision/google/cloud/vision/geometry.py b/vision/google/cloud/vision/geometry.py index 39b429a32ed8..7a800360c051 100644 --- a/vision/google/cloud/vision/geometry.py +++ b/vision/google/cloud/vision/geometry.py @@ -43,7 +43,7 @@ def from_api_repr(cls, vertices): def from_pb(cls, vertices): """Factory: construct BoundsBase instance from a protobuf response. - :type vertices: :class:`~google.cloud.grpc.vision.v1.\ + :type vertices: :class:`~google.cloudvision.v1.\ geometry_pb2.BoundingPoly` :param vertices: List of vertices. diff --git a/vision/google/cloud/vision/likelihood.py b/vision/google/cloud/vision/likelihood.py index fd249e41dff1..ed7ba8c764db 100644 --- a/vision/google/cloud/vision/likelihood.py +++ b/vision/google/cloud/vision/likelihood.py @@ -17,7 +17,7 @@ from enum import Enum -from google.cloud.grpc.vision.v1 import image_annotator_pb2 +from google.cloudvision.v1 import image_annotator_pb2 def _get_pb_likelihood(likelihood): diff --git a/vision/google/cloud/vision/safe_search.py b/vision/google/cloud/vision/safe_search.py index 9b531837db8c..02ae47dfc133 100644 --- a/vision/google/cloud/vision/safe_search.py +++ b/vision/google/cloud/vision/safe_search.py @@ -66,7 +66,7 @@ def from_api_repr(cls, response): def from_pb(cls, image): """Factory: construct SafeSearchAnnotation from Vision API response. - :type image: :class:`~google.cloud.grpc.vision.v1.image_annotator_pb2.\ + :type image: :class:`~google.cloudvision.v1.image_annotator_pb2.\ SafeSearchAnnotation` :param image: Protobuf response from Vision API with safe search data. diff --git a/vision/unit_tests/test__gax.py b/vision/unit_tests/test__gax.py index 2f02bcd90d20..b1dc9b55fd76 100644 --- a/vision/unit_tests/test__gax.py +++ b/vision/unit_tests/test__gax.py @@ -135,7 +135,7 @@ def test_annotate_no_results(self): gax_api._annotator_client.batch_annotate_images.assert_called() def test_annotate_multiple_results(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 from google.cloud.vision.annotations import Annotations from google.cloud.vision.feature import Feature from google.cloud.vision.feature import FeatureTypes @@ -176,7 +176,7 @@ def _call_fut(self, feature): def test__to_gapic_feature(self): from google.cloud.vision.feature import Feature from google.cloud.vision.feature import FeatureTypes - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 feature = Feature(FeatureTypes.LABEL_DETECTION, 5) feature_pb = self._call_fut(feature) @@ -192,7 +192,7 @@ def _call_fut(self, image): def test__to_gapic_image_content(self): from google.cloud.vision.image import Image - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 image_content = b'abc 1 2 3' client = object() @@ -203,7 +203,7 @@ def test__to_gapic_image_content(self): def test__to_gapic_image_uri(self): from google.cloud.vision.image import Image - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 image_uri = 'gs://1234/34.jpg' client = object() diff --git a/vision/unit_tests/test_annotations.py b/vision/unit_tests/test_annotations.py index 41408a17b88c..da160b325e4d 100644 --- a/vision/unit_tests/test_annotations.py +++ b/vision/unit_tests/test_annotations.py @@ -16,8 +16,8 @@ def _make_pb_entity(): - from google.cloud.grpc.vision.v1 import geometry_pb2 - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import geometry_pb2 + from google.cloudvision.v1 import image_annotator_pb2 from google.type import latlng_pb2 description = 'testing 1 2 3' @@ -78,7 +78,7 @@ def test_unsupported_http_annotation(self): def test_from_pb(self): from google.cloud.vision.likelihood import Likelihood from google.cloud.vision.safe_search import SafeSearchAnnotation - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 image_response = image_annotator_pb2.AnnotateImageResponse() annotations = self._make_one().from_pb(image_response) @@ -131,7 +131,7 @@ def _call_fut(self, annotations): return _make_faces_from_pb(annotations) def test_it(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 from google.cloud.vision.face import Face faces_pb = [image_annotator_pb2.FaceAnnotation()] @@ -147,7 +147,7 @@ def _call_fut(self, annotations): return _make_image_properties_from_pb(annotations) def test_it(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 from google.protobuf.wrappers_pb2 import FloatValue from google.type.color_pb2 import Color @@ -178,7 +178,7 @@ def _call_fut(self, image): return _process_image_annotations(image) def test_it(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 description = 'testing 1 2 3' locale = 'US' diff --git a/vision/unit_tests/test_color.py b/vision/unit_tests/test_color.py index 9a9055dac7d2..7689386ef74d 100644 --- a/vision/unit_tests/test_color.py +++ b/vision/unit_tests/test_color.py @@ -95,7 +95,7 @@ def _get_target_class(): return ImagePropertiesAnnotation def test_image_properties_annotation_from_pb(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 from google.protobuf.wrappers_pb2 import FloatValue from google.type.color_pb2 import Color @@ -121,7 +121,7 @@ def test_image_properties_annotation_from_pb(self): self.assertEqual(image_properties.colors[0].color.alpha, 1.0) def test_empty_image_properties_annotation_from_pb(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 image_properties_pb = image_annotator_pb2.ImageProperties() diff --git a/vision/unit_tests/test_entity.py b/vision/unit_tests/test_entity.py index 00d7cd5b4d33..e97731433a91 100644 --- a/vision/unit_tests/test_entity.py +++ b/vision/unit_tests/test_entity.py @@ -34,7 +34,7 @@ def test_logo_annotation(self): self.assertEqual(162, logo.bounds.vertices[0].y_coordinate) def test_logo_pb_annotation(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 description = 'testing 1 2 3' locale = 'US' diff --git a/vision/unit_tests/test_face.py b/vision/unit_tests/test_face.py index 801479bccc44..672d68074ef0 100644 --- a/vision/unit_tests/test_face.py +++ b/vision/unit_tests/test_face.py @@ -22,7 +22,7 @@ def _get_target_class(): return Face def _make_face_pb(self, *args, **kwargs): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 return image_annotator_pb2.FaceAnnotation(*args, **kwargs) @@ -34,8 +34,8 @@ def setUp(self): self.FACE_ANNOTATIONS['faceAnnotations'][0]) def test_face_from_pb(self): - from google.cloud.grpc.vision.v1 import image_annotator_pb2 - from google.cloud.grpc.vision.v1 import geometry_pb2 + from google.cloudvision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import geometry_pb2 position_pb = geometry_pb2.Position(x=1.0, y=2.0, z=3.0) landmark_pb = image_annotator_pb2.FaceAnnotation.Landmark( diff --git a/vision/unit_tests/test_safe_search.py b/vision/unit_tests/test_safe_search.py index 5bc06ac47c52..5c67761c301f 100644 --- a/vision/unit_tests/test_safe_search.py +++ b/vision/unit_tests/test_safe_search.py @@ -38,9 +38,9 @@ def test_safe_search_annotation(self): def test_pb_safe_search_annotation(self): from google.cloud.vision.likelihood import Likelihood - from google.cloud.grpc.vision.v1.image_annotator_pb2 import ( + from google.cloudvision.v1.image_annotator_pb2 import ( Likelihood as LikelihoodPB) - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 possible = LikelihoodPB.Value('POSSIBLE') possible_name = Likelihood.POSSIBLE @@ -57,7 +57,7 @@ def test_pb_safe_search_annotation(self): def test_empty_pb_safe_search_annotation(self): from google.cloud.vision.likelihood import Likelihood - from google.cloud.grpc.vision.v1 import image_annotator_pb2 + from google.cloudvision.v1 import image_annotator_pb2 unknown = Likelihood.UNKNOWN safe_search_annotation = image_annotator_pb2.SafeSearchAnnotation() From 410887e90cfc3b4e7936c7453b10e704d790fd7d Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 11:23:13 -0800 Subject: [PATCH 5/9] Additional fixes. --- vision/google/cloud/vision/_gax.py | 2 +- vision/google/cloud/vision/client.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/vision/google/cloud/vision/_gax.py b/vision/google/cloud/vision/_gax.py index 8246906412f5..a105e432d5f4 100644 --- a/vision/google/cloud/vision/_gax.py +++ b/vision/google/cloud/vision/_gax.py @@ -70,7 +70,7 @@ def _to_gapic_feature(feature): :param feature: Local ``Feature`` class to be converted to gRPC ``Feature`` instance. - :rtype: :class:`~google.cloudvision.v1.image_annotator_pb2.Feature` + :rtype: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.Feature` :returns: gRPC ``Feature`` converted from :class:`~google.cloud.vision.feature.Feature`. """ diff --git a/vision/google/cloud/vision/client.py b/vision/google/cloud/vision/client.py index 9447682fce09..99a7664953ee 100644 --- a/vision/google/cloud/vision/client.py +++ b/vision/google/cloud/vision/client.py @@ -109,8 +109,7 @@ def _vision_api(self): """ if self._vision_api_internal is None: if self._use_gax: - self._vision_api_internal = _GAPICVisionAPI( - self, credentials=None) + self._vision_api_internal = _GAPICVisionAPI(self) else: self._vision_api_internal = _HTTPVisionAPI(self) return self._vision_api_internal From ee2bd3c99596495f0728479ed1bd1ef27bb6a9b8 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 11:24:22 -0800 Subject: [PATCH 6/9] Fix find/replace error. --- vision/google/cloud/vision/_gax.py | 2 +- vision/google/cloud/vision/annotations.py | 12 ++++++------ vision/google/cloud/vision/color.py | 4 ++-- vision/google/cloud/vision/entity.py | 2 +- vision/google/cloud/vision/face.py | 10 +++++----- vision/google/cloud/vision/geometry.py | 2 +- vision/google/cloud/vision/likelihood.py | 2 +- vision/google/cloud/vision/safe_search.py | 2 +- vision/unit_tests/test__gax.py | 8 ++++---- vision/unit_tests/test_annotations.py | 12 ++++++------ vision/unit_tests/test_color.py | 4 ++-- vision/unit_tests/test_entity.py | 2 +- vision/unit_tests/test_face.py | 6 +++--- vision/unit_tests/test_safe_search.py | 6 +++--- 14 files changed, 37 insertions(+), 37 deletions(-) diff --git a/vision/google/cloud/vision/_gax.py b/vision/google/cloud/vision/_gax.py index a105e432d5f4..3d562ef5949c 100644 --- a/vision/google/cloud/vision/_gax.py +++ b/vision/google/cloud/vision/_gax.py @@ -85,7 +85,7 @@ def _to_gapic_image(image): :type image: :class:`~google.cloud.vision.image.Image` :param image: Local ``Image`` class to be converted to gRPC ``Image``. - :rtype: :class:`~google.cloudvision.v1.image_annotator_pb2.Image` + :rtype: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.Image` :returns: gRPC ``Image`` converted from :class:`~google.cloud.vision.image.Image`. """ diff --git a/vision/google/cloud/vision/annotations.py b/vision/google/cloud/vision/annotations.py index eb32230b6f3c..053bb26d6f68 100644 --- a/vision/google/cloud/vision/annotations.py +++ b/vision/google/cloud/vision/annotations.py @@ -99,7 +99,7 @@ def from_api_repr(cls, response): def from_pb(cls, response): """Factory: construct an instance of ``Annotations`` from protobuf. - :type response: :class:`~google.cloudvision.v1.\ + :type response: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.AnnotateImageResponse` :param response: ``AnnotateImageResponse`` from protobuf call. @@ -113,7 +113,7 @@ def from_pb(cls, response): def _process_image_annotations(image): """Helper for processing annotation types from protobuf. - :type image: :class:`~google.cloudvision.v1.image_annotator_pb2.\ + :type image: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.\ AnnotateImageResponse` :param image: ``AnnotateImageResponse`` from protobuf. @@ -137,7 +137,7 @@ def _make_entity_from_pb(annotations): """Create an entity from a protobuf response. :type annotations: - :class:`~google.cloudvision.v1.image_annotator_pb2.EntityAnnotation` + :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.EntityAnnotation` :param annotations: protobuf instance of ``EntityAnnotation``. :rtype: list @@ -150,7 +150,7 @@ def _make_faces_from_pb(faces): """Create face objects from a protobuf response. :type faces: - :class:`~google.cloudvision.v1.image_annotator_pb2.FaceAnnotation` + :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.FaceAnnotation` :param faces: Protobuf instance of ``FaceAnnotation``. :rtype: list @@ -162,7 +162,7 @@ def _make_faces_from_pb(faces): def _make_image_properties_from_pb(image_properties): """Create ``ImageProperties`` object from a protobuf response. - :type image_properties: :class:`~google.cloudvision.v1.\ + :type image_properties: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.ImagePropertiesAnnotation` :param image_properties: Protobuf instance of ``ImagePropertiesAnnotation``. @@ -176,7 +176,7 @@ def _make_image_properties_from_pb(image_properties): def _make_safe_search_from_pb(safe_search): """Create ``SafeSearchAnnotation`` object from a protobuf response. - :type safe_search: :class:`~google.cloudvision.v1.\ + :type safe_search: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.SafeSearchAnnotation` :param safe_search: Protobuf instance of ``SafeSearchAnnotation``. diff --git a/vision/google/cloud/vision/color.py b/vision/google/cloud/vision/color.py index b5f4acff0b9b..205b8f3b1ba6 100644 --- a/vision/google/cloud/vision/color.py +++ b/vision/google/cloud/vision/color.py @@ -45,7 +45,7 @@ def from_api_repr(cls, image_properties): def from_pb(cls, image_properties): """Factory: construct ``ImagePropertiesAnnotation`` from a response. - :type image_properties: :class:`~google.cloudvision.v1.\ + :type image_properties: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.ImageProperties` :param image_properties: Protobuf response from Vision API with image properties data. @@ -196,7 +196,7 @@ def from_api_repr(cls, color_information): def from_pb(cls, color_information): """Factory: construct ``ColorInformation`` for a color. - :type color_information: :class:`~google.cloudvision.v1.\ + :type color_information: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.ColorInfo` :param color_information: Color data with extra meta information. diff --git a/vision/google/cloud/vision/entity.py b/vision/google/cloud/vision/entity.py index 1b465f71ef09..5d1e402b362a 100644 --- a/vision/google/cloud/vision/entity.py +++ b/vision/google/cloud/vision/entity.py @@ -74,7 +74,7 @@ def from_api_repr(cls, response): def from_pb(cls, response): """Factory: construct entity from Vision gRPC response. - :type response: :class:`~google.cloudvision.v1.\ + :type response: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.AnnotateImageResponse` :param response: gRPC response from Vision API with entity data. diff --git a/vision/google/cloud/vision/face.py b/vision/google/cloud/vision/face.py index 193291e34679..cdb744c97cb5 100644 --- a/vision/google/cloud/vision/face.py +++ b/vision/google/cloud/vision/face.py @@ -50,7 +50,7 @@ def from_api_repr(cls, angle): def from_pb(cls, angle): """Factory: convert protobuf Angle object to local Angle object. - :type angle: :class:`~google.cloudvision.v1.\ + :type angle: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.FaceAnnotation` :param angle: Protobuf ``FaceAnnotation`` response with angle data. @@ -126,7 +126,7 @@ def from_api_repr(cls, emotions): def from_pb(cls, emotions): """Factory: construct ``Emotions`` from Vision API response. - :type emotions: :class:`~google.cloudvision.v1.\ + :type emotions: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.FaceAnnotation` :param emotions: Response dictionary representing a face with emotions. @@ -225,7 +225,7 @@ def from_api_repr(cls, face): def from_pb(cls, face): """Factory: construct an instance of a Face from an protobuf response - :type face: :class:`~google.cloudvision.v1.\ + :type face: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb2.AnnotateImageResponse` :param face: ``AnnotateImageResponse`` from gRPC call. @@ -397,7 +397,7 @@ def from_api_repr(cls, face): def from_pb(cls, face): """Factory: construct image properties from image. - :type face: :class:`~google.cloudvision.v1.image_annotator_pb2.\ + :type face: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.\ FaceAnnotation` :param face: Protobuf instace of `Face`. @@ -508,7 +508,7 @@ def from_api_repr(cls, landmark): def from_pb(cls, landmark): """Factory: construct an instance of a Landmark from a response. - :type landmark: :class:`~google.cloudvision.v1.\ + :type landmark: :class:`~google.cloud.proto.vision.v1.\ image_annotator_pb.FaceAnnotation.Landmark` :param landmark: Landmark representation from Vision API. diff --git a/vision/google/cloud/vision/geometry.py b/vision/google/cloud/vision/geometry.py index 7a800360c051..b9cc2a2dd6e2 100644 --- a/vision/google/cloud/vision/geometry.py +++ b/vision/google/cloud/vision/geometry.py @@ -43,7 +43,7 @@ def from_api_repr(cls, vertices): def from_pb(cls, vertices): """Factory: construct BoundsBase instance from a protobuf response. - :type vertices: :class:`~google.cloudvision.v1.\ + :type vertices: :class:`~google.cloud.proto.vision.v1.\ geometry_pb2.BoundingPoly` :param vertices: List of vertices. diff --git a/vision/google/cloud/vision/likelihood.py b/vision/google/cloud/vision/likelihood.py index ed7ba8c764db..a83b2991f2bb 100644 --- a/vision/google/cloud/vision/likelihood.py +++ b/vision/google/cloud/vision/likelihood.py @@ -17,7 +17,7 @@ from enum import Enum -from google.cloudvision.v1 import image_annotator_pb2 +from google.cloud.proto.vision.v1 import image_annotator_pb2 def _get_pb_likelihood(likelihood): diff --git a/vision/google/cloud/vision/safe_search.py b/vision/google/cloud/vision/safe_search.py index 02ae47dfc133..f3ba042bdad4 100644 --- a/vision/google/cloud/vision/safe_search.py +++ b/vision/google/cloud/vision/safe_search.py @@ -66,7 +66,7 @@ def from_api_repr(cls, response): def from_pb(cls, image): """Factory: construct SafeSearchAnnotation from Vision API response. - :type image: :class:`~google.cloudvision.v1.image_annotator_pb2.\ + :type image: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.\ SafeSearchAnnotation` :param image: Protobuf response from Vision API with safe search data. diff --git a/vision/unit_tests/test__gax.py b/vision/unit_tests/test__gax.py index b1dc9b55fd76..42ca4245219a 100644 --- a/vision/unit_tests/test__gax.py +++ b/vision/unit_tests/test__gax.py @@ -135,7 +135,7 @@ def test_annotate_no_results(self): gax_api._annotator_client.batch_annotate_images.assert_called() def test_annotate_multiple_results(self): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 from google.cloud.vision.annotations import Annotations from google.cloud.vision.feature import Feature from google.cloud.vision.feature import FeatureTypes @@ -176,7 +176,7 @@ def _call_fut(self, feature): def test__to_gapic_feature(self): from google.cloud.vision.feature import Feature from google.cloud.vision.feature import FeatureTypes - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 feature = Feature(FeatureTypes.LABEL_DETECTION, 5) feature_pb = self._call_fut(feature) @@ -192,7 +192,7 @@ def _call_fut(self, image): def test__to_gapic_image_content(self): from google.cloud.vision.image import Image - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 image_content = b'abc 1 2 3' client = object() @@ -203,7 +203,7 @@ def test__to_gapic_image_content(self): def test__to_gapic_image_uri(self): from google.cloud.vision.image import Image - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 image_uri = 'gs://1234/34.jpg' client = object() diff --git a/vision/unit_tests/test_annotations.py b/vision/unit_tests/test_annotations.py index da160b325e4d..56be200bfd33 100644 --- a/vision/unit_tests/test_annotations.py +++ b/vision/unit_tests/test_annotations.py @@ -16,8 +16,8 @@ def _make_pb_entity(): - from google.cloudvision.v1 import geometry_pb2 - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import geometry_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 from google.type import latlng_pb2 description = 'testing 1 2 3' @@ -78,7 +78,7 @@ def test_unsupported_http_annotation(self): def test_from_pb(self): from google.cloud.vision.likelihood import Likelihood from google.cloud.vision.safe_search import SafeSearchAnnotation - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 image_response = image_annotator_pb2.AnnotateImageResponse() annotations = self._make_one().from_pb(image_response) @@ -131,7 +131,7 @@ def _call_fut(self, annotations): return _make_faces_from_pb(annotations) def test_it(self): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 from google.cloud.vision.face import Face faces_pb = [image_annotator_pb2.FaceAnnotation()] @@ -147,7 +147,7 @@ def _call_fut(self, annotations): return _make_image_properties_from_pb(annotations) def test_it(self): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 from google.protobuf.wrappers_pb2 import FloatValue from google.type.color_pb2 import Color @@ -178,7 +178,7 @@ def _call_fut(self, image): return _process_image_annotations(image) def test_it(self): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 description = 'testing 1 2 3' locale = 'US' diff --git a/vision/unit_tests/test_color.py b/vision/unit_tests/test_color.py index 7689386ef74d..6421fd5d3423 100644 --- a/vision/unit_tests/test_color.py +++ b/vision/unit_tests/test_color.py @@ -95,7 +95,7 @@ def _get_target_class(): return ImagePropertiesAnnotation def test_image_properties_annotation_from_pb(self): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 from google.protobuf.wrappers_pb2 import FloatValue from google.type.color_pb2 import Color @@ -121,7 +121,7 @@ def test_image_properties_annotation_from_pb(self): self.assertEqual(image_properties.colors[0].color.alpha, 1.0) def test_empty_image_properties_annotation_from_pb(self): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 image_properties_pb = image_annotator_pb2.ImageProperties() diff --git a/vision/unit_tests/test_entity.py b/vision/unit_tests/test_entity.py index e97731433a91..b812bb0b0682 100644 --- a/vision/unit_tests/test_entity.py +++ b/vision/unit_tests/test_entity.py @@ -34,7 +34,7 @@ def test_logo_annotation(self): self.assertEqual(162, logo.bounds.vertices[0].y_coordinate) def test_logo_pb_annotation(self): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 description = 'testing 1 2 3' locale = 'US' diff --git a/vision/unit_tests/test_face.py b/vision/unit_tests/test_face.py index 672d68074ef0..55814e0cad15 100644 --- a/vision/unit_tests/test_face.py +++ b/vision/unit_tests/test_face.py @@ -22,7 +22,7 @@ def _get_target_class(): return Face def _make_face_pb(self, *args, **kwargs): - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 return image_annotator_pb2.FaceAnnotation(*args, **kwargs) @@ -34,8 +34,8 @@ def setUp(self): self.FACE_ANNOTATIONS['faceAnnotations'][0]) def test_face_from_pb(self): - from google.cloudvision.v1 import image_annotator_pb2 - from google.cloudvision.v1 import geometry_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import geometry_pb2 position_pb = geometry_pb2.Position(x=1.0, y=2.0, z=3.0) landmark_pb = image_annotator_pb2.FaceAnnotation.Landmark( diff --git a/vision/unit_tests/test_safe_search.py b/vision/unit_tests/test_safe_search.py index 5c67761c301f..b2ee7593e87b 100644 --- a/vision/unit_tests/test_safe_search.py +++ b/vision/unit_tests/test_safe_search.py @@ -38,9 +38,9 @@ def test_safe_search_annotation(self): def test_pb_safe_search_annotation(self): from google.cloud.vision.likelihood import Likelihood - from google.cloudvision.v1.image_annotator_pb2 import ( + from google.cloud.proto.vision.v1.image_annotator_pb2 import ( Likelihood as LikelihoodPB) - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 possible = LikelihoodPB.Value('POSSIBLE') possible_name = Likelihood.POSSIBLE @@ -57,7 +57,7 @@ def test_pb_safe_search_annotation(self): def test_empty_pb_safe_search_annotation(self): from google.cloud.vision.likelihood import Likelihood - from google.cloudvision.v1 import image_annotator_pb2 + from google.cloud.proto.vision.v1 import image_annotator_pb2 unknown = Likelihood.UNKNOWN safe_search_annotation = image_annotator_pb2.SafeSearchAnnotation() From 5290d6bfbca51eb8148282cacbab321a0a269b73 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 14:04:24 -0800 Subject: [PATCH 7/9] Explicitly set project. --- vision/unit_tests/test__gax.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vision/unit_tests/test__gax.py b/vision/unit_tests/test__gax.py index 42ca4245219a..1a97778bfc1b 100644 --- a/vision/unit_tests/test__gax.py +++ b/vision/unit_tests/test__gax.py @@ -49,7 +49,7 @@ def test_gapic_credentials(self): # Create the GAX client. credentials = _make_credentials() - client = Client(credentials=credentials) + client = Client(credentials=credentials, project='foo') self._make_one(client=client) # Assert that the GAPIC constructor was called once, and @@ -70,7 +70,7 @@ def test_kwarg_lib_name(self): iac.return_value = None # Create the GAX client. - client = Client(credentials=_make_credentials()) + client = Client(credentials=_make_credentials(), project='foo') self._make_one(client=client) # Assert that the GAPIC constructor was called once, and From 241f7613bfd7b40c9ba4755c287495dae8686247 Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 14:51:50 -0800 Subject: [PATCH 8/9] Fix doc/lint issue. --- vision/google/cloud/vision/safe_search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vision/google/cloud/vision/safe_search.py b/vision/google/cloud/vision/safe_search.py index f3ba042bdad4..d439d9ed6015 100644 --- a/vision/google/cloud/vision/safe_search.py +++ b/vision/google/cloud/vision/safe_search.py @@ -66,8 +66,8 @@ def from_api_repr(cls, response): def from_pb(cls, image): """Factory: construct SafeSearchAnnotation from Vision API response. - :type image: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.\ - SafeSearchAnnotation` + :type image: :class:`~google.cloud.proto.vision.v1.\ + image_annotator_pb2.SafeSearchAnnotation` :param image: Protobuf response from Vision API with safe search data. :rtype: :class:`~google.cloud.vision.safe_search.SafeSearchAnnotation` From 73b3b492d4d3e19e53fcb638e02a8c355aa168eb Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Wed, 22 Feb 2017 14:55:59 -0800 Subject: [PATCH 9/9] Remove errant **kwargs documentation. --- vision/google/cloud/vision/_gax.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/vision/google/cloud/vision/_gax.py b/vision/google/cloud/vision/_gax.py index 3d562ef5949c..d738288b5aca 100644 --- a/vision/google/cloud/vision/_gax.py +++ b/vision/google/cloud/vision/_gax.py @@ -26,9 +26,6 @@ class _GAPICVisionAPI(object): :type client: :class:`~google.cloud.vision.client.Client` :param client: Instance of ``Client`` object. - - :type kwargs: dict - :param kwargs: Additional keyword arguments are sent to the GAPIC client. """ def __init__(self, client=None): self._client = client