Skip to content
Permalink
Browse files
feat: add context manager support in client (#247)
- [ ] Regenerate this pull request now.

chore: fix docstring for first attribute of protos

committer: @busunkim96
PiperOrigin-RevId: 401271153

Source-Link: googleapis/googleapis@787f8c9

Source-Link: googleapis/googleapis-gen@81decff
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9
  • Loading branch information
gcf-owl-bot committed Oct 7, 2021
1 parent ca56a71 commit 629365f32d67bf3a6863615832e5443e185b8e3b
Showing with 937 additions and 32 deletions.
  1. +6 −0 google/cloud/vision_v1/services/image_annotator/async_client.py
  2. +14 −4 google/cloud/vision_v1/services/image_annotator/client.py
  3. +9 −0 google/cloud/vision_v1/services/image_annotator/transports/base.py
  4. +3 −0 google/cloud/vision_v1/services/image_annotator/transports/grpc.py
  5. +3 −0 google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py
  6. +6 −0 google/cloud/vision_v1/services/product_search/async_client.py
  7. +14 −4 google/cloud/vision_v1/services/product_search/client.py
  8. +9 −0 google/cloud/vision_v1/services/product_search/transports/base.py
  9. +3 −0 google/cloud/vision_v1/services/product_search/transports/grpc.py
  10. +3 −0 google/cloud/vision_v1/services/product_search/transports/grpc_asyncio.py
  11. +1 −0 google/cloud/vision_v1/types/geometry.py
  12. +23 −0 google/cloud/vision_v1/types/image_annotator.py
  13. +4 −0 google/cloud/vision_v1/types/product_search.py
  14. +26 −0 google/cloud/vision_v1/types/product_search_service.py
  15. +7 −0 google/cloud/vision_v1/types/text_annotation.py
  16. +5 −0 google/cloud/vision_v1/types/web_detection.py
  17. +6 −0 google/cloud/vision_v1p1beta1/services/image_annotator/async_client.py
  18. +14 −4 google/cloud/vision_v1p1beta1/services/image_annotator/client.py
  19. +9 −0 google/cloud/vision_v1p1beta1/services/image_annotator/transports/base.py
  20. +3 −0 google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc.py
  21. +3 −0 google/cloud/vision_v1p1beta1/services/image_annotator/transports/grpc_asyncio.py
  22. +1 −0 google/cloud/vision_v1p1beta1/types/geometry.py
  23. +14 −0 google/cloud/vision_v1p1beta1/types/image_annotator.py
  24. +7 −0 google/cloud/vision_v1p1beta1/types/text_annotation.py
  25. +5 −0 google/cloud/vision_v1p1beta1/types/web_detection.py
  26. +6 −0 google/cloud/vision_v1p2beta1/services/image_annotator/async_client.py
  27. +14 −4 google/cloud/vision_v1p2beta1/services/image_annotator/client.py
  28. +9 −0 google/cloud/vision_v1p2beta1/services/image_annotator/transports/base.py
  29. +3 −0 google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc.py
  30. +3 −0 google/cloud/vision_v1p2beta1/services/image_annotator/transports/grpc_asyncio.py
  31. +1 −0 google/cloud/vision_v1p2beta1/types/geometry.py
  32. +19 −0 google/cloud/vision_v1p2beta1/types/image_annotator.py
  33. +7 −0 google/cloud/vision_v1p2beta1/types/text_annotation.py
  34. +5 −0 google/cloud/vision_v1p2beta1/types/web_detection.py
  35. +6 −0 google/cloud/vision_v1p3beta1/services/image_annotator/async_client.py
  36. +14 −4 google/cloud/vision_v1p3beta1/services/image_annotator/client.py
  37. +9 −0 google/cloud/vision_v1p3beta1/services/image_annotator/transports/base.py
  38. +3 −0 google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc.py
  39. +3 −0 google/cloud/vision_v1p3beta1/services/image_annotator/transports/grpc_asyncio.py
  40. +6 −0 google/cloud/vision_v1p3beta1/services/product_search/async_client.py
  41. +14 −4 google/cloud/vision_v1p3beta1/services/product_search/client.py
  42. +9 −0 google/cloud/vision_v1p3beta1/services/product_search/transports/base.py
  43. +3 −0 google/cloud/vision_v1p3beta1/services/product_search/transports/grpc.py
  44. +3 −0 google/cloud/vision_v1p3beta1/services/product_search/transports/grpc_asyncio.py
  45. +2 −0 google/cloud/vision_v1p3beta1/types/geometry.py
  46. +20 −0 google/cloud/vision_v1p3beta1/types/image_annotator.py
  47. +4 −0 google/cloud/vision_v1p3beta1/types/product_search.py
  48. +25 −0 google/cloud/vision_v1p3beta1/types/product_search_service.py
  49. +7 −0 google/cloud/vision_v1p3beta1/types/text_annotation.py
  50. +5 −0 google/cloud/vision_v1p3beta1/types/web_detection.py
  51. +6 −0 google/cloud/vision_v1p4beta1/services/image_annotator/async_client.py
  52. +14 −4 google/cloud/vision_v1p4beta1/services/image_annotator/client.py
  53. +9 −0 google/cloud/vision_v1p4beta1/services/image_annotator/transports/base.py
  54. +3 −0 google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc.py
  55. +3 −0 google/cloud/vision_v1p4beta1/services/image_annotator/transports/grpc_asyncio.py
  56. +6 −0 google/cloud/vision_v1p4beta1/services/product_search/async_client.py
  57. +14 −4 google/cloud/vision_v1p4beta1/services/product_search/client.py
  58. +9 −0 google/cloud/vision_v1p4beta1/services/product_search/transports/base.py
  59. +3 −0 google/cloud/vision_v1p4beta1/services/product_search/transports/grpc.py
  60. +3 −0 google/cloud/vision_v1p4beta1/services/product_search/transports/grpc_asyncio.py
  61. +3 −0 google/cloud/vision_v1p4beta1/types/face.py
  62. +1 −0 google/cloud/vision_v1p4beta1/types/geometry.py
  63. +23 −0 google/cloud/vision_v1p4beta1/types/image_annotator.py
  64. +4 −0 google/cloud/vision_v1p4beta1/types/product_search.py
  65. +26 −0 google/cloud/vision_v1p4beta1/types/product_search_service.py
  66. +7 −0 google/cloud/vision_v1p4beta1/types/text_annotation.py
  67. +5 −0 google/cloud/vision_v1p4beta1/types/web_detection.py
  68. +50 −0 tests/unit/gapic/vision_v1/test_image_annotator.py
  69. +50 −0 tests/unit/gapic/vision_v1/test_product_search.py
  70. +50 −0 tests/unit/gapic/vision_v1p1beta1/test_image_annotator.py
  71. +50 −0 tests/unit/gapic/vision_v1p2beta1/test_image_annotator.py
  72. +50 −0 tests/unit/gapic/vision_v1p3beta1/test_image_annotator.py
  73. +50 −0 tests/unit/gapic/vision_v1p3beta1/test_product_search.py
  74. +50 −0 tests/unit/gapic/vision_v1p4beta1/test_image_annotator.py
  75. +50 −0 tests/unit/gapic/vision_v1p4beta1/test_product_search.py
@@ -525,6 +525,12 @@ async def async_batch_annotate_files(
# Done; return the response.
return response

async def __aenter__(self):
return self

async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -365,10 +365,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def batch_annotate_images(
@@ -704,6 +701,19 @@ def async_batch_annotate_files(
# Done; return the response.
return response

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
"""
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -219,6 +219,15 @@ def _prep_wrapped_messages(self, client_info):
),
}

def close(self):
"""Closes resources associated with the transport.
.. warning::
Only call this method if the transport is NOT shared
with other clients - this may cause errors in other clients!
"""
raise NotImplementedError()

@property
def operations_client(self) -> operations_v1.OperationsClient:
"""Return the client designed to process long-running operations."""
@@ -384,5 +384,8 @@ def async_batch_annotate_files(
)
return self._stubs["async_batch_annotate_files"]

def close(self):
self.grpc_channel.close()


__all__ = ("ImageAnnotatorGrpcTransport",)
@@ -391,5 +391,8 @@ def async_batch_annotate_files(
)
return self._stubs["async_batch_annotate_files"]

def close(self):
return self.grpc_channel.close()


__all__ = ("ImageAnnotatorGrpcAsyncIOTransport",)
@@ -2080,6 +2080,12 @@ async def purge_products(
# Done; return the response.
return response

async def __aenter__(self):
return self

async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -404,10 +404,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def create_product_set(
@@ -2141,6 +2138,19 @@ def purge_products(
# Done; return the response.
return response

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
"""
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -430,6 +430,15 @@ def _prep_wrapped_messages(self, client_info):
),
}

def close(self):
"""Closes resources associated with the transport.
.. warning::
Only call this method if the transport is NOT shared
with other clients - this may cause errors in other clients!
"""
raise NotImplementedError()

@property
def operations_client(self) -> operations_v1.OperationsClient:
"""Return the client designed to process long-running operations."""
@@ -951,5 +951,8 @@ def purge_products(
)
return self._stubs["purge_products"]

def close(self):
self.grpc_channel.close()


__all__ = ("ProductSearchGrpcTransport",)
@@ -968,5 +968,8 @@ def purge_products(
)
return self._stubs["purge_products"]

def close(self):
return self.grpc_channel.close()


__all__ = ("ProductSearchGrpcAsyncIOTransport",)
@@ -56,6 +56,7 @@ class NormalizedVertex(proto.Message):

class BoundingPoly(proto.Message):
r"""A bounding polygon for the detected image annotation.
Attributes:
vertices (Sequence[google.cloud.vision_v1.types.Vertex]):
The bounding polygon vertices.
@@ -164,6 +164,7 @@ class ImageSource(proto.Message):

class Image(proto.Message):
r"""Client image to perform Google Cloud Vision API tasks over.
Attributes:
content (bytes):
Image content, represented as a stream of bytes. Note: As
@@ -242,6 +243,7 @@ class FaceAnnotation(proto.Message):

class Landmark(proto.Message):
r"""A face-specific landmark (for example, a face feature).
Attributes:
type_ (google.cloud.vision_v1.types.FaceAnnotation.Landmark.Type):
Face landmark type.
@@ -317,6 +319,7 @@ class Type(proto.Enum):

class LocationInfo(proto.Message):
r"""Detected entity location information.
Attributes:
lat_lng (google.type.latlng_pb2.LatLng):
lat/long location coordinates.
@@ -327,6 +330,7 @@ class LocationInfo(proto.Message):

class Property(proto.Message):
r"""A ``Property`` consists of a user-supplied name/value pair.
Attributes:
name (str):
Name of the property.
@@ -343,6 +347,7 @@ class Property(proto.Message):

class EntityAnnotation(proto.Message):
r"""Set of detected entity features.
Attributes:
mid (str):
Opaque entity ID. Some IDs may be available in `Google
@@ -398,6 +403,7 @@ class EntityAnnotation(proto.Message):

class LocalizedObjectAnnotation(proto.Message):
r"""Set of detected objects with bounding boxes.
Attributes:
mid (str):
Object ID that should align with
@@ -484,6 +490,7 @@ class SafeSearchAnnotation(proto.Message):

class LatLongRect(proto.Message):
r"""Rectangle determined by min and max ``LatLng`` pairs.
Attributes:
min_lat_lng (google.type.latlng_pb2.LatLng):
Min lat/long pair.
@@ -516,6 +523,7 @@ class ColorInfo(proto.Message):

class DominantColorsAnnotation(proto.Message):
r"""Set of dominant colors and their corresponding scores.
Attributes:
colors (Sequence[google.cloud.vision_v1.types.ColorInfo]):
RGB color values with their score and pixel
@@ -527,6 +535,7 @@ class DominantColorsAnnotation(proto.Message):

class ImageProperties(proto.Message):
r"""Stores image properties, such as dominant colors.
Attributes:
dominant_colors (google.cloud.vision_v1.types.DominantColorsAnnotation):
If present, dominant colors completed
@@ -573,6 +582,7 @@ class CropHintsAnnotation(proto.Message):

class CropHintsParams(proto.Message):
r"""Parameters for crop hints annotation request.
Attributes:
aspect_ratios (Sequence[float]):
Aspect ratios in floats, representing the
@@ -590,6 +600,7 @@ class CropHintsParams(proto.Message):

class WebDetectionParams(proto.Message):
r"""Parameters for web detection request.
Attributes:
include_geo_results (bool):
Whether to include results derived from the
@@ -615,6 +626,7 @@ class TextDetectionParams(proto.Message):

class ImageContext(proto.Message):
r"""Image context and/or feature-specific parameters.
Attributes:
lat_long_rect (google.cloud.vision_v1.types.LatLongRect):
Not used.
@@ -694,6 +706,7 @@ class ImageAnnotationContext(proto.Message):

class AnnotateImageResponse(proto.Message):
r"""Response to an image annotation request.
Attributes:
face_annotations (Sequence[google.cloud.vision_v1.types.FaceAnnotation]):
If present, face detection has completed
@@ -814,6 +827,7 @@ class BatchAnnotateImagesRequest(proto.Message):

class BatchAnnotateImagesResponse(proto.Message):
r"""Response to a batch image annotation request.
Attributes:
responses (Sequence[google.cloud.vision_v1.types.AnnotateImageResponse]):
Individual responses to image annotation
@@ -922,6 +936,7 @@ class BatchAnnotateFilesRequest(proto.Message):

class BatchAnnotateFilesResponse(proto.Message):
r"""A list of file annotation responses.
Attributes:
responses (Sequence[google.cloud.vision_v1.types.AnnotateFileResponse]):
The list of file annotation responses, each
@@ -937,6 +952,7 @@ class BatchAnnotateFilesResponse(proto.Message):

class AsyncAnnotateFileRequest(proto.Message):
r"""An offline file annotation request.
Attributes:
input_config (google.cloud.vision_v1.types.InputConfig):
Required. Information about the input file.
@@ -958,6 +974,7 @@ class AsyncAnnotateFileRequest(proto.Message):

class AsyncAnnotateFileResponse(proto.Message):
r"""The response for a single offline file annotation request.
Attributes:
output_config (google.cloud.vision_v1.types.OutputConfig):
The output location and metadata from
@@ -969,6 +986,7 @@ class AsyncAnnotateFileResponse(proto.Message):

class AsyncBatchAnnotateImagesRequest(proto.Message):
r"""Request for async image annotation for a list of images.
Attributes:
requests (Sequence[google.cloud.vision_v1.types.AnnotateImageRequest]):
Required. Individual image annotation
@@ -1000,6 +1018,7 @@ class AsyncBatchAnnotateImagesRequest(proto.Message):

class AsyncBatchAnnotateImagesResponse(proto.Message):
r"""Response to an async batch image annotation request.
Attributes:
output_config (google.cloud.vision_v1.types.OutputConfig):
The output location and metadata from
@@ -1040,6 +1059,7 @@ class AsyncBatchAnnotateFilesRequest(proto.Message):

class AsyncBatchAnnotateFilesResponse(proto.Message):
r"""Response to an async batch file annotation request.
Attributes:
responses (Sequence[google.cloud.vision_v1.types.AsyncAnnotateFileResponse]):
The list of file annotation responses, one
@@ -1054,6 +1074,7 @@ class AsyncBatchAnnotateFilesResponse(proto.Message):

class InputConfig(proto.Message):
r"""The desired input location and metadata.
Attributes:
gcs_source (google.cloud.vision_v1.types.GcsSource):
The Google Cloud Storage location to read the
@@ -1079,6 +1100,7 @@ class InputConfig(proto.Message):

class OutputConfig(proto.Message):
r"""The desired output location and metadata.
Attributes:
gcs_destination (google.cloud.vision_v1.types.GcsDestination):
The Google Cloud Storage location to write
@@ -1154,6 +1176,7 @@ class GcsDestination(proto.Message):

class OperationMetadata(proto.Message):
r"""Contains metadata for the BatchAnnotateImages operation.
Attributes:
state (google.cloud.vision_v1.types.OperationMetadata.State):
Current state of the batch operation.
@@ -28,6 +28,7 @@

class ProductSearchParams(proto.Message):
r"""Parameters for a product search request.
Attributes:
bounding_poly (google.cloud.vision_v1.types.BoundingPoly):
The bounding polygon around the area of
@@ -74,6 +75,7 @@ class ProductSearchParams(proto.Message):

class ProductSearchResults(proto.Message):
r"""Results for a product search request.
Attributes:
index_time (google.protobuf.timestamp_pb2.Timestamp):
Timestamp of the index which provided these
@@ -93,6 +95,7 @@ class ProductSearchResults(proto.Message):

class Result(proto.Message):
r"""Information about a product.
Attributes:
product (google.cloud.vision_v1.types.Product):
The Product.
@@ -112,6 +115,7 @@ class Result(proto.Message):

class ObjectAnnotation(proto.Message):
r"""Prediction for what the object in the bounding box is.
Attributes:
mid (str):
Object ID that should align with
Loading

0 comments on commit 629365f

Please sign in to comment.