diff --git a/google/cloud/automl_v1/services/auto_ml/async_client.py b/google/cloud/automl_v1/services/auto_ml/async_client.py index a36438fa..d3c07c45 100644 --- a/google/cloud/automl_v1/services/auto_ml/async_client.py +++ b/google/cloud/automl_v1/services/auto_ml/async_client.py @@ -1904,6 +1904,12 @@ async def list_model_evaluations( # 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( diff --git a/google/cloud/automl_v1/services/auto_ml/client.py b/google/cloud/automl_v1/services/auto_ml/client.py index c82a6566..3c368d73 100644 --- a/google/cloud/automl_v1/services/auto_ml/client.py +++ b/google/cloud/automl_v1/services/auto_ml/client.py @@ -435,10 +435,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_dataset( @@ -2063,6 +2060,19 @@ def list_model_evaluations( # 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( diff --git a/google/cloud/automl_v1/services/auto_ml/transports/base.py b/google/cloud/automl_v1/services/auto_ml/transports/base.py index 36e216d8..8ae4cb86 100644 --- a/google/cloud/automl_v1/services/auto_ml/transports/base.py +++ b/google/cloud/automl_v1/services/auto_ml/transports/base.py @@ -324,6 +324,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.""" diff --git a/google/cloud/automl_v1/services/auto_ml/transports/grpc.py b/google/cloud/automl_v1/services/auto_ml/transports/grpc.py index e6aa5422..14e83e96 100644 --- a/google/cloud/automl_v1/services/auto_ml/transports/grpc.py +++ b/google/cloud/automl_v1/services/auto_ml/transports/grpc.py @@ -780,5 +780,8 @@ def list_model_evaluations( ) return self._stubs["list_model_evaluations"] + def close(self): + self.grpc_channel.close() + __all__ = ("AutoMlGrpcTransport",) diff --git a/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py b/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py index f137ea5b..40840c33 100644 --- a/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1/services/auto_ml/transports/grpc_asyncio.py @@ -794,5 +794,8 @@ def list_model_evaluations( ) return self._stubs["list_model_evaluations"] + def close(self): + return self.grpc_channel.close() + __all__ = ("AutoMlGrpcAsyncIOTransport",) diff --git a/google/cloud/automl_v1/services/prediction_service/async_client.py b/google/cloud/automl_v1/services/prediction_service/async_client.py index 4229ce13..6efce933 100644 --- a/google/cloud/automl_v1/services/prediction_service/async_client.py +++ b/google/cloud/automl_v1/services/prediction_service/async_client.py @@ -544,6 +544,12 @@ async def batch_predict( # 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( diff --git a/google/cloud/automl_v1/services/prediction_service/client.py b/google/cloud/automl_v1/services/prediction_service/client.py index a2539dd3..903d8312 100644 --- a/google/cloud/automl_v1/services/prediction_service/client.py +++ b/google/cloud/automl_v1/services/prediction_service/client.py @@ -355,10 +355,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 predict( @@ -733,6 +730,19 @@ def batch_predict( # 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( diff --git a/google/cloud/automl_v1/services/prediction_service/transports/base.py b/google/cloud/automl_v1/services/prediction_service/transports/base.py index d6357ddd..0ad270ca 100644 --- a/google/cloud/automl_v1/services/prediction_service/transports/base.py +++ b/google/cloud/automl_v1/services/prediction_service/transports/base.py @@ -162,6 +162,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.""" diff --git a/google/cloud/automl_v1/services/prediction_service/transports/grpc.py b/google/cloud/automl_v1/services/prediction_service/transports/grpc.py index ff0e33ac..2f689bb1 100644 --- a/google/cloud/automl_v1/services/prediction_service/transports/grpc.py +++ b/google/cloud/automl_v1/services/prediction_service/transports/grpc.py @@ -354,5 +354,8 @@ def batch_predict( ) return self._stubs["batch_predict"] + def close(self): + self.grpc_channel.close() + __all__ = ("PredictionServiceGrpcTransport",) diff --git a/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py index 1866b9b3..226e2e8b 100644 --- a/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1/services/prediction_service/transports/grpc_asyncio.py @@ -362,5 +362,8 @@ def batch_predict( ) return self._stubs["batch_predict"] + def close(self): + return self.grpc_channel.close() + __all__ = ("PredictionServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/automl_v1/types/annotation_payload.py b/google/cloud/automl_v1/types/annotation_payload.py index e1297261..26ef30e6 100644 --- a/google/cloud/automl_v1/types/annotation_payload.py +++ b/google/cloud/automl_v1/types/annotation_payload.py @@ -29,6 +29,7 @@ class AnnotationPayload(proto.Message): r"""Contains annotation information that is relevant to AutoML. + Attributes: translation (google.cloud.automl_v1.types.TranslationAnnotation): Annotation details for translation. diff --git a/google/cloud/automl_v1/types/annotation_spec.py b/google/cloud/automl_v1/types/annotation_spec.py index 95294100..5bcbcff3 100644 --- a/google/cloud/automl_v1/types/annotation_spec.py +++ b/google/cloud/automl_v1/types/annotation_spec.py @@ -23,6 +23,7 @@ class AnnotationSpec(proto.Message): r"""A definition of an annotation spec. + Attributes: name (str): Output only. Resource name of the annotation spec. Form: diff --git a/google/cloud/automl_v1/types/classification.py b/google/cloud/automl_v1/types/classification.py index 6e1461fa..40202f16 100644 --- a/google/cloud/automl_v1/types/classification.py +++ b/google/cloud/automl_v1/types/classification.py @@ -35,6 +35,7 @@ class ClassificationType(proto.Enum): class ClassificationAnnotation(proto.Message): r"""Contains annotation details specific to classification. + Attributes: score (float): Output only. A confidence estimate between @@ -87,6 +88,7 @@ class ClassificationEvaluationMetrics(proto.Message): class ConfidenceMetricsEntry(proto.Message): r"""Metrics for a single confidence threshold. + Attributes: confidence_threshold (float): Output only. Metrics are computed with an @@ -162,6 +164,7 @@ class ConfidenceMetricsEntry(proto.Message): class ConfusionMatrix(proto.Message): r"""Confusion matrix of the model running the classification. + Attributes: annotation_spec_id (Sequence[str]): Output only. IDs of the annotation specs used in the @@ -189,6 +192,7 @@ class ConfusionMatrix(proto.Message): class Row(proto.Message): r"""Output only. A row in the confusion matrix. + Attributes: example_count (Sequence[int]): Output only. Value of the specific cell in the confusion diff --git a/google/cloud/automl_v1/types/data_items.py b/google/cloud/automl_v1/types/data_items.py index aef31911..ff09d9dd 100644 --- a/google/cloud/automl_v1/types/data_items.py +++ b/google/cloud/automl_v1/types/data_items.py @@ -51,6 +51,7 @@ class Image(proto.Message): class TextSnippet(proto.Message): r"""A representation of a text snippet. + Attributes: content (str): Required. The content of the text snippet as @@ -74,6 +75,7 @@ class TextSnippet(proto.Message): class DocumentDimensions(proto.Message): r"""Message that describes dimension of a document. + Attributes: unit (google.cloud.automl_v1.types.DocumentDimensions.DocumentDimensionUnit): Unit of the dimension. @@ -99,6 +101,7 @@ class DocumentDimensionUnit(proto.Enum): class Document(proto.Message): r"""A structured text document e.g. a PDF. + Attributes: input_config (google.cloud.automl_v1.types.DocumentInputConfig): An input config specifying the content of the @@ -181,6 +184,7 @@ class TextSegmentType(proto.Enum): class ExamplePayload(proto.Message): r"""Example data used for training or prediction. + Attributes: image (google.cloud.automl_v1.types.Image): Example image. diff --git a/google/cloud/automl_v1/types/detection.py b/google/cloud/automl_v1/types/detection.py index 92769d15..3ebf666d 100644 --- a/google/cloud/automl_v1/types/detection.py +++ b/google/cloud/automl_v1/types/detection.py @@ -30,6 +30,7 @@ class ImageObjectDetectionAnnotation(proto.Message): r"""Annotation details for image object detection. + Attributes: bounding_box (google.cloud.automl_v1.types.BoundingPoly): Output only. The rectangle representing the @@ -66,6 +67,7 @@ class BoundingBoxMetricsEntry(proto.Message): class ConfidenceMetricsEntry(proto.Message): r"""Metrics for a single confidence threshold. + Attributes: confidence_threshold (float): Output only. The confidence threshold value diff --git a/google/cloud/automl_v1/types/image.py b/google/cloud/automl_v1/types/image.py index 797bd185..129cb5d7 100644 --- a/google/cloud/automl_v1/types/image.py +++ b/google/cloud/automl_v1/types/image.py @@ -33,6 +33,7 @@ class ImageClassificationDatasetMetadata(proto.Message): r"""Dataset metadata that is specific to image classification. + Attributes: classification_type (google.cloud.automl_v1.types.ClassificationType): Required. Type of the classification problem. @@ -44,11 +45,13 @@ class ImageClassificationDatasetMetadata(proto.Message): class ImageObjectDetectionDatasetMetadata(proto.Message): - r"""Dataset metadata specific to image object detection. """ + r"""Dataset metadata specific to image object detection. + """ class ImageClassificationModelMetadata(proto.Message): r"""Model metadata for image classification. + Attributes: base_model_id (str): Optional. The ID of the ``base`` model. If it is specified, @@ -150,6 +153,7 @@ class ImageClassificationModelMetadata(proto.Message): class ImageObjectDetectionModelMetadata(proto.Message): r"""Model metadata specific to image object detection. + Attributes: model_type (str): Optional. Type of the model. The available values are: @@ -232,6 +236,7 @@ class ImageObjectDetectionModelMetadata(proto.Message): class ImageClassificationModelDeploymentMetadata(proto.Message): r"""Model deployment metadata specific to Image Classification. + Attributes: node_count (int): Input only. The number of nodes to deploy the model on. A @@ -247,6 +252,7 @@ class ImageClassificationModelDeploymentMetadata(proto.Message): class ImageObjectDetectionModelDeploymentMetadata(proto.Message): r"""Model deployment metadata specific to Image Object Detection. + Attributes: node_count (int): Input only. The number of nodes to deploy the model on. A diff --git a/google/cloud/automl_v1/types/io.py b/google/cloud/automl_v1/types/io.py index cac0eec7..f1581316 100644 --- a/google/cloud/automl_v1/types/io.py +++ b/google/cloud/automl_v1/types/io.py @@ -1446,6 +1446,7 @@ class BatchPredictOutputConfig(proto.Message): class ModelExportOutputConfig(proto.Message): r"""Output configuration for ModelExport Action. + Attributes: gcs_destination (google.cloud.automl_v1.types.GcsDestination): Required. The Google Cloud Storage location where the model @@ -1518,6 +1519,7 @@ class ModelExportOutputConfig(proto.Message): class GcsSource(proto.Message): r"""The Google Cloud Storage location for the input content. + Attributes: input_uris (Sequence[str]): Required. Google Cloud Storage URIs to input files, up to diff --git a/google/cloud/automl_v1/types/model.py b/google/cloud/automl_v1/types/model.py index 9d399ae7..ea1a635f 100644 --- a/google/cloud/automl_v1/types/model.py +++ b/google/cloud/automl_v1/types/model.py @@ -26,6 +26,7 @@ class Model(proto.Message): r"""API proto representing a trained machine learning model. + Attributes: translation_model_metadata (google.cloud.automl_v1.types.TranslationModelMetadata): Metadata for translation models. diff --git a/google/cloud/automl_v1/types/model_evaluation.py b/google/cloud/automl_v1/types/model_evaluation.py index 94963927..1530f449 100644 --- a/google/cloud/automl_v1/types/model_evaluation.py +++ b/google/cloud/automl_v1/types/model_evaluation.py @@ -30,6 +30,7 @@ class ModelEvaluation(proto.Message): r"""Evaluation results of a model. + Attributes: classification_evaluation_metrics (google.cloud.automl_v1.types.ClassificationEvaluationMetrics): Model evaluation metrics for image, text, diff --git a/google/cloud/automl_v1/types/operations.py b/google/cloud/automl_v1/types/operations.py index 10d69552..7d6ec2d8 100644 --- a/google/cloud/automl_v1/types/operations.py +++ b/google/cloud/automl_v1/types/operations.py @@ -137,31 +137,38 @@ class OperationMetadata(proto.Message): class DeleteOperationMetadata(proto.Message): - r"""Details of operations that perform deletes of any entities. """ + r"""Details of operations that perform deletes of any entities. + """ class DeployModelOperationMetadata(proto.Message): - r"""Details of DeployModel operation. """ + r"""Details of DeployModel operation. + """ class UndeployModelOperationMetadata(proto.Message): - r"""Details of UndeployModel operation. """ + r"""Details of UndeployModel operation. + """ class CreateDatasetOperationMetadata(proto.Message): - r"""Details of CreateDataset operation. """ + r"""Details of CreateDataset operation. + """ class CreateModelOperationMetadata(proto.Message): - r"""Details of CreateModel operation. """ + r"""Details of CreateModel operation. + """ class ImportDataOperationMetadata(proto.Message): - r"""Details of ImportData operation. """ + r"""Details of ImportData operation. + """ class ExportDataOperationMetadata(proto.Message): r"""Details of ExportData operation. + Attributes: output_info (google.cloud.automl_v1.types.ExportDataOperationMetadata.ExportDataOutputInfo): Output only. Information further describing @@ -188,6 +195,7 @@ class ExportDataOutputInfo(proto.Message): class BatchPredictOperationMetadata(proto.Message): r"""Details of BatchPredict operation. + Attributes: input_config (google.cloud.automl_v1.types.BatchPredictInputConfig): Output only. The input config that was given @@ -221,6 +229,7 @@ class BatchPredictOutputInfo(proto.Message): class ExportModelOperationMetadata(proto.Message): r"""Details of ExportModel operation. + Attributes: output_info (google.cloud.automl_v1.types.ExportModelOperationMetadata.ExportModelOutputInfo): Output only. Information further describing diff --git a/google/cloud/automl_v1/types/text.py b/google/cloud/automl_v1/types/text.py index a666cf46..5122ba20 100644 --- a/google/cloud/automl_v1/types/text.py +++ b/google/cloud/automl_v1/types/text.py @@ -33,6 +33,7 @@ class TextClassificationDatasetMetadata(proto.Message): r"""Dataset metadata for classification. + Attributes: classification_type (google.cloud.automl_v1.types.ClassificationType): Required. Type of the classification problem. @@ -45,6 +46,7 @@ class TextClassificationDatasetMetadata(proto.Message): class TextClassificationModelMetadata(proto.Message): r"""Model metadata that is specific to text classification. + Attributes: classification_type (google.cloud.automl_v1.types.ClassificationType): Output only. Classification type of the @@ -57,15 +59,18 @@ class TextClassificationModelMetadata(proto.Message): class TextExtractionDatasetMetadata(proto.Message): - r"""Dataset metadata that is specific to text extraction """ + r"""Dataset metadata that is specific to text extraction + """ class TextExtractionModelMetadata(proto.Message): - r"""Model metadata that is specific to text extraction. """ + r"""Model metadata that is specific to text extraction. + """ class TextSentimentDatasetMetadata(proto.Message): r"""Dataset metadata for text sentiment. + Attributes: sentiment_max (int): Required. A sentiment is expressed as an integer ordinal, @@ -81,7 +86,8 @@ class TextSentimentDatasetMetadata(proto.Message): class TextSentimentModelMetadata(proto.Message): - r"""Model metadata that is specific to text sentiment. """ + r"""Model metadata that is specific to text sentiment. + """ __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/automl_v1/types/text_extraction.py b/google/cloud/automl_v1/types/text_extraction.py index 188c39d9..9cebeb8f 100644 --- a/google/cloud/automl_v1/types/text_extraction.py +++ b/google/cloud/automl_v1/types/text_extraction.py @@ -26,6 +26,7 @@ class TextExtractionAnnotation(proto.Message): r"""Annotation for identifying spans of text. + Attributes: text_segment (google.cloud.automl_v1.types.TextSegment): An entity annotation will set this, which is @@ -48,6 +49,7 @@ class TextExtractionAnnotation(proto.Message): class TextExtractionEvaluationMetrics(proto.Message): r"""Model evaluation metrics for text extraction problems. + Attributes: au_prc (float): Output only. The Area under precision recall @@ -60,6 +62,7 @@ class TextExtractionEvaluationMetrics(proto.Message): class ConfidenceMetricsEntry(proto.Message): r"""Metrics for a single confidence threshold. + Attributes: confidence_threshold (float): Output only. The confidence threshold value diff --git a/google/cloud/automl_v1/types/text_sentiment.py b/google/cloud/automl_v1/types/text_sentiment.py index c1e50358..106c29fa 100644 --- a/google/cloud/automl_v1/types/text_sentiment.py +++ b/google/cloud/automl_v1/types/text_sentiment.py @@ -26,6 +26,7 @@ class TextSentimentAnnotation(proto.Message): r"""Contains annotation details specific to text sentiment. + Attributes: sentiment (int): Output only. The sentiment with the semantic, as given to @@ -51,6 +52,7 @@ class TextSentimentAnnotation(proto.Message): class TextSentimentEvaluationMetrics(proto.Message): r"""Model evaluation metrics for text sentiment problems. + Attributes: precision (float): Output only. Precision. diff --git a/google/cloud/automl_v1/types/translation.py b/google/cloud/automl_v1/types/translation.py index d2cd6dd5..840c054f 100644 --- a/google/cloud/automl_v1/types/translation.py +++ b/google/cloud/automl_v1/types/translation.py @@ -31,6 +31,7 @@ class TranslationDatasetMetadata(proto.Message): r"""Dataset metadata that is specific to translation. + Attributes: source_language_code (str): Required. The BCP-47 language code of the @@ -46,6 +47,7 @@ class TranslationDatasetMetadata(proto.Message): class TranslationEvaluationMetrics(proto.Message): r"""Evaluation metrics for the dataset. + Attributes: bleu_score (float): Output only. BLEU score. @@ -59,6 +61,7 @@ class TranslationEvaluationMetrics(proto.Message): class TranslationModelMetadata(proto.Message): r"""Model metadata that is specific to translation. + Attributes: base_model (str): The resource name of the model to use as a baseline to train @@ -81,6 +84,7 @@ class TranslationModelMetadata(proto.Message): class TranslationAnnotation(proto.Message): r"""Annotation details specific to translation. + Attributes: translated_content (google.cloud.automl_v1.types.TextSnippet): Output only . The translated content. diff --git a/google/cloud/automl_v1beta1/services/auto_ml/async_client.py b/google/cloud/automl_v1beta1/services/auto_ml/async_client.py index fc95ef81..12166f58 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/async_client.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/async_client.py @@ -2406,6 +2406,12 @@ async def list_model_evaluations( # 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( diff --git a/google/cloud/automl_v1beta1/services/auto_ml/client.py b/google/cloud/automl_v1beta1/services/auto_ml/client.py index 5984253b..11ec38cc 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/client.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/client.py @@ -483,10 +483,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_dataset( @@ -2573,6 +2570,19 @@ def list_model_evaluations( # 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( diff --git a/google/cloud/automl_v1beta1/services/auto_ml/transports/base.py b/google/cloud/automl_v1beta1/services/auto_ml/transports/base.py index 42506d98..adda41a8 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/transports/base.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/transports/base.py @@ -385,6 +385,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.""" diff --git a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py index 4e3ee6e4..518f935f 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc.py @@ -956,5 +956,8 @@ def list_model_evaluations( ) return self._stubs["list_model_evaluations"] + def close(self): + self.grpc_channel.close() + __all__ = ("AutoMlGrpcTransport",) diff --git a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py index 8164fdf3..bd68cade 100644 --- a/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1beta1/services/auto_ml/transports/grpc_asyncio.py @@ -978,5 +978,8 @@ def list_model_evaluations( ) return self._stubs["list_model_evaluations"] + def close(self): + return self.grpc_channel.close() + __all__ = ("AutoMlGrpcAsyncIOTransport",) diff --git a/google/cloud/automl_v1beta1/services/prediction_service/async_client.py b/google/cloud/automl_v1beta1/services/prediction_service/async_client.py index 0d0d8c56..0f82485f 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/async_client.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/async_client.py @@ -516,6 +516,12 @@ async def batch_predict( # 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( diff --git a/google/cloud/automl_v1beta1/services/prediction_service/client.py b/google/cloud/automl_v1beta1/services/prediction_service/client.py index 855ec386..61c4a8d1 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/client.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/client.py @@ -355,10 +355,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 predict( @@ -705,6 +702,19 @@ def batch_predict( # 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( diff --git a/google/cloud/automl_v1beta1/services/prediction_service/transports/base.py b/google/cloud/automl_v1beta1/services/prediction_service/transports/base.py index af685b4e..a711adb7 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/transports/base.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/transports/base.py @@ -162,6 +162,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.""" diff --git a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py index 59f2f81f..50d4c1e3 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc.py @@ -335,5 +335,8 @@ def batch_predict( ) return self._stubs["batch_predict"] + def close(self): + self.grpc_channel.close() + __all__ = ("PredictionServiceGrpcTransport",) diff --git a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py index 2ecadd9a..13fb21fc 100644 --- a/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/automl_v1beta1/services/prediction_service/transports/grpc_asyncio.py @@ -343,5 +343,8 @@ def batch_predict( ) return self._stubs["batch_predict"] + def close(self): + return self.grpc_channel.close() + __all__ = ("PredictionServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/automl_v1beta1/types/annotation_payload.py b/google/cloud/automl_v1beta1/types/annotation_payload.py index e1e9b12a..ca714225 100644 --- a/google/cloud/automl_v1beta1/types/annotation_payload.py +++ b/google/cloud/automl_v1beta1/types/annotation_payload.py @@ -30,6 +30,7 @@ class AnnotationPayload(proto.Message): r"""Contains annotation information that is relevant to AutoML. + Attributes: translation (google.cloud.automl_v1beta1.types.TranslationAnnotation): Annotation details for translation. diff --git a/google/cloud/automl_v1beta1/types/annotation_spec.py b/google/cloud/automl_v1beta1/types/annotation_spec.py index 7481ac52..5d720a6a 100644 --- a/google/cloud/automl_v1beta1/types/annotation_spec.py +++ b/google/cloud/automl_v1beta1/types/annotation_spec.py @@ -23,6 +23,7 @@ class AnnotationSpec(proto.Message): r"""A definition of an annotation spec. + Attributes: name (str): Output only. Resource name of the annotation spec. Form: diff --git a/google/cloud/automl_v1beta1/types/classification.py b/google/cloud/automl_v1beta1/types/classification.py index 356aef21..5cca2d9e 100644 --- a/google/cloud/automl_v1beta1/types/classification.py +++ b/google/cloud/automl_v1beta1/types/classification.py @@ -38,6 +38,7 @@ class ClassificationType(proto.Enum): class ClassificationAnnotation(proto.Message): r"""Contains annotation details specific to classification. + Attributes: score (float): Output only. A confidence estimate between @@ -54,6 +55,7 @@ class ClassificationAnnotation(proto.Message): class VideoClassificationAnnotation(proto.Message): r"""Contains annotation details specific to video classification. + Attributes: type_ (str): Output only. Expresses the type of video classification. @@ -140,6 +142,7 @@ class ClassificationEvaluationMetrics(proto.Message): class ConfidenceMetricsEntry(proto.Message): r"""Metrics for a single confidence threshold. + Attributes: confidence_threshold (float): Output only. Metrics are computed with an @@ -215,6 +218,7 @@ class ConfidenceMetricsEntry(proto.Message): class ConfusionMatrix(proto.Message): r"""Confusion matrix of the model running the classification. + Attributes: annotation_spec_id (Sequence[str]): Output only. IDs of the annotation specs used in the @@ -242,6 +246,7 @@ class ConfusionMatrix(proto.Message): class Row(proto.Message): r"""Output only. A row in the confusion matrix. + Attributes: example_count (Sequence[int]): Output only. Value of the specific cell in the confusion diff --git a/google/cloud/automl_v1beta1/types/data_items.py b/google/cloud/automl_v1beta1/types/data_items.py index 3ac72882..3328f97f 100644 --- a/google/cloud/automl_v1beta1/types/data_items.py +++ b/google/cloud/automl_v1beta1/types/data_items.py @@ -59,6 +59,7 @@ class Image(proto.Message): class TextSnippet(proto.Message): r"""A representation of a text snippet. + Attributes: content (str): Required. The content of the text snippet as @@ -82,6 +83,7 @@ class TextSnippet(proto.Message): class DocumentDimensions(proto.Message): r"""Message that describes dimension of a document. + Attributes: unit (google.cloud.automl_v1beta1.types.DocumentDimensions.DocumentDimensionUnit): Unit of the dimension. @@ -107,6 +109,7 @@ class DocumentDimensionUnit(proto.Enum): class Document(proto.Message): r"""A structured text document e.g. a PDF. + Attributes: input_config (google.cloud.automl_v1beta1.types.DocumentInputConfig): An input config specifying the content of the @@ -189,6 +192,7 @@ class TextSegmentType(proto.Enum): class Row(proto.Message): r"""A representation of a row in a relational table. + Attributes: column_spec_ids (Sequence[str]): The resource IDs of the column specs describing the columns @@ -214,6 +218,7 @@ class Row(proto.Message): class ExamplePayload(proto.Message): r"""Example data used for training or prediction. + Attributes: image (google.cloud.automl_v1beta1.types.Image): Example image. diff --git a/google/cloud/automl_v1beta1/types/data_stats.py b/google/cloud/automl_v1beta1/types/data_stats.py index f8a890b2..be4e3f9f 100644 --- a/google/cloud/automl_v1beta1/types/data_stats.py +++ b/google/cloud/automl_v1beta1/types/data_stats.py @@ -81,6 +81,7 @@ class DataStats(proto.Message): class Float64Stats(proto.Message): r"""The data statistics of a series of FLOAT64 values. + Attributes: mean (float): The mean of the series. @@ -102,6 +103,7 @@ class Float64Stats(proto.Message): class HistogramBucket(proto.Message): r"""A bucket of a histogram. + Attributes: min_ (float): The minimum value of the bucket, inclusive. @@ -127,6 +129,7 @@ class HistogramBucket(proto.Message): class StringStats(proto.Message): r"""The data statistics of a series of STRING values. + Attributes: top_unigram_stats (Sequence[google.cloud.automl_v1beta1.types.StringStats.UnigramStats]): The statistics of the top 20 unigrams, ordered by @@ -135,6 +138,7 @@ class StringStats(proto.Message): class UnigramStats(proto.Message): r"""The statistics of a unigram. + Attributes: value (str): The unigram. @@ -153,6 +157,7 @@ class UnigramStats(proto.Message): class TimestampStats(proto.Message): r"""The data statistics of a series of TIMESTAMP values. + Attributes: granular_stats (Sequence[google.cloud.automl_v1beta1.types.TimestampStats.GranularStatsEntry]): The string key is the pre-defined granularity. Currently @@ -164,6 +169,7 @@ class TimestampStats(proto.Message): class GranularStats(proto.Message): r"""Stats split by a defined in context granularity. + Attributes: buckets (Sequence[google.cloud.automl_v1beta1.types.TimestampStats.GranularStats.BucketsEntry]): A map from granularity key to example count for that key. @@ -180,6 +186,7 @@ class GranularStats(proto.Message): class ArrayStats(proto.Message): r"""The data statistics of a series of ARRAY values. + Attributes: member_stats (google.cloud.automl_v1beta1.types.DataStats): Stats of all the values of all arrays, as if @@ -192,6 +199,7 @@ class ArrayStats(proto.Message): class StructStats(proto.Message): r"""The data statistics of a series of STRUCT values. + Attributes: field_stats (Sequence[google.cloud.automl_v1beta1.types.StructStats.FieldStatsEntry]): Map from a field name of the struct to data @@ -206,6 +214,7 @@ class StructStats(proto.Message): class CategoryStats(proto.Message): r"""The data statistics of a series of CATEGORY values. + Attributes: top_category_stats (Sequence[google.cloud.automl_v1beta1.types.CategoryStats.SingleCategoryStats]): The statistics of the top 20 CATEGORY values, ordered by @@ -215,6 +224,7 @@ class CategoryStats(proto.Message): class SingleCategoryStats(proto.Message): r"""The statistics of a single CATEGORY value. + Attributes: value (str): The CATEGORY value. diff --git a/google/cloud/automl_v1beta1/types/detection.py b/google/cloud/automl_v1beta1/types/detection.py index 5f1cba6d..92908cd2 100644 --- a/google/cloud/automl_v1beta1/types/detection.py +++ b/google/cloud/automl_v1beta1/types/detection.py @@ -33,6 +33,7 @@ class ImageObjectDetectionAnnotation(proto.Message): r"""Annotation details for image object detection. + Attributes: bounding_box (google.cloud.automl_v1beta1.types.BoundingPoly): Output only. The rectangle representing the @@ -49,6 +50,7 @@ class ImageObjectDetectionAnnotation(proto.Message): class VideoObjectTrackingAnnotation(proto.Message): r"""Annotation details for video object tracking. + Attributes: instance_id (str): Optional. The instance of the object, @@ -105,6 +107,7 @@ class BoundingBoxMetricsEntry(proto.Message): class ConfidenceMetricsEntry(proto.Message): r"""Metrics for a single confidence threshold. + Attributes: confidence_threshold (float): Output only. The confidence threshold value diff --git a/google/cloud/automl_v1beta1/types/image.py b/google/cloud/automl_v1beta1/types/image.py index 689b8a4f..7de1afb7 100644 --- a/google/cloud/automl_v1beta1/types/image.py +++ b/google/cloud/automl_v1beta1/types/image.py @@ -33,6 +33,7 @@ class ImageClassificationDatasetMetadata(proto.Message): r"""Dataset metadata that is specific to image classification. + Attributes: classification_type (google.cloud.automl_v1beta1.types.ClassificationType): Required. Type of the classification problem. @@ -44,11 +45,13 @@ class ImageClassificationDatasetMetadata(proto.Message): class ImageObjectDetectionDatasetMetadata(proto.Message): - r"""Dataset metadata specific to image object detection. """ + r"""Dataset metadata specific to image object detection. + """ class ImageClassificationModelMetadata(proto.Message): r"""Model metadata for image classification. + Attributes: base_model_id (str): Optional. The ID of the ``base`` model. If it is specified, @@ -134,6 +137,7 @@ class ImageClassificationModelMetadata(proto.Message): class ImageObjectDetectionModelMetadata(proto.Message): r"""Model metadata specific to image object detection. + Attributes: model_type (str): Optional. Type of the model. The available values are: @@ -216,6 +220,7 @@ class ImageObjectDetectionModelMetadata(proto.Message): class ImageClassificationModelDeploymentMetadata(proto.Message): r"""Model deployment metadata specific to Image Classification. + Attributes: node_count (int): Input only. The number of nodes to deploy the model on. A @@ -231,6 +236,7 @@ class ImageClassificationModelDeploymentMetadata(proto.Message): class ImageObjectDetectionModelDeploymentMetadata(proto.Message): r"""Model deployment metadata specific to Image Object Detection. + Attributes: node_count (int): Input only. The number of nodes to deploy the model on. A diff --git a/google/cloud/automl_v1beta1/types/io.py b/google/cloud/automl_v1beta1/types/io.py index 4e69b64a..d7d6be0f 100644 --- a/google/cloud/automl_v1beta1/types/io.py +++ b/google/cloud/automl_v1beta1/types/io.py @@ -902,6 +902,7 @@ class BatchPredictOutputConfig(proto.Message): class ModelExportOutputConfig(proto.Message): r"""Output configuration for ModelExport Action. + Attributes: gcs_destination (google.cloud.automl_v1beta1.types.GcsDestination): The Google Cloud Storage location where the model is to be @@ -1041,6 +1042,7 @@ class ExportEvaluatedExamplesOutputConfig(proto.Message): class GcsSource(proto.Message): r"""The Google Cloud Storage location for the input content. + Attributes: input_uris (Sequence[str]): Required. Google Cloud Storage URIs to input files, up to @@ -1054,6 +1056,7 @@ class GcsSource(proto.Message): class BigQuerySource(proto.Message): r"""The BigQuery location for the input content. + Attributes: input_uri (str): Required. BigQuery URI to a table, up to 2000 characters @@ -1084,6 +1087,7 @@ class GcsDestination(proto.Message): class BigQueryDestination(proto.Message): r"""The BigQuery location for the output content. + Attributes: output_uri (str): Required. BigQuery URI to a project, up to 2000 characters @@ -1097,6 +1101,7 @@ class BigQueryDestination(proto.Message): class GcrDestination(proto.Message): r"""The GCR location where the image must be pushed to. + Attributes: output_uri (str): Required. Google Contained Registry URI of the new image, up diff --git a/google/cloud/automl_v1beta1/types/model.py b/google/cloud/automl_v1beta1/types/model.py index a91520fe..af38c584 100644 --- a/google/cloud/automl_v1beta1/types/model.py +++ b/google/cloud/automl_v1beta1/types/model.py @@ -28,6 +28,7 @@ class Model(proto.Message): r"""API proto representing a trained machine learning model. + Attributes: translation_model_metadata (google.cloud.automl_v1beta1.types.TranslationModelMetadata): Metadata for translation models. diff --git a/google/cloud/automl_v1beta1/types/model_evaluation.py b/google/cloud/automl_v1beta1/types/model_evaluation.py index b419463f..a140006f 100644 --- a/google/cloud/automl_v1beta1/types/model_evaluation.py +++ b/google/cloud/automl_v1beta1/types/model_evaluation.py @@ -31,6 +31,7 @@ class ModelEvaluation(proto.Message): r"""Evaluation results of a model. + Attributes: classification_evaluation_metrics (google.cloud.automl_v1beta1.types.ClassificationEvaluationMetrics): Model evaluation metrics for image, text, diff --git a/google/cloud/automl_v1beta1/types/operations.py b/google/cloud/automl_v1beta1/types/operations.py index 923fcb18..aa6bfc02 100644 --- a/google/cloud/automl_v1beta1/types/operations.py +++ b/google/cloud/automl_v1beta1/types/operations.py @@ -137,27 +137,33 @@ class OperationMetadata(proto.Message): class DeleteOperationMetadata(proto.Message): - r"""Details of operations that perform deletes of any entities. """ + r"""Details of operations that perform deletes of any entities. + """ class DeployModelOperationMetadata(proto.Message): - r"""Details of DeployModel operation. """ + r"""Details of DeployModel operation. + """ class UndeployModelOperationMetadata(proto.Message): - r"""Details of UndeployModel operation. """ + r"""Details of UndeployModel operation. + """ class CreateModelOperationMetadata(proto.Message): - r"""Details of CreateModel operation. """ + r"""Details of CreateModel operation. + """ class ImportDataOperationMetadata(proto.Message): - r"""Details of ImportData operation. """ + r"""Details of ImportData operation. + """ class ExportDataOperationMetadata(proto.Message): r"""Details of ExportData operation. + Attributes: output_info (google.cloud.automl_v1beta1.types.ExportDataOperationMetadata.ExportDataOutputInfo): Output only. Information further describing @@ -191,6 +197,7 @@ class ExportDataOutputInfo(proto.Message): class BatchPredictOperationMetadata(proto.Message): r"""Details of BatchPredict operation. + Attributes: input_config (google.cloud.automl_v1beta1.types.BatchPredictInputConfig): Output only. The input config that was given @@ -231,6 +238,7 @@ class BatchPredictOutputInfo(proto.Message): class ExportModelOperationMetadata(proto.Message): r"""Details of ExportModel operation. + Attributes: output_info (google.cloud.automl_v1beta1.types.ExportModelOperationMetadata.ExportModelOutputInfo): Output only. Information further describing @@ -256,6 +264,7 @@ class ExportModelOutputInfo(proto.Message): class ExportEvaluatedExamplesOperationMetadata(proto.Message): r"""Details of EvaluatedExamples operation. + Attributes: output_info (google.cloud.automl_v1beta1.types.ExportEvaluatedExamplesOperationMetadata.ExportEvaluatedExamplesOutputInfo): Output only. Information further describing diff --git a/google/cloud/automl_v1beta1/types/ranges.py b/google/cloud/automl_v1beta1/types/ranges.py index 27c834d0..4af1f95f 100644 --- a/google/cloud/automl_v1beta1/types/ranges.py +++ b/google/cloud/automl_v1beta1/types/ranges.py @@ -23,6 +23,7 @@ class DoubleRange(proto.Message): r"""A range between two double numbers. + Attributes: start (float): Start of the range, inclusive. diff --git a/google/cloud/automl_v1beta1/types/regression.py b/google/cloud/automl_v1beta1/types/regression.py index a047d1b8..da042e57 100644 --- a/google/cloud/automl_v1beta1/types/regression.py +++ b/google/cloud/automl_v1beta1/types/regression.py @@ -23,6 +23,7 @@ class RegressionEvaluationMetrics(proto.Message): r"""Metrics for regression problems. + Attributes: root_mean_squared_error (float): Output only. Root Mean Squared Error (RMSE). diff --git a/google/cloud/automl_v1beta1/types/tables.py b/google/cloud/automl_v1beta1/types/tables.py index 15258ecc..d6662e63 100644 --- a/google/cloud/automl_v1beta1/types/tables.py +++ b/google/cloud/automl_v1beta1/types/tables.py @@ -35,6 +35,7 @@ class TablesDatasetMetadata(proto.Message): r"""Metadata for a dataset used for AutoML Tables. + Attributes: primary_table_spec_id (str): Output only. The table_spec_id of the primary table of this @@ -115,6 +116,7 @@ class TablesDatasetMetadata(proto.Message): class TablesModelMetadata(proto.Message): r"""Model metadata specific to AutoML Tables. + Attributes: optimization_objective_recall_value (float): Required when optimization_objective is @@ -241,6 +243,7 @@ class TablesModelMetadata(proto.Message): class TablesAnnotation(proto.Message): r"""Contains annotation details specific to Tables. + Attributes: score (float): Output only. A confidence estimate between 0.0 and 1.0, diff --git a/google/cloud/automl_v1beta1/types/text.py b/google/cloud/automl_v1beta1/types/text.py index 233c03a2..ba0f3ef1 100644 --- a/google/cloud/automl_v1beta1/types/text.py +++ b/google/cloud/automl_v1beta1/types/text.py @@ -33,6 +33,7 @@ class TextClassificationDatasetMetadata(proto.Message): r"""Dataset metadata for classification. + Attributes: classification_type (google.cloud.automl_v1beta1.types.ClassificationType): Required. Type of the classification problem. @@ -45,6 +46,7 @@ class TextClassificationDatasetMetadata(proto.Message): class TextClassificationModelMetadata(proto.Message): r"""Model metadata that is specific to text classification. + Attributes: classification_type (google.cloud.automl_v1beta1.types.ClassificationType): Output only. Classification type of the @@ -57,11 +59,13 @@ class TextClassificationModelMetadata(proto.Message): class TextExtractionDatasetMetadata(proto.Message): - r"""Dataset metadata that is specific to text extraction """ + r"""Dataset metadata that is specific to text extraction + """ class TextExtractionModelMetadata(proto.Message): r"""Model metadata that is specific to text extraction. + Attributes: model_hint (str): Indicates the scope of model use case. @@ -78,6 +82,7 @@ class TextExtractionModelMetadata(proto.Message): class TextSentimentDatasetMetadata(proto.Message): r"""Dataset metadata for text sentiment. + Attributes: sentiment_max (int): Required. A sentiment is expressed as an integer ordinal, @@ -93,7 +98,8 @@ class TextSentimentDatasetMetadata(proto.Message): class TextSentimentModelMetadata(proto.Message): - r"""Model metadata that is specific to text sentiment. """ + r"""Model metadata that is specific to text sentiment. + """ __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/automl_v1beta1/types/text_extraction.py b/google/cloud/automl_v1beta1/types/text_extraction.py index e120608b..f1570d08 100644 --- a/google/cloud/automl_v1beta1/types/text_extraction.py +++ b/google/cloud/automl_v1beta1/types/text_extraction.py @@ -26,6 +26,7 @@ class TextExtractionAnnotation(proto.Message): r"""Annotation for identifying spans of text. + Attributes: text_segment (google.cloud.automl_v1beta1.types.TextSegment): An entity annotation will set this, which is @@ -48,6 +49,7 @@ class TextExtractionAnnotation(proto.Message): class TextExtractionEvaluationMetrics(proto.Message): r"""Model evaluation metrics for text extraction problems. + Attributes: au_prc (float): Output only. The Area under precision recall @@ -60,6 +62,7 @@ class TextExtractionEvaluationMetrics(proto.Message): class ConfidenceMetricsEntry(proto.Message): r"""Metrics for a single confidence threshold. + Attributes: confidence_threshold (float): Output only. The confidence threshold value diff --git a/google/cloud/automl_v1beta1/types/text_sentiment.py b/google/cloud/automl_v1beta1/types/text_sentiment.py index 0cdb0def..e5d03e94 100644 --- a/google/cloud/automl_v1beta1/types/text_sentiment.py +++ b/google/cloud/automl_v1beta1/types/text_sentiment.py @@ -26,6 +26,7 @@ class TextSentimentAnnotation(proto.Message): r"""Contains annotation details specific to text sentiment. + Attributes: sentiment (int): Output only. The sentiment with the semantic, as given to @@ -51,6 +52,7 @@ class TextSentimentAnnotation(proto.Message): class TextSentimentEvaluationMetrics(proto.Message): r"""Model evaluation metrics for text sentiment problems. + Attributes: precision (float): Output only. Precision. diff --git a/google/cloud/automl_v1beta1/types/translation.py b/google/cloud/automl_v1beta1/types/translation.py index 231624b0..f92c7648 100644 --- a/google/cloud/automl_v1beta1/types/translation.py +++ b/google/cloud/automl_v1beta1/types/translation.py @@ -31,6 +31,7 @@ class TranslationDatasetMetadata(proto.Message): r"""Dataset metadata that is specific to translation. + Attributes: source_language_code (str): Required. The BCP-47 language code of the @@ -46,6 +47,7 @@ class TranslationDatasetMetadata(proto.Message): class TranslationEvaluationMetrics(proto.Message): r"""Evaluation metrics for the dataset. + Attributes: bleu_score (float): Output only. BLEU score. @@ -59,6 +61,7 @@ class TranslationEvaluationMetrics(proto.Message): class TranslationModelMetadata(proto.Message): r"""Model metadata that is specific to translation. + Attributes: base_model (str): The resource name of the model to use as a baseline to train @@ -81,6 +84,7 @@ class TranslationModelMetadata(proto.Message): class TranslationAnnotation(proto.Message): r"""Annotation details specific to translation. + Attributes: translated_content (google.cloud.automl_v1beta1.types.TextSnippet): Output only . The translated content. diff --git a/google/cloud/automl_v1beta1/types/video.py b/google/cloud/automl_v1beta1/types/video.py index 02315f55..88d1cc48 100644 --- a/google/cloud/automl_v1beta1/types/video.py +++ b/google/cloud/automl_v1beta1/types/video.py @@ -30,19 +30,23 @@ class VideoClassificationDatasetMetadata(proto.Message): r"""Dataset metadata specific to video classification. All Video Classification datasets are treated as multi label. - """ + + """ class VideoObjectTrackingDatasetMetadata(proto.Message): - r"""Dataset metadata specific to video object tracking. """ + r"""Dataset metadata specific to video object tracking. + """ class VideoClassificationModelMetadata(proto.Message): - r"""Model metadata specific to video classification. """ + r"""Model metadata specific to video classification. + """ class VideoObjectTrackingModelMetadata(proto.Message): - r"""Model metadata specific to video object tracking. """ + r"""Model metadata specific to video object tracking. + """ __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/tests/unit/gapic/automl_v1/test_auto_ml.py b/tests/unit/gapic/automl_v1/test_auto_ml.py index c906c83e..a458606a 100644 --- a/tests/unit/gapic/automl_v1/test_auto_ml.py +++ b/tests/unit/gapic/automl_v1/test_auto_ml.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.automl_v1.services.auto_ml import AutoMlAsyncClient @@ -4891,6 +4892,9 @@ def test_auto_ml_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -5473,3 +5477,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = AutoMlAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = AutoMlClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = AutoMlClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/automl_v1/test_prediction_service.py b/tests/unit/gapic/automl_v1/test_prediction_service.py index 93df8b43..6fa2f1b8 100644 --- a/tests/unit/gapic/automl_v1/test_prediction_service.py +++ b/tests/unit/gapic/automl_v1/test_prediction_service.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.automl_v1.services.prediction_service import ( @@ -1110,6 +1111,9 @@ def test_prediction_service_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -1623,3 +1627,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = PredictionServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/automl_v1beta1/test_auto_ml.py b/tests/unit/gapic/automl_v1beta1/test_auto_ml.py index 912f04bd..4b90ba5f 100644 --- a/tests/unit/gapic/automl_v1beta1/test_auto_ml.py +++ b/tests/unit/gapic/automl_v1beta1/test_auto_ml.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.automl_v1beta1.services.auto_ml import AutoMlAsyncClient @@ -6490,6 +6491,9 @@ def test_auto_ml_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -7132,3 +7136,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = AutoMlAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = AutoMlClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = AutoMlClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/automl_v1beta1/test_prediction_service.py b/tests/unit/gapic/automl_v1beta1/test_prediction_service.py index 47f66dd1..6a106577 100644 --- a/tests/unit/gapic/automl_v1beta1/test_prediction_service.py +++ b/tests/unit/gapic/automl_v1beta1/test_prediction_service.py @@ -32,6 +32,7 @@ from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.automl_v1beta1.services.prediction_service import ( @@ -1113,6 +1114,9 @@ def test_prediction_service_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + # Additionally, the LRO client (a property) should # also raise NotImplementedError with pytest.raises(NotImplementedError): @@ -1626,3 +1630,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = PredictionServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called()