diff --git a/google/cloud/datalabeling_v1beta1/services/data_labeling_service/async_client.py b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/async_client.py index 93325b9..3018c1a 100644 --- a/google/cloud/datalabeling_v1beta1/services/data_labeling_service/async_client.py +++ b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/async_client.py @@ -3264,6 +3264,12 @@ async def list_evaluation_jobs( # 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/datalabeling_v1beta1/services/data_labeling_service/client.py b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/client.py index 03d437c..97554e8 100644 --- a/google/cloud/datalabeling_v1beta1/services/data_labeling_service/client.py +++ b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/client.py @@ -479,10 +479,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( @@ -3355,6 +3352,19 @@ def list_evaluation_jobs( # 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/datalabeling_v1beta1/services/data_labeling_service/transports/base.py b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/base.py index 75da4fc..42745e0 100644 --- a/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/base.py +++ b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/base.py @@ -537,6 +537,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/datalabeling_v1beta1/services/data_labeling_service/transports/grpc.py b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc.py index bf83c01..42b93b3 100644 --- a/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc.py +++ b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc.py @@ -1224,5 +1224,8 @@ def list_evaluation_jobs( ) return self._stubs["list_evaluation_jobs"] + def close(self): + self.grpc_channel.close() + __all__ = ("DataLabelingServiceGrpcTransport",) diff --git a/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc_asyncio.py b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc_asyncio.py index f067bfc..1c8ff43 100644 --- a/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc_asyncio.py +++ b/google/cloud/datalabeling_v1beta1/services/data_labeling_service/transports/grpc_asyncio.py @@ -1266,5 +1266,8 @@ def list_evaluation_jobs( ) return self._stubs["list_evaluation_jobs"] + def close(self): + return self.grpc_channel.close() + __all__ = ("DataLabelingServiceGrpcAsyncIOTransport",) diff --git a/google/cloud/datalabeling_v1beta1/types/annotation.py b/google/cloud/datalabeling_v1beta1/types/annotation.py index 74ddc84..f905e2a 100644 --- a/google/cloud/datalabeling_v1beta1/types/annotation.py +++ b/google/cloud/datalabeling_v1beta1/types/annotation.py @@ -121,6 +121,7 @@ class Annotation(proto.Message): class AnnotationValue(proto.Message): r"""Annotation value for an example. + Attributes: image_classification_annotation (google.cloud.datalabeling_v1beta1.types.ImageClassificationAnnotation): Annotation value for image classification @@ -204,6 +205,7 @@ class AnnotationValue(proto.Message): class ImageClassificationAnnotation(proto.Message): r"""Image classification annotation definition. + Attributes: annotation_spec (google.cloud.datalabeling_v1beta1.types.AnnotationSpec): Label of image. @@ -248,6 +250,7 @@ class NormalizedVertex(proto.Message): class BoundingPoly(proto.Message): r"""A bounding polygon in the image. + Attributes: vertices (Sequence[google.cloud.datalabeling_v1beta1.types.Vertex]): The bounding polygon vertices. @@ -258,6 +261,7 @@ class BoundingPoly(proto.Message): class NormalizedBoundingPoly(proto.Message): r"""Normalized bounding polygon. + Attributes: normalized_vertices (Sequence[google.cloud.datalabeling_v1beta1.types.NormalizedVertex]): The bounding polygon normalized vertices. @@ -294,6 +298,7 @@ class ImageBoundingPolyAnnotation(proto.Message): class Polyline(proto.Message): r"""A line with multiple line segments. + Attributes: vertices (Sequence[google.cloud.datalabeling_v1beta1.types.Vertex]): The polyline vertices. @@ -304,6 +309,7 @@ class Polyline(proto.Message): class NormalizedPolyline(proto.Message): r"""Normalized polyline. + Attributes: normalized_vertices (Sequence[google.cloud.datalabeling_v1beta1.types.NormalizedVertex]): The normalized polyline vertices. @@ -316,6 +322,7 @@ class NormalizedPolyline(proto.Message): class ImagePolylineAnnotation(proto.Message): r"""A polyline for the image annotation. + Attributes: polyline (google.cloud.datalabeling_v1beta1.types.Polyline): @@ -336,6 +343,7 @@ class ImagePolylineAnnotation(proto.Message): class ImageSegmentationAnnotation(proto.Message): r"""Image segmentation annotation. + Attributes: annotation_colors (Sequence[google.cloud.datalabeling_v1beta1.types.ImageSegmentationAnnotation.AnnotationColorsEntry]): The mapping between rgb color and annotation @@ -360,6 +368,7 @@ class ImageSegmentationAnnotation(proto.Message): class TextClassificationAnnotation(proto.Message): r"""Text classification annotation. + Attributes: annotation_spec (google.cloud.datalabeling_v1beta1.types.AnnotationSpec): Label of the text. @@ -372,6 +381,7 @@ class TextClassificationAnnotation(proto.Message): class TextEntityExtractionAnnotation(proto.Message): r"""Text entity extraction annotation. + Attributes: annotation_spec (google.cloud.datalabeling_v1beta1.types.AnnotationSpec): Label of the text entities. @@ -389,6 +399,7 @@ class TextEntityExtractionAnnotation(proto.Message): class SequentialSegment(proto.Message): r"""Start and end position in a sequence (e.g. text segment). + Attributes: start (int): Start position (inclusive). @@ -425,6 +436,7 @@ class TimeSegment(proto.Message): class VideoClassificationAnnotation(proto.Message): r"""Video classification annotation. + Attributes: time_segment (google.cloud.datalabeling_v1beta1.types.TimeSegment): The time segment of the video to which the @@ -464,6 +476,7 @@ class ObjectTrackingFrame(proto.Message): class VideoObjectTrackingAnnotation(proto.Message): r"""Video object tracking annotation. + Attributes: annotation_spec (google.cloud.datalabeling_v1beta1.types.AnnotationSpec): Label of the object tracked in this @@ -487,6 +500,7 @@ class VideoObjectTrackingAnnotation(proto.Message): class VideoEventAnnotation(proto.Message): r"""Video event annotation. + Attributes: annotation_spec (google.cloud.datalabeling_v1beta1.types.AnnotationSpec): Label of the event in this annotation. @@ -503,6 +517,7 @@ class VideoEventAnnotation(proto.Message): class AnnotationMetadata(proto.Message): r"""Additional information associated with the annotation. + Attributes: operator_metadata (google.cloud.datalabeling_v1beta1.types.OperatorMetadata): Metadata related to human labeling. diff --git a/google/cloud/datalabeling_v1beta1/types/data_labeling_service.py b/google/cloud/datalabeling_v1beta1/types/data_labeling_service.py index 35384e5..f7aed56 100644 --- a/google/cloud/datalabeling_v1beta1/types/data_labeling_service.py +++ b/google/cloud/datalabeling_v1beta1/types/data_labeling_service.py @@ -78,6 +78,7 @@ class CreateDatasetRequest(proto.Message): r"""Request message for CreateDataset. + Attributes: parent (str): Required. Dataset resource parent, format: @@ -92,6 +93,7 @@ class CreateDatasetRequest(proto.Message): class GetDatasetRequest(proto.Message): r"""Request message for GetDataSet. + Attributes: name (str): Required. Dataset resource name, format: @@ -103,6 +105,7 @@ class GetDatasetRequest(proto.Message): class ListDatasetsRequest(proto.Message): r"""Request message for ListDataset. + Attributes: parent (str): Required. Dataset resource parent, format: @@ -130,6 +133,7 @@ class ListDatasetsRequest(proto.Message): class ListDatasetsResponse(proto.Message): r"""Results of listing datasets within a project. + Attributes: datasets (Sequence[google.cloud.datalabeling_v1beta1.types.Dataset]): The list of datasets to return. @@ -149,6 +153,7 @@ def raw_page(self): class DeleteDatasetRequest(proto.Message): r"""Request message for DeleteDataset. + Attributes: name (str): Required. Dataset resource name, format: @@ -160,6 +165,7 @@ class DeleteDatasetRequest(proto.Message): class ImportDataRequest(proto.Message): r"""Request message for ImportData API. + Attributes: name (str): Required. Dataset resource name, format: @@ -182,6 +188,7 @@ class ImportDataRequest(proto.Message): class ExportDataRequest(proto.Message): r"""Request message for ExportData API. + Attributes: name (str): Required. Dataset resource name, format: @@ -214,6 +221,7 @@ class ExportDataRequest(proto.Message): class GetDataItemRequest(proto.Message): r"""Request message for GetDataItem. + Attributes: name (str): Required. The name of the data item to get, format: @@ -225,6 +233,7 @@ class GetDataItemRequest(proto.Message): class ListDataItemsRequest(proto.Message): r"""Request message for ListDataItems. + Attributes: parent (str): Required. Name of the dataset to list data items, format: @@ -252,6 +261,7 @@ class ListDataItemsRequest(proto.Message): class ListDataItemsResponse(proto.Message): r"""Results of listing data items in a dataset. + Attributes: data_items (Sequence[google.cloud.datalabeling_v1beta1.types.DataItem]): The list of data items to return. @@ -271,6 +281,7 @@ def raw_page(self): class GetAnnotatedDatasetRequest(proto.Message): r"""Request message for GetAnnotatedDataset. + Attributes: name (str): Required. Name of the annotated dataset to get, format: @@ -283,6 +294,7 @@ class GetAnnotatedDatasetRequest(proto.Message): class ListAnnotatedDatasetsRequest(proto.Message): r"""Request message for ListAnnotatedDatasets. + Attributes: parent (str): Required. Name of the dataset to list annotated datasets, @@ -310,6 +322,7 @@ class ListAnnotatedDatasetsRequest(proto.Message): class ListAnnotatedDatasetsResponse(proto.Message): r"""Results of listing annotated datasets for a dataset. + Attributes: annotated_datasets (Sequence[google.cloud.datalabeling_v1beta1.types.AnnotatedDataset]): The list of annotated datasets to return. @@ -329,6 +342,7 @@ def raw_page(self): class DeleteAnnotatedDatasetRequest(proto.Message): r"""Request message for DeleteAnnotatedDataset. + Attributes: name (str): Required. Name of the annotated dataset to delete, format: @@ -341,6 +355,7 @@ class DeleteAnnotatedDatasetRequest(proto.Message): class LabelImageRequest(proto.Message): r"""Request message for starting an image labeling task. + Attributes: image_classification_config (google.cloud.datalabeling_v1beta1.types.ImageClassificationConfig): Configuration for image classification task. One of @@ -410,6 +425,7 @@ class Feature(proto.Enum): class LabelVideoRequest(proto.Message): r"""Request message for LabelVideo. + Attributes: video_classification_config (google.cloud.datalabeling_v1beta1.types.VideoClassificationConfig): Configuration for video classification task. One of @@ -477,6 +493,7 @@ class Feature(proto.Enum): class LabelTextRequest(proto.Message): r"""Request message for LabelText. + Attributes: text_classification_config (google.cloud.datalabeling_v1beta1.types.TextClassificationConfig): Configuration for text classification task. One of @@ -522,6 +539,7 @@ class Feature(proto.Enum): class GetExampleRequest(proto.Message): r"""Request message for GetExample + Attributes: name (str): Required. Name of example, format: @@ -539,6 +557,7 @@ class GetExampleRequest(proto.Message): class ListExamplesRequest(proto.Message): r"""Request message for ListExamples. + Attributes: parent (str): Required. Example resource parent. @@ -567,6 +586,7 @@ class ListExamplesRequest(proto.Message): class ListExamplesResponse(proto.Message): r"""Results of listing Examples in and annotated dataset. + Attributes: examples (Sequence[google.cloud.datalabeling_v1beta1.types.Example]): The list of examples to return. @@ -586,6 +606,7 @@ def raw_page(self): class CreateAnnotationSpecSetRequest(proto.Message): r"""Request message for CreateAnnotationSpecSet. + Attributes: parent (str): Required. AnnotationSpecSet resource parent, format: @@ -604,6 +625,7 @@ class CreateAnnotationSpecSetRequest(proto.Message): class GetAnnotationSpecSetRequest(proto.Message): r"""Request message for GetAnnotationSpecSet. + Attributes: name (str): Required. AnnotationSpecSet resource name, format: @@ -615,6 +637,7 @@ class GetAnnotationSpecSetRequest(proto.Message): class ListAnnotationSpecSetsRequest(proto.Message): r"""Request message for ListAnnotationSpecSets. + Attributes: parent (str): Required. Parent of AnnotationSpecSet resource, format: @@ -642,6 +665,7 @@ class ListAnnotationSpecSetsRequest(proto.Message): class ListAnnotationSpecSetsResponse(proto.Message): r"""Results of listing annotation spec set under a project. + Attributes: annotation_spec_sets (Sequence[google.cloud.datalabeling_v1beta1.types.AnnotationSpecSet]): The list of annotation spec sets. @@ -661,6 +685,7 @@ def raw_page(self): class DeleteAnnotationSpecSetRequest(proto.Message): r"""Request message for DeleteAnnotationSpecSet. + Attributes: name (str): Required. AnnotationSpec resource name, format: @@ -672,6 +697,7 @@ class DeleteAnnotationSpecSetRequest(proto.Message): class CreateInstructionRequest(proto.Message): r"""Request message for CreateInstruction. + Attributes: parent (str): Required. Instruction resource parent, format: @@ -689,6 +715,7 @@ class CreateInstructionRequest(proto.Message): class GetInstructionRequest(proto.Message): r"""Request message for GetInstruction. + Attributes: name (str): Required. Instruction resource name, format: @@ -700,6 +727,7 @@ class GetInstructionRequest(proto.Message): class DeleteInstructionRequest(proto.Message): r"""Request message for DeleteInstruction. + Attributes: name (str): Required. Instruction resource name, format: @@ -711,6 +739,7 @@ class DeleteInstructionRequest(proto.Message): class ListInstructionsRequest(proto.Message): r"""Request message for ListInstructions. + Attributes: parent (str): Required. Instruction resource parent, format: @@ -738,6 +767,7 @@ class ListInstructionsRequest(proto.Message): class ListInstructionsResponse(proto.Message): r"""Results of listing instructions under a project. + Attributes: instructions (Sequence[google.cloud.datalabeling_v1beta1.types.Instruction]): The list of Instructions to return. @@ -757,6 +787,7 @@ def raw_page(self): class GetEvaluationRequest(proto.Message): r"""Request message for GetEvaluation. + Attributes: name (str): Required. Name of the evaluation. Format: @@ -769,6 +800,7 @@ class GetEvaluationRequest(proto.Message): class SearchEvaluationsRequest(proto.Message): r"""Request message for SearchEvaluation. + Attributes: parent (str): Required. Evaluation search parent (project ID). Format: @@ -827,6 +859,7 @@ class SearchEvaluationsRequest(proto.Message): class SearchEvaluationsResponse(proto.Message): r"""Results of searching evaluations. + Attributes: evaluations (Sequence[google.cloud.datalabeling_v1beta1.types.Evaluation]): The list of evaluations matching the search. @@ -846,6 +879,7 @@ def raw_page(self): class SearchExampleComparisonsRequest(proto.Message): r"""Request message of SearchExampleComparisons. + Attributes: parent (str): Required. Name of the @@ -874,6 +908,7 @@ class SearchExampleComparisonsRequest(proto.Message): class SearchExampleComparisonsResponse(proto.Message): r"""Results of searching example comparisons. + Attributes: example_comparisons (Sequence[google.cloud.datalabeling_v1beta1.types.SearchExampleComparisonsResponse.ExampleComparison]): A list of example comparisons matching the @@ -912,6 +947,7 @@ def raw_page(self): class CreateEvaluationJobRequest(proto.Message): r"""Request message for CreateEvaluationJob. + Attributes: parent (str): Required. Evaluation job resource parent. Format: @@ -928,6 +964,7 @@ class CreateEvaluationJobRequest(proto.Message): class UpdateEvaluationJobRequest(proto.Message): r"""Request message for UpdateEvaluationJob. + Attributes: evaluation_job (google.cloud.datalabeling_v1beta1.types.EvaluationJob): Required. Evaluation job that is going to be @@ -954,6 +991,7 @@ class UpdateEvaluationJobRequest(proto.Message): class GetEvaluationJobRequest(proto.Message): r"""Request message for GetEvaluationJob. + Attributes: name (str): Required. Name of the evaluation job. Format: @@ -966,6 +1004,7 @@ class GetEvaluationJobRequest(proto.Message): class PauseEvaluationJobRequest(proto.Message): r"""Request message for PauseEvaluationJob. + Attributes: name (str): Required. Name of the evaluation job that is going to be @@ -979,6 +1018,7 @@ class PauseEvaluationJobRequest(proto.Message): class ResumeEvaluationJobRequest(proto.Message): r"""Request message ResumeEvaluationJob. + Attributes: name (str): Required. Name of the evaluation job that is going to be @@ -992,6 +1032,7 @@ class ResumeEvaluationJobRequest(proto.Message): class DeleteEvaluationJobRequest(proto.Message): r"""Request message DeleteEvaluationJob. + Attributes: name (str): Required. Name of the evaluation job that is going to be @@ -1005,6 +1046,7 @@ class DeleteEvaluationJobRequest(proto.Message): class ListEvaluationJobsRequest(proto.Message): r"""Request message for ListEvaluationJobs. + Attributes: parent (str): Required. Evaluation job resource parent. Format: @@ -1040,6 +1082,7 @@ class ListEvaluationJobsRequest(proto.Message): class ListEvaluationJobsResponse(proto.Message): r"""Results for listing evaluation jobs. + Attributes: evaluation_jobs (Sequence[google.cloud.datalabeling_v1beta1.types.EvaluationJob]): The list of evaluation jobs to return. diff --git a/google/cloud/datalabeling_v1beta1/types/data_payloads.py b/google/cloud/datalabeling_v1beta1/types/data_payloads.py index bb70d32..1461f6e 100644 --- a/google/cloud/datalabeling_v1beta1/types/data_payloads.py +++ b/google/cloud/datalabeling_v1beta1/types/data_payloads.py @@ -26,6 +26,7 @@ class ImagePayload(proto.Message): r"""Container of information about an image. + Attributes: mime_type (str): Image format. @@ -46,6 +47,7 @@ class ImagePayload(proto.Message): class TextPayload(proto.Message): r"""Container of information about a piece of text. + Attributes: text_content (str): Text content. @@ -56,6 +58,7 @@ class TextPayload(proto.Message): class VideoThumbnail(proto.Message): r"""Container of information of a video thumbnail. + Attributes: thumbnail (bytes): A byte string of the video frame. @@ -71,6 +74,7 @@ class VideoThumbnail(proto.Message): class VideoPayload(proto.Message): r"""Container of information of a video. + Attributes: mime_type (str): Video format. diff --git a/google/cloud/datalabeling_v1beta1/types/dataset.py b/google/cloud/datalabeling_v1beta1/types/dataset.py index e5abd68..e50fb30 100644 --- a/google/cloud/datalabeling_v1beta1/types/dataset.py +++ b/google/cloud/datalabeling_v1beta1/types/dataset.py @@ -142,6 +142,7 @@ class InputConfig(proto.Message): class TextMetadata(proto.Message): r"""Metadata for the text. + Attributes: language_code (str): The language of this text, as a @@ -154,6 +155,7 @@ class TextMetadata(proto.Message): class ClassificationMetadata(proto.Message): r"""Metadata for classification annotations. + Attributes: is_multi_label (bool): Whether the classification task is multi- @@ -165,6 +167,7 @@ class ClassificationMetadata(proto.Message): class GcsSource(proto.Message): r"""Source of the Cloud Storage file to be imported. + Attributes: input_uri (str): Required. The input URI of source file. This must be a Cloud @@ -208,6 +211,7 @@ class BigQuerySource(proto.Message): class OutputConfig(proto.Message): r"""The configuration of output data. + Attributes: gcs_destination (google.cloud.datalabeling_v1beta1.types.GcsDestination): Output to a file in Cloud Storage. Should be @@ -245,6 +249,7 @@ class GcsDestination(proto.Message): class GcsFolderDestination(proto.Message): r"""Export folder destination of the data. + Attributes: output_folder_uri (str): Required. Cloud Storage directory to export @@ -349,6 +354,7 @@ class AnnotatedDataset(proto.Message): class LabelStats(proto.Message): r"""Statistics about annotation specs. + Attributes: example_count (Sequence[google.cloud.datalabeling_v1beta1.types.LabelStats.ExampleCountEntry]): Map of each annotation spec's example count. @@ -365,6 +371,7 @@ class LabelStats(proto.Message): class AnnotatedDatasetMetadata(proto.Message): r"""Metadata on AnnotatedDataset. + Attributes: image_classification_config (google.cloud.datalabeling_v1beta1.types.ImageClassificationConfig): Configuration for image classification task. diff --git a/google/cloud/datalabeling_v1beta1/types/evaluation.py b/google/cloud/datalabeling_v1beta1/types/evaluation.py index ea72b33..0bd1ff8 100644 --- a/google/cloud/datalabeling_v1beta1/types/evaluation.py +++ b/google/cloud/datalabeling_v1beta1/types/evaluation.py @@ -107,6 +107,7 @@ class EvaluationConfig(proto.Message): class BoundingBoxEvaluationOptions(proto.Message): r"""Options regarding evaluation between bounding boxes. + Attributes: iou_threshold (float): Minimum [intersection-over-union @@ -121,6 +122,7 @@ class BoundingBoxEvaluationOptions(proto.Message): class EvaluationMetrics(proto.Message): r""" + Attributes: classification_metrics (google.cloud.datalabeling_v1beta1.types.ClassificationMetrics): @@ -138,6 +140,7 @@ class EvaluationMetrics(proto.Message): class ClassificationMetrics(proto.Message): r"""Metrics calculated for a classification model. + Attributes: pr_curve (google.cloud.datalabeling_v1beta1.types.PrCurve): Precision-recall curve based on ground truth @@ -166,6 +169,7 @@ class ObjectDetectionMetrics(proto.Message): class PrCurve(proto.Message): r""" + Attributes: annotation_spec (google.cloud.datalabeling_v1beta1.types.AnnotationSpec): The annotation spec of the label for which @@ -186,6 +190,7 @@ class PrCurve(proto.Message): class ConfidenceMetricsEntry(proto.Message): r""" + Attributes: confidence_threshold (float): Threshold used for this entry. @@ -263,6 +268,7 @@ class ConfusionMatrix(proto.Message): class ConfusionMatrixEntry(proto.Message): r""" + Attributes: annotation_spec (google.cloud.datalabeling_v1beta1.types.AnnotationSpec): The annotation spec of a predicted label. diff --git a/google/cloud/datalabeling_v1beta1/types/evaluation_job.py b/google/cloud/datalabeling_v1beta1/types/evaluation_job.py index 4ca05fc..e9186a9 100644 --- a/google/cloud/datalabeling_v1beta1/types/evaluation_job.py +++ b/google/cloud/datalabeling_v1beta1/types/evaluation_job.py @@ -301,6 +301,7 @@ class EvaluationJobAlertConfig(proto.Message): class Attempt(proto.Message): r"""Records a failed evaluation job run. + Attributes: attempt_time (google.protobuf.timestamp_pb2.Timestamp): diff --git a/google/cloud/datalabeling_v1beta1/types/human_annotation_config.py b/google/cloud/datalabeling_v1beta1/types/human_annotation_config.py index 567a941..06e953a 100644 --- a/google/cloud/datalabeling_v1beta1/types/human_annotation_config.py +++ b/google/cloud/datalabeling_v1beta1/types/human_annotation_config.py @@ -48,6 +48,7 @@ class StringAggregationType(proto.Enum): class HumanAnnotationConfig(proto.Message): r"""Configuration for how human labeling task should be done. + Attributes: instruction (str): Required. Instruction resource name. @@ -108,6 +109,7 @@ class HumanAnnotationConfig(proto.Message): class ImageClassificationConfig(proto.Message): r"""Config for image classification human labeling task. + Attributes: annotation_spec_set (str): Required. Annotation spec set resource name. @@ -144,6 +146,7 @@ class BoundingPolyConfig(proto.Message): class PolylineConfig(proto.Message): r"""Config for image polyline human labeling task. + Attributes: annotation_spec_set (str): Required. Annotation spec set resource name. @@ -158,6 +161,7 @@ class PolylineConfig(proto.Message): class SegmentationConfig(proto.Message): r"""Config for image segmentation + Attributes: annotation_spec_set (str): Required. Annotation spec set resource name. format: @@ -234,6 +238,7 @@ class ObjectDetectionConfig(proto.Message): class ObjectTrackingConfig(proto.Message): r"""Config for video object tracking human labeling task. + Attributes: annotation_spec_set (str): Required. Annotation spec set resource name. @@ -244,6 +249,7 @@ class ObjectTrackingConfig(proto.Message): class EventConfig(proto.Message): r"""Config for video event human labeling task. + Attributes: annotation_spec_sets (Sequence[str]): Required. The list of annotation spec set @@ -257,6 +263,7 @@ class EventConfig(proto.Message): class TextClassificationConfig(proto.Message): r"""Config for text classification human labeling task. + Attributes: allow_multi_label (bool): Optional. If allow_multi_label is true, contributors are @@ -274,6 +281,7 @@ class TextClassificationConfig(proto.Message): class SentimentConfig(proto.Message): r"""Config for setting up sentiments. + Attributes: enable_label_sentiment_selection (bool): If set to true, contributors will have the @@ -287,6 +295,7 @@ class SentimentConfig(proto.Message): class TextEntityExtractionConfig(proto.Message): r"""Config for text entity extraction human labeling task. + Attributes: annotation_spec_set (str): Required. Annotation spec set resource name. diff --git a/google/cloud/datalabeling_v1beta1/types/instruction.py b/google/cloud/datalabeling_v1beta1/types/instruction.py index 4479bfd..1af72eb 100644 --- a/google/cloud/datalabeling_v1beta1/types/instruction.py +++ b/google/cloud/datalabeling_v1beta1/types/instruction.py @@ -91,6 +91,7 @@ class CsvInstruction(proto.Message): class PdfInstruction(proto.Message): r"""Instruction from a PDF file. + Attributes: gcs_file_uri (str): PDF file for the instruction. Only gcs path diff --git a/google/cloud/datalabeling_v1beta1/types/operations.py b/google/cloud/datalabeling_v1beta1/types/operations.py index c99585f..e7f37c4 100644 --- a/google/cloud/datalabeling_v1beta1/types/operations.py +++ b/google/cloud/datalabeling_v1beta1/types/operations.py @@ -48,6 +48,7 @@ class ImportDataOperationResponse(proto.Message): r"""Response used for ImportData longrunning operation. + Attributes: dataset (str): Ouptut only. The name of imported dataset. @@ -66,6 +67,7 @@ class ImportDataOperationResponse(proto.Message): class ExportDataOperationResponse(proto.Message): r"""Response used for ExportDataset longrunning operation. + Attributes: dataset (str): Ouptut only. The name of dataset. "projects/*/datasets/*". @@ -93,6 +95,7 @@ class ExportDataOperationResponse(proto.Message): class ImportDataOperationMetadata(proto.Message): r"""Metadata of an ImportData operation. + Attributes: dataset (str): Output only. The name of imported dataset. @@ -116,6 +119,7 @@ class ImportDataOperationMetadata(proto.Message): class ExportDataOperationMetadata(proto.Message): r"""Metadata of an ExportData operation. + Attributes: dataset (str): Output only. The name of dataset to be exported. @@ -271,6 +275,7 @@ class LabelOperationMetadata(proto.Message): class LabelImageClassificationOperationMetadata(proto.Message): r"""Metadata of a LabelImageClassification operation. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -284,6 +289,7 @@ class LabelImageClassificationOperationMetadata(proto.Message): class LabelImageBoundingBoxOperationMetadata(proto.Message): r"""Details of a LabelImageBoundingBox operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -311,6 +317,7 @@ class LabelImageOrientedBoundingBoxOperationMetadata(proto.Message): class LabelImageBoundingPolyOperationMetadata(proto.Message): r"""Details of LabelImageBoundingPoly operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -324,6 +331,7 @@ class LabelImageBoundingPolyOperationMetadata(proto.Message): class LabelImagePolylineOperationMetadata(proto.Message): r"""Details of LabelImagePolyline operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -337,6 +345,7 @@ class LabelImagePolylineOperationMetadata(proto.Message): class LabelImageSegmentationOperationMetadata(proto.Message): r"""Details of a LabelImageSegmentation operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config. @@ -349,6 +358,7 @@ class LabelImageSegmentationOperationMetadata(proto.Message): class LabelVideoClassificationOperationMetadata(proto.Message): r"""Details of a LabelVideoClassification operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -362,6 +372,7 @@ class LabelVideoClassificationOperationMetadata(proto.Message): class LabelVideoObjectDetectionOperationMetadata(proto.Message): r"""Details of a LabelVideoObjectDetection operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -375,6 +386,7 @@ class LabelVideoObjectDetectionOperationMetadata(proto.Message): class LabelVideoObjectTrackingOperationMetadata(proto.Message): r"""Details of a LabelVideoObjectTracking operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -388,6 +400,7 @@ class LabelVideoObjectTrackingOperationMetadata(proto.Message): class LabelVideoEventOperationMetadata(proto.Message): r"""Details of a LabelVideoEvent operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -401,6 +414,7 @@ class LabelVideoEventOperationMetadata(proto.Message): class LabelTextClassificationOperationMetadata(proto.Message): r"""Details of a LabelTextClassification operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -414,6 +428,7 @@ class LabelTextClassificationOperationMetadata(proto.Message): class LabelTextEntityExtractionOperationMetadata(proto.Message): r"""Details of a LabelTextEntityExtraction operation metadata. + Attributes: basic_config (google.cloud.datalabeling_v1beta1.types.HumanAnnotationConfig): Basic human annotation config used in @@ -427,6 +442,7 @@ class LabelTextEntityExtractionOperationMetadata(proto.Message): class CreateInstructionMetadata(proto.Message): r"""Metadata of a CreateInstruction operation. + Attributes: instruction (str): The name of the created Instruction. diff --git a/tests/unit/gapic/datalabeling_v1beta1/test_data_labeling_service.py b/tests/unit/gapic/datalabeling_v1beta1/test_data_labeling_service.py index 78027b2..a4d2fe6 100644 --- a/tests/unit/gapic/datalabeling_v1beta1/test_data_labeling_service.py +++ b/tests/unit/gapic/datalabeling_v1beta1/test_data_labeling_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.datalabeling_v1beta1.services.data_labeling_service import ( @@ -9970,6 +9971,9 @@ def test_data_labeling_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): @@ -10656,3 +10660,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 = DataLabelingServiceAsyncClient( + 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 = DataLabelingServiceClient( + 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 = DataLabelingServiceClient( + 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()