Skip to content

Commit

Permalink
Vision code re-organization (#3952)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer authored Sep 15, 2017
1 parent 6cddf11 commit 3100238
Show file tree
Hide file tree
Showing 51 changed files with 318 additions and 293 deletions.
3 changes: 3 additions & 0 deletions packages/google-cloud-vision/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[run]
branch = True
omit =
google/cloud/vision_v1/gapic/*.py
google/cloud/vision_v1/proto/*.py

[report]
fail_under = 100
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 4 additions & 1 deletion packages/google-cloud-vision/google/cloud/vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
__version__ = get_distribution('google-cloud-vision').version

from google.cloud.vision.client import Client
from google.cloud.vision_v1 import * # noqa

from google.cloud.vision_v1 import enums
from google.cloud.vision_v1 import ImageAnnotatorClient
from google.cloud.vision_v1 import types


__all__ = (
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-vision/google/cloud/vision/_gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

"""GAX Client for interacting with the Google Cloud Vision API."""

from google.cloud.gapic.vision.v1 import image_annotator_client
from google.cloud.proto.vision.v1 import image_annotator_pb2
from google.cloud.vision_v1.gapic import image_annotator_client
from google.cloud.vision_v1.proto import image_annotator_pb2

from google.cloud.vision import __version__
from google.cloud.vision.annotations import Annotations
Expand Down Expand Up @@ -43,7 +43,7 @@ def annotate(self, images=None, requests_pb=None):
e.g. [(image, [feature_one, feature_two]),]
:type requests_pb: list
:param requests_pb: List of :class:`google.cloud.proto.vision.v1.\
:param requests_pb: List of :class:`google.cloud.vision_v1.proto.\
image_annotator_pb2.AnnotateImageRequest`
:rtype: list
Expand Down Expand Up @@ -77,7 +77,7 @@ def _to_gapic_feature(feature):
:param feature: Local ``Feature`` class to be converted to gRPC ``Feature``
instance.
:rtype: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.Feature`
:rtype: :class:`~google.cloud.vision_v1.proto.image_annotator_pb2.Feature`
:returns: gRPC ``Feature`` converted from
:class:`~google.cloud.vision.feature.Feature`.
"""
Expand All @@ -92,7 +92,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.proto.vision.v1.image_annotator_pb2.Image`
:rtype: :class:`~google.cloud.vision_v1.proto.image_annotator_pb2.Image`
:returns: gRPC ``Image`` converted from
:class:`~google.cloud.vision.image.Image`.
"""
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-vision/google/cloud/vision/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def annotate(self, images=None, requests_pb=None):
:returns: List of :class:`~googe.cloud.vision.annotations.Annotations`.
:type requests_pb: list
:param requests_pb: List of :class:`google.cloud.proto.vision.v1.\
:param requests_pb: List of :class:`google.cloud.vision_v1.proto.\
image_annotator_b2.AnnotateImageRequest`.
:rtype: list
Expand Down
16 changes: 8 additions & 8 deletions packages/google-cloud-vision/google/cloud/vision/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,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.proto.vision.v1.\
:type response: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.AnnotateImageResponse`
:param response: ``AnnotateImageResponse`` from protobuf call.
Expand All @@ -138,7 +138,7 @@ def from_pb(cls, response):
def _process_image_annotations(image):
"""Helper for processing annotation types from protobuf.
:type image: :class:`~google.cloud.proto.vision.v1.image_annotator_pb2.\
:type image: :class:`~google.cloud.vision_v1.proto.image_annotator_pb2.\
AnnotateImageResponse`
:param image: ``AnnotateImageResponse`` from protobuf.
Expand Down Expand Up @@ -179,7 +179,7 @@ def _make_entity_from_pb(annotations):
"""Create an entity from a protobuf response.
:type annotations:
:class:`~google.cloud.proto.vision.v1.image_annotator_pb2.EntityAnnotation`
:class:`~google.cloud.vision_v1.proto.image_annotator_pb2.EntityAnnotation`
:param annotations: protobuf instance of ``EntityAnnotation``.
:rtype: list
Expand All @@ -192,7 +192,7 @@ def _make_faces_from_pb(faces):
"""Create face objects from a protobuf response.
:type faces:
:class:`~google.cloud.proto.vision.v1.image_annotator_pb2.FaceAnnotation`
:class:`~google.cloud.vision_v1.proto.image_annotator_pb2.FaceAnnotation`
:param faces: Protobuf instance of ``FaceAnnotation``.
:rtype: list
Expand All @@ -204,7 +204,7 @@ def _make_faces_from_pb(faces):
def _make_full_text_from_pb(full_text):
"""Create text annotation object from protobuf response.
:type full_text: :class:`~google.cloud.proto.vision.v1.\
:type full_text: :class:`~google.cloud.vision_v1.proto.\
text_annotation_pb2.TextAnnotation`
:param full_text: Protobuf instance of ``TextAnnotation``.
Expand All @@ -217,7 +217,7 @@ def _make_full_text_from_pb(full_text):
def _make_image_properties_from_pb(image_properties):
"""Create ``ImageProperties`` object from a protobuf response.
:type image_properties: :class:`~google.cloud.proto.vision.v1.\
:type image_properties: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.ImagePropertiesAnnotation`
:param image_properties: Protobuf instance of
``ImagePropertiesAnnotation``.
Expand All @@ -231,7 +231,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.proto.vision.v1.\
:type safe_search: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.SafeSearchAnnotation`
:param safe_search: Protobuf instance of ``SafeSearchAnnotation``.
Expand All @@ -244,7 +244,7 @@ def _make_safe_search_from_pb(safe_search):
def _make_web_detection_from_pb(annotation):
"""Create ``WebDetection`` object from a protobuf response.
:type annotation: :class:`~google.cloud.proto.vision.v1.web_detection_pb2\
:type annotation: :class:`~google.cloud.vision_v1.proto.web_detection_pb2\
.WebDetection`
:param annotation: Protobuf instance of ``WebDetection``.
Expand Down
4 changes: 2 additions & 2 deletions packages/google-cloud-vision/google/cloud/vision/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.proto.vision.v1.\
:type image_properties: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.ImageProperties`
:param image_properties: Protobuf response from Vision API with image
properties data.
Expand Down Expand Up @@ -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.proto.vision.v1.\
:type color_information: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.ColorInfo`
:param color_information: Color data with extra meta information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def from_api_repr(cls, response):
def from_pb(cls, response):
"""Factory: construct ``CropHint`` from Vision gRPC response.
:type response: :class:`google.cloud.proto.vision.v1.\
:type response: :class:`google.cloud.vision_v1.proto.\
image_annotator_pb2.CropHint`
:param response: gRPC response from Vision API with entity data.
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-vision/google/cloud/vision/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.proto.vision.v1.\
:type response: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.AnnotateImageResponse`
:param response: gRPC response from Vision API with entity data.
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-vision/google/cloud/vision/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.proto.vision.v1.\
:type angle: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.FaceAnnotation`
:param angle: Protobuf ``FaceAnnotation`` response with angle data.
Expand Down Expand Up @@ -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.proto.vision.v1.\
:type emotions: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.FaceAnnotation`
:param emotions: Response dictionary representing a face with emotions.
Expand Down Expand Up @@ -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.proto.vision.v1.\
:type face: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.AnnotateImageResponse`
:param face: ``AnnotateImageResponse`` from gRPC call.
Expand Down Expand Up @@ -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.proto.vision.v1.image_annotator_pb2.\
:type face: :class:`~google.cloud.vision_v1.proto.image_annotator_pb2.\
FaceAnnotation`
:param face: Protobuf instace of `Face`.
Expand Down Expand Up @@ -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.proto.vision.v1.\
:type landmark: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb.FaceAnnotation.Landmark`
:param landmark: Landmark representation from Vision API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.proto.vision.v1.\
:type vertices: :class:`~google.cloud.vision_v1.proto.\
geometry_pb2.BoundingPoly`
:param vertices: List of vertices.
Expand Down
4 changes: 2 additions & 2 deletions packages/google-cloud-vision/google/cloud/vision/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from base64 import b64encode

from google.cloud.proto.vision.v1 import image_annotator_pb2
from google.cloud.vision_v1.proto import image_annotator_pb2

from google.cloud.vision._gax import _to_gapic_image
from google.cloud._helpers import _to_bytes
Expand Down Expand Up @@ -120,7 +120,7 @@ def _detect_annotation_from_pb(self, requests_pb=None):
"""Helper for pre-made requests.
:type requests_pb: list
:param requests_pb: List of :class:`google.cloud.proto.vision.v1.\
:param requests_pb: List of :class:`google.cloud.vision_v1.proto.\
image_annotator_pb2.AnnotateImageRequest`
:rtype: :class:`~google.cloud.vision.annotations.Annotations`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from enum import Enum

from google.cloud.proto.vision.v1 import image_annotator_pb2
from google.cloud.vision_v1.proto import image_annotator_pb2


def _get_pb_likelihood(likelihood):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.proto.vision.v1.\
:type image: :class:`~google.cloud.vision_v1.proto.\
image_annotator_pb2.SafeSearchAnnotation`
:param image: Protobuf response from Vision API with safe search data.
Expand Down
8 changes: 4 additions & 4 deletions packages/google-cloud-vision/google/cloud/vision/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import json

from google.cloud.proto.vision.v1 import text_annotation_pb2
from google.cloud.vision_v1.proto import text_annotation_pb2
from google.protobuf import json_format


Expand All @@ -25,7 +25,7 @@ class TextAnnotation(object):
:type pages: list
:param pages: List of
:class:`~google.cloud.proto.vision.v1.\
:class:`~google.cloud.vision_v1.proto.\
text_annotation_pb2.Page`.
:type text: str
Expand Down Expand Up @@ -54,7 +54,7 @@ def from_api_repr(cls, annotation):
def from_pb(cls, annotation):
"""Factory: construct an instance of ``TextAnnotation`` from protobuf.
:type annotation: :class:`~google.cloud.proto.vision.v1.\
:type annotation: :class:`~google.cloud.vision_v1.proto.\
text_annotation_pb2.TextAnnotation`
:param annotation: Populated instance of ``TextAnnotation``.
Expand All @@ -68,7 +68,7 @@ def pages(self):
"""Pages found in text image.
:rtype: list
:returns: List of :class:`~google.cloud.proto.vision.v1.\
:returns: List of :class:`~google.cloud.vision_v1.proto.\
text_annotation_pb2.Page`.
"""
return self._pages
Expand Down
Loading

0 comments on commit 3100238

Please sign in to comment.