diff --git a/.coveragerc b/.coveragerc index 5b3f287a0f..01d28d4b2c 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,7 +2,6 @@ branch = True [report] -fail_under = 100 show_missing = True omit = google/cloud/aiplatform/v1/schema/trainingjob/definition/__init__.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1bbd787833..4f00c7cffc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,6 @@ repos: hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.1 + rev: 3.9.2 hooks: - id: flake8 diff --git a/docs/aiplatform_v1/dataset_service.rst b/docs/aiplatform_v1/dataset_service.rst index 46694cf2c0..79ddc4623f 100644 --- a/docs/aiplatform_v1/dataset_service.rst +++ b/docs/aiplatform_v1/dataset_service.rst @@ -5,7 +5,6 @@ DatasetService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1.services.dataset_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1/endpoint_service.rst b/docs/aiplatform_v1/endpoint_service.rst index 29d05c30b4..3b900f851e 100644 --- a/docs/aiplatform_v1/endpoint_service.rst +++ b/docs/aiplatform_v1/endpoint_service.rst @@ -5,7 +5,6 @@ EndpointService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1.services.endpoint_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1/job_service.rst b/docs/aiplatform_v1/job_service.rst index 6bfd457244..6afcbbb4d0 100644 --- a/docs/aiplatform_v1/job_service.rst +++ b/docs/aiplatform_v1/job_service.rst @@ -5,7 +5,6 @@ JobService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1.services.job_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1/migration_service.rst b/docs/aiplatform_v1/migration_service.rst index f322a1b3bf..ac0a5fb3aa 100644 --- a/docs/aiplatform_v1/migration_service.rst +++ b/docs/aiplatform_v1/migration_service.rst @@ -5,7 +5,6 @@ MigrationService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1.services.migration_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1/model_service.rst b/docs/aiplatform_v1/model_service.rst index ca269a9ad2..8baab43cbc 100644 --- a/docs/aiplatform_v1/model_service.rst +++ b/docs/aiplatform_v1/model_service.rst @@ -5,7 +5,6 @@ ModelService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1.services.model_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1/pipeline_service.rst b/docs/aiplatform_v1/pipeline_service.rst index b718db39b4..bbf6b32092 100644 --- a/docs/aiplatform_v1/pipeline_service.rst +++ b/docs/aiplatform_v1/pipeline_service.rst @@ -5,7 +5,6 @@ PipelineService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1.services.pipeline_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1/specialist_pool_service.rst b/docs/aiplatform_v1/specialist_pool_service.rst index 37ac386b31..4a6f288894 100644 --- a/docs/aiplatform_v1/specialist_pool_service.rst +++ b/docs/aiplatform_v1/specialist_pool_service.rst @@ -5,7 +5,6 @@ SpecialistPoolService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1.services.specialist_pool_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/dataset_service.rst b/docs/aiplatform_v1beta1/dataset_service.rst index ad3866e1e4..43fad30e55 100644 --- a/docs/aiplatform_v1beta1/dataset_service.rst +++ b/docs/aiplatform_v1beta1/dataset_service.rst @@ -5,7 +5,6 @@ DatasetService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.dataset_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/endpoint_service.rst b/docs/aiplatform_v1beta1/endpoint_service.rst index c5ce91ed19..022799a059 100644 --- a/docs/aiplatform_v1beta1/endpoint_service.rst +++ b/docs/aiplatform_v1beta1/endpoint_service.rst @@ -5,7 +5,6 @@ EndpointService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.endpoint_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/featurestore_service.rst b/docs/aiplatform_v1beta1/featurestore_service.rst index d05deb4c2c..8d2f33039e 100644 --- a/docs/aiplatform_v1beta1/featurestore_service.rst +++ b/docs/aiplatform_v1beta1/featurestore_service.rst @@ -5,7 +5,6 @@ FeaturestoreService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.featurestore_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/index_endpoint_service.rst b/docs/aiplatform_v1beta1/index_endpoint_service.rst index 2389e5bf64..65c910142e 100644 --- a/docs/aiplatform_v1beta1/index_endpoint_service.rst +++ b/docs/aiplatform_v1beta1/index_endpoint_service.rst @@ -5,7 +5,6 @@ IndexEndpointService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.index_endpoint_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/index_service.rst b/docs/aiplatform_v1beta1/index_service.rst index e42ade6eaa..96afb58594 100644 --- a/docs/aiplatform_v1beta1/index_service.rst +++ b/docs/aiplatform_v1beta1/index_service.rst @@ -5,7 +5,6 @@ IndexService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.index_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/job_service.rst b/docs/aiplatform_v1beta1/job_service.rst index eee169a096..46b1268166 100644 --- a/docs/aiplatform_v1beta1/job_service.rst +++ b/docs/aiplatform_v1beta1/job_service.rst @@ -5,7 +5,6 @@ JobService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.job_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/metadata_service.rst b/docs/aiplatform_v1beta1/metadata_service.rst index c1ebfa9585..3c07725687 100644 --- a/docs/aiplatform_v1beta1/metadata_service.rst +++ b/docs/aiplatform_v1beta1/metadata_service.rst @@ -5,7 +5,6 @@ MetadataService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.metadata_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/migration_service.rst b/docs/aiplatform_v1beta1/migration_service.rst index 42ff54c101..be164d59ba 100644 --- a/docs/aiplatform_v1beta1/migration_service.rst +++ b/docs/aiplatform_v1beta1/migration_service.rst @@ -5,7 +5,6 @@ MigrationService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.migration_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/model_service.rst b/docs/aiplatform_v1beta1/model_service.rst index 0fc01a1bd6..be68f796b0 100644 --- a/docs/aiplatform_v1beta1/model_service.rst +++ b/docs/aiplatform_v1beta1/model_service.rst @@ -5,7 +5,6 @@ ModelService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.model_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/pipeline_service.rst b/docs/aiplatform_v1beta1/pipeline_service.rst index 465949eeb0..1180370863 100644 --- a/docs/aiplatform_v1beta1/pipeline_service.rst +++ b/docs/aiplatform_v1beta1/pipeline_service.rst @@ -5,7 +5,6 @@ PipelineService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.pipeline_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/specialist_pool_service.rst b/docs/aiplatform_v1beta1/specialist_pool_service.rst index 4d264dc256..2f13b68844 100644 --- a/docs/aiplatform_v1beta1/specialist_pool_service.rst +++ b/docs/aiplatform_v1beta1/specialist_pool_service.rst @@ -5,7 +5,6 @@ SpecialistPoolService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.specialist_pool_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/tensorboard_service.rst b/docs/aiplatform_v1beta1/tensorboard_service.rst index 423efcd796..97d94feedc 100644 --- a/docs/aiplatform_v1beta1/tensorboard_service.rst +++ b/docs/aiplatform_v1beta1/tensorboard_service.rst @@ -5,7 +5,6 @@ TensorboardService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.tensorboard_service.pagers :members: :inherited-members: diff --git a/docs/aiplatform_v1beta1/vizier_service.rst b/docs/aiplatform_v1beta1/vizier_service.rst index 7235400038..8cad590f6c 100644 --- a/docs/aiplatform_v1beta1/vizier_service.rst +++ b/docs/aiplatform_v1beta1/vizier_service.rst @@ -5,7 +5,6 @@ VizierService :members: :inherited-members: - .. automodule:: google.cloud.aiplatform_v1beta1.services.vizier_service.pagers :members: :inherited-members: diff --git a/examples/feature_fragments b/examples/feature_fragments new file mode 100644 index 0000000000..7d1b624770 --- /dev/null +++ b/examples/feature_fragments @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +} diff --git a/google/cloud/aiplatform/v1/schema/predict/instance/__init__.py b/google/cloud/aiplatform/v1/schema/predict/instance/__init__.py index fb2668afb5..135e131a29 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_classification import ( ImageClassificationPredictionInstance, ) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/__init__.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/__init__.py index f6d9a128ad..fdfe1ca46f 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.image_classification import ImageClassificationPredictionInstance from .types.image_object_detection import ImageObjectDetectionPredictionInstance from .types.image_segmentation import ImageSegmentationPredictionInstance @@ -25,8 +25,8 @@ from .types.video_classification import VideoClassificationPredictionInstance from .types.video_object_tracking import VideoObjectTrackingPredictionInstance - __all__ = ( + "ImageClassificationPredictionInstance", "ImageObjectDetectionPredictionInstance", "ImageSegmentationPredictionInstance", "TextClassificationPredictionInstance", @@ -35,5 +35,4 @@ "VideoActionRecognitionPredictionInstance", "VideoClassificationPredictionInstance", "VideoObjectTrackingPredictionInstance", - "ImageClassificationPredictionInstance", ) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_metadata.json b/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_metadata.json new file mode 100644 index 0000000000..0ae909d6ea --- /dev/null +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1.schema.predict.instance_v1", + "protoPackage": "google.cloud.aiplatform.v1.schema.predict.instance", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/__init__.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/__init__.py index 041fe6cdb1..744852e8a3 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .image_classification import ImageClassificationPredictionInstance from .image_object_detection import ImageObjectDetectionPredictionInstance from .image_segmentation import ImageSegmentationPredictionInstance diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_classification.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_classification.py index b5fa9b4dbf..04e7b841a5 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageClassificationPredictionInstance(proto.Message): r"""Prediction input format for Image Classification. - Attributes: content (str): The image bytes or GCS URI to make the @@ -43,9 +40,8 @@ class ImageClassificationPredictionInstance(proto.Message): - image/vnd.microsoft.icon """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_object_detection.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_object_detection.py index 45752ce7e2..5180c12ece 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_object_detection.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageObjectDetectionPredictionInstance(proto.Message): r"""Prediction input format for Image Object Detection. - Attributes: content (str): The image bytes or GCS URI to make the @@ -43,9 +40,8 @@ class ImageObjectDetectionPredictionInstance(proto.Message): - image/vnd.microsoft.icon """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_segmentation.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_segmentation.py index cb436d7029..0591b17208 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_segmentation.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageSegmentationPredictionInstance(proto.Message): r"""Prediction input format for Image Segmentation. - Attributes: content (str): The image bytes to make the predictions on. @@ -37,9 +34,8 @@ class ImageSegmentationPredictionInstance(proto.Message): - image/png """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_classification.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_classification.py index ceff5308b7..aafbcac3e7 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextClassificationPredictionInstance(proto.Message): r"""Prediction input format for Text Classification. - Attributes: content (str): The text snippet to make the predictions on. @@ -36,9 +33,8 @@ class TextClassificationPredictionInstance(proto.Message): - text/plain """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_extraction.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_extraction.py index 2e96216466..ba1997ba05 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_extraction.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_extraction.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextExtractionPredictionInstance(proto.Message): r"""Prediction input format for Text Extraction. - Attributes: content (str): The text snippet to make the predictions on. @@ -45,11 +42,9 @@ class TextExtractionPredictionInstance(proto.Message): unique. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - key = proto.Field(proto.STRING, number=3) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + key = proto.Field(proto.STRING, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_sentiment.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_sentiment.py index 37353ad806..d86d58f40f 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_sentiment.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/text_sentiment.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextSentimentPredictionInstance(proto.Message): r"""Prediction input format for Text Sentiment. - Attributes: content (str): The text snippet to make the predictions on. @@ -36,9 +33,8 @@ class TextSentimentPredictionInstance(proto.Message): - text/plain """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_action_recognition.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_action_recognition.py index 6de5665312..d8db889408 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_action_recognition.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoActionRecognitionPredictionInstance(proto.Message): r"""Prediction input format for Video Action Recognition. - Attributes: content (str): The Google Cloud Storage location of the @@ -52,13 +49,10 @@ class VideoActionRecognitionPredictionInstance(proto.Message): is allowed, which means the end of the video. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - time_segment_start = proto.Field(proto.STRING, number=3) - - time_segment_end = proto.Field(proto.STRING, number=4) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + time_segment_start = proto.Field(proto.STRING, number=3,) + time_segment_end = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_classification.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_classification.py index ab7c0edfe1..f03e673f90 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoClassificationPredictionInstance(proto.Message): r"""Prediction input format for Video Classification. - Attributes: content (str): The Google Cloud Storage location of the @@ -52,13 +49,10 @@ class VideoClassificationPredictionInstance(proto.Message): is allowed, which means the end of the video. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - time_segment_start = proto.Field(proto.STRING, number=3) - - time_segment_end = proto.Field(proto.STRING, number=4) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + time_segment_start = proto.Field(proto.STRING, number=3,) + time_segment_end = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_object_tracking.py b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_object_tracking.py index f797f58f4e..5df1e42eb5 100644 --- a/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_object_tracking.py +++ b/google/cloud/aiplatform/v1/schema/predict/instance_v1/types/video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoObjectTrackingPredictionInstance(proto.Message): r"""Prediction input format for Video Object Tracking. - Attributes: content (str): The Google Cloud Storage location of the @@ -52,13 +49,10 @@ class VideoObjectTrackingPredictionInstance(proto.Message): is allowed, which means the end of the video. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - time_segment_start = proto.Field(proto.STRING, number=3) - - time_segment_end = proto.Field(proto.STRING, number=4) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + time_segment_start = proto.Field(proto.STRING, number=3,) + time_segment_end = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/params/__init__.py b/google/cloud/aiplatform/v1/schema/predict/params/__init__.py index c046f4d7e5..a55ff6dc0f 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/params/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_classification import ( ImageClassificationPredictionParams, ) diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/__init__.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/__init__.py index 79fb1c2097..dcf74bb7a0 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.image_classification import ImageClassificationPredictionParams from .types.image_object_detection import ImageObjectDetectionPredictionParams from .types.image_segmentation import ImageSegmentationPredictionParams @@ -22,12 +22,11 @@ from .types.video_classification import VideoClassificationPredictionParams from .types.video_object_tracking import VideoObjectTrackingPredictionParams - __all__ = ( + "ImageClassificationPredictionParams", "ImageObjectDetectionPredictionParams", "ImageSegmentationPredictionParams", "VideoActionRecognitionPredictionParams", "VideoClassificationPredictionParams", "VideoObjectTrackingPredictionParams", - "ImageClassificationPredictionParams", ) diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_metadata.json b/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_metadata.json new file mode 100644 index 0000000000..edfffb441b --- /dev/null +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1.schema.predict.params_v1", + "protoPackage": "google.cloud.aiplatform.v1.schema.predict.params", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/__init__.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/__init__.py index 2f2c29bba5..26997a8d81 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .image_classification import ImageClassificationPredictionParams from .image_object_detection import ImageObjectDetectionPredictionParams from .image_segmentation import ImageSegmentationPredictionParams diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_classification.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_classification.py index 3a9efd0ea2..e042f39854 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageClassificationPredictionParams(proto.Message): r"""Prediction model parameters for Image Classification. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -39,9 +36,8 @@ class ImageClassificationPredictionParams(proto.Message): return fewer predictions. Default value is 10. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_object_detection.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_object_detection.py index c37507a4e0..4ca8404d61 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_object_detection.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageObjectDetectionPredictionParams(proto.Message): r"""Prediction model parameters for Image Object Detection. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -40,9 +37,8 @@ class ImageObjectDetectionPredictionParams(proto.Message): value is 10. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_segmentation.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_segmentation.py index 108cff107b..6a2102b808 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_segmentation.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageSegmentationPredictionParams(proto.Message): r"""Prediction model parameters for Image Segmentation. - Attributes: confidence_threshold (float): When the model predicts category of pixels of @@ -36,7 +33,7 @@ class ImageSegmentationPredictionParams(proto.Message): background. Default value is 0.5. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_action_recognition.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_action_recognition.py index 66f1f19e76..f09d2058e3 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_action_recognition.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoActionRecognitionPredictionParams(proto.Message): r"""Prediction model parameters for Video Action Recognition. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -40,9 +37,8 @@ class VideoActionRecognitionPredictionParams(proto.Message): Default value is 50. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_classification.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_classification.py index bfe8df9f5c..1ab180bbe2 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoClassificationPredictionParams(proto.Message): r"""Prediction model parameters for Video Classification. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -71,15 +68,11 @@ class VideoClassificationPredictionParams(proto.Message): is false """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) - - segment_classification = proto.Field(proto.BOOL, number=3) - - shot_classification = proto.Field(proto.BOOL, number=4) - - one_sec_interval_classification = proto.Field(proto.BOOL, number=5) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) + segment_classification = proto.Field(proto.BOOL, number=3,) + shot_classification = proto.Field(proto.BOOL, number=4,) + one_sec_interval_classification = proto.Field(proto.BOOL, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_object_tracking.py b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_object_tracking.py index 899de1050a..83dedee1d9 100644 --- a/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_object_tracking.py +++ b/google/cloud/aiplatform/v1/schema/predict/params_v1/types/video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoObjectTrackingPredictionParams(proto.Message): r"""Prediction model parameters for Video Object Tracking. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -44,11 +41,9 @@ class VideoObjectTrackingPredictionParams(proto.Message): frame size are returned. Default value is 0.0. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) - - min_bounding_box_size = proto.Field(proto.FLOAT, number=3) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) + min_bounding_box_size = proto.Field(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction/__init__.py b/google/cloud/aiplatform/v1/schema/predict/prediction/__init__.py index d8e2b782c2..a39dd71937 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.classification import ( ClassificationPredictionResult, ) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/__init__.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/__init__.py index 91fae5a3b1..866cade4d0 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.classification import ClassificationPredictionResult from .types.image_object_detection import ImageObjectDetectionPredictionResult from .types.image_segmentation import ImageSegmentationPredictionResult @@ -26,8 +26,8 @@ from .types.video_classification import VideoClassificationPredictionResult from .types.video_object_tracking import VideoObjectTrackingPredictionResult - __all__ = ( + "ClassificationPredictionResult", "ImageObjectDetectionPredictionResult", "ImageSegmentationPredictionResult", "TabularClassificationPredictionResult", @@ -37,5 +37,4 @@ "VideoActionRecognitionPredictionResult", "VideoClassificationPredictionResult", "VideoObjectTrackingPredictionResult", - "ClassificationPredictionResult", ) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_metadata.json b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_metadata.json new file mode 100644 index 0000000000..ba1d67a00c --- /dev/null +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1.schema.predict.prediction_v1", + "protoPackage": "google.cloud.aiplatform.v1.schema.predict.prediction", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/__init__.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/__init__.py index a0fd2058e0..0bb99636b3 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/__init__.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .classification import ClassificationPredictionResult from .image_object_detection import ImageObjectDetectionPredictionResult from .image_segmentation import ImageSegmentationPredictionResult diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/classification.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/classification.py index cfc8e2e602..490d81e91d 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ClassificationPredictionResult(proto.Message): r"""Prediction output format for Image and Text Classification. - Attributes: ids (Sequence[int]): The resource IDs of the AnnotationSpecs that @@ -41,11 +38,9 @@ class ClassificationPredictionResult(proto.Message): confidence. Order matches the Ids. """ - ids = proto.RepeatedField(proto.INT64, number=1) - - display_names = proto.RepeatedField(proto.STRING, number=2) - - confidences = proto.RepeatedField(proto.FLOAT, number=3) + ids = proto.RepeatedField(proto.INT64, number=1,) + display_names = proto.RepeatedField(proto.STRING, number=2,) + confidences = proto.RepeatedField(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_object_detection.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_object_detection.py index 31d37010db..c44d4744a3 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_object_detection.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore +from google.protobuf import struct_pb2 # type: ignore __protobuf__ = proto.module( @@ -29,7 +26,6 @@ class ImageObjectDetectionPredictionResult(proto.Message): r"""Prediction output format for Image Object Detection. - Attributes: ids (Sequence[int]): The resource IDs of the AnnotationSpecs that @@ -52,13 +48,10 @@ class ImageObjectDetectionPredictionResult(proto.Message): image. """ - ids = proto.RepeatedField(proto.INT64, number=1) - - display_names = proto.RepeatedField(proto.STRING, number=2) - - confidences = proto.RepeatedField(proto.FLOAT, number=3) - - bboxes = proto.RepeatedField(proto.MESSAGE, number=4, message=struct.ListValue,) + ids = proto.RepeatedField(proto.INT64, number=1,) + display_names = proto.RepeatedField(proto.STRING, number=2,) + confidences = proto.RepeatedField(proto.FLOAT, number=3,) + bboxes = proto.RepeatedField(proto.MESSAGE, number=4, message=struct_pb2.ListValue,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_segmentation.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_segmentation.py index 1261f19723..4608baeaf6 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_segmentation.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageSegmentationPredictionResult(proto.Message): r"""Prediction output format for Image Segmentation. - Attributes: category_mask (str): A PNG image where each pixel in the mask @@ -49,9 +46,8 @@ class ImageSegmentationPredictionResult(proto.Message): confidence and white means complete confidence. """ - category_mask = proto.Field(proto.STRING, number=1) - - confidence_mask = proto.Field(proto.STRING, number=2) + category_mask = proto.Field(proto.STRING, number=1,) + confidence_mask = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_classification.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_classification.py index 7e78051467..295fd13983 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TabularClassificationPredictionResult(proto.Message): r"""Prediction output format for Tabular Classification. - Attributes: classes (Sequence[str]): The name of the classes being classified, @@ -39,9 +36,8 @@ class TabularClassificationPredictionResult(proto.Message): classes. """ - classes = proto.RepeatedField(proto.STRING, number=1) - - scores = proto.RepeatedField(proto.FLOAT, number=2) + classes = proto.RepeatedField(proto.STRING, number=1,) + scores = proto.RepeatedField(proto.FLOAT, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_regression.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_regression.py index c813f3e45c..76be0023f1 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_regression.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/tabular_regression.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TabularRegressionPredictionResult(proto.Message): r"""Prediction output format for Tabular Regression. - Attributes: value (float): The regression value. @@ -36,11 +33,9 @@ class TabularRegressionPredictionResult(proto.Message): The upper bound of the prediction interval. """ - value = proto.Field(proto.FLOAT, number=1) - - lower_bound = proto.Field(proto.FLOAT, number=2) - - upper_bound = proto.Field(proto.FLOAT, number=3) + value = proto.Field(proto.FLOAT, number=1,) + lower_bound = proto.Field(proto.FLOAT, number=2,) + upper_bound = proto.Field(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_extraction.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_extraction.py index 201f10d08a..601509934a 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_extraction.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_extraction.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextExtractionPredictionResult(proto.Message): r"""Prediction output format for Text Extraction. - Attributes: ids (Sequence[int]): The resource IDs of the AnnotationSpecs that @@ -53,15 +50,11 @@ class TextExtractionPredictionResult(proto.Message): confidence. Order matches the Ids. """ - ids = proto.RepeatedField(proto.INT64, number=1) - - display_names = proto.RepeatedField(proto.STRING, number=2) - - text_segment_start_offsets = proto.RepeatedField(proto.INT64, number=3) - - text_segment_end_offsets = proto.RepeatedField(proto.INT64, number=4) - - confidences = proto.RepeatedField(proto.FLOAT, number=5) + ids = proto.RepeatedField(proto.INT64, number=1,) + display_names = proto.RepeatedField(proto.STRING, number=2,) + text_segment_start_offsets = proto.RepeatedField(proto.INT64, number=3,) + text_segment_end_offsets = proto.RepeatedField(proto.INT64, number=4,) + confidences = proto.RepeatedField(proto.FLOAT, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_sentiment.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_sentiment.py index 73c670f4ec..663a40ce7c 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_sentiment.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/text_sentiment.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextSentimentPredictionResult(proto.Message): r"""Prediction output format for Text Sentiment - Attributes: sentiment (int): The integer sentiment labels between 0 @@ -39,7 +36,7 @@ class TextSentimentPredictionResult(proto.Message): (inclusive) and 10 (inclusive). """ - sentiment = proto.Field(proto.INT32, number=1) + sentiment = proto.Field(proto.INT32, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_action_recognition.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_action_recognition.py index 486853c63d..c23c8b8e07 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_action_recognition.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class VideoActionRecognitionPredictionResult(proto.Message): r"""Prediction output format for Video Action Recognition. - Attributes: id (str): The resource ID of the AnnotationSpec that @@ -58,17 +54,15 @@ class VideoActionRecognitionPredictionResult(proto.Message): confidence. """ - id = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + id = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) time_segment_start = proto.Field( - proto.MESSAGE, number=4, message=duration.Duration, + proto.MESSAGE, number=4, message=duration_pb2.Duration, ) - - time_segment_end = proto.Field(proto.MESSAGE, number=5, message=duration.Duration,) - - confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers.FloatValue,) + time_segment_end = proto.Field( + proto.MESSAGE, number=5, message=duration_pb2.Duration, + ) + confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers_pb2.FloatValue,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_classification.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_classification.py index c043547d04..5edacfb81c 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_classification.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class VideoClassificationPredictionResult(proto.Message): r"""Prediction output format for Video Classification. - Attributes: id (str): The resource ID of the AnnotationSpec that @@ -72,19 +68,16 @@ class VideoClassificationPredictionResult(proto.Message): confidence. """ - id = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - type_ = proto.Field(proto.STRING, number=3) - + id = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + type_ = proto.Field(proto.STRING, number=3,) time_segment_start = proto.Field( - proto.MESSAGE, number=4, message=duration.Duration, + proto.MESSAGE, number=4, message=duration_pb2.Duration, ) - - time_segment_end = proto.Field(proto.MESSAGE, number=5, message=duration.Duration,) - - confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers.FloatValue,) + time_segment_end = proto.Field( + proto.MESSAGE, number=5, message=duration_pb2.Duration, + ) + confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers_pb2.FloatValue,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_object_tracking.py b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_object_tracking.py index d1b515a895..b103c70546 100644 --- a/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_object_tracking.py +++ b/google/cloud/aiplatform/v1/schema/predict/prediction_v1/types/video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class VideoObjectTrackingPredictionResult(proto.Message): r"""Prediction output format for Video Object Tracking. - Attributes: id (str): The resource ID of the AnnotationSpec that @@ -87,28 +83,23 @@ class Frame(proto.Message): box. """ - time_offset = proto.Field(proto.MESSAGE, number=1, message=duration.Duration,) - - x_min = proto.Field(proto.MESSAGE, number=2, message=wrappers.FloatValue,) - - x_max = proto.Field(proto.MESSAGE, number=3, message=wrappers.FloatValue,) - - y_min = proto.Field(proto.MESSAGE, number=4, message=wrappers.FloatValue,) - - y_max = proto.Field(proto.MESSAGE, number=5, message=wrappers.FloatValue,) - - id = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) + time_offset = proto.Field( + proto.MESSAGE, number=1, message=duration_pb2.Duration, + ) + x_min = proto.Field(proto.MESSAGE, number=2, message=wrappers_pb2.FloatValue,) + x_max = proto.Field(proto.MESSAGE, number=3, message=wrappers_pb2.FloatValue,) + y_min = proto.Field(proto.MESSAGE, number=4, message=wrappers_pb2.FloatValue,) + y_max = proto.Field(proto.MESSAGE, number=5, message=wrappers_pb2.FloatValue,) + id = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) time_segment_start = proto.Field( - proto.MESSAGE, number=3, message=duration.Duration, + proto.MESSAGE, number=3, message=duration_pb2.Duration, ) - - time_segment_end = proto.Field(proto.MESSAGE, number=4, message=duration.Duration,) - - confidence = proto.Field(proto.MESSAGE, number=5, message=wrappers.FloatValue,) - + time_segment_end = proto.Field( + proto.MESSAGE, number=4, message=duration_pb2.Duration, + ) + confidence = proto.Field(proto.MESSAGE, number=5, message=wrappers_pb2.FloatValue,) frames = proto.RepeatedField(proto.MESSAGE, number=6, message=Frame,) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition/__init__.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition/__init__.py index f8620bb25d..bd4624d83b 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition/__init__.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_classification import ( AutoMlImageClassification, ) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/__init__.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/__init__.py index 34958e5add..16b66c2fb6 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/__init__.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.automl_image_classification import AutoMlImageClassification from .types.automl_image_classification import AutoMlImageClassificationInputs from .types.automl_image_classification import AutoMlImageClassificationMetadata @@ -41,8 +41,8 @@ from .types.automl_video_object_tracking import AutoMlVideoObjectTrackingInputs from .types.export_evaluated_data_items_config import ExportEvaluatedDataItemsConfig - __all__ = ( + "AutoMlImageClassification", "AutoMlImageClassificationInputs", "AutoMlImageClassificationMetadata", "AutoMlImageObjectDetection", @@ -67,5 +67,4 @@ "AutoMlVideoObjectTracking", "AutoMlVideoObjectTrackingInputs", "ExportEvaluatedDataItemsConfig", - "AutoMlImageClassification", ) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_metadata.json b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_metadata.json new file mode 100644 index 0000000000..620ff75f05 --- /dev/null +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1.schema.trainingjob.definition_v1", + "protoPackage": "google.cloud.aiplatform.v1.schema.trainingjob.definition", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/__init__.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/__init__.py index a15aa2c041..d70e297826 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/__init__.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .automl_image_classification import ( AutoMlImageClassification, AutoMlImageClassificationInputs, diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_classification.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_classification.py index f7e13c60b7..d8732f8865 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_classification.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -42,7 +40,6 @@ class AutoMlImageClassification(proto.Message): inputs = proto.Field( proto.MESSAGE, number=1, message="AutoMlImageClassificationInputs", ) - metadata = proto.Field( proto.MESSAGE, number=2, message="AutoMlImageClassificationMetadata", ) @@ -50,7 +47,6 @@ class AutoMlImageClassification(proto.Message): class AutoMlImageClassificationInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlImageClassificationInputs.ModelType): @@ -102,19 +98,14 @@ class ModelType(proto.Enum): MOBILE_TF_HIGH_ACCURACY_1 = 4 model_type = proto.Field(proto.ENUM, number=1, enum=ModelType,) - - base_model_id = proto.Field(proto.STRING, number=2) - - budget_milli_node_hours = proto.Field(proto.INT64, number=3) - - disable_early_stopping = proto.Field(proto.BOOL, number=4) - - multi_label = proto.Field(proto.BOOL, number=5) + base_model_id = proto.Field(proto.STRING, number=2,) + budget_milli_node_hours = proto.Field(proto.INT64, number=3,) + disable_early_stopping = proto.Field(proto.BOOL, number=4,) + multi_label = proto.Field(proto.BOOL, number=5,) class AutoMlImageClassificationMetadata(proto.Message): r""" - Attributes: cost_milli_node_hours (int): The actual training cost of creating this @@ -133,8 +124,7 @@ class SuccessfulStopReason(proto.Enum): BUDGET_REACHED = 1 MODEL_CONVERGED = 2 - cost_milli_node_hours = proto.Field(proto.INT64, number=1) - + cost_milli_node_hours = proto.Field(proto.INT64, number=1,) successful_stop_reason = proto.Field( proto.ENUM, number=2, enum=SuccessfulStopReason, ) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_object_detection.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_object_detection.py index 1c2c9f83b7..c9284686fd 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_object_detection.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -42,7 +40,6 @@ class AutoMlImageObjectDetection(proto.Message): inputs = proto.Field( proto.MESSAGE, number=1, message="AutoMlImageObjectDetectionInputs", ) - metadata = proto.Field( proto.MESSAGE, number=2, message="AutoMlImageObjectDetectionMetadata", ) @@ -50,7 +47,6 @@ class AutoMlImageObjectDetection(proto.Message): class AutoMlImageObjectDetectionInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlImageObjectDetectionInputs.ModelType): @@ -91,15 +87,12 @@ class ModelType(proto.Enum): MOBILE_TF_HIGH_ACCURACY_1 = 5 model_type = proto.Field(proto.ENUM, number=1, enum=ModelType,) - - budget_milli_node_hours = proto.Field(proto.INT64, number=2) - - disable_early_stopping = proto.Field(proto.BOOL, number=3) + budget_milli_node_hours = proto.Field(proto.INT64, number=2,) + disable_early_stopping = proto.Field(proto.BOOL, number=3,) class AutoMlImageObjectDetectionMetadata(proto.Message): r""" - Attributes: cost_milli_node_hours (int): The actual training cost of creating this @@ -118,8 +111,7 @@ class SuccessfulStopReason(proto.Enum): BUDGET_REACHED = 1 MODEL_CONVERGED = 2 - cost_milli_node_hours = proto.Field(proto.INT64, number=1) - + cost_milli_node_hours = proto.Field(proto.INT64, number=1,) successful_stop_reason = proto.Field( proto.ENUM, number=2, enum=SuccessfulStopReason, ) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_segmentation.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_segmentation.py index a81103657e..ccd2449ccd 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_segmentation.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -42,7 +40,6 @@ class AutoMlImageSegmentation(proto.Message): inputs = proto.Field( proto.MESSAGE, number=1, message="AutoMlImageSegmentationInputs", ) - metadata = proto.Field( proto.MESSAGE, number=2, message="AutoMlImageSegmentationMetadata", ) @@ -50,7 +47,6 @@ class AutoMlImageSegmentation(proto.Message): class AutoMlImageSegmentationInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlImageSegmentationInputs.ModelType): @@ -85,15 +81,12 @@ class ModelType(proto.Enum): MOBILE_TF_LOW_LATENCY_1 = 3 model_type = proto.Field(proto.ENUM, number=1, enum=ModelType,) - - budget_milli_node_hours = proto.Field(proto.INT64, number=2) - - base_model_id = proto.Field(proto.STRING, number=3) + budget_milli_node_hours = proto.Field(proto.INT64, number=2,) + base_model_id = proto.Field(proto.STRING, number=3,) class AutoMlImageSegmentationMetadata(proto.Message): r""" - Attributes: cost_milli_node_hours (int): The actual training cost of creating this @@ -112,8 +105,7 @@ class SuccessfulStopReason(proto.Enum): BUDGET_REACHED = 1 MODEL_CONVERGED = 2 - cost_milli_node_hours = proto.Field(proto.INT64, number=1) - + cost_milli_node_hours = proto.Field(proto.INT64, number=1,) successful_stop_reason = proto.Field( proto.ENUM, number=2, enum=SuccessfulStopReason, ) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_tables.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_tables.py index 1c3d0c8da7..f05b633c87 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_tables.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_tables.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types import ( export_evaluated_data_items_config as gcastd_export_evaluated_data_items_config, ) @@ -31,7 +28,6 @@ class AutoMlTables(proto.Message): r"""A TrainingJob that trains and uploads an AutoML Tables Model. - Attributes: inputs (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlTablesInputs): The input parameters of this TrainingJob. @@ -40,13 +36,11 @@ class AutoMlTables(proto.Message): """ inputs = proto.Field(proto.MESSAGE, number=1, message="AutoMlTablesInputs",) - metadata = proto.Field(proto.MESSAGE, number=2, message="AutoMlTablesMetadata",) class AutoMlTablesInputs(proto.Message): r""" - Attributes: optimization_objective_recall_value (float): Required when optimization_objective is @@ -149,7 +143,6 @@ class AutoMlTablesInputs(proto.Message): class Transformation(proto.Message): r""" - Attributes: auto (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlTablesInputs.Transformation.AutoTransformation): @@ -178,7 +171,7 @@ class AutoTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class NumericTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -204,9 +197,8 @@ class NumericTransformation(proto.Message): from trainining data. """ - column_name = proto.Field(proto.STRING, number=1) - - invalid_values_allowed = proto.Field(proto.BOOL, number=2) + column_name = proto.Field(proto.STRING, number=1,) + invalid_values_allowed = proto.Field(proto.BOOL, number=2,) class CategoricalTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -224,7 +216,7 @@ class CategoricalTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class TimestampTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -261,11 +253,9 @@ class TimestampTransformation(proto.Message): from trainining data. """ - column_name = proto.Field(proto.STRING, number=1) - - time_format = proto.Field(proto.STRING, number=2) - - invalid_values_allowed = proto.Field(proto.BOOL, number=3) + column_name = proto.Field(proto.STRING, number=1,) + time_format = proto.Field(proto.STRING, number=2,) + invalid_values_allowed = proto.Field(proto.BOOL, number=3,) class TextTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -285,7 +275,7 @@ class TextTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class NumericArrayTransformation(proto.Message): r"""Treats the column as numerical array and performs following @@ -306,9 +296,8 @@ class NumericArrayTransformation(proto.Message): from trainining data. """ - column_name = proto.Field(proto.STRING, number=1) - - invalid_values_allowed = proto.Field(proto.BOOL, number=2) + column_name = proto.Field(proto.STRING, number=1,) + invalid_values_allowed = proto.Field(proto.BOOL, number=2,) class CategoricalArrayTransformation(proto.Message): r"""Treats the column as categorical array and performs following @@ -325,7 +314,7 @@ class CategoricalArrayTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class TextArrayTransformation(proto.Message): r"""Treats the column as text array and performs following @@ -341,7 +330,7 @@ class TextArrayTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) auto = proto.Field( proto.MESSAGE, @@ -349,49 +338,42 @@ class TextArrayTransformation(proto.Message): oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.AutoTransformation", ) - numeric = proto.Field( proto.MESSAGE, number=2, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.NumericTransformation", ) - categorical = proto.Field( proto.MESSAGE, number=3, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.CategoricalTransformation", ) - timestamp = proto.Field( proto.MESSAGE, number=4, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.TimestampTransformation", ) - text = proto.Field( proto.MESSAGE, number=5, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.TextTransformation", ) - repeated_numeric = proto.Field( proto.MESSAGE, number=6, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.NumericArrayTransformation", ) - repeated_categorical = proto.Field( proto.MESSAGE, number=7, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.CategoricalArrayTransformation", ) - repeated_text = proto.Field( proto.MESSAGE, number=8, @@ -400,29 +382,20 @@ class TextArrayTransformation(proto.Message): ) optimization_objective_recall_value = proto.Field( - proto.FLOAT, number=5, oneof="additional_optimization_objective_config" + proto.FLOAT, number=5, oneof="additional_optimization_objective_config", ) - optimization_objective_precision_value = proto.Field( - proto.FLOAT, number=6, oneof="additional_optimization_objective_config" + proto.FLOAT, number=6, oneof="additional_optimization_objective_config", ) - - prediction_type = proto.Field(proto.STRING, number=1) - - target_column = proto.Field(proto.STRING, number=2) - + prediction_type = proto.Field(proto.STRING, number=1,) + target_column = proto.Field(proto.STRING, number=2,) transformations = proto.RepeatedField( proto.MESSAGE, number=3, message=Transformation, ) - - optimization_objective = proto.Field(proto.STRING, number=4) - - train_budget_milli_node_hours = proto.Field(proto.INT64, number=7) - - disable_early_stopping = proto.Field(proto.BOOL, number=8) - - weight_column_name = proto.Field(proto.STRING, number=9) - + optimization_objective = proto.Field(proto.STRING, number=4,) + train_budget_milli_node_hours = proto.Field(proto.INT64, number=7,) + disable_early_stopping = proto.Field(proto.BOOL, number=8,) + weight_column_name = proto.Field(proto.STRING, number=9,) export_evaluated_data_items_config = proto.Field( proto.MESSAGE, number=10, @@ -432,7 +405,6 @@ class TextArrayTransformation(proto.Message): class AutoMlTablesMetadata(proto.Message): r"""Model metadata specific to AutoML Tables. - Attributes: train_cost_milli_node_hours (int): Output only. The actual training cost of the @@ -441,7 +413,7 @@ class AutoMlTablesMetadata(proto.Message): Guaranteed to not exceed the train budget. """ - train_cost_milli_node_hours = proto.Field(proto.INT64, number=1) + train_cost_milli_node_hours = proto.Field(proto.INT64, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_classification.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_classification.py index 205deaf375..21014e1b0a 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_classification.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,13 +38,12 @@ class AutoMlTextClassification(proto.Message): class AutoMlTextClassificationInputs(proto.Message): r""" - Attributes: multi_label (bool): """ - multi_label = proto.Field(proto.BOOL, number=1) + multi_label = proto.Field(proto.BOOL, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_extraction.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_extraction.py index fad28847af..e475b1989b 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_extraction.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_extraction.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -37,7 +35,7 @@ class AutoMlTextExtraction(proto.Message): class AutoMlTextExtractionInputs(proto.Message): - r"""""" + r""" """ __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_sentiment.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_sentiment.py index ca80a44d1d..373ea85902 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_sentiment.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_text_sentiment.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -38,7 +36,6 @@ class AutoMlTextSentiment(proto.Message): class AutoMlTextSentimentInputs(proto.Message): r""" - Attributes: sentiment_max (int): A sentiment is expressed as an integer @@ -53,7 +50,7 @@ class AutoMlTextSentimentInputs(proto.Message): between 1 and 10 (inclusive). """ - sentiment_max = proto.Field(proto.INT32, number=1) + sentiment_max = proto.Field(proto.INT32, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_action_recognition.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_action_recognition.py index 1a20a6d725..f9eefb8c4d 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_action_recognition.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,7 +38,6 @@ class AutoMlVideoActionRecognition(proto.Message): class AutoMlVideoActionRecognitionInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlVideoActionRecognitionInputs.ModelType): diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_classification.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_classification.py index ba7f2d5b21..a0a4e88195 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_classification.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,7 +38,6 @@ class AutoMlVideoClassification(proto.Message): class AutoMlVideoClassificationInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlVideoClassificationInputs.ModelType): diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_object_tracking.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_object_tracking.py index 0ecb1113d9..4db3a783cf 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_object_tracking.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/automl_video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,7 +38,6 @@ class AutoMlVideoObjectTracking(proto.Message): class AutoMlVideoObjectTrackingInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.AutoMlVideoObjectTrackingInputs.ModelType): diff --git a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/export_evaluated_data_items_config.py b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/export_evaluated_data_items_config.py index dc8a629412..47d910fefb 100644 --- a/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/export_evaluated_data_items_config.py +++ b/google/cloud/aiplatform/v1/schema/trainingjob/definition_v1/types/export_evaluated_data_items_config.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -45,9 +43,8 @@ class ExportEvaluatedDataItemsConfig(proto.Message): operation fails. """ - destination_bigquery_uri = proto.Field(proto.STRING, number=1) - - override_existing_table = proto.Field(proto.BOOL, number=2) + destination_bigquery_uri = proto.Field(proto.STRING, number=1,) + override_existing_table = proto.Field(proto.BOOL, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance/__init__.py index 2f514ac4ed..4ddd6e1439 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_classification import ( ImageClassificationPredictionInstance, ) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/__init__.py index f6d9a128ad..fdfe1ca46f 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.image_classification import ImageClassificationPredictionInstance from .types.image_object_detection import ImageObjectDetectionPredictionInstance from .types.image_segmentation import ImageSegmentationPredictionInstance @@ -25,8 +25,8 @@ from .types.video_classification import VideoClassificationPredictionInstance from .types.video_object_tracking import VideoObjectTrackingPredictionInstance - __all__ = ( + "ImageClassificationPredictionInstance", "ImageObjectDetectionPredictionInstance", "ImageSegmentationPredictionInstance", "TextClassificationPredictionInstance", @@ -35,5 +35,4 @@ "VideoActionRecognitionPredictionInstance", "VideoClassificationPredictionInstance", "VideoObjectTrackingPredictionInstance", - "ImageClassificationPredictionInstance", ) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_metadata.json b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_metadata.json new file mode 100644 index 0000000000..38379e8208 --- /dev/null +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1", + "protoPackage": "google.cloud.aiplatform.v1beta1.schema.predict.instance", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/__init__.py index 041fe6cdb1..744852e8a3 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .image_classification import ImageClassificationPredictionInstance from .image_object_detection import ImageObjectDetectionPredictionInstance from .image_segmentation import ImageSegmentationPredictionInstance diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_classification.py index 84b1ef0bbe..4c2154dd90 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageClassificationPredictionInstance(proto.Message): r"""Prediction input format for Image Classification. - Attributes: content (str): The image bytes or GCS URI to make the @@ -43,9 +40,8 @@ class ImageClassificationPredictionInstance(proto.Message): - image/vnd.microsoft.icon """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_object_detection.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_object_detection.py index 79c3efc2c6..d7b41623aa 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_object_detection.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageObjectDetectionPredictionInstance(proto.Message): r"""Prediction input format for Image Object Detection. - Attributes: content (str): The image bytes or GCS URI to make the @@ -43,9 +40,8 @@ class ImageObjectDetectionPredictionInstance(proto.Message): - image/vnd.microsoft.icon """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_segmentation.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_segmentation.py index 5a3232c6d2..13c96535a1 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_segmentation.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageSegmentationPredictionInstance(proto.Message): r"""Prediction input format for Image Segmentation. - Attributes: content (str): The image bytes to make the predictions on. @@ -37,9 +34,8 @@ class ImageSegmentationPredictionInstance(proto.Message): - image/png """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_classification.py index a615dc7e49..141b031701 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextClassificationPredictionInstance(proto.Message): r"""Prediction input format for Text Classification. - Attributes: content (str): The text snippet to make the predictions on. @@ -36,9 +33,8 @@ class TextClassificationPredictionInstance(proto.Message): - text/plain """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_extraction.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_extraction.py index c6fecf80b7..9c393faa73 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_extraction.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_extraction.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextExtractionPredictionInstance(proto.Message): r"""Prediction input format for Text Extraction. - Attributes: content (str): The text snippet to make the predictions on. @@ -45,11 +42,9 @@ class TextExtractionPredictionInstance(proto.Message): unique. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - key = proto.Field(proto.STRING, number=3) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + key = proto.Field(proto.STRING, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_sentiment.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_sentiment.py index 69836d0e96..cc530e26b9 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_sentiment.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/text_sentiment.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextSentimentPredictionInstance(proto.Message): r"""Prediction input format for Text Sentiment. - Attributes: content (str): The text snippet to make the predictions on. @@ -36,9 +33,8 @@ class TextSentimentPredictionInstance(proto.Message): - text/plain """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_action_recognition.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_action_recognition.py index ae3935d387..921f17b892 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_action_recognition.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoActionRecognitionPredictionInstance(proto.Message): r"""Prediction input format for Video Action Recognition. - Attributes: content (str): The Google Cloud Storage location of the @@ -52,13 +49,10 @@ class VideoActionRecognitionPredictionInstance(proto.Message): is allowed, which means the end of the video. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - time_segment_start = proto.Field(proto.STRING, number=3) - - time_segment_end = proto.Field(proto.STRING, number=4) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + time_segment_start = proto.Field(proto.STRING, number=3,) + time_segment_end = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_classification.py index 2f944bb99e..f7c58db248 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoClassificationPredictionInstance(proto.Message): r"""Prediction input format for Video Classification. - Attributes: content (str): The Google Cloud Storage location of the @@ -52,13 +49,10 @@ class VideoClassificationPredictionInstance(proto.Message): is allowed, which means the end of the video. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - time_segment_start = proto.Field(proto.STRING, number=3) - - time_segment_end = proto.Field(proto.STRING, number=4) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + time_segment_start = proto.Field(proto.STRING, number=3,) + time_segment_end = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_object_tracking.py b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_object_tracking.py index e635b5174b..8fd28ed924 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_object_tracking.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/instance_v1beta1/types/video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoObjectTrackingPredictionInstance(proto.Message): r"""Prediction input format for Video Object Tracking. - Attributes: content (str): The Google Cloud Storage location of the @@ -52,13 +49,10 @@ class VideoObjectTrackingPredictionInstance(proto.Message): is allowed, which means the end of the video. """ - content = proto.Field(proto.STRING, number=1) - - mime_type = proto.Field(proto.STRING, number=2) - - time_segment_start = proto.Field(proto.STRING, number=3) - - time_segment_end = proto.Field(proto.STRING, number=4) + content = proto.Field(proto.STRING, number=1,) + mime_type = proto.Field(proto.STRING, number=2,) + time_segment_start = proto.Field(proto.STRING, number=3,) + time_segment_end = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/params/__init__.py index dc7cd58e9a..4a5b144b93 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_classification import ( ImageClassificationPredictionParams, ) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/__init__.py index 79fb1c2097..dcf74bb7a0 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.image_classification import ImageClassificationPredictionParams from .types.image_object_detection import ImageObjectDetectionPredictionParams from .types.image_segmentation import ImageSegmentationPredictionParams @@ -22,12 +22,11 @@ from .types.video_classification import VideoClassificationPredictionParams from .types.video_object_tracking import VideoObjectTrackingPredictionParams - __all__ = ( + "ImageClassificationPredictionParams", "ImageObjectDetectionPredictionParams", "ImageSegmentationPredictionParams", "VideoActionRecognitionPredictionParams", "VideoClassificationPredictionParams", "VideoObjectTrackingPredictionParams", - "ImageClassificationPredictionParams", ) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_metadata.json b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_metadata.json new file mode 100644 index 0000000000..6b925dd9dc --- /dev/null +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1", + "protoPackage": "google.cloud.aiplatform.v1beta1.schema.predict.params", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/__init__.py index 2f2c29bba5..26997a8d81 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .image_classification import ImageClassificationPredictionParams from .image_object_detection import ImageObjectDetectionPredictionParams from .image_segmentation import ImageSegmentationPredictionParams diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_classification.py index 681a8c3d87..ada760e415 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageClassificationPredictionParams(proto.Message): r"""Prediction model parameters for Image Classification. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -39,9 +36,8 @@ class ImageClassificationPredictionParams(proto.Message): return fewer predictions. Default value is 10. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_object_detection.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_object_detection.py index 146dd324b7..b160fc8400 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_object_detection.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageObjectDetectionPredictionParams(proto.Message): r"""Prediction model parameters for Image Object Detection. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -40,9 +37,8 @@ class ImageObjectDetectionPredictionParams(proto.Message): value is 10. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_segmentation.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_segmentation.py index aa11739a61..1c1e3cdb2e 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_segmentation.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageSegmentationPredictionParams(proto.Message): r"""Prediction model parameters for Image Segmentation. - Attributes: confidence_threshold (float): When the model predicts category of pixels of @@ -36,7 +33,7 @@ class ImageSegmentationPredictionParams(proto.Message): background. Default value is 0.5. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_action_recognition.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_action_recognition.py index c1f8f9f3bc..86afdac15f 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_action_recognition.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoActionRecognitionPredictionParams(proto.Message): r"""Prediction model parameters for Video Action Recognition. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -40,9 +37,8 @@ class VideoActionRecognitionPredictionParams(proto.Message): Default value is 50. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_classification.py index 1b8d84a7d1..35ad2ca0ee 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoClassificationPredictionParams(proto.Message): r"""Prediction model parameters for Video Classification. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -71,15 +68,11 @@ class VideoClassificationPredictionParams(proto.Message): is false """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) - - segment_classification = proto.Field(proto.BOOL, number=3) - - shot_classification = proto.Field(proto.BOOL, number=4) - - one_sec_interval_classification = proto.Field(proto.BOOL, number=5) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) + segment_classification = proto.Field(proto.BOOL, number=3,) + shot_classification = proto.Field(proto.BOOL, number=4,) + one_sec_interval_classification = proto.Field(proto.BOOL, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_object_tracking.py b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_object_tracking.py index 4c0b6846bc..b4cd10b795 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_object_tracking.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/params_v1beta1/types/video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class VideoObjectTrackingPredictionParams(proto.Message): r"""Prediction model parameters for Video Object Tracking. - Attributes: confidence_threshold (float): The Model only returns predictions with at @@ -44,11 +41,9 @@ class VideoObjectTrackingPredictionParams(proto.Message): frame size are returned. Default value is 0.0. """ - confidence_threshold = proto.Field(proto.FLOAT, number=1) - - max_predictions = proto.Field(proto.INT32, number=2) - - min_bounding_box_size = proto.Field(proto.FLOAT, number=3) + confidence_threshold = proto.Field(proto.FLOAT, number=1,) + max_predictions = proto.Field(proto.INT32, number=2,) + min_bounding_box_size = proto.Field(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction/__init__.py index d5f2762504..df5f78f60c 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.classification import ( ClassificationPredictionResult, ) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/__init__.py index 91fae5a3b1..866cade4d0 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.classification import ClassificationPredictionResult from .types.image_object_detection import ImageObjectDetectionPredictionResult from .types.image_segmentation import ImageSegmentationPredictionResult @@ -26,8 +26,8 @@ from .types.video_classification import VideoClassificationPredictionResult from .types.video_object_tracking import VideoObjectTrackingPredictionResult - __all__ = ( + "ClassificationPredictionResult", "ImageObjectDetectionPredictionResult", "ImageSegmentationPredictionResult", "TabularClassificationPredictionResult", @@ -37,5 +37,4 @@ "VideoActionRecognitionPredictionResult", "VideoClassificationPredictionResult", "VideoObjectTrackingPredictionResult", - "ClassificationPredictionResult", ) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_metadata.json b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_metadata.json new file mode 100644 index 0000000000..99d3dc6402 --- /dev/null +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1", + "protoPackage": "google.cloud.aiplatform.v1beta1.schema.predict.prediction", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/__init__.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/__init__.py index a0fd2058e0..0bb99636b3 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .classification import ClassificationPredictionResult from .image_object_detection import ImageObjectDetectionPredictionResult from .image_segmentation import ImageSegmentationPredictionResult diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/classification.py index 3bfe82f64e..d37236a5cc 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ClassificationPredictionResult(proto.Message): r"""Prediction output format for Image and Text Classification. - Attributes: ids (Sequence[int]): The resource IDs of the AnnotationSpecs that @@ -41,11 +38,9 @@ class ClassificationPredictionResult(proto.Message): confidence. Order matches the Ids. """ - ids = proto.RepeatedField(proto.INT64, number=1) - - display_names = proto.RepeatedField(proto.STRING, number=2) - - confidences = proto.RepeatedField(proto.FLOAT, number=3) + ids = proto.RepeatedField(proto.INT64, number=1,) + display_names = proto.RepeatedField(proto.STRING, number=2,) + confidences = proto.RepeatedField(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_object_detection.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_object_detection.py index 3d0f7f1f76..e1ed4f5c1e 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_object_detection.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore +from google.protobuf import struct_pb2 # type: ignore __protobuf__ = proto.module( @@ -29,7 +26,6 @@ class ImageObjectDetectionPredictionResult(proto.Message): r"""Prediction output format for Image Object Detection. - Attributes: ids (Sequence[int]): The resource IDs of the AnnotationSpecs that @@ -52,13 +48,10 @@ class ImageObjectDetectionPredictionResult(proto.Message): image. """ - ids = proto.RepeatedField(proto.INT64, number=1) - - display_names = proto.RepeatedField(proto.STRING, number=2) - - confidences = proto.RepeatedField(proto.FLOAT, number=3) - - bboxes = proto.RepeatedField(proto.MESSAGE, number=4, message=struct.ListValue,) + ids = proto.RepeatedField(proto.INT64, number=1,) + display_names = proto.RepeatedField(proto.STRING, number=2,) + confidences = proto.RepeatedField(proto.FLOAT, number=3,) + bboxes = proto.RepeatedField(proto.MESSAGE, number=4, message=struct_pb2.ListValue,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_segmentation.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_segmentation.py index ffd6fb9380..538de9f561 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_segmentation.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ImageSegmentationPredictionResult(proto.Message): r"""Prediction output format for Image Segmentation. - Attributes: category_mask (str): A PNG image where each pixel in the mask @@ -49,9 +46,8 @@ class ImageSegmentationPredictionResult(proto.Message): confidence and white means complete confidence. """ - category_mask = proto.Field(proto.STRING, number=1) - - confidence_mask = proto.Field(proto.STRING, number=2) + category_mask = proto.Field(proto.STRING, number=1,) + confidence_mask = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_classification.py index 4906ad59a5..e6673fe360 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TabularClassificationPredictionResult(proto.Message): r"""Prediction output format for Tabular Classification. - Attributes: classes (Sequence[str]): The name of the classes being classified, @@ -39,9 +36,8 @@ class TabularClassificationPredictionResult(proto.Message): classes. """ - classes = proto.RepeatedField(proto.STRING, number=1) - - scores = proto.RepeatedField(proto.FLOAT, number=2) + classes = proto.RepeatedField(proto.STRING, number=1,) + scores = proto.RepeatedField(proto.FLOAT, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_regression.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_regression.py index 71d535c1f0..f8273be054 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_regression.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/tabular_regression.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TabularRegressionPredictionResult(proto.Message): r"""Prediction output format for Tabular Regression. - Attributes: value (float): The regression value. @@ -36,11 +33,9 @@ class TabularRegressionPredictionResult(proto.Message): The upper bound of the prediction interval. """ - value = proto.Field(proto.FLOAT, number=1) - - lower_bound = proto.Field(proto.FLOAT, number=2) - - upper_bound = proto.Field(proto.FLOAT, number=3) + value = proto.Field(proto.FLOAT, number=1,) + lower_bound = proto.Field(proto.FLOAT, number=2,) + upper_bound = proto.Field(proto.FLOAT, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_extraction.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_extraction.py index e3c10b5d75..1c70ab440b 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_extraction.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_extraction.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextExtractionPredictionResult(proto.Message): r"""Prediction output format for Text Extraction. - Attributes: ids (Sequence[int]): The resource IDs of the AnnotationSpecs that @@ -53,15 +50,11 @@ class TextExtractionPredictionResult(proto.Message): confidence. Order matches the Ids. """ - ids = proto.RepeatedField(proto.INT64, number=1) - - display_names = proto.RepeatedField(proto.STRING, number=2) - - text_segment_start_offsets = proto.RepeatedField(proto.INT64, number=3) - - text_segment_end_offsets = proto.RepeatedField(proto.INT64, number=4) - - confidences = proto.RepeatedField(proto.FLOAT, number=5) + ids = proto.RepeatedField(proto.INT64, number=1,) + display_names = proto.RepeatedField(proto.STRING, number=2,) + text_segment_start_offsets = proto.RepeatedField(proto.INT64, number=3,) + text_segment_end_offsets = proto.RepeatedField(proto.INT64, number=4,) + confidences = proto.RepeatedField(proto.FLOAT, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_sentiment.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_sentiment.py index f31b95a18f..76ac7392aa 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_sentiment.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/text_sentiment.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class TextSentimentPredictionResult(proto.Message): r"""Prediction output format for Text Sentiment - Attributes: sentiment (int): The integer sentiment labels between 0 @@ -39,7 +36,7 @@ class TextSentimentPredictionResult(proto.Message): (inclusive) and 10 (inclusive). """ - sentiment = proto.Field(proto.INT32, number=1) + sentiment = proto.Field(proto.INT32, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_action_recognition.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_action_recognition.py index 99fa365b47..b33184277e 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_action_recognition.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class VideoActionRecognitionPredictionResult(proto.Message): r"""Prediction output format for Video Action Recognition. - Attributes: id (str): The resource ID of the AnnotationSpec that @@ -58,17 +54,15 @@ class VideoActionRecognitionPredictionResult(proto.Message): confidence. """ - id = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + id = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) time_segment_start = proto.Field( - proto.MESSAGE, number=4, message=duration.Duration, + proto.MESSAGE, number=4, message=duration_pb2.Duration, ) - - time_segment_end = proto.Field(proto.MESSAGE, number=5, message=duration.Duration,) - - confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers.FloatValue,) + time_segment_end = proto.Field( + proto.MESSAGE, number=5, message=duration_pb2.Duration, + ) + confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers_pb2.FloatValue,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_classification.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_classification.py index 3fca68fe64..3d4abadd6a 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class VideoClassificationPredictionResult(proto.Message): r"""Prediction output format for Video Classification. - Attributes: id (str): The resource ID of the AnnotationSpec that @@ -72,19 +68,16 @@ class VideoClassificationPredictionResult(proto.Message): confidence. """ - id = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - type_ = proto.Field(proto.STRING, number=3) - + id = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + type_ = proto.Field(proto.STRING, number=3,) time_segment_start = proto.Field( - proto.MESSAGE, number=4, message=duration.Duration, + proto.MESSAGE, number=4, message=duration_pb2.Duration, ) - - time_segment_end = proto.Field(proto.MESSAGE, number=5, message=duration.Duration,) - - confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers.FloatValue,) + time_segment_end = proto.Field( + proto.MESSAGE, number=5, message=duration_pb2.Duration, + ) + confidence = proto.Field(proto.MESSAGE, number=6, message=wrappers_pb2.FloatValue,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_object_tracking.py b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_object_tracking.py index 6fd431c0dd..9b085f2309 100644 --- a/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_object_tracking.py +++ b/google/cloud/aiplatform/v1beta1/schema/predict/prediction_v1beta1/types/video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class VideoObjectTrackingPredictionResult(proto.Message): r"""Prediction output format for Video Object Tracking. - Attributes: id (str): The resource ID of the AnnotationSpec that @@ -87,28 +83,23 @@ class Frame(proto.Message): box. """ - time_offset = proto.Field(proto.MESSAGE, number=1, message=duration.Duration,) - - x_min = proto.Field(proto.MESSAGE, number=2, message=wrappers.FloatValue,) - - x_max = proto.Field(proto.MESSAGE, number=3, message=wrappers.FloatValue,) - - y_min = proto.Field(proto.MESSAGE, number=4, message=wrappers.FloatValue,) - - y_max = proto.Field(proto.MESSAGE, number=5, message=wrappers.FloatValue,) - - id = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) + time_offset = proto.Field( + proto.MESSAGE, number=1, message=duration_pb2.Duration, + ) + x_min = proto.Field(proto.MESSAGE, number=2, message=wrappers_pb2.FloatValue,) + x_max = proto.Field(proto.MESSAGE, number=3, message=wrappers_pb2.FloatValue,) + y_min = proto.Field(proto.MESSAGE, number=4, message=wrappers_pb2.FloatValue,) + y_max = proto.Field(proto.MESSAGE, number=5, message=wrappers_pb2.FloatValue,) + id = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) time_segment_start = proto.Field( - proto.MESSAGE, number=3, message=duration.Duration, + proto.MESSAGE, number=3, message=duration_pb2.Duration, ) - - time_segment_end = proto.Field(proto.MESSAGE, number=4, message=duration.Duration,) - - confidence = proto.Field(proto.MESSAGE, number=5, message=wrappers.FloatValue,) - + time_segment_end = proto.Field( + proto.MESSAGE, number=4, message=duration_pb2.Duration, + ) + confidence = proto.Field(proto.MESSAGE, number=5, message=wrappers_pb2.FloatValue,) frames = proto.RepeatedField(proto.MESSAGE, number=6, message=Frame,) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/__init__.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/__init__.py index d632ef9609..eae6c5d2fa 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_classification import ( AutoMlImageClassification, ) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/__init__.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/__init__.py index 34958e5add..16b66c2fb6 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +14,7 @@ # limitations under the License. # + from .types.automl_image_classification import AutoMlImageClassification from .types.automl_image_classification import AutoMlImageClassificationInputs from .types.automl_image_classification import AutoMlImageClassificationMetadata @@ -41,8 +41,8 @@ from .types.automl_video_object_tracking import AutoMlVideoObjectTrackingInputs from .types.export_evaluated_data_items_config import ExportEvaluatedDataItemsConfig - __all__ = ( + "AutoMlImageClassification", "AutoMlImageClassificationInputs", "AutoMlImageClassificationMetadata", "AutoMlImageObjectDetection", @@ -67,5 +67,4 @@ "AutoMlVideoObjectTracking", "AutoMlVideoObjectTrackingInputs", "ExportEvaluatedDataItemsConfig", - "AutoMlImageClassification", ) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_metadata.json b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_metadata.json new file mode 100644 index 0000000000..6de794c90a --- /dev/null +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/gapic_metadata.json @@ -0,0 +1,7 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1", + "protoPackage": "google.cloud.aiplatform.v1beta1.schema.trainingjob.definition", + "schema": "1.0" +} diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/__init__.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/__init__.py index a15aa2c041..d70e297826 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/__init__.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .automl_image_classification import ( AutoMlImageClassification, AutoMlImageClassificationInputs, diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_classification.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_classification.py index 8ee27076d2..945962bb50 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -42,7 +40,6 @@ class AutoMlImageClassification(proto.Message): inputs = proto.Field( proto.MESSAGE, number=1, message="AutoMlImageClassificationInputs", ) - metadata = proto.Field( proto.MESSAGE, number=2, message="AutoMlImageClassificationMetadata", ) @@ -50,7 +47,6 @@ class AutoMlImageClassification(proto.Message): class AutoMlImageClassificationInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlImageClassificationInputs.ModelType): @@ -102,19 +98,14 @@ class ModelType(proto.Enum): MOBILE_TF_HIGH_ACCURACY_1 = 4 model_type = proto.Field(proto.ENUM, number=1, enum=ModelType,) - - base_model_id = proto.Field(proto.STRING, number=2) - - budget_milli_node_hours = proto.Field(proto.INT64, number=3) - - disable_early_stopping = proto.Field(proto.BOOL, number=4) - - multi_label = proto.Field(proto.BOOL, number=5) + base_model_id = proto.Field(proto.STRING, number=2,) + budget_milli_node_hours = proto.Field(proto.INT64, number=3,) + disable_early_stopping = proto.Field(proto.BOOL, number=4,) + multi_label = proto.Field(proto.BOOL, number=5,) class AutoMlImageClassificationMetadata(proto.Message): r""" - Attributes: cost_milli_node_hours (int): The actual training cost of creating this @@ -133,8 +124,7 @@ class SuccessfulStopReason(proto.Enum): BUDGET_REACHED = 1 MODEL_CONVERGED = 2 - cost_milli_node_hours = proto.Field(proto.INT64, number=1) - + cost_milli_node_hours = proto.Field(proto.INT64, number=1,) successful_stop_reason = proto.Field( proto.ENUM, number=2, enum=SuccessfulStopReason, ) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_object_detection.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_object_detection.py index 512e35ed1d..1d95b93970 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_object_detection.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_object_detection.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -42,7 +40,6 @@ class AutoMlImageObjectDetection(proto.Message): inputs = proto.Field( proto.MESSAGE, number=1, message="AutoMlImageObjectDetectionInputs", ) - metadata = proto.Field( proto.MESSAGE, number=2, message="AutoMlImageObjectDetectionMetadata", ) @@ -50,7 +47,6 @@ class AutoMlImageObjectDetection(proto.Message): class AutoMlImageObjectDetectionInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlImageObjectDetectionInputs.ModelType): @@ -91,15 +87,12 @@ class ModelType(proto.Enum): MOBILE_TF_HIGH_ACCURACY_1 = 5 model_type = proto.Field(proto.ENUM, number=1, enum=ModelType,) - - budget_milli_node_hours = proto.Field(proto.INT64, number=2) - - disable_early_stopping = proto.Field(proto.BOOL, number=3) + budget_milli_node_hours = proto.Field(proto.INT64, number=2,) + disable_early_stopping = proto.Field(proto.BOOL, number=3,) class AutoMlImageObjectDetectionMetadata(proto.Message): r""" - Attributes: cost_milli_node_hours (int): The actual training cost of creating this @@ -118,8 +111,7 @@ class SuccessfulStopReason(proto.Enum): BUDGET_REACHED = 1 MODEL_CONVERGED = 2 - cost_milli_node_hours = proto.Field(proto.INT64, number=1) - + cost_milli_node_hours = proto.Field(proto.INT64, number=1,) successful_stop_reason = proto.Field( proto.ENUM, number=2, enum=SuccessfulStopReason, ) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_segmentation.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_segmentation.py index 014df43b2f..4b47874f37 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_segmentation.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_image_segmentation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -42,7 +40,6 @@ class AutoMlImageSegmentation(proto.Message): inputs = proto.Field( proto.MESSAGE, number=1, message="AutoMlImageSegmentationInputs", ) - metadata = proto.Field( proto.MESSAGE, number=2, message="AutoMlImageSegmentationMetadata", ) @@ -50,7 +47,6 @@ class AutoMlImageSegmentation(proto.Message): class AutoMlImageSegmentationInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlImageSegmentationInputs.ModelType): @@ -85,15 +81,12 @@ class ModelType(proto.Enum): MOBILE_TF_LOW_LATENCY_1 = 3 model_type = proto.Field(proto.ENUM, number=1, enum=ModelType,) - - budget_milli_node_hours = proto.Field(proto.INT64, number=2) - - base_model_id = proto.Field(proto.STRING, number=3) + budget_milli_node_hours = proto.Field(proto.INT64, number=2,) + base_model_id = proto.Field(proto.STRING, number=3,) class AutoMlImageSegmentationMetadata(proto.Message): r""" - Attributes: cost_milli_node_hours (int): The actual training cost of creating this @@ -112,8 +105,7 @@ class SuccessfulStopReason(proto.Enum): BUDGET_REACHED = 1 MODEL_CONVERGED = 2 - cost_milli_node_hours = proto.Field(proto.INT64, number=1) - + cost_milli_node_hours = proto.Field(proto.INT64, number=1,) successful_stop_reason = proto.Field( proto.ENUM, number=2, enum=SuccessfulStopReason, ) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_tables.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_tables.py index 19c43929e8..3531ec74f6 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_tables.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_tables.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types import ( export_evaluated_data_items_config as gcastd_export_evaluated_data_items_config, ) @@ -31,7 +28,6 @@ class AutoMlTables(proto.Message): r"""A TrainingJob that trains and uploads an AutoML Tables Model. - Attributes: inputs (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlTablesInputs): The input parameters of this TrainingJob. @@ -40,13 +36,11 @@ class AutoMlTables(proto.Message): """ inputs = proto.Field(proto.MESSAGE, number=1, message="AutoMlTablesInputs",) - metadata = proto.Field(proto.MESSAGE, number=2, message="AutoMlTablesMetadata",) class AutoMlTablesInputs(proto.Message): r""" - Attributes: optimization_objective_recall_value (float): Required when optimization_objective is @@ -149,7 +143,6 @@ class AutoMlTablesInputs(proto.Message): class Transformation(proto.Message): r""" - Attributes: auto (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlTablesInputs.Transformation.AutoTransformation): @@ -178,7 +171,7 @@ class AutoTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class NumericTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -204,9 +197,8 @@ class NumericTransformation(proto.Message): from trainining data. """ - column_name = proto.Field(proto.STRING, number=1) - - invalid_values_allowed = proto.Field(proto.BOOL, number=2) + column_name = proto.Field(proto.STRING, number=1,) + invalid_values_allowed = proto.Field(proto.BOOL, number=2,) class CategoricalTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -224,7 +216,7 @@ class CategoricalTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class TimestampTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -261,11 +253,9 @@ class TimestampTransformation(proto.Message): from trainining data. """ - column_name = proto.Field(proto.STRING, number=1) - - time_format = proto.Field(proto.STRING, number=2) - - invalid_values_allowed = proto.Field(proto.BOOL, number=3) + column_name = proto.Field(proto.STRING, number=1,) + time_format = proto.Field(proto.STRING, number=2,) + invalid_values_allowed = proto.Field(proto.BOOL, number=3,) class TextTransformation(proto.Message): r"""Training pipeline will perform following transformation functions. @@ -285,7 +275,7 @@ class TextTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class NumericArrayTransformation(proto.Message): r"""Treats the column as numerical array and performs following @@ -306,9 +296,8 @@ class NumericArrayTransformation(proto.Message): from trainining data. """ - column_name = proto.Field(proto.STRING, number=1) - - invalid_values_allowed = proto.Field(proto.BOOL, number=2) + column_name = proto.Field(proto.STRING, number=1,) + invalid_values_allowed = proto.Field(proto.BOOL, number=2,) class CategoricalArrayTransformation(proto.Message): r"""Treats the column as categorical array and performs following @@ -325,7 +314,7 @@ class CategoricalArrayTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) class TextArrayTransformation(proto.Message): r"""Treats the column as text array and performs following @@ -341,7 +330,7 @@ class TextArrayTransformation(proto.Message): """ - column_name = proto.Field(proto.STRING, number=1) + column_name = proto.Field(proto.STRING, number=1,) auto = proto.Field( proto.MESSAGE, @@ -349,49 +338,42 @@ class TextArrayTransformation(proto.Message): oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.AutoTransformation", ) - numeric = proto.Field( proto.MESSAGE, number=2, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.NumericTransformation", ) - categorical = proto.Field( proto.MESSAGE, number=3, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.CategoricalTransformation", ) - timestamp = proto.Field( proto.MESSAGE, number=4, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.TimestampTransformation", ) - text = proto.Field( proto.MESSAGE, number=5, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.TextTransformation", ) - repeated_numeric = proto.Field( proto.MESSAGE, number=6, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.NumericArrayTransformation", ) - repeated_categorical = proto.Field( proto.MESSAGE, number=7, oneof="transformation_detail", message="AutoMlTablesInputs.Transformation.CategoricalArrayTransformation", ) - repeated_text = proto.Field( proto.MESSAGE, number=8, @@ -400,29 +382,20 @@ class TextArrayTransformation(proto.Message): ) optimization_objective_recall_value = proto.Field( - proto.FLOAT, number=5, oneof="additional_optimization_objective_config" + proto.FLOAT, number=5, oneof="additional_optimization_objective_config", ) - optimization_objective_precision_value = proto.Field( - proto.FLOAT, number=6, oneof="additional_optimization_objective_config" + proto.FLOAT, number=6, oneof="additional_optimization_objective_config", ) - - prediction_type = proto.Field(proto.STRING, number=1) - - target_column = proto.Field(proto.STRING, number=2) - + prediction_type = proto.Field(proto.STRING, number=1,) + target_column = proto.Field(proto.STRING, number=2,) transformations = proto.RepeatedField( proto.MESSAGE, number=3, message=Transformation, ) - - optimization_objective = proto.Field(proto.STRING, number=4) - - train_budget_milli_node_hours = proto.Field(proto.INT64, number=7) - - disable_early_stopping = proto.Field(proto.BOOL, number=8) - - weight_column_name = proto.Field(proto.STRING, number=9) - + optimization_objective = proto.Field(proto.STRING, number=4,) + train_budget_milli_node_hours = proto.Field(proto.INT64, number=7,) + disable_early_stopping = proto.Field(proto.BOOL, number=8,) + weight_column_name = proto.Field(proto.STRING, number=9,) export_evaluated_data_items_config = proto.Field( proto.MESSAGE, number=10, @@ -432,7 +405,6 @@ class TextArrayTransformation(proto.Message): class AutoMlTablesMetadata(proto.Message): r"""Model metadata specific to AutoML Tables. - Attributes: train_cost_milli_node_hours (int): Output only. The actual training cost of the @@ -441,7 +413,7 @@ class AutoMlTablesMetadata(proto.Message): Guaranteed to not exceed the train budget. """ - train_cost_milli_node_hours = proto.Field(proto.INT64, number=1) + train_cost_milli_node_hours = proto.Field(proto.INT64, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_classification.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_classification.py index 9fe6b865c9..bd52a0e808 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,13 +38,12 @@ class AutoMlTextClassification(proto.Message): class AutoMlTextClassificationInputs(proto.Message): r""" - Attributes: multi_label (bool): """ - multi_label = proto.Field(proto.BOOL, number=1) + multi_label = proto.Field(proto.BOOL, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_extraction.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_extraction.py index c7b1fc6dba..ba838e0ccc 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_extraction.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_extraction.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -37,7 +35,7 @@ class AutoMlTextExtraction(proto.Message): class AutoMlTextExtractionInputs(proto.Message): - r"""""" + r""" """ __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_sentiment.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_sentiment.py index 8239b55fdf..4439db4bcc 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_sentiment.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_text_sentiment.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -38,7 +36,6 @@ class AutoMlTextSentiment(proto.Message): class AutoMlTextSentimentInputs(proto.Message): r""" - Attributes: sentiment_max (int): A sentiment is expressed as an integer @@ -53,7 +50,7 @@ class AutoMlTextSentimentInputs(proto.Message): between 1 and 10 (inclusive). """ - sentiment_max = proto.Field(proto.INT32, number=1) + sentiment_max = proto.Field(proto.INT32, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_action_recognition.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_action_recognition.py index 66448faf01..4132a92bdc 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_action_recognition.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_action_recognition.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,7 +38,6 @@ class AutoMlVideoActionRecognition(proto.Message): class AutoMlVideoActionRecognitionInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlVideoActionRecognitionInputs.ModelType): diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_classification.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_classification.py index e1c12eb46c..f5860b0d16 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_classification.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_classification.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,7 +38,6 @@ class AutoMlVideoClassification(proto.Message): class AutoMlVideoClassificationInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlVideoClassificationInputs.ModelType): diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_object_tracking.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_object_tracking.py index 328e266a3b..ea684c9977 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_object_tracking.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/automl_video_object_tracking.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,7 +38,6 @@ class AutoMlVideoObjectTracking(proto.Message): class AutoMlVideoObjectTrackingInputs(proto.Message): r""" - Attributes: model_type (google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.AutoMlVideoObjectTrackingInputs.ModelType): diff --git a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/export_evaluated_data_items_config.py b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/export_evaluated_data_items_config.py index 9a6195fec2..15046f72c1 100644 --- a/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/export_evaluated_data_items_config.py +++ b/google/cloud/aiplatform/v1beta1/schema/trainingjob/definition_v1beta1/types/export_evaluated_data_items_config.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -45,9 +43,8 @@ class ExportEvaluatedDataItemsConfig(proto.Message): operation fails. """ - destination_bigquery_uri = proto.Field(proto.STRING, number=1) - - override_existing_table = proto.Field(proto.BOOL, number=2) + destination_bigquery_uri = proto.Field(proto.STRING, number=1,) + override_existing_table = proto.Field(proto.BOOL, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/__init__.py b/google/cloud/aiplatform_v1/__init__.py index 1b0c76e834..d765cc599d 100644 --- a/google/cloud/aiplatform_v1/__init__.py +++ b/google/cloud/aiplatform_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,13 +15,22 @@ # from .services.dataset_service import DatasetServiceClient +from .services.dataset_service import DatasetServiceAsyncClient from .services.endpoint_service import EndpointServiceClient +from .services.endpoint_service import EndpointServiceAsyncClient from .services.job_service import JobServiceClient +from .services.job_service import JobServiceAsyncClient from .services.migration_service import MigrationServiceClient +from .services.migration_service import MigrationServiceAsyncClient from .services.model_service import ModelServiceClient +from .services.model_service import ModelServiceAsyncClient from .services.pipeline_service import PipelineServiceClient +from .services.pipeline_service import PipelineServiceAsyncClient from .services.prediction_service import PredictionServiceClient +from .services.prediction_service import PredictionServiceAsyncClient from .services.specialist_pool_service import SpecialistPoolServiceClient +from .services.specialist_pool_service import SpecialistPoolServiceAsyncClient + from .types.accelerator_type import AcceleratorType from .types.annotation import Annotation from .types.annotation_spec import AnnotationSpec @@ -178,8 +186,15 @@ from .types.training_pipeline import TrainingPipeline from .types.user_action_reference import UserActionReference - __all__ = ( + "DatasetServiceAsyncClient", + "EndpointServiceAsyncClient", + "JobServiceAsyncClient", + "MigrationServiceAsyncClient", + "ModelServiceAsyncClient", + "PipelineServiceAsyncClient", + "PredictionServiceAsyncClient", + "SpecialistPoolServiceAsyncClient", "AcceleratorType", "ActiveLearningConfig", "Annotation", @@ -323,6 +338,7 @@ "SearchMigratableResourcesRequest", "SearchMigratableResourcesResponse", "SpecialistPool", + "SpecialistPoolServiceClient", "StudySpec", "TimestampSplit", "TrainingConfig", @@ -341,5 +357,4 @@ "UploadModelResponse", "UserActionReference", "WorkerPoolSpec", - "SpecialistPoolServiceClient", ) diff --git a/google/cloud/aiplatform_v1/gapic_metadata.json b/google/cloud/aiplatform_v1/gapic_metadata.json new file mode 100644 index 0000000000..0abed0fd70 --- /dev/null +++ b/google/cloud/aiplatform_v1/gapic_metadata.json @@ -0,0 +1,721 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform_v1", + "protoPackage": "google.cloud.aiplatform.v1", + "schema": "1.0", + "services": { + "DatasetService": { + "clients": { + "grpc": { + "libraryClient": "DatasetServiceClient", + "rpcs": { + "CreateDataset": { + "methods": [ + "create_dataset" + ] + }, + "DeleteDataset": { + "methods": [ + "delete_dataset" + ] + }, + "ExportData": { + "methods": [ + "export_data" + ] + }, + "GetAnnotationSpec": { + "methods": [ + "get_annotation_spec" + ] + }, + "GetDataset": { + "methods": [ + "get_dataset" + ] + }, + "ImportData": { + "methods": [ + "import_data" + ] + }, + "ListAnnotations": { + "methods": [ + "list_annotations" + ] + }, + "ListDataItems": { + "methods": [ + "list_data_items" + ] + }, + "ListDatasets": { + "methods": [ + "list_datasets" + ] + }, + "UpdateDataset": { + "methods": [ + "update_dataset" + ] + } + } + }, + "grpc-async": { + "libraryClient": "DatasetServiceAsyncClient", + "rpcs": { + "CreateDataset": { + "methods": [ + "create_dataset" + ] + }, + "DeleteDataset": { + "methods": [ + "delete_dataset" + ] + }, + "ExportData": { + "methods": [ + "export_data" + ] + }, + "GetAnnotationSpec": { + "methods": [ + "get_annotation_spec" + ] + }, + "GetDataset": { + "methods": [ + "get_dataset" + ] + }, + "ImportData": { + "methods": [ + "import_data" + ] + }, + "ListAnnotations": { + "methods": [ + "list_annotations" + ] + }, + "ListDataItems": { + "methods": [ + "list_data_items" + ] + }, + "ListDatasets": { + "methods": [ + "list_datasets" + ] + }, + "UpdateDataset": { + "methods": [ + "update_dataset" + ] + } + } + } + } + }, + "EndpointService": { + "clients": { + "grpc": { + "libraryClient": "EndpointServiceClient", + "rpcs": { + "CreateEndpoint": { + "methods": [ + "create_endpoint" + ] + }, + "DeleteEndpoint": { + "methods": [ + "delete_endpoint" + ] + }, + "DeployModel": { + "methods": [ + "deploy_model" + ] + }, + "GetEndpoint": { + "methods": [ + "get_endpoint" + ] + }, + "ListEndpoints": { + "methods": [ + "list_endpoints" + ] + }, + "UndeployModel": { + "methods": [ + "undeploy_model" + ] + }, + "UpdateEndpoint": { + "methods": [ + "update_endpoint" + ] + } + } + }, + "grpc-async": { + "libraryClient": "EndpointServiceAsyncClient", + "rpcs": { + "CreateEndpoint": { + "methods": [ + "create_endpoint" + ] + }, + "DeleteEndpoint": { + "methods": [ + "delete_endpoint" + ] + }, + "DeployModel": { + "methods": [ + "deploy_model" + ] + }, + "GetEndpoint": { + "methods": [ + "get_endpoint" + ] + }, + "ListEndpoints": { + "methods": [ + "list_endpoints" + ] + }, + "UndeployModel": { + "methods": [ + "undeploy_model" + ] + }, + "UpdateEndpoint": { + "methods": [ + "update_endpoint" + ] + } + } + } + } + }, + "JobService": { + "clients": { + "grpc": { + "libraryClient": "JobServiceClient", + "rpcs": { + "CancelBatchPredictionJob": { + "methods": [ + "cancel_batch_prediction_job" + ] + }, + "CancelCustomJob": { + "methods": [ + "cancel_custom_job" + ] + }, + "CancelDataLabelingJob": { + "methods": [ + "cancel_data_labeling_job" + ] + }, + "CancelHyperparameterTuningJob": { + "methods": [ + "cancel_hyperparameter_tuning_job" + ] + }, + "CreateBatchPredictionJob": { + "methods": [ + "create_batch_prediction_job" + ] + }, + "CreateCustomJob": { + "methods": [ + "create_custom_job" + ] + }, + "CreateDataLabelingJob": { + "methods": [ + "create_data_labeling_job" + ] + }, + "CreateHyperparameterTuningJob": { + "methods": [ + "create_hyperparameter_tuning_job" + ] + }, + "DeleteBatchPredictionJob": { + "methods": [ + "delete_batch_prediction_job" + ] + }, + "DeleteCustomJob": { + "methods": [ + "delete_custom_job" + ] + }, + "DeleteDataLabelingJob": { + "methods": [ + "delete_data_labeling_job" + ] + }, + "DeleteHyperparameterTuningJob": { + "methods": [ + "delete_hyperparameter_tuning_job" + ] + }, + "GetBatchPredictionJob": { + "methods": [ + "get_batch_prediction_job" + ] + }, + "GetCustomJob": { + "methods": [ + "get_custom_job" + ] + }, + "GetDataLabelingJob": { + "methods": [ + "get_data_labeling_job" + ] + }, + "GetHyperparameterTuningJob": { + "methods": [ + "get_hyperparameter_tuning_job" + ] + }, + "ListBatchPredictionJobs": { + "methods": [ + "list_batch_prediction_jobs" + ] + }, + "ListCustomJobs": { + "methods": [ + "list_custom_jobs" + ] + }, + "ListDataLabelingJobs": { + "methods": [ + "list_data_labeling_jobs" + ] + }, + "ListHyperparameterTuningJobs": { + "methods": [ + "list_hyperparameter_tuning_jobs" + ] + } + } + }, + "grpc-async": { + "libraryClient": "JobServiceAsyncClient", + "rpcs": { + "CancelBatchPredictionJob": { + "methods": [ + "cancel_batch_prediction_job" + ] + }, + "CancelCustomJob": { + "methods": [ + "cancel_custom_job" + ] + }, + "CancelDataLabelingJob": { + "methods": [ + "cancel_data_labeling_job" + ] + }, + "CancelHyperparameterTuningJob": { + "methods": [ + "cancel_hyperparameter_tuning_job" + ] + }, + "CreateBatchPredictionJob": { + "methods": [ + "create_batch_prediction_job" + ] + }, + "CreateCustomJob": { + "methods": [ + "create_custom_job" + ] + }, + "CreateDataLabelingJob": { + "methods": [ + "create_data_labeling_job" + ] + }, + "CreateHyperparameterTuningJob": { + "methods": [ + "create_hyperparameter_tuning_job" + ] + }, + "DeleteBatchPredictionJob": { + "methods": [ + "delete_batch_prediction_job" + ] + }, + "DeleteCustomJob": { + "methods": [ + "delete_custom_job" + ] + }, + "DeleteDataLabelingJob": { + "methods": [ + "delete_data_labeling_job" + ] + }, + "DeleteHyperparameterTuningJob": { + "methods": [ + "delete_hyperparameter_tuning_job" + ] + }, + "GetBatchPredictionJob": { + "methods": [ + "get_batch_prediction_job" + ] + }, + "GetCustomJob": { + "methods": [ + "get_custom_job" + ] + }, + "GetDataLabelingJob": { + "methods": [ + "get_data_labeling_job" + ] + }, + "GetHyperparameterTuningJob": { + "methods": [ + "get_hyperparameter_tuning_job" + ] + }, + "ListBatchPredictionJobs": { + "methods": [ + "list_batch_prediction_jobs" + ] + }, + "ListCustomJobs": { + "methods": [ + "list_custom_jobs" + ] + }, + "ListDataLabelingJobs": { + "methods": [ + "list_data_labeling_jobs" + ] + }, + "ListHyperparameterTuningJobs": { + "methods": [ + "list_hyperparameter_tuning_jobs" + ] + } + } + } + } + }, + "MigrationService": { + "clients": { + "grpc": { + "libraryClient": "MigrationServiceClient", + "rpcs": { + "BatchMigrateResources": { + "methods": [ + "batch_migrate_resources" + ] + }, + "SearchMigratableResources": { + "methods": [ + "search_migratable_resources" + ] + } + } + }, + "grpc-async": { + "libraryClient": "MigrationServiceAsyncClient", + "rpcs": { + "BatchMigrateResources": { + "methods": [ + "batch_migrate_resources" + ] + }, + "SearchMigratableResources": { + "methods": [ + "search_migratable_resources" + ] + } + } + } + } + }, + "ModelService": { + "clients": { + "grpc": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "DeleteModel": { + "methods": [ + "delete_model" + ] + }, + "ExportModel": { + "methods": [ + "export_model" + ] + }, + "GetModel": { + "methods": [ + "get_model" + ] + }, + "GetModelEvaluation": { + "methods": [ + "get_model_evaluation" + ] + }, + "GetModelEvaluationSlice": { + "methods": [ + "get_model_evaluation_slice" + ] + }, + "ListModelEvaluationSlices": { + "methods": [ + "list_model_evaluation_slices" + ] + }, + "ListModelEvaluations": { + "methods": [ + "list_model_evaluations" + ] + }, + "ListModels": { + "methods": [ + "list_models" + ] + }, + "UpdateModel": { + "methods": [ + "update_model" + ] + }, + "UploadModel": { + "methods": [ + "upload_model" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ModelServiceAsyncClient", + "rpcs": { + "DeleteModel": { + "methods": [ + "delete_model" + ] + }, + "ExportModel": { + "methods": [ + "export_model" + ] + }, + "GetModel": { + "methods": [ + "get_model" + ] + }, + "GetModelEvaluation": { + "methods": [ + "get_model_evaluation" + ] + }, + "GetModelEvaluationSlice": { + "methods": [ + "get_model_evaluation_slice" + ] + }, + "ListModelEvaluationSlices": { + "methods": [ + "list_model_evaluation_slices" + ] + }, + "ListModelEvaluations": { + "methods": [ + "list_model_evaluations" + ] + }, + "ListModels": { + "methods": [ + "list_models" + ] + }, + "UpdateModel": { + "methods": [ + "update_model" + ] + }, + "UploadModel": { + "methods": [ + "upload_model" + ] + } + } + } + } + }, + "PipelineService": { + "clients": { + "grpc": { + "libraryClient": "PipelineServiceClient", + "rpcs": { + "CancelTrainingPipeline": { + "methods": [ + "cancel_training_pipeline" + ] + }, + "CreateTrainingPipeline": { + "methods": [ + "create_training_pipeline" + ] + }, + "DeleteTrainingPipeline": { + "methods": [ + "delete_training_pipeline" + ] + }, + "GetTrainingPipeline": { + "methods": [ + "get_training_pipeline" + ] + }, + "ListTrainingPipelines": { + "methods": [ + "list_training_pipelines" + ] + } + } + }, + "grpc-async": { + "libraryClient": "PipelineServiceAsyncClient", + "rpcs": { + "CancelTrainingPipeline": { + "methods": [ + "cancel_training_pipeline" + ] + }, + "CreateTrainingPipeline": { + "methods": [ + "create_training_pipeline" + ] + }, + "DeleteTrainingPipeline": { + "methods": [ + "delete_training_pipeline" + ] + }, + "GetTrainingPipeline": { + "methods": [ + "get_training_pipeline" + ] + }, + "ListTrainingPipelines": { + "methods": [ + "list_training_pipelines" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-async": { + "libraryClient": "PredictionServiceAsyncClient", + "rpcs": { + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "SpecialistPoolService": { + "clients": { + "grpc": { + "libraryClient": "SpecialistPoolServiceClient", + "rpcs": { + "CreateSpecialistPool": { + "methods": [ + "create_specialist_pool" + ] + }, + "DeleteSpecialistPool": { + "methods": [ + "delete_specialist_pool" + ] + }, + "GetSpecialistPool": { + "methods": [ + "get_specialist_pool" + ] + }, + "ListSpecialistPools": { + "methods": [ + "list_specialist_pools" + ] + }, + "UpdateSpecialistPool": { + "methods": [ + "update_specialist_pool" + ] + } + } + }, + "grpc-async": { + "libraryClient": "SpecialistPoolServiceAsyncClient", + "rpcs": { + "CreateSpecialistPool": { + "methods": [ + "create_specialist_pool" + ] + }, + "DeleteSpecialistPool": { + "methods": [ + "delete_specialist_pool" + ] + }, + "GetSpecialistPool": { + "methods": [ + "get_specialist_pool" + ] + }, + "ListSpecialistPools": { + "methods": [ + "list_specialist_pools" + ] + }, + "UpdateSpecialistPool": { + "methods": [ + "update_specialist_pool" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/aiplatform_v1/services/__init__.py b/google/cloud/aiplatform_v1/services/__init__.py index 42ffdf2bc4..4de65971c2 100644 --- a/google/cloud/aiplatform_v1/services/__init__.py +++ b/google/cloud/aiplatform_v1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/aiplatform_v1/services/dataset_service/__init__.py b/google/cloud/aiplatform_v1/services/dataset_service/__init__.py index 597f654cb9..42adf5e5af 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import DatasetServiceClient from .async_client import DatasetServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/dataset_service/async_client.py b/google/cloud/aiplatform_v1/services/dataset_service/async_client.py index 0faf10bac8..b937183e37 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -39,11 +37,10 @@ from google.cloud.aiplatform_v1.types import dataset_service from google.cloud.aiplatform_v1.types import encryption_spec from google.cloud.aiplatform_v1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import DatasetServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import DatasetServiceGrpcAsyncIOTransport from .client import DatasetServiceClient @@ -67,31 +64,26 @@ class DatasetServiceAsyncClient: parse_data_item_path = staticmethod(DatasetServiceClient.parse_data_item_path) dataset_path = staticmethod(DatasetServiceClient.dataset_path) parse_dataset_path = staticmethod(DatasetServiceClient.parse_dataset_path) - common_billing_account_path = staticmethod( DatasetServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( DatasetServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(DatasetServiceClient.common_folder_path) parse_common_folder_path = staticmethod( DatasetServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( DatasetServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( DatasetServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(DatasetServiceClient.common_project_path) parse_common_project_path = staticmethod( DatasetServiceClient.parse_common_project_path ) - common_location_path = staticmethod(DatasetServiceClient.common_location_path) parse_common_location_path = staticmethod( DatasetServiceClient.parse_common_location_path @@ -145,7 +137,7 @@ def transport(self) -> DatasetServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, DatasetServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -182,7 +174,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = DatasetServiceClient( credentials=credentials, transport=transport, @@ -219,7 +210,6 @@ async def create_dataset( This corresponds to the ``dataset`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -249,7 +239,6 @@ async def create_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if dataset is not None: @@ -305,7 +294,6 @@ async def get_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -332,7 +320,6 @@ async def get_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -361,7 +348,7 @@ async def update_dataset( request: dataset_service.UpdateDatasetRequest = None, *, dataset: gca_dataset.Dataset = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -392,7 +379,6 @@ async def update_dataset( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -419,7 +405,6 @@ async def update_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if dataset is not None: request.dataset = dataset if update_mask is not None: @@ -469,7 +454,6 @@ async def list_datasets( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -499,7 +483,6 @@ async def list_datasets( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -552,7 +535,6 @@ async def delete_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -592,7 +574,6 @@ async def delete_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -617,7 +598,7 @@ async def delete_dataset( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -655,7 +636,6 @@ async def import_data( This corresponds to the ``import_configs`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -686,10 +666,8 @@ async def import_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name - if import_configs: request.import_configs.extend(import_configs) @@ -751,7 +729,6 @@ async def export_data( This corresponds to the ``export_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -782,7 +759,6 @@ async def export_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if export_config is not None: @@ -839,7 +815,6 @@ async def list_data_items( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -869,7 +844,6 @@ async def list_data_items( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -923,7 +897,6 @@ async def get_annotation_spec( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -950,7 +923,6 @@ async def get_annotation_spec( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -998,7 +970,6 @@ async def list_annotations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1028,7 +999,6 @@ async def list_annotations( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1/services/dataset_service/client.py b/google/cloud/aiplatform_v1/services/dataset_service/client.py index e1fcc167f2..201d814c99 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/client.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -43,11 +41,10 @@ from google.cloud.aiplatform_v1.types import dataset_service from google.cloud.aiplatform_v1.types import encryption_spec from google.cloud.aiplatform_v1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import DatasetServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import DatasetServiceGrpcTransport from .transports.grpc_asyncio import DatasetServiceGrpcAsyncIOTransport @@ -307,7 +304,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, DatasetServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -446,7 +443,6 @@ def create_dataset( This corresponds to the ``dataset`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -478,10 +474,8 @@ def create_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.CreateDatasetRequest): request = dataset_service.CreateDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if dataset is not None: @@ -533,7 +527,6 @@ def get_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -562,10 +555,8 @@ def get_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.GetDatasetRequest): request = dataset_service.GetDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -590,7 +581,7 @@ def update_dataset( request: dataset_service.UpdateDatasetRequest = None, *, dataset: gca_dataset.Dataset = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -621,7 +612,6 @@ def update_dataset( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -650,10 +640,8 @@ def update_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.UpdateDatasetRequest): request = dataset_service.UpdateDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if dataset is not None: request.dataset = dataset if update_mask is not None: @@ -699,7 +687,6 @@ def list_datasets( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -731,10 +718,8 @@ def list_datasets( # there are no flattened fields. if not isinstance(request, dataset_service.ListDatasetsRequest): request = dataset_service.ListDatasetsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -783,7 +768,6 @@ def delete_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -825,10 +809,8 @@ def delete_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.DeleteDatasetRequest): request = dataset_service.DeleteDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -849,7 +831,7 @@ def delete_dataset( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -887,7 +869,6 @@ def import_data( This corresponds to the ``import_configs`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -920,10 +901,8 @@ def import_data( # there are no flattened fields. if not isinstance(request, dataset_service.ImportDataRequest): request = dataset_service.ImportDataRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if import_configs is not None: @@ -983,7 +962,6 @@ def export_data( This corresponds to the ``export_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1016,10 +994,8 @@ def export_data( # there are no flattened fields. if not isinstance(request, dataset_service.ExportDataRequest): request = dataset_service.ExportDataRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if export_config is not None: @@ -1072,7 +1048,6 @@ def list_data_items( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1104,10 +1079,8 @@ def list_data_items( # there are no flattened fields. if not isinstance(request, dataset_service.ListDataItemsRequest): request = dataset_service.ListDataItemsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1157,7 +1130,6 @@ def get_annotation_spec( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1186,10 +1158,8 @@ def get_annotation_spec( # there are no flattened fields. if not isinstance(request, dataset_service.GetAnnotationSpecRequest): request = dataset_service.GetAnnotationSpecRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1233,7 +1203,6 @@ def list_annotations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1265,10 +1234,8 @@ def list_annotations( # there are no flattened fields. if not isinstance(request, dataset_service.ListAnnotationsRequest): request = dataset_service.ListAnnotationsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1/services/dataset_service/pagers.py b/google/cloud/aiplatform_v1/services/dataset_service/pagers.py index c3f8265b6e..be142bd36e 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/pagers.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/__init__.py index a4461d2ced..902a4fb01f 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py index 10653cbf25..c049ed37ba 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import annotation_spec from google.cloud.aiplatform_v1.types import dataset from google.cloud.aiplatform_v1.types import dataset as gca_dataset from google.cloud.aiplatform_v1.types import dataset_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -42,27 +41,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class DatasetServiceTransport(abc.ABC): """Abstract transport class for DatasetService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -71,7 +84,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -85,29 +98,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -151,38 +211,38 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.CreateDatasetRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.GetDatasetRequest], - typing.Union[dataset.Dataset, typing.Awaitable[dataset.Dataset]], + Union[dataset.Dataset, Awaitable[dataset.Dataset]], ]: raise NotImplementedError() @property def update_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.UpdateDatasetRequest], - typing.Union[gca_dataset.Dataset, typing.Awaitable[gca_dataset.Dataset]], + Union[gca_dataset.Dataset, Awaitable[gca_dataset.Dataset]], ]: raise NotImplementedError() @property def list_datasets( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ListDatasetsRequest], - typing.Union[ + Union[ dataset_service.ListDatasetsResponse, - typing.Awaitable[dataset_service.ListDatasetsResponse], + Awaitable[dataset_service.ListDatasetsResponse], ], ]: raise NotImplementedError() @@ -190,38 +250,38 @@ def list_datasets( @property def delete_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.DeleteDatasetRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def import_data( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ImportDataRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def export_data( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ExportDataRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_data_items( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ListDataItemsRequest], - typing.Union[ + Union[ dataset_service.ListDataItemsResponse, - typing.Awaitable[dataset_service.ListDataItemsResponse], + Awaitable[dataset_service.ListDataItemsResponse], ], ]: raise NotImplementedError() @@ -229,11 +289,10 @@ def list_data_items( @property def get_annotation_spec( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.GetAnnotationSpecRequest], - typing.Union[ - annotation_spec.AnnotationSpec, - typing.Awaitable[annotation_spec.AnnotationSpec], + Union[ + annotation_spec.AnnotationSpec, Awaitable[annotation_spec.AnnotationSpec] ], ]: raise NotImplementedError() @@ -241,11 +300,11 @@ def get_annotation_spec( @property def list_annotations( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ListAnnotationsRequest], - typing.Union[ + Union[ dataset_service.ListAnnotationsResponse, - typing.Awaitable[dataset_service.ListAnnotationsResponse], + Awaitable[dataset_service.ListAnnotationsResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py index 65bd8baf79..d38f841665 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -31,8 +29,7 @@ from google.cloud.aiplatform_v1.types import dataset from google.cloud.aiplatform_v1.types import dataset as gca_dataset from google.cloud.aiplatform_v1.types import dataset_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DatasetServiceTransport, DEFAULT_CLIENT_INFO @@ -53,7 +50,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -67,7 +64,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -178,7 +176,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -209,13 +207,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -242,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_dataset( self, - ) -> Callable[[dataset_service.CreateDatasetRequest], operations.Operation]: + ) -> Callable[[dataset_service.CreateDatasetRequest], operations_pb2.Operation]: r"""Return a callable for the create dataset method over gRPC. Creates a Dataset. @@ -261,7 +261,7 @@ def create_dataset( self._stubs["create_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/CreateDataset", request_serializer=dataset_service.CreateDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset"] @@ -348,7 +348,7 @@ def list_datasets( @property def delete_dataset( self, - ) -> Callable[[dataset_service.DeleteDatasetRequest], operations.Operation]: + ) -> Callable[[dataset_service.DeleteDatasetRequest], operations_pb2.Operation]: r"""Return a callable for the delete dataset method over gRPC. Deletes a Dataset. @@ -367,14 +367,14 @@ def delete_dataset( self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteDataset", request_serializer=dataset_service.DeleteDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset"] @property def import_data( self, - ) -> Callable[[dataset_service.ImportDataRequest], operations.Operation]: + ) -> Callable[[dataset_service.ImportDataRequest], operations_pb2.Operation]: r"""Return a callable for the import data method over gRPC. Imports data into a Dataset. @@ -393,14 +393,14 @@ def import_data( self._stubs["import_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ImportData", request_serializer=dataset_service.ImportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_data"] @property def export_data( self, - ) -> Callable[[dataset_service.ExportDataRequest], operations.Operation]: + ) -> Callable[[dataset_service.ExportDataRequest], operations_pb2.Operation]: r"""Return a callable for the export data method over gRPC. Exports data from a Dataset. @@ -419,7 +419,7 @@ def export_data( self._stubs["export_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ExportData", request_serializer=dataset_service.ExportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_data"] diff --git a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py index 90d4dc67f2..dad35d6eca 100644 --- a/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -32,8 +30,7 @@ from google.cloud.aiplatform_v1.types import dataset from google.cloud.aiplatform_v1.types import dataset as gca_dataset from google.cloud.aiplatform_v1.types import dataset_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DatasetServiceTransport, DEFAULT_CLIENT_INFO from .grpc import DatasetServiceGrpcTransport @@ -56,7 +53,7 @@ class DatasetServiceGrpcAsyncIOTransport(DatasetServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -83,13 +80,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -97,7 +96,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -111,7 +110,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -170,7 +170,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -249,7 +248,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: def create_dataset( self, ) -> Callable[ - [dataset_service.CreateDatasetRequest], Awaitable[operations.Operation] + [dataset_service.CreateDatasetRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create dataset method over gRPC. @@ -269,7 +268,7 @@ def create_dataset( self._stubs["create_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/CreateDataset", request_serializer=dataset_service.CreateDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset"] @@ -360,7 +359,7 @@ def list_datasets( def delete_dataset( self, ) -> Callable[ - [dataset_service.DeleteDatasetRequest], Awaitable[operations.Operation] + [dataset_service.DeleteDatasetRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete dataset method over gRPC. @@ -380,14 +379,16 @@ def delete_dataset( self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/DeleteDataset", request_serializer=dataset_service.DeleteDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset"] @property def import_data( self, - ) -> Callable[[dataset_service.ImportDataRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [dataset_service.ImportDataRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the import data method over gRPC. Imports data into a Dataset. @@ -406,14 +407,16 @@ def import_data( self._stubs["import_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ImportData", request_serializer=dataset_service.ImportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_data"] @property def export_data( self, - ) -> Callable[[dataset_service.ExportDataRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [dataset_service.ExportDataRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the export data method over gRPC. Exports data from a Dataset. @@ -432,7 +435,7 @@ def export_data( self._stubs["export_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.DatasetService/ExportData", request_serializer=dataset_service.ExportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_data"] diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/__init__.py b/google/cloud/aiplatform_v1/services/endpoint_service/__init__.py index 035a5b2388..96fb4ad6d6 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import EndpointServiceClient from .async_client import EndpointServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/async_client.py b/google/cloud/aiplatform_v1/services/endpoint_service/async_client.py index d66270549f..544a7788df 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -36,10 +34,9 @@ from google.cloud.aiplatform_v1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1.types import endpoint_service from google.cloud.aiplatform_v1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import EndpointServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import EndpointServiceGrpcAsyncIOTransport from .client import EndpointServiceClient @@ -57,31 +54,26 @@ class EndpointServiceAsyncClient: parse_endpoint_path = staticmethod(EndpointServiceClient.parse_endpoint_path) model_path = staticmethod(EndpointServiceClient.model_path) parse_model_path = staticmethod(EndpointServiceClient.parse_model_path) - common_billing_account_path = staticmethod( EndpointServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( EndpointServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(EndpointServiceClient.common_folder_path) parse_common_folder_path = staticmethod( EndpointServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( EndpointServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( EndpointServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(EndpointServiceClient.common_project_path) parse_common_project_path = staticmethod( EndpointServiceClient.parse_common_project_path ) - common_location_path = staticmethod(EndpointServiceClient.common_location_path) parse_common_location_path = staticmethod( EndpointServiceClient.parse_common_location_path @@ -135,7 +127,7 @@ def transport(self) -> EndpointServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, EndpointServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -172,7 +164,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = EndpointServiceClient( credentials=credentials, transport=transport, @@ -209,7 +200,6 @@ async def create_endpoint( This corresponds to the ``endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -238,7 +228,6 @@ async def create_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if endpoint is not None: @@ -294,7 +283,6 @@ async def get_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -322,7 +310,6 @@ async def get_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -369,7 +356,6 @@ async def list_endpoints( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -399,7 +385,6 @@ async def list_endpoints( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -434,7 +419,7 @@ async def update_endpoint( request: endpoint_service.UpdateEndpointRequest = None, *, endpoint: gca_endpoint.Endpoint = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -459,7 +444,6 @@ async def update_endpoint( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -487,7 +471,6 @@ async def update_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if update_mask is not None: @@ -538,7 +521,6 @@ async def delete_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -578,7 +560,6 @@ async def delete_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -603,7 +584,7 @@ async def delete_endpoint( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -669,7 +650,6 @@ async def deploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -700,7 +680,6 @@ async def deploy_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model is not None: @@ -787,7 +766,6 @@ async def undeploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -818,7 +796,6 @@ async def undeploy_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model_id is not None: diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/client.py b/google/cloud/aiplatform_v1/services/endpoint_service/client.py index e4a5878537..8bc3a8026f 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/client.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -40,10 +38,9 @@ from google.cloud.aiplatform_v1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1.types import endpoint_service from google.cloud.aiplatform_v1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import EndpointServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import EndpointServiceGrpcTransport from .transports.grpc_asyncio import EndpointServiceGrpcAsyncIOTransport @@ -258,7 +255,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, EndpointServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -397,7 +394,6 @@ def create_endpoint( This corresponds to the ``endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -428,10 +424,8 @@ def create_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.CreateEndpointRequest): request = endpoint_service.CreateEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if endpoint is not None: @@ -483,7 +477,6 @@ def get_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -513,10 +506,8 @@ def get_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.GetEndpointRequest): request = endpoint_service.GetEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -559,7 +550,6 @@ def list_endpoints( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -591,10 +581,8 @@ def list_endpoints( # there are no flattened fields. if not isinstance(request, endpoint_service.ListEndpointsRequest): request = endpoint_service.ListEndpointsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -625,7 +613,7 @@ def update_endpoint( request: endpoint_service.UpdateEndpointRequest = None, *, endpoint: gca_endpoint.Endpoint = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -650,7 +638,6 @@ def update_endpoint( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -680,10 +667,8 @@ def update_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.UpdateEndpointRequest): request = endpoint_service.UpdateEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if update_mask is not None: @@ -730,7 +715,6 @@ def delete_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -772,10 +756,8 @@ def delete_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.DeleteEndpointRequest): request = endpoint_service.DeleteEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -796,7 +778,7 @@ def delete_endpoint( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -862,7 +844,6 @@ def deploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -895,10 +876,8 @@ def deploy_model( # there are no flattened fields. if not isinstance(request, endpoint_service.DeployModelRequest): request = endpoint_service.DeployModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model is not None: @@ -980,7 +959,6 @@ def undeploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1013,10 +991,8 @@ def undeploy_model( # there are no flattened fields. if not isinstance(request, endpoint_service.UndeployModelRequest): request = endpoint_service.UndeployModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model_id is not None: diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/pagers.py b/google/cloud/aiplatform_v1/services/endpoint_service/pagers.py index c22df91c8c..0b222aee01 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/pagers.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/__init__.py index 3d0695461d..4d336c5875 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py index 054d6c9b01..a760eddfef 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import endpoint from google.cloud.aiplatform_v1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1.types import endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -41,27 +40,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class EndpointServiceTransport(abc.ABC): """Abstract transport class for EndpointService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -70,7 +83,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -84,29 +97,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -141,29 +201,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.CreateEndpointRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.GetEndpointRequest], - typing.Union[endpoint.Endpoint, typing.Awaitable[endpoint.Endpoint]], + Union[endpoint.Endpoint, Awaitable[endpoint.Endpoint]], ]: raise NotImplementedError() @property def list_endpoints( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.ListEndpointsRequest], - typing.Union[ + Union[ endpoint_service.ListEndpointsResponse, - typing.Awaitable[endpoint_service.ListEndpointsResponse], + Awaitable[endpoint_service.ListEndpointsResponse], ], ]: raise NotImplementedError() @@ -171,36 +231,36 @@ def list_endpoints( @property def update_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.UpdateEndpointRequest], - typing.Union[gca_endpoint.Endpoint, typing.Awaitable[gca_endpoint.Endpoint]], + Union[gca_endpoint.Endpoint, Awaitable[gca_endpoint.Endpoint]], ]: raise NotImplementedError() @property def delete_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.DeleteEndpointRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def deploy_model( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.DeployModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def undeploy_model( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.UndeployModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py index 8a2c837161..d81853d560 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -30,8 +28,7 @@ from google.cloud.aiplatform_v1.types import endpoint from google.cloud.aiplatform_v1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1.types import endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import EndpointServiceTransport, DEFAULT_CLIENT_INFO @@ -52,7 +49,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -66,7 +63,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -177,7 +175,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -208,13 +206,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -241,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_endpoint( self, - ) -> Callable[[endpoint_service.CreateEndpointRequest], operations.Operation]: + ) -> Callable[[endpoint_service.CreateEndpointRequest], operations_pb2.Operation]: r"""Return a callable for the create endpoint method over gRPC. Creates an Endpoint. @@ -260,7 +260,7 @@ def create_endpoint( self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/CreateEndpoint", request_serializer=endpoint_service.CreateEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_endpoint"] @@ -347,7 +347,7 @@ def update_endpoint( @property def delete_endpoint( self, - ) -> Callable[[endpoint_service.DeleteEndpointRequest], operations.Operation]: + ) -> Callable[[endpoint_service.DeleteEndpointRequest], operations_pb2.Operation]: r"""Return a callable for the delete endpoint method over gRPC. Deletes an Endpoint. @@ -366,14 +366,14 @@ def delete_endpoint( self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeleteEndpoint", request_serializer=endpoint_service.DeleteEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_endpoint"] @property def deploy_model( self, - ) -> Callable[[endpoint_service.DeployModelRequest], operations.Operation]: + ) -> Callable[[endpoint_service.DeployModelRequest], operations_pb2.Operation]: r"""Return a callable for the deploy model method over gRPC. Deploys a Model into this Endpoint, creating a @@ -393,14 +393,14 @@ def deploy_model( self._stubs["deploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeployModel", request_serializer=endpoint_service.DeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_model"] @property def undeploy_model( self, - ) -> Callable[[endpoint_service.UndeployModelRequest], operations.Operation]: + ) -> Callable[[endpoint_service.UndeployModelRequest], operations_pb2.Operation]: r"""Return a callable for the undeploy model method over gRPC. Undeploys a Model from an Endpoint, removing a @@ -421,7 +421,7 @@ def undeploy_model( self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UndeployModel", request_serializer=endpoint_service.UndeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_model"] diff --git a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py index d10160a493..41f295e135 100644 --- a/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -31,8 +29,7 @@ from google.cloud.aiplatform_v1.types import endpoint from google.cloud.aiplatform_v1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1.types import endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import EndpointServiceTransport, DEFAULT_CLIENT_INFO from .grpc import EndpointServiceGrpcTransport @@ -55,7 +52,7 @@ class EndpointServiceGrpcAsyncIOTransport(EndpointServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -82,13 +79,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -96,7 +95,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -110,7 +109,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -169,7 +169,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -248,7 +247,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: def create_endpoint( self, ) -> Callable[ - [endpoint_service.CreateEndpointRequest], Awaitable[operations.Operation] + [endpoint_service.CreateEndpointRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create endpoint method over gRPC. @@ -268,7 +267,7 @@ def create_endpoint( self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/CreateEndpoint", request_serializer=endpoint_service.CreateEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_endpoint"] @@ -359,7 +358,7 @@ def update_endpoint( def delete_endpoint( self, ) -> Callable[ - [endpoint_service.DeleteEndpointRequest], Awaitable[operations.Operation] + [endpoint_service.DeleteEndpointRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete endpoint method over gRPC. @@ -379,7 +378,7 @@ def delete_endpoint( self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeleteEndpoint", request_serializer=endpoint_service.DeleteEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_endpoint"] @@ -387,7 +386,7 @@ def delete_endpoint( def deploy_model( self, ) -> Callable[ - [endpoint_service.DeployModelRequest], Awaitable[operations.Operation] + [endpoint_service.DeployModelRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the deploy model method over gRPC. @@ -408,7 +407,7 @@ def deploy_model( self._stubs["deploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/DeployModel", request_serializer=endpoint_service.DeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_model"] @@ -416,7 +415,7 @@ def deploy_model( def undeploy_model( self, ) -> Callable[ - [endpoint_service.UndeployModelRequest], Awaitable[operations.Operation] + [endpoint_service.UndeployModelRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the undeploy model method over gRPC. @@ -438,7 +437,7 @@ def undeploy_model( self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.EndpointService/UndeployModel", request_serializer=endpoint_service.UndeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_model"] diff --git a/google/cloud/aiplatform_v1/services/job_service/__init__.py b/google/cloud/aiplatform_v1/services/job_service/__init__.py index 5f157047f5..3d8d94dbd8 100644 --- a/google/cloud/aiplatform_v1/services/job_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/job_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import JobServiceClient from .async_client import JobServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/job_service/async_client.py b/google/cloud/aiplatform_v1/services/job_service/async_client.py index 91284c5bf6..ff31a99af8 100644 --- a/google/cloud/aiplatform_v1/services/job_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/job_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -51,12 +49,11 @@ from google.cloud.aiplatform_v1.types import manual_batch_tuning_parameters from google.cloud.aiplatform_v1.types import operation as gca_operation from google.cloud.aiplatform_v1.types import study -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport from .client import JobServiceClient @@ -92,25 +89,20 @@ class JobServiceAsyncClient: parse_model_path = staticmethod(JobServiceClient.parse_model_path) trial_path = staticmethod(JobServiceClient.trial_path) parse_trial_path = staticmethod(JobServiceClient.parse_trial_path) - common_billing_account_path = staticmethod( JobServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( JobServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(JobServiceClient.common_folder_path) parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(JobServiceClient.common_organization_path) parse_common_organization_path = staticmethod( JobServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(JobServiceClient.common_project_path) parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) - common_location_path = staticmethod(JobServiceClient.common_location_path) parse_common_location_path = staticmethod( JobServiceClient.parse_common_location_path @@ -164,7 +156,7 @@ def transport(self) -> JobServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, JobServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -201,7 +193,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = JobServiceClient( credentials=credentials, transport=transport, @@ -239,7 +230,6 @@ async def create_custom_job( This corresponds to the ``custom_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -272,7 +262,6 @@ async def create_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if custom_job is not None: @@ -320,7 +309,6 @@ async def get_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -353,7 +341,6 @@ async def get_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -400,7 +387,6 @@ async def list_custom_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -430,7 +416,6 @@ async def list_custom_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -483,7 +468,6 @@ async def delete_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -523,7 +507,6 @@ async def delete_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -548,7 +531,7 @@ async def delete_custom_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -589,7 +572,6 @@ async def cancel_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -610,7 +592,6 @@ async def cancel_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -663,7 +644,6 @@ async def create_data_labeling_job( This corresponds to the ``data_labeling_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -691,7 +671,6 @@ async def create_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if data_labeling_job is not None: @@ -740,7 +719,6 @@ async def get_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -768,7 +746,6 @@ async def get_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -814,7 +791,6 @@ async def list_data_labeling_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -844,7 +820,6 @@ async def list_data_labeling_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -898,7 +873,6 @@ async def delete_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -938,7 +912,6 @@ async def delete_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -963,7 +936,7 @@ async def delete_data_labeling_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -994,7 +967,6 @@ async def cancel_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1015,7 +987,6 @@ async def cancel_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1069,7 +1040,6 @@ async def create_hyperparameter_tuning_job( This corresponds to the ``hyperparameter_tuning_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1098,7 +1068,6 @@ async def create_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if hyperparameter_tuning_job is not None: @@ -1148,7 +1117,6 @@ async def get_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1177,7 +1145,6 @@ async def get_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1224,7 +1191,6 @@ async def list_hyperparameter_tuning_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1254,7 +1220,6 @@ async def list_hyperparameter_tuning_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1308,7 +1273,6 @@ async def delete_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1348,7 +1312,6 @@ async def delete_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1373,7 +1336,7 @@ async def delete_hyperparameter_tuning_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1417,7 +1380,6 @@ async def cancel_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1438,7 +1400,6 @@ async def cancel_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1493,7 +1454,6 @@ async def create_batch_prediction_job( This corresponds to the ``batch_prediction_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1524,7 +1484,6 @@ async def create_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if batch_prediction_job is not None: @@ -1574,7 +1533,6 @@ async def get_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1605,7 +1563,6 @@ async def get_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1652,7 +1609,6 @@ async def list_batch_prediction_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1682,7 +1638,6 @@ async def list_batch_prediction_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1737,7 +1692,6 @@ async def delete_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1777,7 +1731,6 @@ async def delete_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1802,7 +1755,7 @@ async def delete_batch_prediction_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1844,7 +1797,6 @@ async def cancel_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1865,7 +1817,6 @@ async def cancel_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1/services/job_service/client.py b/google/cloud/aiplatform_v1/services/job_service/client.py index efdee645c8..d06dece139 100644 --- a/google/cloud/aiplatform_v1/services/job_service/client.py +++ b/google/cloud/aiplatform_v1/services/job_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -55,12 +53,11 @@ from google.cloud.aiplatform_v1.types import manual_batch_tuning_parameters from google.cloud.aiplatform_v1.types import operation as gca_operation from google.cloud.aiplatform_v1.types import study -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import JobServiceGrpcTransport from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport @@ -363,7 +360,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, JobServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -503,7 +500,6 @@ def create_custom_job( This corresponds to the ``custom_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -538,10 +534,8 @@ def create_custom_job( # there are no flattened fields. if not isinstance(request, job_service.CreateCustomJobRequest): request = job_service.CreateCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if custom_job is not None: @@ -585,7 +579,6 @@ def get_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -620,10 +613,8 @@ def get_custom_job( # there are no flattened fields. if not isinstance(request, job_service.GetCustomJobRequest): request = job_service.GetCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -666,7 +657,6 @@ def list_custom_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -698,10 +688,8 @@ def list_custom_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListCustomJobsRequest): request = job_service.ListCustomJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -750,7 +738,6 @@ def delete_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -792,10 +779,8 @@ def delete_custom_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteCustomJobRequest): request = job_service.DeleteCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -816,7 +801,7 @@ def delete_custom_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -857,7 +842,6 @@ def cancel_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -880,10 +864,8 @@ def cancel_custom_job( # there are no flattened fields. if not isinstance(request, job_service.CancelCustomJobRequest): request = job_service.CancelCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -932,7 +914,6 @@ def create_data_labeling_job( This corresponds to the ``data_labeling_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -962,10 +943,8 @@ def create_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.CreateDataLabelingJobRequest): request = job_service.CreateDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if data_labeling_job is not None: @@ -1010,7 +989,6 @@ def get_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1040,10 +1018,8 @@ def get_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.GetDataLabelingJobRequest): request = job_service.GetDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1085,7 +1061,6 @@ def list_data_labeling_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1117,10 +1092,8 @@ def list_data_labeling_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListDataLabelingJobsRequest): request = job_service.ListDataLabelingJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1170,7 +1143,6 @@ def delete_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1212,10 +1184,8 @@ def delete_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteDataLabelingJobRequest): request = job_service.DeleteDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1236,7 +1206,7 @@ def delete_data_labeling_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1267,7 +1237,6 @@ def cancel_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1290,10 +1259,8 @@ def cancel_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.CancelDataLabelingJobRequest): request = job_service.CancelDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1343,7 +1310,6 @@ def create_hyperparameter_tuning_job( This corresponds to the ``hyperparameter_tuning_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1374,10 +1340,8 @@ def create_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.CreateHyperparameterTuningJobRequest): request = job_service.CreateHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if hyperparameter_tuning_job is not None: @@ -1425,7 +1389,6 @@ def get_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1456,10 +1419,8 @@ def get_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.GetHyperparameterTuningJobRequest): request = job_service.GetHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1504,7 +1465,6 @@ def list_hyperparameter_tuning_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1536,10 +1496,8 @@ def list_hyperparameter_tuning_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListHyperparameterTuningJobsRequest): request = job_service.ListHyperparameterTuningJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1591,7 +1549,6 @@ def delete_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1633,10 +1590,8 @@ def delete_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteHyperparameterTuningJobRequest): request = job_service.DeleteHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1659,7 +1614,7 @@ def delete_hyperparameter_tuning_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1703,7 +1658,6 @@ def cancel_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1726,10 +1680,8 @@ def cancel_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.CancelHyperparameterTuningJobRequest): request = job_service.CancelHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1782,7 +1734,6 @@ def create_batch_prediction_job( This corresponds to the ``batch_prediction_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1815,10 +1766,8 @@ def create_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.CreateBatchPredictionJobRequest): request = job_service.CreateBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if batch_prediction_job is not None: @@ -1866,7 +1815,6 @@ def get_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1899,10 +1847,8 @@ def get_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.GetBatchPredictionJobRequest): request = job_service.GetBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1945,7 +1891,6 @@ def list_batch_prediction_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1977,10 +1922,8 @@ def list_batch_prediction_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListBatchPredictionJobsRequest): request = job_service.ListBatchPredictionJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2033,7 +1976,6 @@ def delete_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2075,10 +2017,8 @@ def delete_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteBatchPredictionJobRequest): request = job_service.DeleteBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2101,7 +2041,7 @@ def delete_batch_prediction_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -2143,7 +2083,6 @@ def cancel_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2166,10 +2105,8 @@ def cancel_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.CancelBatchPredictionJobRequest): request = job_service.CancelBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1/services/job_service/pagers.py b/google/cloud/aiplatform_v1/services/job_service/pagers.py index 35d679b6ad..53d7a12e57 100644 --- a/google/cloud/aiplatform_v1/services/job_service/pagers.py +++ b/google/cloud/aiplatform_v1/services/job_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/job_service/transports/__init__.py index 349bfbcdea..c512946de1 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/base.py b/google/cloud/aiplatform_v1/services/job_service/transports/base.py index 5cddf58749..c8b47f54c6 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import batch_prediction_job from google.cloud.aiplatform_v1.types import ( @@ -39,9 +39,8 @@ hyperparameter_tuning_job as gca_hyperparameter_tuning_job, ) from google.cloud.aiplatform_v1.types import job_service -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -52,27 +51,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class JobServiceTransport(abc.ABC): """Abstract transport class for JobService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -81,7 +94,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -95,29 +108,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -221,31 +281,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateCustomJobRequest], - typing.Union[ - gca_custom_job.CustomJob, typing.Awaitable[gca_custom_job.CustomJob] - ], + Union[gca_custom_job.CustomJob, Awaitable[gca_custom_job.CustomJob]], ]: raise NotImplementedError() @property def get_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetCustomJobRequest], - typing.Union[custom_job.CustomJob, typing.Awaitable[custom_job.CustomJob]], + Union[custom_job.CustomJob, Awaitable[custom_job.CustomJob]], ]: raise NotImplementedError() @property def list_custom_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListCustomJobsRequest], - typing.Union[ + Union[ job_service.ListCustomJobsResponse, - typing.Awaitable[job_service.ListCustomJobsResponse], + Awaitable[job_service.ListCustomJobsResponse], ], ]: raise NotImplementedError() @@ -253,29 +311,29 @@ def list_custom_jobs( @property def delete_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteCustomJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelCustomJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateDataLabelingJobRequest], - typing.Union[ + Union[ gca_data_labeling_job.DataLabelingJob, - typing.Awaitable[gca_data_labeling_job.DataLabelingJob], + Awaitable[gca_data_labeling_job.DataLabelingJob], ], ]: raise NotImplementedError() @@ -283,11 +341,11 @@ def create_data_labeling_job( @property def get_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetDataLabelingJobRequest], - typing.Union[ + Union[ data_labeling_job.DataLabelingJob, - typing.Awaitable[data_labeling_job.DataLabelingJob], + Awaitable[data_labeling_job.DataLabelingJob], ], ]: raise NotImplementedError() @@ -295,11 +353,11 @@ def get_data_labeling_job( @property def list_data_labeling_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListDataLabelingJobsRequest], - typing.Union[ + Union[ job_service.ListDataLabelingJobsResponse, - typing.Awaitable[job_service.ListDataLabelingJobsResponse], + Awaitable[job_service.ListDataLabelingJobsResponse], ], ]: raise NotImplementedError() @@ -307,29 +365,29 @@ def list_data_labeling_jobs( @property def delete_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteDataLabelingJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelDataLabelingJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateHyperparameterTuningJobRequest], - typing.Union[ + Union[ gca_hyperparameter_tuning_job.HyperparameterTuningJob, - typing.Awaitable[gca_hyperparameter_tuning_job.HyperparameterTuningJob], + Awaitable[gca_hyperparameter_tuning_job.HyperparameterTuningJob], ], ]: raise NotImplementedError() @@ -337,11 +395,11 @@ def create_hyperparameter_tuning_job( @property def get_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetHyperparameterTuningJobRequest], - typing.Union[ + Union[ hyperparameter_tuning_job.HyperparameterTuningJob, - typing.Awaitable[hyperparameter_tuning_job.HyperparameterTuningJob], + Awaitable[hyperparameter_tuning_job.HyperparameterTuningJob], ], ]: raise NotImplementedError() @@ -349,11 +407,11 @@ def get_hyperparameter_tuning_job( @property def list_hyperparameter_tuning_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListHyperparameterTuningJobsRequest], - typing.Union[ + Union[ job_service.ListHyperparameterTuningJobsResponse, - typing.Awaitable[job_service.ListHyperparameterTuningJobsResponse], + Awaitable[job_service.ListHyperparameterTuningJobsResponse], ], ]: raise NotImplementedError() @@ -361,29 +419,29 @@ def list_hyperparameter_tuning_jobs( @property def delete_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteHyperparameterTuningJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelHyperparameterTuningJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateBatchPredictionJobRequest], - typing.Union[ + Union[ gca_batch_prediction_job.BatchPredictionJob, - typing.Awaitable[gca_batch_prediction_job.BatchPredictionJob], + Awaitable[gca_batch_prediction_job.BatchPredictionJob], ], ]: raise NotImplementedError() @@ -391,11 +449,11 @@ def create_batch_prediction_job( @property def get_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetBatchPredictionJobRequest], - typing.Union[ + Union[ batch_prediction_job.BatchPredictionJob, - typing.Awaitable[batch_prediction_job.BatchPredictionJob], + Awaitable[batch_prediction_job.BatchPredictionJob], ], ]: raise NotImplementedError() @@ -403,11 +461,11 @@ def get_batch_prediction_job( @property def list_batch_prediction_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListBatchPredictionJobsRequest], - typing.Union[ + Union[ job_service.ListBatchPredictionJobsResponse, - typing.Awaitable[job_service.ListBatchPredictionJobsResponse], + Awaitable[job_service.ListBatchPredictionJobsResponse], ], ]: raise NotImplementedError() @@ -415,18 +473,18 @@ def list_batch_prediction_jobs( @property def delete_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteBatchPredictionJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelBatchPredictionJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py index ac94aff183..2a74d1c8d6 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -40,9 +38,8 @@ hyperparameter_tuning_job as gca_hyperparameter_tuning_job, ) from google.cloud.aiplatform_v1.types import job_service -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import JobServiceTransport, DEFAULT_CLIENT_INFO @@ -65,7 +62,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -79,7 +76,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -190,7 +188,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -221,13 +219,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -335,7 +335,7 @@ def list_custom_jobs( @property def delete_custom_job( self, - ) -> Callable[[job_service.DeleteCustomJobRequest], operations.Operation]: + ) -> Callable[[job_service.DeleteCustomJobRequest], operations_pb2.Operation]: r"""Return a callable for the delete custom job method over gRPC. Deletes a CustomJob. @@ -354,14 +354,14 @@ def delete_custom_job( self._stubs["delete_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteCustomJob", request_serializer=job_service.DeleteCustomJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_custom_job"] @property def cancel_custom_job( self, - ) -> Callable[[job_service.CancelCustomJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelCustomJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel custom job method over gRPC. Cancels a CustomJob. Starts asynchronous cancellation on the @@ -392,7 +392,7 @@ def cancel_custom_job( self._stubs["cancel_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelCustomJob", request_serializer=job_service.CancelCustomJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_custom_job"] @@ -485,7 +485,7 @@ def list_data_labeling_jobs( @property def delete_data_labeling_job( self, - ) -> Callable[[job_service.DeleteDataLabelingJobRequest], operations.Operation]: + ) -> Callable[[job_service.DeleteDataLabelingJobRequest], operations_pb2.Operation]: r"""Return a callable for the delete data labeling job method over gRPC. Deletes a DataLabelingJob. @@ -504,14 +504,14 @@ def delete_data_labeling_job( self._stubs["delete_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteDataLabelingJob", request_serializer=job_service.DeleteDataLabelingJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_data_labeling_job"] @property def cancel_data_labeling_job( self, - ) -> Callable[[job_service.CancelDataLabelingJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelDataLabelingJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel data labeling job method over gRPC. Cancels a DataLabelingJob. Success of cancellation is @@ -531,7 +531,7 @@ def cancel_data_labeling_job( self._stubs["cancel_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelDataLabelingJob", request_serializer=job_service.CancelDataLabelingJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_data_labeling_job"] @@ -634,7 +634,7 @@ def list_hyperparameter_tuning_jobs( def delete_hyperparameter_tuning_job( self, ) -> Callable[ - [job_service.DeleteHyperparameterTuningJobRequest], operations.Operation + [job_service.DeleteHyperparameterTuningJobRequest], operations_pb2.Operation ]: r"""Return a callable for the delete hyperparameter tuning job method over gRPC. @@ -657,14 +657,14 @@ def delete_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteHyperparameterTuningJob", request_serializer=job_service.DeleteHyperparameterTuningJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_hyperparameter_tuning_job"] @property def cancel_hyperparameter_tuning_job( self, - ) -> Callable[[job_service.CancelHyperparameterTuningJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelHyperparameterTuningJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel hyperparameter tuning job method over gRPC. @@ -699,7 +699,7 @@ def cancel_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelHyperparameterTuningJob", request_serializer=job_service.CancelHyperparameterTuningJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_hyperparameter_tuning_job"] @@ -794,7 +794,9 @@ def list_batch_prediction_jobs( @property def delete_batch_prediction_job( self, - ) -> Callable[[job_service.DeleteBatchPredictionJobRequest], operations.Operation]: + ) -> Callable[ + [job_service.DeleteBatchPredictionJobRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete batch prediction job method over gRPC. Deletes a BatchPredictionJob. Can only be called on @@ -814,14 +816,14 @@ def delete_batch_prediction_job( self._stubs["delete_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteBatchPredictionJob", request_serializer=job_service.DeleteBatchPredictionJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_batch_prediction_job"] @property def cancel_batch_prediction_job( self, - ) -> Callable[[job_service.CancelBatchPredictionJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelBatchPredictionJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel batch prediction job method over gRPC. Cancels a BatchPredictionJob. @@ -851,7 +853,7 @@ def cancel_batch_prediction_job( self._stubs["cancel_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelBatchPredictionJob", request_serializer=job_service.CancelBatchPredictionJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_batch_prediction_job"] diff --git a/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py index 0b4943e563..95c2e34118 100644 --- a/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/job_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -41,9 +39,8 @@ hyperparameter_tuning_job as gca_hyperparameter_tuning_job, ) from google.cloud.aiplatform_v1.types import job_service -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import JobServiceTransport, DEFAULT_CLIENT_INFO from .grpc import JobServiceGrpcTransport @@ -68,7 +65,7 @@ class JobServiceGrpcAsyncIOTransport(JobServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -95,13 +92,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -109,7 +108,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -123,7 +122,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -182,7 +182,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -345,7 +344,7 @@ def list_custom_jobs( def delete_custom_job( self, ) -> Callable[ - [job_service.DeleteCustomJobRequest], Awaitable[operations.Operation] + [job_service.DeleteCustomJobRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete custom job method over gRPC. @@ -365,14 +364,14 @@ def delete_custom_job( self._stubs["delete_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteCustomJob", request_serializer=job_service.DeleteCustomJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_custom_job"] @property def cancel_custom_job( self, - ) -> Callable[[job_service.CancelCustomJobRequest], Awaitable[empty.Empty]]: + ) -> Callable[[job_service.CancelCustomJobRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the cancel custom job method over gRPC. Cancels a CustomJob. Starts asynchronous cancellation on the @@ -403,7 +402,7 @@ def cancel_custom_job( self._stubs["cancel_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelCustomJob", request_serializer=job_service.CancelCustomJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_custom_job"] @@ -498,7 +497,7 @@ def list_data_labeling_jobs( def delete_data_labeling_job( self, ) -> Callable[ - [job_service.DeleteDataLabelingJobRequest], Awaitable[operations.Operation] + [job_service.DeleteDataLabelingJobRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete data labeling job method over gRPC. @@ -518,14 +517,16 @@ def delete_data_labeling_job( self._stubs["delete_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteDataLabelingJob", request_serializer=job_service.DeleteDataLabelingJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_data_labeling_job"] @property def cancel_data_labeling_job( self, - ) -> Callable[[job_service.CancelDataLabelingJobRequest], Awaitable[empty.Empty]]: + ) -> Callable[ + [job_service.CancelDataLabelingJobRequest], Awaitable[empty_pb2.Empty] + ]: r"""Return a callable for the cancel data labeling job method over gRPC. Cancels a DataLabelingJob. Success of cancellation is @@ -545,7 +546,7 @@ def cancel_data_labeling_job( self._stubs["cancel_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelDataLabelingJob", request_serializer=job_service.CancelDataLabelingJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_data_labeling_job"] @@ -649,7 +650,7 @@ def delete_hyperparameter_tuning_job( self, ) -> Callable[ [job_service.DeleteHyperparameterTuningJobRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete hyperparameter tuning job method over gRPC. @@ -672,7 +673,7 @@ def delete_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteHyperparameterTuningJob", request_serializer=job_service.DeleteHyperparameterTuningJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_hyperparameter_tuning_job"] @@ -680,7 +681,7 @@ def delete_hyperparameter_tuning_job( def cancel_hyperparameter_tuning_job( self, ) -> Callable[ - [job_service.CancelHyperparameterTuningJobRequest], Awaitable[empty.Empty] + [job_service.CancelHyperparameterTuningJobRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the cancel hyperparameter tuning job method over gRPC. @@ -716,7 +717,7 @@ def cancel_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelHyperparameterTuningJob", request_serializer=job_service.CancelHyperparameterTuningJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_hyperparameter_tuning_job"] @@ -812,7 +813,8 @@ def list_batch_prediction_jobs( def delete_batch_prediction_job( self, ) -> Callable[ - [job_service.DeleteBatchPredictionJobRequest], Awaitable[operations.Operation] + [job_service.DeleteBatchPredictionJobRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete batch prediction job method over gRPC. @@ -833,7 +835,7 @@ def delete_batch_prediction_job( self._stubs["delete_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/DeleteBatchPredictionJob", request_serializer=job_service.DeleteBatchPredictionJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_batch_prediction_job"] @@ -841,7 +843,7 @@ def delete_batch_prediction_job( def cancel_batch_prediction_job( self, ) -> Callable[ - [job_service.CancelBatchPredictionJobRequest], Awaitable[empty.Empty] + [job_service.CancelBatchPredictionJobRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the cancel batch prediction job method over gRPC. @@ -872,7 +874,7 @@ def cancel_batch_prediction_job( self._stubs["cancel_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.JobService/CancelBatchPredictionJob", request_serializer=job_service.CancelBatchPredictionJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_batch_prediction_job"] diff --git a/google/cloud/aiplatform_v1/services/migration_service/__init__.py b/google/cloud/aiplatform_v1/services/migration_service/__init__.py index 1d6216d1f7..5af6b09eb3 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/migration_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import MigrationServiceClient from .async_client import MigrationServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/migration_service/async_client.py b/google/cloud/aiplatform_v1/services/migration_service/async_client.py index 6ddb72a2d2..3895ec95f2 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/migration_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore @@ -33,7 +31,6 @@ from google.cloud.aiplatform_v1.services.migration_service import pagers from google.cloud.aiplatform_v1.types import migratable_resource from google.cloud.aiplatform_v1.types import migration_service - from .transports.base import MigrationServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import MigrationServiceGrpcAsyncIOTransport from .client import MigrationServiceClient @@ -66,31 +63,26 @@ class MigrationServiceAsyncClient: parse_model_path = staticmethod(MigrationServiceClient.parse_model_path) version_path = staticmethod(MigrationServiceClient.version_path) parse_version_path = staticmethod(MigrationServiceClient.parse_version_path) - common_billing_account_path = staticmethod( MigrationServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( MigrationServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(MigrationServiceClient.common_folder_path) parse_common_folder_path = staticmethod( MigrationServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( MigrationServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( MigrationServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(MigrationServiceClient.common_project_path) parse_common_project_path = staticmethod( MigrationServiceClient.parse_common_project_path ) - common_location_path = staticmethod(MigrationServiceClient.common_location_path) parse_common_location_path = staticmethod( MigrationServiceClient.parse_common_location_path @@ -144,7 +136,7 @@ def transport(self) -> MigrationServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, MigrationServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -181,7 +173,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = MigrationServiceClient( credentials=credentials, transport=transport, @@ -217,7 +208,6 @@ async def search_migratable_resources( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -247,7 +237,6 @@ async def search_migratable_resources( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -315,7 +304,6 @@ async def batch_migrate_resources( This corresponds to the ``migrate_resource_requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -346,10 +334,8 @@ async def batch_migrate_resources( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent - if migrate_resource_requests: request.migrate_resource_requests.extend(migrate_resource_requests) diff --git a/google/cloud/aiplatform_v1/services/migration_service/client.py b/google/cloud/aiplatform_v1/services/migration_service/client.py index 75fa0ce0a7..8f91e19bfe 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/client.py +++ b/google/cloud/aiplatform_v1/services/migration_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -37,7 +35,6 @@ from google.cloud.aiplatform_v1.services.migration_service import pagers from google.cloud.aiplatform_v1.types import migratable_resource from google.cloud.aiplatform_v1.types import migration_service - from .transports.base import MigrationServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import MigrationServiceGrpcTransport from .transports.grpc_asyncio import MigrationServiceGrpcAsyncIOTransport @@ -195,19 +192,6 @@ def parse_dataset_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} - @staticmethod - def dataset_path(project: str, dataset: str,) -> str: - """Return a fully-qualified dataset string.""" - return "projects/{project}/datasets/{dataset}".format( - project=project, dataset=dataset, - ) - - @staticmethod - def parse_dataset_path(path: str) -> Dict[str, str]: - """Parse a dataset path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/datasets/(?P.+?)$", path) - return m.groupdict() if m else {} - @staticmethod def dataset_path(project: str, location: str, dataset: str,) -> str: """Return a fully-qualified dataset string.""" @@ -224,6 +208,19 @@ def parse_dataset_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + # @staticmethod + # def dataset_path(project: str, dataset: str,) -> str: + # """Return a fully-qualified dataset string.""" + # return "projects/{project}/datasets/{dataset}".format( + # project=project, dataset=dataset, + # ) + + # @staticmethod + # def parse_dataset_path(path: str) -> Dict[str, str]: + # """Parse a dataset path into its component segments.""" + # m = re.match(r"^projects/(?P.+?)/datasets/(?P.+?)$", path) + # return m.groupdict() if m else {} + @staticmethod def model_path(project: str, location: str, model: str,) -> str: """Return a fully-qualified model string.""" @@ -334,7 +331,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, MigrationServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -472,7 +469,6 @@ def search_migratable_resources( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -504,10 +500,8 @@ def search_migratable_resources( # there are no flattened fields. if not isinstance(request, migration_service.SearchMigratableResourcesRequest): request = migration_service.SearchMigratableResourcesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -573,7 +567,6 @@ def batch_migrate_resources( This corresponds to the ``migrate_resource_requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -606,10 +599,8 @@ def batch_migrate_resources( # there are no flattened fields. if not isinstance(request, migration_service.BatchMigrateResourcesRequest): request = migration_service.BatchMigrateResourcesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if migrate_resource_requests is not None: diff --git a/google/cloud/aiplatform_v1/services/migration_service/pagers.py b/google/cloud/aiplatform_v1/services/migration_service/pagers.py index 02a46451df..331763e599 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/pagers.py +++ b/google/cloud/aiplatform_v1/services/migration_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1/services/migration_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/migration_service/transports/__init__.py index 38c72756f6..565048f2a3 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/migration_service/transports/base.py b/google/cloud/aiplatform_v1/services/migration_service/transports/base.py index f10e4627c6..6dc3d69c17 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import migration_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -39,27 +38,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class MigrationServiceTransport(abc.ABC): """Abstract transport class for MigrationService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -68,7 +81,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -82,29 +95,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -128,11 +188,11 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def search_migratable_resources( self, - ) -> typing.Callable[ + ) -> Callable[ [migration_service.SearchMigratableResourcesRequest], - typing.Union[ + Union[ migration_service.SearchMigratableResourcesResponse, - typing.Awaitable[migration_service.SearchMigratableResourcesResponse], + Awaitable[migration_service.SearchMigratableResourcesResponse], ], ]: raise NotImplementedError() @@ -140,9 +200,9 @@ def search_migratable_resources( @property def batch_migrate_resources( self, - ) -> typing.Callable[ + ) -> Callable[ [migration_service.BatchMigrateResourcesRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py index b8cdb273a1..e138cb32c6 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1.types import migration_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import MigrationServiceTransport, DEFAULT_CLIENT_INFO @@ -54,7 +51,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -68,7 +65,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -179,7 +177,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -210,13 +208,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -276,7 +276,7 @@ def search_migratable_resources( def batch_migrate_resources( self, ) -> Callable[ - [migration_service.BatchMigrateResourcesRequest], operations.Operation + [migration_service.BatchMigrateResourcesRequest], operations_pb2.Operation ]: r"""Return a callable for the batch migrate resources method over gRPC. @@ -298,7 +298,7 @@ def batch_migrate_resources( self._stubs["batch_migrate_resources"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.MigrationService/BatchMigrateResources", request_serializer=migration_service.BatchMigrateResourcesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_migrate_resources"] diff --git a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py index 190f45eac1..ba8d3a4841 100644 --- a/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/migration_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1.types import migration_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import MigrationServiceTransport, DEFAULT_CLIENT_INFO from .grpc import MigrationServiceGrpcTransport @@ -57,7 +54,7 @@ class MigrationServiceGrpcAsyncIOTransport(MigrationServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -84,13 +81,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -98,7 +97,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -112,7 +111,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -171,7 +171,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -283,7 +282,7 @@ def batch_migrate_resources( self, ) -> Callable[ [migration_service.BatchMigrateResourcesRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the batch migrate resources method over gRPC. @@ -305,7 +304,7 @@ def batch_migrate_resources( self._stubs["batch_migrate_resources"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.MigrationService/BatchMigrateResources", request_serializer=migration_service.BatchMigrateResourcesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_migrate_resources"] diff --git a/google/cloud/aiplatform_v1/services/model_service/__init__.py b/google/cloud/aiplatform_v1/services/model_service/__init__.py index b39295ebfe..7395b28fcb 100644 --- a/google/cloud/aiplatform_v1/services/model_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/model_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import ModelServiceClient from .async_client import ModelServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/model_service/async_client.py b/google/cloud/aiplatform_v1/services/model_service/async_client.py index e1c69562f0..d6d932f62f 100644 --- a/google/cloud/aiplatform_v1/services/model_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/model_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -39,11 +37,10 @@ from google.cloud.aiplatform_v1.types import model_evaluation_slice from google.cloud.aiplatform_v1.types import model_service from google.cloud.aiplatform_v1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ModelServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport from .client import ModelServiceClient @@ -75,27 +72,22 @@ class ModelServiceAsyncClient: parse_training_pipeline_path = staticmethod( ModelServiceClient.parse_training_pipeline_path ) - common_billing_account_path = staticmethod( ModelServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( ModelServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(ModelServiceClient.common_folder_path) parse_common_folder_path = staticmethod(ModelServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(ModelServiceClient.common_organization_path) parse_common_organization_path = staticmethod( ModelServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(ModelServiceClient.common_project_path) parse_common_project_path = staticmethod( ModelServiceClient.parse_common_project_path ) - common_location_path = staticmethod(ModelServiceClient.common_location_path) parse_common_location_path = staticmethod( ModelServiceClient.parse_common_location_path @@ -149,7 +141,7 @@ def transport(self) -> ModelServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, ModelServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -186,7 +178,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = ModelServiceClient( credentials=credentials, transport=transport, @@ -223,7 +214,6 @@ async def upload_model( This corresponds to the ``model`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -255,7 +245,6 @@ async def upload_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if model is not None: @@ -311,7 +300,6 @@ async def get_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -336,7 +324,6 @@ async def get_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -383,7 +370,6 @@ async def list_models( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -413,7 +399,6 @@ async def list_models( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -448,7 +433,7 @@ async def update_model( request: model_service.UpdateModelRequest = None, *, model: gca_model.Model = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -474,7 +459,6 @@ async def update_model( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -499,7 +483,6 @@ async def update_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if model is not None: request.model = model if update_mask is not None: @@ -552,7 +535,6 @@ async def delete_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -592,7 +574,6 @@ async def delete_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -617,7 +598,7 @@ async def delete_model( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -658,7 +639,6 @@ async def export_model( This corresponds to the ``output_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -690,7 +670,6 @@ async def export_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if output_config is not None: @@ -748,7 +727,6 @@ async def get_model_evaluation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -777,7 +755,6 @@ async def get_model_evaluation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -824,7 +801,6 @@ async def list_model_evaluations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -854,7 +830,6 @@ async def list_model_evaluations( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -908,7 +883,6 @@ async def get_model_evaluation_slice( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -937,7 +911,6 @@ async def get_model_evaluation_slice( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -985,7 +958,6 @@ async def list_model_evaluation_slices( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1015,7 +987,6 @@ async def list_model_evaluation_slices( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1/services/model_service/client.py b/google/cloud/aiplatform_v1/services/model_service/client.py index 9f2de43306..6a1f353dbc 100644 --- a/google/cloud/aiplatform_v1/services/model_service/client.py +++ b/google/cloud/aiplatform_v1/services/model_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -43,11 +41,10 @@ from google.cloud.aiplatform_v1.types import model_evaluation_slice from google.cloud.aiplatform_v1.types import model_service from google.cloud.aiplatform_v1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ModelServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import ModelServiceGrpcTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport @@ -318,7 +315,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, ModelServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -457,7 +454,6 @@ def upload_model( This corresponds to the ``model`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -491,10 +487,8 @@ def upload_model( # there are no flattened fields. if not isinstance(request, model_service.UploadModelRequest): request = model_service.UploadModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if model is not None: @@ -546,7 +540,6 @@ def get_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -573,10 +566,8 @@ def get_model( # there are no flattened fields. if not isinstance(request, model_service.GetModelRequest): request = model_service.GetModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -619,7 +610,6 @@ def list_models( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -651,10 +641,8 @@ def list_models( # there are no flattened fields. if not isinstance(request, model_service.ListModelsRequest): request = model_service.ListModelsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -685,7 +673,7 @@ def update_model( request: model_service.UpdateModelRequest = None, *, model: gca_model.Model = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -711,7 +699,6 @@ def update_model( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -738,10 +725,8 @@ def update_model( # there are no flattened fields. if not isinstance(request, model_service.UpdateModelRequest): request = model_service.UpdateModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if model is not None: request.model = model if update_mask is not None: @@ -790,7 +775,6 @@ def delete_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -832,10 +816,8 @@ def delete_model( # there are no flattened fields. if not isinstance(request, model_service.DeleteModelRequest): request = model_service.DeleteModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -856,7 +838,7 @@ def delete_model( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -897,7 +879,6 @@ def export_model( This corresponds to the ``output_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -931,10 +912,8 @@ def export_model( # there are no flattened fields. if not isinstance(request, model_service.ExportModelRequest): request = model_service.ExportModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if output_config is not None: @@ -988,7 +967,6 @@ def get_model_evaluation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1019,10 +997,8 @@ def get_model_evaluation( # there are no flattened fields. if not isinstance(request, model_service.GetModelEvaluationRequest): request = model_service.GetModelEvaluationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1065,7 +1041,6 @@ def list_model_evaluations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1097,10 +1072,8 @@ def list_model_evaluations( # there are no flattened fields. if not isinstance(request, model_service.ListModelEvaluationsRequest): request = model_service.ListModelEvaluationsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1150,7 +1123,6 @@ def get_model_evaluation_slice( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1181,10 +1153,8 @@ def get_model_evaluation_slice( # there are no flattened fields. if not isinstance(request, model_service.GetModelEvaluationSliceRequest): request = model_service.GetModelEvaluationSliceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1230,7 +1200,6 @@ def list_model_evaluation_slices( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1262,10 +1231,8 @@ def list_model_evaluation_slices( # there are no flattened fields. if not isinstance(request, model_service.ListModelEvaluationSlicesRequest): request = model_service.ListModelEvaluationSlicesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1/services/model_service/pagers.py b/google/cloud/aiplatform_v1/services/model_service/pagers.py index d01f0057c1..b178c162d2 100644 --- a/google/cloud/aiplatform_v1/services/model_service/pagers.py +++ b/google/cloud/aiplatform_v1/services/model_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1/services/model_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/model_service/transports/__init__.py index 5d1cb51abc..656b644033 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/model_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/model_service/transports/base.py b/google/cloud/aiplatform_v1/services/model_service/transports/base.py index 5252ac9c36..70481a015a 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/model_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,25 +13,25 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import model from google.cloud.aiplatform_v1.types import model as gca_model from google.cloud.aiplatform_v1.types import model_evaluation from google.cloud.aiplatform_v1.types import model_evaluation_slice from google.cloud.aiplatform_v1.types import model_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -43,27 +42,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class ModelServiceTransport(abc.ABC): """Abstract transport class for ModelService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -72,7 +85,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -86,29 +99,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -158,29 +218,28 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def upload_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.UploadModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_model( self, - ) -> typing.Callable[ - [model_service.GetModelRequest], - typing.Union[model.Model, typing.Awaitable[model.Model]], + ) -> Callable[ + [model_service.GetModelRequest], Union[model.Model, Awaitable[model.Model]] ]: raise NotImplementedError() @property def list_models( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ListModelsRequest], - typing.Union[ + Union[ model_service.ListModelsResponse, - typing.Awaitable[model_service.ListModelsResponse], + Awaitable[model_service.ListModelsResponse], ], ]: raise NotImplementedError() @@ -188,38 +247,38 @@ def list_models( @property def update_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.UpdateModelRequest], - typing.Union[gca_model.Model, typing.Awaitable[gca_model.Model]], + Union[gca_model.Model, Awaitable[gca_model.Model]], ]: raise NotImplementedError() @property def delete_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.DeleteModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def export_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ExportModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_model_evaluation( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.GetModelEvaluationRequest], - typing.Union[ + Union[ model_evaluation.ModelEvaluation, - typing.Awaitable[model_evaluation.ModelEvaluation], + Awaitable[model_evaluation.ModelEvaluation], ], ]: raise NotImplementedError() @@ -227,11 +286,11 @@ def get_model_evaluation( @property def list_model_evaluations( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ListModelEvaluationsRequest], - typing.Union[ + Union[ model_service.ListModelEvaluationsResponse, - typing.Awaitable[model_service.ListModelEvaluationsResponse], + Awaitable[model_service.ListModelEvaluationsResponse], ], ]: raise NotImplementedError() @@ -239,11 +298,11 @@ def list_model_evaluations( @property def get_model_evaluation_slice( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.GetModelEvaluationSliceRequest], - typing.Union[ + Union[ model_evaluation_slice.ModelEvaluationSlice, - typing.Awaitable[model_evaluation_slice.ModelEvaluationSlice], + Awaitable[model_evaluation_slice.ModelEvaluationSlice], ], ]: raise NotImplementedError() @@ -251,11 +310,11 @@ def get_model_evaluation_slice( @property def list_model_evaluation_slices( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ListModelEvaluationSlicesRequest], - typing.Union[ + Union[ model_service.ListModelEvaluationSlicesResponse, - typing.Awaitable[model_service.ListModelEvaluationSlicesResponse], + Awaitable[model_service.ListModelEvaluationSlicesResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py index 92015d0848..91479bd3ae 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/model_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -32,8 +30,7 @@ from google.cloud.aiplatform_v1.types import model_evaluation from google.cloud.aiplatform_v1.types import model_evaluation_slice from google.cloud.aiplatform_v1.types import model_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ModelServiceTransport, DEFAULT_CLIENT_INFO @@ -56,7 +53,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -70,7 +67,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -181,7 +179,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -212,13 +210,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -245,7 +245,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def upload_model( self, - ) -> Callable[[model_service.UploadModelRequest], operations.Operation]: + ) -> Callable[[model_service.UploadModelRequest], operations_pb2.Operation]: r"""Return a callable for the upload model method over gRPC. Uploads a Model artifact into AI Platform. @@ -264,7 +264,7 @@ def upload_model( self._stubs["upload_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.ModelService/UploadModel", request_serializer=model_service.UploadModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["upload_model"] @@ -347,7 +347,7 @@ def update_model( @property def delete_model( self, - ) -> Callable[[model_service.DeleteModelRequest], operations.Operation]: + ) -> Callable[[model_service.DeleteModelRequest], operations_pb2.Operation]: r"""Return a callable for the delete model method over gRPC. Deletes a Model. @@ -368,14 +368,14 @@ def delete_model( self._stubs["delete_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_model"] @property def export_model( self, - ) -> Callable[[model_service.ExportModelRequest], operations.Operation]: + ) -> Callable[[model_service.ExportModelRequest], operations_pb2.Operation]: r"""Return a callable for the export model method over gRPC. Exports a trained, exportable, Model to a location specified by @@ -397,7 +397,7 @@ def export_model( self._stubs["export_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.ModelService/ExportModel", request_serializer=model_service.ExportModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_model"] diff --git a/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py index 2de86d2623..0ce380ad4a 100644 --- a/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/model_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -33,8 +31,7 @@ from google.cloud.aiplatform_v1.types import model_evaluation from google.cloud.aiplatform_v1.types import model_evaluation_slice from google.cloud.aiplatform_v1.types import model_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ModelServiceTransport, DEFAULT_CLIENT_INFO from .grpc import ModelServiceGrpcTransport @@ -59,7 +56,7 @@ class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -86,13 +83,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -100,7 +99,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -114,7 +113,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -173,7 +173,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -251,7 +250,9 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: @property def upload_model( self, - ) -> Callable[[model_service.UploadModelRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [model_service.UploadModelRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the upload model method over gRPC. Uploads a Model artifact into AI Platform. @@ -270,7 +271,7 @@ def upload_model( self._stubs["upload_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.ModelService/UploadModel", request_serializer=model_service.UploadModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["upload_model"] @@ -357,7 +358,9 @@ def update_model( @property def delete_model( self, - ) -> Callable[[model_service.DeleteModelRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [model_service.DeleteModelRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete model method over gRPC. Deletes a Model. @@ -378,14 +381,16 @@ def delete_model( self._stubs["delete_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_model"] @property def export_model( self, - ) -> Callable[[model_service.ExportModelRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [model_service.ExportModelRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the export model method over gRPC. Exports a trained, exportable, Model to a location specified by @@ -407,7 +412,7 @@ def export_model( self._stubs["export_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.ModelService/ExportModel", request_serializer=model_service.ExportModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_model"] diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/__init__.py b/google/cloud/aiplatform_v1/services/pipeline_service/__init__.py index 7f02b47358..f6234690cb 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import PipelineServiceClient from .async_client import PipelineServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/async_client.py b/google/cloud/aiplatform_v1/services/pipeline_service/async_client.py index 70315eb5de..6d3e8ed6ec 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -38,11 +36,10 @@ from google.cloud.aiplatform_v1.types import pipeline_state from google.cloud.aiplatform_v1.types import training_pipeline from google.cloud.aiplatform_v1.types import training_pipeline as gca_training_pipeline -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore from .transports.base import PipelineServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import PipelineServiceGrpcAsyncIOTransport from .client import PipelineServiceClient @@ -64,31 +61,26 @@ class PipelineServiceAsyncClient: parse_training_pipeline_path = staticmethod( PipelineServiceClient.parse_training_pipeline_path ) - common_billing_account_path = staticmethod( PipelineServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( PipelineServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(PipelineServiceClient.common_folder_path) parse_common_folder_path = staticmethod( PipelineServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( PipelineServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( PipelineServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(PipelineServiceClient.common_project_path) parse_common_project_path = staticmethod( PipelineServiceClient.parse_common_project_path ) - common_location_path = staticmethod(PipelineServiceClient.common_location_path) parse_common_location_path = staticmethod( PipelineServiceClient.parse_common_location_path @@ -142,7 +134,7 @@ def transport(self) -> PipelineServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, PipelineServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -179,7 +171,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = PipelineServiceClient( credentials=credentials, transport=transport, @@ -219,7 +210,6 @@ async def create_training_pipeline( This corresponds to the ``training_pipeline`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -250,7 +240,6 @@ async def create_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if training_pipeline is not None: @@ -300,7 +289,6 @@ async def get_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -331,7 +319,6 @@ async def get_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -378,7 +365,6 @@ async def list_training_pipelines( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -408,7 +394,6 @@ async def list_training_pipelines( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -462,7 +447,6 @@ async def delete_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -502,7 +486,6 @@ async def delete_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -527,7 +510,7 @@ async def delete_training_pipeline( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -570,7 +553,6 @@ async def cancel_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -591,7 +573,6 @@ async def cancel_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/client.py b/google/cloud/aiplatform_v1/services/pipeline_service/client.py index 388997af9d..73c1f37a1a 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/client.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -42,11 +40,10 @@ from google.cloud.aiplatform_v1.types import pipeline_state from google.cloud.aiplatform_v1.types import training_pipeline from google.cloud.aiplatform_v1.types import training_pipeline as gca_training_pipeline -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore from .transports.base import PipelineServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import PipelineServiceGrpcTransport from .transports.grpc_asyncio import PipelineServiceGrpcAsyncIOTransport @@ -279,7 +276,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, PipelineServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -421,7 +418,6 @@ def create_training_pipeline( This corresponds to the ``training_pipeline`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -454,10 +450,8 @@ def create_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.CreateTrainingPipelineRequest): request = pipeline_service.CreateTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if training_pipeline is not None: @@ -503,7 +497,6 @@ def get_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -536,10 +529,8 @@ def get_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.GetTrainingPipelineRequest): request = pipeline_service.GetTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -582,7 +573,6 @@ def list_training_pipelines( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -614,10 +604,8 @@ def list_training_pipelines( # there are no flattened fields. if not isinstance(request, pipeline_service.ListTrainingPipelinesRequest): request = pipeline_service.ListTrainingPipelinesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -667,7 +655,6 @@ def delete_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -709,10 +696,8 @@ def delete_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.DeleteTrainingPipelineRequest): request = pipeline_service.DeleteTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -733,7 +718,7 @@ def delete_training_pipeline( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -776,7 +761,6 @@ def cancel_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -799,10 +783,8 @@ def cancel_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.CancelTrainingPipelineRequest): request = pipeline_service.CancelTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/pagers.py b/google/cloud/aiplatform_v1/services/pipeline_service/pagers.py index 987c37dba2..cb70e4585b 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/pagers.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/__init__.py index 9d4610087a..c7a40586e8 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py index 9d8f56b2ab..2a1fd56abe 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import pipeline_service from google.cloud.aiplatform_v1.types import training_pipeline from google.cloud.aiplatform_v1.types import training_pipeline as gca_training_pipeline -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -42,27 +41,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class PipelineServiceTransport(abc.ABC): """Abstract transport class for PipelineService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -71,7 +84,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -85,29 +98,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -146,11 +206,11 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.CreateTrainingPipelineRequest], - typing.Union[ + Union[ gca_training_pipeline.TrainingPipeline, - typing.Awaitable[gca_training_pipeline.TrainingPipeline], + Awaitable[gca_training_pipeline.TrainingPipeline], ], ]: raise NotImplementedError() @@ -158,11 +218,11 @@ def create_training_pipeline( @property def get_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.GetTrainingPipelineRequest], - typing.Union[ + Union[ training_pipeline.TrainingPipeline, - typing.Awaitable[training_pipeline.TrainingPipeline], + Awaitable[training_pipeline.TrainingPipeline], ], ]: raise NotImplementedError() @@ -170,11 +230,11 @@ def get_training_pipeline( @property def list_training_pipelines( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.ListTrainingPipelinesRequest], - typing.Union[ + Union[ pipeline_service.ListTrainingPipelinesResponse, - typing.Awaitable[pipeline_service.ListTrainingPipelinesResponse], + Awaitable[pipeline_service.ListTrainingPipelinesResponse], ], ]: raise NotImplementedError() @@ -182,18 +242,18 @@ def list_training_pipelines( @property def delete_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.DeleteTrainingPipelineRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.CancelTrainingPipelineRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py index 2e5af04a2c..9c86da69d3 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -30,9 +28,8 @@ from google.cloud.aiplatform_v1.types import pipeline_service from google.cloud.aiplatform_v1.types import training_pipeline from google.cloud.aiplatform_v1.types import training_pipeline as gca_training_pipeline -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import PipelineServiceTransport, DEFAULT_CLIENT_INFO @@ -55,7 +52,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -69,7 +66,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -180,7 +178,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -211,13 +209,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -333,7 +333,7 @@ def list_training_pipelines( def delete_training_pipeline( self, ) -> Callable[ - [pipeline_service.DeleteTrainingPipelineRequest], operations.Operation + [pipeline_service.DeleteTrainingPipelineRequest], operations_pb2.Operation ]: r"""Return a callable for the delete training pipeline method over gRPC. @@ -353,14 +353,14 @@ def delete_training_pipeline( self._stubs["delete_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.PipelineService/DeleteTrainingPipeline", request_serializer=pipeline_service.DeleteTrainingPipelineRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_training_pipeline"] @property def cancel_training_pipeline( self, - ) -> Callable[[pipeline_service.CancelTrainingPipelineRequest], empty.Empty]: + ) -> Callable[[pipeline_service.CancelTrainingPipelineRequest], empty_pb2.Empty]: r"""Return a callable for the cancel training pipeline method over gRPC. Cancels a TrainingPipeline. Starts asynchronous cancellation on @@ -391,7 +391,7 @@ def cancel_training_pipeline( self._stubs["cancel_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.PipelineService/CancelTrainingPipeline", request_serializer=pipeline_service.CancelTrainingPipelineRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_training_pipeline"] diff --git a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py index 747611c44b..98ee8ec8c2 100644 --- a/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/pipeline_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -31,9 +29,8 @@ from google.cloud.aiplatform_v1.types import pipeline_service from google.cloud.aiplatform_v1.types import training_pipeline from google.cloud.aiplatform_v1.types import training_pipeline as gca_training_pipeline -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import PipelineServiceTransport, DEFAULT_CLIENT_INFO from .grpc import PipelineServiceGrpcTransport @@ -58,7 +55,7 @@ class PipelineServiceGrpcAsyncIOTransport(PipelineServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -85,13 +82,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -99,7 +98,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -113,7 +112,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -172,7 +172,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -340,7 +339,7 @@ def delete_training_pipeline( self, ) -> Callable[ [pipeline_service.DeleteTrainingPipelineRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete training pipeline method over gRPC. @@ -360,7 +359,7 @@ def delete_training_pipeline( self._stubs["delete_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.PipelineService/DeleteTrainingPipeline", request_serializer=pipeline_service.DeleteTrainingPipelineRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_training_pipeline"] @@ -368,7 +367,7 @@ def delete_training_pipeline( def cancel_training_pipeline( self, ) -> Callable[ - [pipeline_service.CancelTrainingPipelineRequest], Awaitable[empty.Empty] + [pipeline_service.CancelTrainingPipelineRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the cancel training pipeline method over gRPC. @@ -400,7 +399,7 @@ def cancel_training_pipeline( self._stubs["cancel_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.PipelineService/CancelTrainingPipeline", request_serializer=pipeline_service.CancelTrainingPipelineRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_training_pipeline"] diff --git a/google/cloud/aiplatform_v1/services/prediction_service/__init__.py b/google/cloud/aiplatform_v1/services/prediction_service/__init__.py index 0c847693e0..12491bb171 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import PredictionServiceClient from .async_client import PredictionServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/prediction_service/async_client.py b/google/cloud/aiplatform_v1/services/prediction_service/async_client.py index 5d3654a498..bec5e54ea1 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,15 +20,14 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.aiplatform_v1.types import prediction_service -from google.protobuf import struct_pb2 as struct # type: ignore - +from google.protobuf import struct_pb2 # type: ignore from .transports.base import PredictionServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport from .client import PredictionServiceClient @@ -46,31 +43,26 @@ class PredictionServiceAsyncClient: endpoint_path = staticmethod(PredictionServiceClient.endpoint_path) parse_endpoint_path = staticmethod(PredictionServiceClient.parse_endpoint_path) - common_billing_account_path = staticmethod( PredictionServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( PredictionServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(PredictionServiceClient.common_folder_path) parse_common_folder_path = staticmethod( PredictionServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( PredictionServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( PredictionServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(PredictionServiceClient.common_project_path) parse_common_project_path = staticmethod( PredictionServiceClient.parse_common_project_path ) - common_location_path = staticmethod(PredictionServiceClient.common_location_path) parse_common_location_path = staticmethod( PredictionServiceClient.parse_common_location_path @@ -124,7 +116,7 @@ def transport(self) -> PredictionServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, PredictionServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -161,7 +153,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = PredictionServiceClient( credentials=credentials, transport=transport, @@ -174,8 +165,8 @@ async def predict( request: prediction_service.PredictRequest = None, *, endpoint: str = None, - instances: Sequence[struct.Value] = None, - parameters: struct.Value = None, + instances: Sequence[struct_pb2.Value] = None, + parameters: struct_pb2.Value = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -221,7 +212,6 @@ async def predict( This corresponds to the ``parameters`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -248,12 +238,10 @@ async def predict( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if parameters is not None: request.parameters = parameters - if instances: request.instances.extend(instances) diff --git a/google/cloud/aiplatform_v1/services/prediction_service/client.py b/google/cloud/aiplatform_v1/services/prediction_service/client.py index 340c9dc16f..2bbfba4c5c 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/client.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,18 +21,17 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.aiplatform_v1.types import prediction_service -from google.protobuf import struct_pb2 as struct # type: ignore - +from google.protobuf import struct_pb2 # type: ignore from .transports.base import PredictionServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import PredictionServiceGrpcTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport @@ -235,7 +232,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, PredictionServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -350,8 +347,8 @@ def predict( request: prediction_service.PredictRequest = None, *, endpoint: str = None, - instances: Sequence[struct.Value] = None, - parameters: struct.Value = None, + instances: Sequence[struct_pb2.Value] = None, + parameters: struct_pb2.Value = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -397,7 +394,6 @@ def predict( This corresponds to the ``parameters`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -426,10 +422,8 @@ def predict( # there are no flattened fields. if not isinstance(request, prediction_service.PredictRequest): request = prediction_service.PredictRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if instances is not None: diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/__init__.py index 9ec1369a05..86d2e8a7f3 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py index bee77f7896..804afddd08 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,20 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import prediction_service - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=pkg_resources.get_distribution( @@ -37,27 +36,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class PredictionServiceTransport(abc.ABC): """Abstract transport class for PredictionService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -66,7 +79,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -80,29 +93,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -114,11 +174,11 @@ def _prep_wrapped_messages(self, client_info): @property def predict( self, - ) -> typing.Callable[ + ) -> Callable[ [prediction_service.PredictRequest], - typing.Union[ + Union[ prediction_service.PredictResponse, - typing.Awaitable[prediction_service.PredictResponse], + Awaitable[prediction_service.PredictResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py index f78e11bd2d..5c27627e00 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,20 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1.types import prediction_service - from .base import PredictionServiceTransport, DEFAULT_CLIENT_INFO @@ -50,7 +47,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -64,7 +61,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -174,7 +172,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -205,13 +203,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) diff --git a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py index c9d5e2ba94..e3c927de5b 100644 --- a/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/prediction_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1.types import prediction_service - from .base import PredictionServiceTransport, DEFAULT_CLIENT_INFO from .grpc import PredictionServiceGrpcTransport @@ -53,7 +50,7 @@ class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -80,13 +77,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -94,7 +93,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -108,7 +107,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -166,7 +166,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/__init__.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/__init__.py index 49e9cdf0a0..dea5d1cc17 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/__init__.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import SpecialistPoolServiceClient from .async_client import SpecialistPoolServiceAsyncClient diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/async_client.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/async_client.py index 3cbd1325f2..704ee2ab21 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/async_client.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -35,9 +33,8 @@ from google.cloud.aiplatform_v1.types import specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool as gca_specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool_service -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore from .transports.base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import SpecialistPoolServiceGrpcAsyncIOTransport from .client import SpecialistPoolServiceClient @@ -63,31 +60,26 @@ class SpecialistPoolServiceAsyncClient: parse_specialist_pool_path = staticmethod( SpecialistPoolServiceClient.parse_specialist_pool_path ) - common_billing_account_path = staticmethod( SpecialistPoolServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( SpecialistPoolServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(SpecialistPoolServiceClient.common_folder_path) parse_common_folder_path = staticmethod( SpecialistPoolServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( SpecialistPoolServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( SpecialistPoolServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(SpecialistPoolServiceClient.common_project_path) parse_common_project_path = staticmethod( SpecialistPoolServiceClient.parse_common_project_path ) - common_location_path = staticmethod( SpecialistPoolServiceClient.common_location_path ) @@ -144,7 +136,7 @@ def transport(self) -> SpecialistPoolServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, SpecialistPoolServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -181,7 +173,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = SpecialistPoolServiceClient( credentials=credentials, transport=transport, @@ -220,7 +211,6 @@ async def create_specialist_pool( This corresponds to the ``specialist_pool`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -255,7 +245,6 @@ async def create_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if specialist_pool is not None: @@ -313,7 +302,6 @@ async def get_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -349,7 +337,6 @@ async def get_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -396,7 +383,6 @@ async def list_specialist_pools( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -426,7 +412,6 @@ async def list_specialist_pools( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -480,7 +465,6 @@ async def delete_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -520,7 +504,6 @@ async def delete_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -545,7 +528,7 @@ async def delete_specialist_pool( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -557,7 +540,7 @@ async def update_specialist_pool( request: specialist_pool_service.UpdateSpecialistPoolRequest = None, *, specialist_pool: gca_specialist_pool.SpecialistPool = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -582,7 +565,6 @@ async def update_specialist_pool( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -617,7 +599,6 @@ async def update_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if specialist_pool is not None: request.specialist_pool = specialist_pool if update_mask is not None: diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py index 12d11c3b42..310211d4dd 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -39,9 +37,8 @@ from google.cloud.aiplatform_v1.types import specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool as gca_specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool_service -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore from .transports.base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import SpecialistPoolServiceGrpcTransport from .transports.grpc_asyncio import SpecialistPoolServiceGrpcAsyncIOTransport @@ -248,7 +245,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, SpecialistPoolServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -389,7 +386,6 @@ def create_specialist_pool( This corresponds to the ``specialist_pool`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -426,10 +422,8 @@ def create_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.CreateSpecialistPoolRequest): request = specialist_pool_service.CreateSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if specialist_pool is not None: @@ -483,7 +477,6 @@ def get_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -521,10 +514,8 @@ def get_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.GetSpecialistPoolRequest): request = specialist_pool_service.GetSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -567,7 +558,6 @@ def list_specialist_pools( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -599,10 +589,8 @@ def list_specialist_pools( # there are no flattened fields. if not isinstance(request, specialist_pool_service.ListSpecialistPoolsRequest): request = specialist_pool_service.ListSpecialistPoolsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -652,7 +640,6 @@ def delete_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -694,10 +681,8 @@ def delete_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.DeleteSpecialistPoolRequest): request = specialist_pool_service.DeleteSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -718,7 +703,7 @@ def delete_specialist_pool( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -730,7 +715,7 @@ def update_specialist_pool( request: specialist_pool_service.UpdateSpecialistPoolRequest = None, *, specialist_pool: gca_specialist_pool.SpecialistPool = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -755,7 +740,6 @@ def update_specialist_pool( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -792,10 +776,8 @@ def update_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.UpdateSpecialistPoolRequest): request = specialist_pool_service.UpdateSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if specialist_pool is not None: request.specialist_pool = specialist_pool if update_mask is not None: diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/pagers.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/pagers.py index e64a827049..afc17c2fde 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/pagers.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/__init__.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/__init__.py index 1bb2fbf22a..cfdda56eda 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py index bf7e0209d7..b4edeb5a73 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1.types import specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -40,27 +39,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class SpecialistPoolServiceTransport(abc.ABC): """Abstract transport class for SpecialistPoolService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -69,7 +82,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -83,29 +96,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -142,20 +202,19 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.CreateSpecialistPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.GetSpecialistPoolRequest], - typing.Union[ - specialist_pool.SpecialistPool, - typing.Awaitable[specialist_pool.SpecialistPool], + Union[ + specialist_pool.SpecialistPool, Awaitable[specialist_pool.SpecialistPool] ], ]: raise NotImplementedError() @@ -163,11 +222,11 @@ def get_specialist_pool( @property def list_specialist_pools( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.ListSpecialistPoolsRequest], - typing.Union[ + Union[ specialist_pool_service.ListSpecialistPoolsResponse, - typing.Awaitable[specialist_pool_service.ListSpecialistPoolsResponse], + Awaitable[specialist_pool_service.ListSpecialistPoolsResponse], ], ]: raise NotImplementedError() @@ -175,18 +234,18 @@ def list_specialist_pools( @property def delete_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.DeleteSpecialistPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.UpdateSpecialistPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py index 97bb19e261..1abf96a347 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1.types import specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO @@ -58,7 +55,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -72,7 +69,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -183,7 +181,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -214,13 +212,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -248,7 +248,7 @@ def operations_client(self) -> operations_v1.OperationsClient: def create_specialist_pool( self, ) -> Callable[ - [specialist_pool_service.CreateSpecialistPoolRequest], operations.Operation + [specialist_pool_service.CreateSpecialistPoolRequest], operations_pb2.Operation ]: r"""Return a callable for the create specialist pool method over gRPC. @@ -268,7 +268,7 @@ def create_specialist_pool( self._stubs["create_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.SpecialistPoolService/CreateSpecialistPool", request_serializer=specialist_pool_service.CreateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_specialist_pool"] @@ -334,7 +334,7 @@ def list_specialist_pools( def delete_specialist_pool( self, ) -> Callable[ - [specialist_pool_service.DeleteSpecialistPoolRequest], operations.Operation + [specialist_pool_service.DeleteSpecialistPoolRequest], operations_pb2.Operation ]: r"""Return a callable for the delete specialist pool method over gRPC. @@ -355,7 +355,7 @@ def delete_specialist_pool( self._stubs["delete_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.SpecialistPoolService/DeleteSpecialistPool", request_serializer=specialist_pool_service.DeleteSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_specialist_pool"] @@ -363,7 +363,7 @@ def delete_specialist_pool( def update_specialist_pool( self, ) -> Callable[ - [specialist_pool_service.UpdateSpecialistPoolRequest], operations.Operation + [specialist_pool_service.UpdateSpecialistPoolRequest], operations_pb2.Operation ]: r"""Return a callable for the update specialist pool method over gRPC. @@ -383,7 +383,7 @@ def update_specialist_pool( self._stubs["update_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.SpecialistPoolService/UpdateSpecialistPool", request_serializer=specialist_pool_service.UpdateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_specialist_pool"] diff --git a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py index fd7766a767..4ff2f8484c 100644 --- a/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1/services/specialist_pool_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1.types import specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO from .grpc import SpecialistPoolServiceGrpcTransport @@ -61,7 +58,7 @@ class SpecialistPoolServiceGrpcAsyncIOTransport(SpecialistPoolServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -88,13 +85,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -102,7 +101,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -116,7 +115,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -175,7 +175,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -255,7 +254,7 @@ def create_specialist_pool( self, ) -> Callable[ [specialist_pool_service.CreateSpecialistPoolRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create specialist pool method over gRPC. @@ -275,7 +274,7 @@ def create_specialist_pool( self._stubs["create_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.SpecialistPoolService/CreateSpecialistPool", request_serializer=specialist_pool_service.CreateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_specialist_pool"] @@ -342,7 +341,7 @@ def delete_specialist_pool( self, ) -> Callable[ [specialist_pool_service.DeleteSpecialistPoolRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete specialist pool method over gRPC. @@ -363,7 +362,7 @@ def delete_specialist_pool( self._stubs["delete_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.SpecialistPoolService/DeleteSpecialistPool", request_serializer=specialist_pool_service.DeleteSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_specialist_pool"] @@ -372,7 +371,7 @@ def update_specialist_pool( self, ) -> Callable[ [specialist_pool_service.UpdateSpecialistPoolRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update specialist pool method over gRPC. @@ -392,7 +391,7 @@ def update_specialist_pool( self._stubs["update_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1.SpecialistPoolService/UpdateSpecialistPool", request_serializer=specialist_pool_service.UpdateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_specialist_pool"] diff --git a/google/cloud/aiplatform_v1/types/__init__.py b/google/cloud/aiplatform_v1/types/__init__.py index 6d7c9ca42f..42bab0a05e 100644 --- a/google/cloud/aiplatform_v1/types/__init__.py +++ b/google/cloud/aiplatform_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .annotation import Annotation from .annotation_spec import AnnotationSpec from .batch_prediction_job import BatchPredictionJob diff --git a/google/cloud/aiplatform_v1/types/accelerator_type.py b/google/cloud/aiplatform_v1/types/accelerator_type.py index 640436c38c..6728739a23 100644 --- a/google/cloud/aiplatform_v1/types/accelerator_type.py +++ b/google/cloud/aiplatform_v1/types/accelerator_type.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore diff --git a/google/cloud/aiplatform_v1/types/annotation.py b/google/cloud/aiplatform_v1/types/annotation.py index 46b3eea8b5..0671829241 100644 --- a/google/cloud/aiplatform_v1/types/annotation.py +++ b/google/cloud/aiplatform_v1/types/annotation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import user_action_reference -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -87,23 +84,16 @@ class Annotation(proto.Message): title. """ - name = proto.Field(proto.STRING, number=1) - - payload_schema_uri = proto.Field(proto.STRING, number=2) - - payload = proto.Field(proto.MESSAGE, number=3, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=8) - + name = proto.Field(proto.STRING, number=1,) + payload_schema_uri = proto.Field(proto.STRING, number=2,) + payload = proto.Field(proto.MESSAGE, number=3, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=8,) annotation_source = proto.Field( proto.MESSAGE, number=5, message=user_action_reference.UserActionReference, ) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/annotation_spec.py b/google/cloud/aiplatform_v1/types/annotation_spec.py index 41f228ad72..626db3df7e 100644 --- a/google/cloud/aiplatform_v1/types/annotation_spec.py +++ b/google/cloud/aiplatform_v1/types/annotation_spec.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -51,15 +48,11 @@ class AnnotationSpec(proto.Message): "overwrite" update happens. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=5) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/batch_prediction_job.py b/google/cloud/aiplatform_v1/types/batch_prediction_job.py index 52be77e3b8..757ee3164e 100644 --- a/google/cloud/aiplatform_v1/types/batch_prediction_job.py +++ b/google/cloud/aiplatform_v1/types/batch_prediction_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import completion_stats as gca_completion_stats from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import io @@ -26,9 +23,9 @@ from google.cloud.aiplatform_v1.types import ( manual_batch_tuning_parameters as gca_manual_batch_tuning_parameters, ) -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -177,12 +174,10 @@ class InputConfig(proto.Message): gcs_source = proto.Field( proto.MESSAGE, number=2, oneof="source", message=io.GcsSource, ) - bigquery_source = proto.Field( proto.MESSAGE, number=3, oneof="source", message=io.BigQuerySource, ) - - instances_format = proto.Field(proto.STRING, number=1) + instances_format = proto.Field(proto.STRING, number=1,) class OutputConfig(proto.Message): r"""Configures the output of @@ -253,15 +248,13 @@ class OutputConfig(proto.Message): gcs_destination = proto.Field( proto.MESSAGE, number=2, oneof="destination", message=io.GcsDestination, ) - bigquery_destination = proto.Field( proto.MESSAGE, number=3, oneof="destination", message=io.BigQueryDestination, ) - - predictions_format = proto.Field(proto.STRING, number=1) + predictions_format = proto.Field(proto.STRING, number=1,) class OutputInfo(proto.Message): r"""Further describes this job's output. Supplements @@ -279,63 +272,47 @@ class OutputInfo(proto.Message): """ gcs_output_directory = proto.Field( - proto.STRING, number=1, oneof="output_location" + proto.STRING, number=1, oneof="output_location", ) - bigquery_output_dataset = proto.Field( - proto.STRING, number=2, oneof="output_location" + proto.STRING, number=2, oneof="output_location", ) - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - model = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + model = proto.Field(proto.STRING, number=3,) input_config = proto.Field(proto.MESSAGE, number=4, message=InputConfig,) - - model_parameters = proto.Field(proto.MESSAGE, number=5, message=struct.Value,) - + model_parameters = proto.Field(proto.MESSAGE, number=5, message=struct_pb2.Value,) output_config = proto.Field(proto.MESSAGE, number=6, message=OutputConfig,) - dedicated_resources = proto.Field( proto.MESSAGE, number=7, message=machine_resources.BatchDedicatedResources, ) - manual_batch_tuning_parameters = proto.Field( proto.MESSAGE, number=8, message=gca_manual_batch_tuning_parameters.ManualBatchTuningParameters, ) - output_info = proto.Field(proto.MESSAGE, number=9, message=OutputInfo,) - state = proto.Field(proto.ENUM, number=10, enum=job_state.JobState,) - - error = proto.Field(proto.MESSAGE, number=11, message=status.Status,) - + error = proto.Field(proto.MESSAGE, number=11, message=status_pb2.Status,) partial_failures = proto.RepeatedField( - proto.MESSAGE, number=12, message=status.Status, + proto.MESSAGE, number=12, message=status_pb2.Status, ) - resources_consumed = proto.Field( proto.MESSAGE, number=13, message=machine_resources.ResourcesConsumed, ) - completion_stats = proto.Field( proto.MESSAGE, number=14, message=gca_completion_stats.CompletionStats, ) - - create_time = proto.Field(proto.MESSAGE, number=15, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=16, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=17, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=18, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=19) - + create_time = proto.Field( + proto.MESSAGE, number=15, message=timestamp_pb2.Timestamp, + ) + start_time = proto.Field(proto.MESSAGE, number=16, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=17, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=18, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=19,) encryption_spec = proto.Field( proto.MESSAGE, number=24, message=gca_encryption_spec.EncryptionSpec, ) diff --git a/google/cloud/aiplatform_v1/types/completion_stats.py b/google/cloud/aiplatform_v1/types/completion_stats.py index 05648d82c4..43a2bff9b7 100644 --- a/google/cloud/aiplatform_v1/types/completion_stats.py +++ b/google/cloud/aiplatform_v1/types/completion_stats.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -45,11 +43,9 @@ class CompletionStats(proto.Message): number could be collected). """ - successful_count = proto.Field(proto.INT64, number=1) - - failed_count = proto.Field(proto.INT64, number=2) - - incomplete_count = proto.Field(proto.INT64, number=3) + successful_count = proto.Field(proto.INT64, number=1,) + failed_count = proto.Field(proto.INT64, number=2,) + incomplete_count = proto.Field(proto.INT64, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/custom_job.py b/google/cloud/aiplatform_v1/types/custom_job.py index ec0dbf3892..55fe308c87 100644 --- a/google/cloud/aiplatform_v1/types/custom_job.py +++ b/google/cloud/aiplatform_v1/types/custom_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,18 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import env_var from google.cloud.aiplatform_v1.types import io from google.cloud.aiplatform_v1.types import job_state from google.cloud.aiplatform_v1.types import machine_resources -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -92,26 +89,16 @@ class CustomJob(proto.Message): the provided encryption key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) job_spec = proto.Field(proto.MESSAGE, number=4, message="CustomJobSpec",) - state = proto.Field(proto.ENUM, number=5, enum=job_state.JobState,) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - - error = proto.Field(proto.MESSAGE, number=10, message=status.Status,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=11) - + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) + error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) + labels = proto.MapField(proto.STRING, proto.STRING, number=11,) encryption_spec = proto.Field( proto.MESSAGE, number=12, message=gca_encryption_spec.EncryptionSpec, ) @@ -119,7 +106,6 @@ class CustomJob(proto.Message): class CustomJobSpec(proto.Message): r"""Represents the spec of a CustomJob. - Attributes: worker_pool_specs (Sequence[google.cloud.aiplatform_v1.types.WorkerPoolSpec]): Required. The spec of the worker pools @@ -179,13 +165,9 @@ class CustomJobSpec(proto.Message): worker_pool_specs = proto.RepeatedField( proto.MESSAGE, number=1, message="WorkerPoolSpec", ) - scheduling = proto.Field(proto.MESSAGE, number=3, message="Scheduling",) - - service_account = proto.Field(proto.STRING, number=4) - - network = proto.Field(proto.STRING, number=5) - + service_account = proto.Field(proto.STRING, number=4,) + network = proto.Field(proto.STRING, number=5,) base_output_directory = proto.Field( proto.MESSAGE, number=6, message=io.GcsDestination, ) @@ -193,7 +175,6 @@ class CustomJobSpec(proto.Message): class WorkerPoolSpec(proto.Message): r"""Represents the spec of a worker pool in a job. - Attributes: container_spec (google.cloud.aiplatform_v1.types.ContainerSpec): The custom container task. @@ -212,17 +193,13 @@ class WorkerPoolSpec(proto.Message): container_spec = proto.Field( proto.MESSAGE, number=6, oneof="task", message="ContainerSpec", ) - python_package_spec = proto.Field( proto.MESSAGE, number=7, oneof="task", message="PythonPackageSpec", ) - machine_spec = proto.Field( proto.MESSAGE, number=1, message=machine_resources.MachineSpec, ) - - replica_count = proto.Field(proto.INT64, number=2) - + replica_count = proto.Field(proto.INT64, number=2,) disk_spec = proto.Field( proto.MESSAGE, number=5, message=machine_resources.DiskSpec, ) @@ -230,7 +207,6 @@ class WorkerPoolSpec(proto.Message): class ContainerSpec(proto.Message): r"""The spec of a Container. - Attributes: image_uri (str): Required. The URI of a container image in the @@ -248,18 +224,14 @@ class ContainerSpec(proto.Message): container. """ - image_uri = proto.Field(proto.STRING, number=1) - - command = proto.RepeatedField(proto.STRING, number=2) - - args = proto.RepeatedField(proto.STRING, number=3) - + image_uri = proto.Field(proto.STRING, number=1,) + command = proto.RepeatedField(proto.STRING, number=2,) + args = proto.RepeatedField(proto.STRING, number=3,) env = proto.RepeatedField(proto.MESSAGE, number=4, message=env_var.EnvVar,) class PythonPackageSpec(proto.Message): r"""The spec of a Python packaged code. - Attributes: executor_image_uri (str): Required. The URI of a container image in the @@ -284,14 +256,10 @@ class PythonPackageSpec(proto.Message): python module. """ - executor_image_uri = proto.Field(proto.STRING, number=1) - - package_uris = proto.RepeatedField(proto.STRING, number=2) - - python_module = proto.Field(proto.STRING, number=3) - - args = proto.RepeatedField(proto.STRING, number=4) - + executor_image_uri = proto.Field(proto.STRING, number=1,) + package_uris = proto.RepeatedField(proto.STRING, number=2,) + python_module = proto.Field(proto.STRING, number=3,) + args = proto.RepeatedField(proto.STRING, number=4,) env = proto.RepeatedField(proto.MESSAGE, number=5, message=env_var.EnvVar,) @@ -310,9 +278,8 @@ class Scheduling(proto.Message): to workers leaving and joining a job. """ - timeout = proto.Field(proto.MESSAGE, number=1, message=duration.Duration,) - - restart_job_on_worker_restart = proto.Field(proto.BOOL, number=3) + timeout = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + restart_job_on_worker_restart = proto.Field(proto.BOOL, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/data_item.py b/google/cloud/aiplatform_v1/types/data_item.py index 20ff14a0d8..447850e95e 100644 --- a/google/cloud/aiplatform_v1/types/data_item.py +++ b/google/cloud/aiplatform_v1/types/data_item.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -68,17 +65,12 @@ class DataItem(proto.Message): "overwrite" update happens. """ - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=3) - - payload = proto.Field(proto.MESSAGE, number=4, message=struct.Value,) - - etag = proto.Field(proto.STRING, number=7) + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=3,) + payload = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Value,) + etag = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/data_labeling_job.py b/google/cloud/aiplatform_v1/types/data_labeling_job.py index 414aa231ec..988b283a77 100644 --- a/google/cloud/aiplatform_v1/types/data_labeling_job.py +++ b/google/cloud/aiplatform_v1/types/data_labeling_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import job_state -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore __protobuf__ = proto.module( @@ -140,42 +137,27 @@ class DataLabelingJob(proto.Message): on the sampling strategy. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - datasets = proto.RepeatedField(proto.STRING, number=3) - - annotation_labels = proto.MapField(proto.STRING, proto.STRING, number=12) - - labeler_count = proto.Field(proto.INT32, number=4) - - instruction_uri = proto.Field(proto.STRING, number=5) - - inputs_schema_uri = proto.Field(proto.STRING, number=6) - - inputs = proto.Field(proto.MESSAGE, number=7, message=struct.Value,) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + datasets = proto.RepeatedField(proto.STRING, number=3,) + annotation_labels = proto.MapField(proto.STRING, proto.STRING, number=12,) + labeler_count = proto.Field(proto.INT32, number=4,) + instruction_uri = proto.Field(proto.STRING, number=5,) + inputs_schema_uri = proto.Field(proto.STRING, number=6,) + inputs = proto.Field(proto.MESSAGE, number=7, message=struct_pb2.Value,) state = proto.Field(proto.ENUM, number=8, enum=job_state.JobState,) - - labeling_progress = proto.Field(proto.INT32, number=13) - - current_spend = proto.Field(proto.MESSAGE, number=14, message=money.Money,) - - create_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=10, message=timestamp.Timestamp,) - - error = proto.Field(proto.MESSAGE, number=22, message=status.Status,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=11) - - specialist_pools = proto.RepeatedField(proto.STRING, number=16) - + labeling_progress = proto.Field(proto.INT32, number=13,) + current_spend = proto.Field(proto.MESSAGE, number=14, message=money_pb2.Money,) + create_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, + ) + error = proto.Field(proto.MESSAGE, number=22, message=status_pb2.Status,) + labels = proto.MapField(proto.STRING, proto.STRING, number=11,) + specialist_pools = proto.RepeatedField(proto.STRING, number=16,) encryption_spec = proto.Field( proto.MESSAGE, number=20, message=gca_encryption_spec.EncryptionSpec, ) - active_learning_config = proto.Field( proto.MESSAGE, number=21, message="ActiveLearningConfig", ) @@ -207,15 +189,12 @@ class ActiveLearningConfig(proto.Message): """ max_data_item_count = proto.Field( - proto.INT64, number=1, oneof="human_labeling_budget" + proto.INT64, number=1, oneof="human_labeling_budget", ) - max_data_item_percentage = proto.Field( - proto.INT32, number=2, oneof="human_labeling_budget" + proto.INT32, number=2, oneof="human_labeling_budget", ) - sample_config = proto.Field(proto.MESSAGE, number=3, message="SampleConfig",) - training_config = proto.Field(proto.MESSAGE, number=4, message="TrainingConfig",) @@ -246,13 +225,11 @@ class SampleStrategy(proto.Enum): UNCERTAINTY = 1 initial_batch_sample_percentage = proto.Field( - proto.INT32, number=1, oneof="initial_batch_sample_size" + proto.INT32, number=1, oneof="initial_batch_sample_size", ) - following_batch_sample_percentage = proto.Field( - proto.INT32, number=3, oneof="following_batch_sample_size" + proto.INT32, number=3, oneof="following_batch_sample_size", ) - sample_strategy = proto.Field(proto.ENUM, number=5, enum=SampleStrategy,) @@ -269,7 +246,7 @@ class TrainingConfig(proto.Message): this field means 1 hour. """ - timeout_training_milli_hours = proto.Field(proto.INT64, number=1) + timeout_training_milli_hours = proto.Field(proto.INT64, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/dataset.py b/google/cloud/aiplatform_v1/types/dataset.py index 97d244caf4..d1d8f8f363 100644 --- a/google/cloud/aiplatform_v1/types/dataset.py +++ b/google/cloud/aiplatform_v1/types/dataset.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,14 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import io -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -32,7 +29,6 @@ class Dataset(proto.Message): r"""A collection of DataItems and Annotations on them. - Attributes: name (str): Output only. The resource name of the @@ -88,22 +84,14 @@ class Dataset(proto.Message): this key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - metadata_schema_uri = proto.Field(proto.STRING, number=3) - - metadata = proto.Field(proto.MESSAGE, number=8, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=6) - - labels = proto.MapField(proto.STRING, proto.STRING, number=7) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + metadata_schema_uri = proto.Field(proto.STRING, number=3,) + metadata = proto.Field(proto.MESSAGE, number=8, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=6,) + labels = proto.MapField(proto.STRING, proto.STRING, number=7,) encryption_spec = proto.Field( proto.MESSAGE, number=11, message=gca_encryption_spec.EncryptionSpec, ) @@ -144,10 +132,8 @@ class ImportDataConfig(proto.Message): gcs_source = proto.Field( proto.MESSAGE, number=1, oneof="source", message=io.GcsSource, ) - - data_item_labels = proto.MapField(proto.STRING, proto.STRING, number=2) - - import_schema_uri = proto.Field(proto.STRING, number=4) + data_item_labels = proto.MapField(proto.STRING, proto.STRING, number=2,) + import_schema_uri = proto.Field(proto.STRING, number=4,) class ExportDataConfig(proto.Message): @@ -178,8 +164,7 @@ class ExportDataConfig(proto.Message): gcs_destination = proto.Field( proto.MESSAGE, number=1, oneof="destination", message=io.GcsDestination, ) - - annotations_filter = proto.Field(proto.STRING, number=2) + annotations_filter = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/dataset_service.py b/google/cloud/aiplatform_v1/types/dataset_service.py index c02abc82ca..3305dc7268 100644 --- a/google/cloud/aiplatform_v1/types/dataset_service.py +++ b/google/cloud/aiplatform_v1/types/dataset_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import annotation from google.cloud.aiplatform_v1.types import data_item from google.cloud.aiplatform_v1.types import dataset as gca_dataset from google.cloud.aiplatform_v1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -63,8 +60,7 @@ class CreateDatasetRequest(proto.Message): Required. The Dataset to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) dataset = proto.Field(proto.MESSAGE, number=2, message=gca_dataset.Dataset,) @@ -93,9 +89,8 @@ class GetDatasetRequest(proto.Message): Mask specifying which fields to read. """ - name = proto.Field(proto.STRING, number=1) - - read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + name = proto.Field(proto.STRING, number=1,) + read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) class UpdateDatasetRequest(proto.Message): @@ -118,8 +113,9 @@ class UpdateDatasetRequest(proto.Message): """ dataset = proto.Field(proto.MESSAGE, number=1, message=gca_dataset.Dataset,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class ListDatasetsRequest(proto.Message): @@ -163,17 +159,12 @@ class ListDatasetsRequest(proto.Message): - ``update_time`` """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListDatasetsResponse(proto.Message): @@ -195,8 +186,7 @@ def raw_page(self): datasets = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_dataset.Dataset, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteDatasetRequest(proto.Message): @@ -210,7 +200,7 @@ class DeleteDatasetRequest(proto.Message): ``projects/{project}/locations/{location}/datasets/{dataset}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ImportDataRequest(proto.Message): @@ -227,8 +217,7 @@ class ImportDataRequest(proto.Message): in one batch. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) import_configs = proto.RepeatedField( proto.MESSAGE, number=2, message=gca_dataset.ImportDataConfig, ) @@ -237,7 +226,7 @@ class ImportDataRequest(proto.Message): class ImportDataResponse(proto.Message): r"""Response message for [DatasetService.ImportData][google.cloud.aiplatform.v1.DatasetService.ImportData]. - """ + """ class ImportDataOperationMetadata(proto.Message): @@ -266,8 +255,7 @@ class ExportDataRequest(proto.Message): Required. The desired output location. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) export_config = proto.Field( proto.MESSAGE, number=2, message=gca_dataset.ExportDataConfig, ) @@ -283,7 +271,7 @@ class ExportDataResponse(proto.Message): export operation. """ - exported_files = proto.RepeatedField(proto.STRING, number=1) + exported_files = proto.RepeatedField(proto.STRING, number=1,) class ExportDataOperationMetadata(proto.Message): @@ -302,8 +290,7 @@ class ExportDataOperationMetadata(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - - gcs_output_directory = proto.Field(proto.STRING, number=2) + gcs_output_directory = proto.Field(proto.STRING, number=2,) class ListDataItemsRequest(proto.Message): @@ -329,17 +316,12 @@ class ListDataItemsRequest(proto.Message): field name for descending. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListDataItemsResponse(proto.Message): @@ -361,8 +343,7 @@ def raw_page(self): data_items = proto.RepeatedField( proto.MESSAGE, number=1, message=data_item.DataItem, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetAnnotationSpecRequest(proto.Message): @@ -378,9 +359,8 @@ class GetAnnotationSpecRequest(proto.Message): Mask specifying which fields to read. """ - name = proto.Field(proto.STRING, number=1) - - read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + name = proto.Field(proto.STRING, number=1,) + read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) class ListAnnotationsRequest(proto.Message): @@ -407,17 +387,12 @@ class ListAnnotationsRequest(proto.Message): field name for descending. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListAnnotationsResponse(proto.Message): @@ -439,8 +414,7 @@ def raw_page(self): annotations = proto.RepeatedField( proto.MESSAGE, number=1, message=annotation.Annotation, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/deployed_model_ref.py b/google/cloud/aiplatform_v1/types/deployed_model_ref.py index 2d53610ed5..f95a292a8a 100644 --- a/google/cloud/aiplatform_v1/types/deployed_model_ref.py +++ b/google/cloud/aiplatform_v1/types/deployed_model_ref.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -25,7 +23,6 @@ class DeployedModelRef(proto.Message): r"""Points to a DeployedModel. - Attributes: endpoint (str): Immutable. A resource name of an Endpoint. @@ -34,9 +31,8 @@ class DeployedModelRef(proto.Message): above Endpoint. """ - endpoint = proto.Field(proto.STRING, number=1) - - deployed_model_id = proto.Field(proto.STRING, number=2) + endpoint = proto.Field(proto.STRING, number=1,) + deployed_model_id = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/encryption_spec.py b/google/cloud/aiplatform_v1/types/encryption_spec.py index ae908d4b72..74a553b82d 100644 --- a/google/cloud/aiplatform_v1/types/encryption_spec.py +++ b/google/cloud/aiplatform_v1/types/encryption_spec.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -37,7 +35,7 @@ class EncryptionSpec(proto.Message): resource is created. """ - kms_key_name = proto.Field(proto.STRING, number=1) + kms_key_name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/endpoint.py b/google/cloud/aiplatform_v1/types/endpoint.py index e2ceb4f7e3..ea035eef5d 100644 --- a/google/cloud/aiplatform_v1/types/endpoint.py +++ b/google/cloud/aiplatform_v1/types/endpoint.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import machine_resources -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -86,26 +83,17 @@ class Endpoint(proto.Message): this key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) deployed_models = proto.RepeatedField( proto.MESSAGE, number=4, message="DeployedModel", ) - - traffic_split = proto.MapField(proto.STRING, proto.INT32, number=5) - - etag = proto.Field(proto.STRING, number=6) - - labels = proto.MapField(proto.STRING, proto.STRING, number=7) - - create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - + traffic_split = proto.MapField(proto.STRING, proto.INT32, number=5,) + etag = proto.Field(proto.STRING, number=6,) + labels = proto.MapField(proto.STRING, proto.STRING, number=7,) + create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) encryption_spec = proto.Field( proto.MESSAGE, number=10, message=gca_encryption_spec.EncryptionSpec, ) @@ -174,27 +162,19 @@ class DeployedModel(proto.Message): oneof="prediction_resources", message=machine_resources.DedicatedResources, ) - automatic_resources = proto.Field( proto.MESSAGE, number=8, oneof="prediction_resources", message=machine_resources.AutomaticResources, ) - - id = proto.Field(proto.STRING, number=1) - - model = proto.Field(proto.STRING, number=2) - - display_name = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - service_account = proto.Field(proto.STRING, number=11) - - disable_container_logging = proto.Field(proto.BOOL, number=15) - - enable_access_logging = proto.Field(proto.BOOL, number=13) + id = proto.Field(proto.STRING, number=1,) + model = proto.Field(proto.STRING, number=2,) + display_name = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + service_account = proto.Field(proto.STRING, number=11,) + disable_container_logging = proto.Field(proto.BOOL, number=15,) + enable_access_logging = proto.Field(proto.BOOL, number=13,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/endpoint_service.py b/google/cloud/aiplatform_v1/types/endpoint_service.py index fd3f3b4c03..688336ab71 100644 --- a/google/cloud/aiplatform_v1/types/endpoint_service.py +++ b/google/cloud/aiplatform_v1/types/endpoint_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -56,8 +53,7 @@ class CreateEndpointRequest(proto.Message): Required. The Endpoint to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) endpoint = proto.Field(proto.MESSAGE, number=2, message=gca_endpoint.Endpoint,) @@ -85,7 +81,7 @@ class GetEndpointRequest(proto.Message): ``projects/{project}/locations/{location}/endpoints/{endpoint}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListEndpointsRequest(proto.Message): @@ -143,17 +139,12 @@ class ListEndpointsRequest(proto.Message): Example: ``display_name, create_time desc``. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListEndpointsResponse(proto.Message): @@ -176,8 +167,7 @@ def raw_page(self): endpoints = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_endpoint.Endpoint, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateEndpointRequest(proto.Message): @@ -194,8 +184,9 @@ class UpdateEndpointRequest(proto.Message): """ endpoint = proto.Field(proto.MESSAGE, number=1, message=gca_endpoint.Endpoint,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteEndpointRequest(proto.Message): @@ -209,7 +200,7 @@ class DeleteEndpointRequest(proto.Message): ``projects/{project}/locations/{location}/endpoints/{endpoint}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeployModelRequest(proto.Message): @@ -246,13 +237,11 @@ class DeployModelRequest(proto.Message): is not updated. """ - endpoint = proto.Field(proto.STRING, number=1) - + endpoint = proto.Field(proto.STRING, number=1,) deployed_model = proto.Field( proto.MESSAGE, number=2, message=gca_endpoint.DeployedModel, ) - - traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3) + traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3,) class DeployModelResponse(proto.Message): @@ -307,17 +296,15 @@ class UndeployModelRequest(proto.Message): executes, or if this field unassigns any traffic to it. """ - endpoint = proto.Field(proto.STRING, number=1) - - deployed_model_id = proto.Field(proto.STRING, number=2) - - traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3) + endpoint = proto.Field(proto.STRING, number=1,) + deployed_model_id = proto.Field(proto.STRING, number=2,) + traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3,) class UndeployModelResponse(proto.Message): r"""Response message for [EndpointService.UndeployModel][google.cloud.aiplatform.v1.EndpointService.UndeployModel]. - """ + """ class UndeployModelOperationMetadata(proto.Message): diff --git a/google/cloud/aiplatform_v1/types/env_var.py b/google/cloud/aiplatform_v1/types/env_var.py index f456c15808..8c6160b49f 100644 --- a/google/cloud/aiplatform_v1/types/env_var.py +++ b/google/cloud/aiplatform_v1/types/env_var.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -40,9 +38,8 @@ class EnvVar(proto.Message): variable exists or not. """ - name = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/hyperparameter_tuning_job.py b/google/cloud/aiplatform_v1/types/hyperparameter_tuning_job.py index 63290ff9b4..d5485873a6 100644 --- a/google/cloud/aiplatform_v1/types/hyperparameter_tuning_job.py +++ b/google/cloud/aiplatform_v1/types/hyperparameter_tuning_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import custom_job from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import job_state from google.cloud.aiplatform_v1.types import study -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -102,38 +99,27 @@ class HyperparameterTuningJob(proto.Message): the provided encryption key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) study_spec = proto.Field(proto.MESSAGE, number=4, message=study.StudySpec,) - - max_trial_count = proto.Field(proto.INT32, number=5) - - parallel_trial_count = proto.Field(proto.INT32, number=6) - - max_failed_trial_count = proto.Field(proto.INT32, number=7) - + max_trial_count = proto.Field(proto.INT32, number=5,) + parallel_trial_count = proto.Field(proto.INT32, number=6,) + max_failed_trial_count = proto.Field(proto.INT32, number=7,) trial_job_spec = proto.Field( proto.MESSAGE, number=8, message=custom_job.CustomJobSpec, ) - trials = proto.RepeatedField(proto.MESSAGE, number=9, message=study.Trial,) - state = proto.Field(proto.ENUM, number=10, enum=job_state.JobState,) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=14, message=timestamp.Timestamp,) - - error = proto.Field(proto.MESSAGE, number=15, message=status.Status,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=16) - + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, + ) + error = proto.Field(proto.MESSAGE, number=15, message=status_pb2.Status,) + labels = proto.MapField(proto.STRING, proto.STRING, number=16,) encryption_spec = proto.Field( proto.MESSAGE, number=17, message=gca_encryption_spec.EncryptionSpec, ) diff --git a/google/cloud/aiplatform_v1/types/io.py b/google/cloud/aiplatform_v1/types/io.py index 1a75ea33bc..243ec1a745 100644 --- a/google/cloud/aiplatform_v1/types/io.py +++ b/google/cloud/aiplatform_v1/types/io.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -32,7 +30,6 @@ class GcsSource(proto.Message): r"""The Google Cloud Storage location for the input content. - Attributes: uris (Sequence[str]): Required. Google Cloud Storage URI(-s) to the @@ -41,7 +38,7 @@ class GcsSource(proto.Message): https://cloud.google.com/storage/docs/gsutil/addlhelp/WildcardNames. """ - uris = proto.RepeatedField(proto.STRING, number=1) + uris = proto.RepeatedField(proto.STRING, number=1,) class GcsDestination(proto.Message): @@ -56,12 +53,11 @@ class GcsDestination(proto.Message): directory is created if it doesn't exist. """ - output_uri_prefix = proto.Field(proto.STRING, number=1) + output_uri_prefix = proto.Field(proto.STRING, number=1,) 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 @@ -71,12 +67,11 @@ class BigQuerySource(proto.Message): ``bq://projectId.bqDatasetId.bqTableId``. """ - input_uri = proto.Field(proto.STRING, number=1) + input_uri = proto.Field(proto.STRING, number=1,) class BigQueryDestination(proto.Message): r"""The BigQuery location for the output content. - Attributes: output_uri (str): Required. BigQuery URI to a project or table, up to 2000 @@ -92,12 +87,11 @@ class BigQueryDestination(proto.Message): ``bq://projectId.bqDatasetId.bqTableId``. """ - output_uri = proto.Field(proto.STRING, number=1) + output_uri = proto.Field(proto.STRING, number=1,) class ContainerRegistryDestination(proto.Message): r"""The Container Registry location for the container image. - Attributes: output_uri (str): Required. Container Registry URI of a container image. Only @@ -114,7 +108,7 @@ class ContainerRegistryDestination(proto.Message): default tag. """ - output_uri = proto.Field(proto.STRING, number=1) + output_uri = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/job_service.py b/google/cloud/aiplatform_v1/types/job_service.py index b48fcfbf08..331b91d6e4 100644 --- a/google/cloud/aiplatform_v1/types/job_service.py +++ b/google/cloud/aiplatform_v1/types/job_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import ( batch_prediction_job as gca_batch_prediction_job, ) @@ -26,7 +23,7 @@ from google.cloud.aiplatform_v1.types import ( hyperparameter_tuning_job as gca_hyperparameter_tuning_job, ) -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -73,8 +70,7 @@ class CreateCustomJobRequest(proto.Message): Required. The CustomJob to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) custom_job = proto.Field(proto.MESSAGE, number=2, message=gca_custom_job.CustomJob,) @@ -88,7 +84,7 @@ class GetCustomJobRequest(proto.Message): ``projects/{project}/locations/{location}/customJobs/{custom_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCustomJobsRequest(proto.Message): @@ -130,15 +126,11 @@ class ListCustomJobsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListCustomJobsResponse(proto.Message): @@ -161,8 +153,7 @@ def raw_page(self): custom_jobs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_custom_job.CustomJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteCustomJobRequest(proto.Message): @@ -176,7 +167,7 @@ class DeleteCustomJobRequest(proto.Message): ``projects/{project}/locations/{location}/customJobs/{custom_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelCustomJobRequest(proto.Message): @@ -189,7 +180,7 @@ class CancelCustomJobRequest(proto.Message): ``projects/{project}/locations/{location}/customJobs/{custom_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateDataLabelingJobRequest(proto.Message): @@ -204,8 +195,7 @@ class CreateDataLabelingJobRequest(proto.Message): Required. The DataLabelingJob to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) data_labeling_job = proto.Field( proto.MESSAGE, number=2, message=gca_data_labeling_job.DataLabelingJob, ) @@ -213,7 +203,6 @@ class CreateDataLabelingJobRequest(proto.Message): class GetDataLabelingJobRequest(proto.Message): r"""Request message for [DataLabelingJobService.GetDataLabelingJob][]. - Attributes: name (str): Required. The name of the DataLabelingJob. Format: @@ -221,12 +210,11 @@ class GetDataLabelingJobRequest(proto.Message): ``projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListDataLabelingJobsRequest(proto.Message): r"""Request message for [DataLabelingJobService.ListDataLabelingJobs][]. - Attributes: parent (str): Required. The parent of the DataLabelingJob. Format: @@ -265,17 +253,12 @@ class ListDataLabelingJobsRequest(proto.Message): for descending. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListDataLabelingJobsResponse(proto.Message): @@ -297,8 +280,7 @@ def raw_page(self): data_labeling_jobs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_data_labeling_job.DataLabelingJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteDataLabelingJobRequest(proto.Message): @@ -313,7 +295,7 @@ class DeleteDataLabelingJobRequest(proto.Message): ``projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelDataLabelingJobRequest(proto.Message): @@ -327,7 +309,7 @@ class CancelDataLabelingJobRequest(proto.Message): ``projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateHyperparameterTuningJobRequest(proto.Message): @@ -344,8 +326,7 @@ class CreateHyperparameterTuningJobRequest(proto.Message): create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) hyperparameter_tuning_job = proto.Field( proto.MESSAGE, number=2, @@ -365,7 +346,7 @@ class GetHyperparameterTuningJobRequest(proto.Message): ``projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListHyperparameterTuningJobsRequest(proto.Message): @@ -407,15 +388,11 @@ class ListHyperparameterTuningJobsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListHyperparameterTuningJobsResponse(proto.Message): @@ -442,8 +419,7 @@ def raw_page(self): number=1, message=gca_hyperparameter_tuning_job.HyperparameterTuningJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteHyperparameterTuningJobRequest(proto.Message): @@ -458,7 +434,7 @@ class DeleteHyperparameterTuningJobRequest(proto.Message): ``projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelHyperparameterTuningJobRequest(proto.Message): @@ -473,7 +449,7 @@ class CancelHyperparameterTuningJobRequest(proto.Message): ``projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateBatchPredictionJobRequest(proto.Message): @@ -489,8 +465,7 @@ class CreateBatchPredictionJobRequest(proto.Message): Required. The BatchPredictionJob to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) batch_prediction_job = proto.Field( proto.MESSAGE, number=2, message=gca_batch_prediction_job.BatchPredictionJob, ) @@ -508,7 +483,7 @@ class GetBatchPredictionJobRequest(proto.Message): ``projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListBatchPredictionJobsRequest(proto.Message): @@ -550,15 +525,11 @@ class ListBatchPredictionJobsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListBatchPredictionJobsResponse(proto.Message): @@ -582,8 +553,7 @@ def raw_page(self): batch_prediction_jobs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_batch_prediction_job.BatchPredictionJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteBatchPredictionJobRequest(proto.Message): @@ -598,7 +568,7 @@ class DeleteBatchPredictionJobRequest(proto.Message): ``projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelBatchPredictionJobRequest(proto.Message): @@ -613,7 +583,7 @@ class CancelBatchPredictionJobRequest(proto.Message): ``projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/job_state.py b/google/cloud/aiplatform_v1/types/job_state.py index 40b1694f86..59c0949844 100644 --- a/google/cloud/aiplatform_v1/types/job_state.py +++ b/google/cloud/aiplatform_v1/types/job_state.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore diff --git a/google/cloud/aiplatform_v1/types/machine_resources.py b/google/cloud/aiplatform_v1/types/machine_resources.py index d828052afc..8f76f04416 100644 --- a/google/cloud/aiplatform_v1/types/machine_resources.py +++ b/google/cloud/aiplatform_v1/types/machine_resources.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import accelerator_type as gca_accelerator_type @@ -36,7 +33,6 @@ class MachineSpec(proto.Message): r"""Specification of a single machine. - Attributes: machine_type (str): Immutable. The type of the machine. For the machine types @@ -62,13 +58,11 @@ class MachineSpec(proto.Message): machine. """ - machine_type = proto.Field(proto.STRING, number=1) - + machine_type = proto.Field(proto.STRING, number=1,) accelerator_type = proto.Field( proto.ENUM, number=2, enum=gca_accelerator_type.AcceleratorType, ) - - accelerator_count = proto.Field(proto.INT32, number=3) + accelerator_count = proto.Field(proto.INT32, number=3,) class DedicatedResources(proto.Message): @@ -105,10 +99,8 @@ class DedicatedResources(proto.Message): """ machine_spec = proto.Field(proto.MESSAGE, number=1, message="MachineSpec",) - - min_replica_count = proto.Field(proto.INT32, number=2) - - max_replica_count = proto.Field(proto.INT32, number=3) + min_replica_count = proto.Field(proto.INT32, number=2,) + max_replica_count = proto.Field(proto.INT32, number=3,) class AutomaticResources(proto.Message): @@ -143,9 +135,8 @@ class AutomaticResources(proto.Message): number. """ - min_replica_count = proto.Field(proto.INT32, number=1) - - max_replica_count = proto.Field(proto.INT32, number=2) + min_replica_count = proto.Field(proto.INT32, number=1,) + max_replica_count = proto.Field(proto.INT32, number=2,) class BatchDedicatedResources(proto.Message): @@ -169,15 +160,12 @@ class BatchDedicatedResources(proto.Message): """ machine_spec = proto.Field(proto.MESSAGE, number=1, message="MachineSpec",) - - starting_replica_count = proto.Field(proto.INT32, number=2) - - max_replica_count = proto.Field(proto.INT32, number=3) + starting_replica_count = proto.Field(proto.INT32, number=2,) + max_replica_count = proto.Field(proto.INT32, number=3,) class ResourcesConsumed(proto.Message): r"""Statistics information about resource consumption. - Attributes: replica_hours (float): Output only. The number of replica hours @@ -187,12 +175,11 @@ class ResourcesConsumed(proto.Message): not strictly related to wall time. """ - replica_hours = proto.Field(proto.DOUBLE, number=1) + replica_hours = proto.Field(proto.DOUBLE, number=1,) class DiskSpec(proto.Message): r"""Represents the spec of disk options. - Attributes: boot_disk_type (str): Type of the boot disk (default is "pd-ssd"). @@ -204,9 +191,8 @@ class DiskSpec(proto.Message): 100GB). """ - boot_disk_type = proto.Field(proto.STRING, number=1) - - boot_disk_size_gb = proto.Field(proto.INT32, number=2) + boot_disk_type = proto.Field(proto.STRING, number=1,) + boot_disk_size_gb = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py b/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py index 7500d618a0..b5d2465b36 100644 --- a/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py +++ b/google/cloud/aiplatform_v1/types/manual_batch_tuning_parameters.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -25,7 +23,6 @@ class ManualBatchTuningParameters(proto.Message): r"""Manual batch tuning parameters. - Attributes: batch_size (int): Immutable. The number of the records (e.g. @@ -40,7 +37,7 @@ class ManualBatchTuningParameters(proto.Message): The default value is 4. """ - batch_size = proto.Field(proto.INT32, number=1) + batch_size = proto.Field(proto.INT32, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/migratable_resource.py b/google/cloud/aiplatform_v1/types/migratable_resource.py index 652a835c89..2ea22001c6 100644 --- a/google/cloud/aiplatform_v1/types/migratable_resource.py +++ b/google/cloud/aiplatform_v1/types/migratable_resource.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -55,7 +52,6 @@ class MigratableResource(proto.Message): class MlEngineModelVersion(proto.Message): r"""Represents one model Version in ml.googleapis.com. - Attributes: endpoint (str): The ml.googleapis.com endpoint that this model Version @@ -70,13 +66,11 @@ class MlEngineModelVersion(proto.Message): ``projects/{project}/models/{model}/versions/{version}``. """ - endpoint = proto.Field(proto.STRING, number=1) - - version = proto.Field(proto.STRING, number=2) + endpoint = proto.Field(proto.STRING, number=1,) + version = proto.Field(proto.STRING, number=2,) class AutomlModel(proto.Message): r"""Represents one Model in automl.googleapis.com. - Attributes: model (str): Full resource name of automl Model. Format: @@ -86,13 +80,11 @@ class AutomlModel(proto.Message): automl.googleapis.com. """ - model = proto.Field(proto.STRING, number=1) - - model_display_name = proto.Field(proto.STRING, number=3) + model = proto.Field(proto.STRING, number=1,) + model_display_name = proto.Field(proto.STRING, number=3,) class AutomlDataset(proto.Message): r"""Represents one Dataset in automl.googleapis.com. - Attributes: dataset (str): Full resource name of automl Dataset. Format: @@ -102,13 +94,11 @@ class AutomlDataset(proto.Message): automl.googleapis.com. """ - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=4) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=4,) class DataLabelingDataset(proto.Message): r"""Represents one Dataset in datalabeling.googleapis.com. - Attributes: dataset (str): Full resource name of data labeling Dataset. Format: @@ -137,14 +127,11 @@ class DataLabelingAnnotatedDataset(proto.Message): datalabeling.googleapis.com. """ - annotated_dataset = proto.Field(proto.STRING, number=1) - - annotated_dataset_display_name = proto.Field(proto.STRING, number=3) - - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=4) + annotated_dataset = proto.Field(proto.STRING, number=1,) + annotated_dataset_display_name = proto.Field(proto.STRING, number=3,) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=4,) data_labeling_annotated_datasets = proto.RepeatedField( proto.MESSAGE, number=3, @@ -154,25 +141,20 @@ class DataLabelingAnnotatedDataset(proto.Message): ml_engine_model_version = proto.Field( proto.MESSAGE, number=1, oneof="resource", message=MlEngineModelVersion, ) - automl_model = proto.Field( proto.MESSAGE, number=2, oneof="resource", message=AutomlModel, ) - automl_dataset = proto.Field( proto.MESSAGE, number=3, oneof="resource", message=AutomlDataset, ) - data_labeling_dataset = proto.Field( proto.MESSAGE, number=4, oneof="resource", message=DataLabelingDataset, ) - last_migrate_time = proto.Field( - proto.MESSAGE, number=5, message=timestamp.Timestamp, + proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp, ) - last_update_time = proto.Field( - proto.MESSAGE, number=6, message=timestamp.Timestamp, + proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp, ) diff --git a/google/cloud/aiplatform_v1/types/migration_service.py b/google/cloud/aiplatform_v1/types/migration_service.py index ec2dbd6bc8..6a9d231aaf 100644 --- a/google/cloud/aiplatform_v1/types/migration_service.py +++ b/google/cloud/aiplatform_v1/types/migration_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import ( migratable_resource as gca_migratable_resource, ) from google.cloud.aiplatform_v1.types import operation -from google.rpc import status_pb2 as status # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -74,13 +71,10 @@ class SearchMigratableResourcesRequest(proto.Message): migrated resources. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class SearchMigratableResourcesResponse(proto.Message): @@ -104,8 +98,7 @@ def raw_page(self): migratable_resources = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_migratable_resource.MigratableResource, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class BatchMigrateResourcesRequest(proto.Message): @@ -123,8 +116,7 @@ class BatchMigrateResourcesRequest(proto.Message): can be migrated in one batch. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) migrate_resource_requests = proto.RepeatedField( proto.MESSAGE, number=2, message="MigrateResourceRequest", ) @@ -177,11 +169,9 @@ class MigrateMlEngineModelVersionConfig(proto.Message): unspecified. """ - endpoint = proto.Field(proto.STRING, number=1) - - model_version = proto.Field(proto.STRING, number=2) - - model_display_name = proto.Field(proto.STRING, number=3) + endpoint = proto.Field(proto.STRING, number=1,) + model_version = proto.Field(proto.STRING, number=2,) + model_display_name = proto.Field(proto.STRING, number=3,) class MigrateAutomlModelConfig(proto.Message): r"""Config for migrating Model in automl.googleapis.com to AI @@ -197,9 +187,8 @@ class MigrateAutomlModelConfig(proto.Message): unspecified. """ - model = proto.Field(proto.STRING, number=1) - - model_display_name = proto.Field(proto.STRING, number=2) + model = proto.Field(proto.STRING, number=1,) + model_display_name = proto.Field(proto.STRING, number=2,) class MigrateAutomlDatasetConfig(proto.Message): r"""Config for migrating Dataset in automl.googleapis.com to AI @@ -215,9 +204,8 @@ class MigrateAutomlDatasetConfig(proto.Message): unspecified. """ - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=2) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=2,) class MigrateDataLabelingDatasetConfig(proto.Message): r"""Config for migrating Dataset in datalabeling.googleapis.com @@ -251,12 +239,10 @@ class MigrateDataLabelingAnnotatedDatasetConfig(proto.Message): ``projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}``. """ - annotated_dataset = proto.Field(proto.STRING, number=1) - - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=2) + annotated_dataset = proto.Field(proto.STRING, number=1,) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=2,) migrate_data_labeling_annotated_dataset_configs = proto.RepeatedField( proto.MESSAGE, number=3, @@ -269,15 +255,12 @@ class MigrateDataLabelingAnnotatedDatasetConfig(proto.Message): oneof="request", message=MigrateMlEngineModelVersionConfig, ) - migrate_automl_model_config = proto.Field( proto.MESSAGE, number=2, oneof="request", message=MigrateAutomlModelConfig, ) - migrate_automl_dataset_config = proto.Field( proto.MESSAGE, number=3, oneof="request", message=MigrateAutomlDatasetConfig, ) - migrate_data_labeling_dataset_config = proto.Field( proto.MESSAGE, number=4, @@ -302,7 +285,6 @@ class BatchMigrateResourcesResponse(proto.Message): class MigrateResourceResponse(proto.Message): r"""Describes a successfully migrated resource. - Attributes: dataset (str): Migrated Dataset's resource name. @@ -314,10 +296,8 @@ class MigrateResourceResponse(proto.Message): datalabeling.googleapis.com. """ - dataset = proto.Field(proto.STRING, number=1, oneof="migrated_resource") - - model = proto.Field(proto.STRING, number=2, oneof="migrated_resource") - + dataset = proto.Field(proto.STRING, number=1, oneof="migrated_resource",) + model = proto.Field(proto.STRING, number=2, oneof="migrated_resource",) migratable_resource = proto.Field( proto.MESSAGE, number=3, message=gca_migratable_resource.MigratableResource, ) @@ -353,13 +333,10 @@ class PartialResult(proto.Message): """ error = proto.Field( - proto.MESSAGE, number=2, oneof="result", message=status.Status, + proto.MESSAGE, number=2, oneof="result", message=status_pb2.Status, ) - - model = proto.Field(proto.STRING, number=3, oneof="result") - - dataset = proto.Field(proto.STRING, number=4, oneof="result") - + model = proto.Field(proto.STRING, number=3, oneof="result",) + dataset = proto.Field(proto.STRING, number=4, oneof="result",) request = proto.Field( proto.MESSAGE, number=1, message="MigrateResourceRequest", ) @@ -367,7 +344,6 @@ class PartialResult(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - partial_results = proto.RepeatedField( proto.MESSAGE, number=2, message=PartialResult, ) diff --git a/google/cloud/aiplatform_v1/types/model.py b/google/cloud/aiplatform_v1/types/model.py index 7a2f1cf0dd..6a6f4043b7 100644 --- a/google/cloud/aiplatform_v1/types/model.py +++ b/google/cloud/aiplatform_v1/types/model.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import deployed_model_ref from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import env_var -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -33,7 +30,6 @@ class Model(proto.Message): r"""A trained machine learning Model. - Attributes: name (str): The resource name of the Model. @@ -257,54 +253,39 @@ class ExportableContent(proto.Enum): ARTIFACT = 1 IMAGE = 2 - id = proto.Field(proto.STRING, number=1) - + id = proto.Field(proto.STRING, number=1,) exportable_contents = proto.RepeatedField( proto.ENUM, number=2, enum="Model.ExportFormat.ExportableContent", ) - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) predict_schemata = proto.Field(proto.MESSAGE, number=4, message="PredictSchemata",) - - metadata_schema_uri = proto.Field(proto.STRING, number=5) - - metadata = proto.Field(proto.MESSAGE, number=6, message=struct.Value,) - + metadata_schema_uri = proto.Field(proto.STRING, number=5,) + metadata = proto.Field(proto.MESSAGE, number=6, message=struct_pb2.Value,) supported_export_formats = proto.RepeatedField( proto.MESSAGE, number=20, message=ExportFormat, ) - - training_pipeline = proto.Field(proto.STRING, number=7) - + training_pipeline = proto.Field(proto.STRING, number=7,) container_spec = proto.Field(proto.MESSAGE, number=9, message="ModelContainerSpec",) - - artifact_uri = proto.Field(proto.STRING, number=26) - + artifact_uri = proto.Field(proto.STRING, number=26,) supported_deployment_resources_types = proto.RepeatedField( proto.ENUM, number=10, enum=DeploymentResourcesType, ) - - supported_input_storage_formats = proto.RepeatedField(proto.STRING, number=11) - - supported_output_storage_formats = proto.RepeatedField(proto.STRING, number=12) - - create_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=14, message=timestamp.Timestamp,) - + supported_input_storage_formats = proto.RepeatedField(proto.STRING, number=11,) + supported_output_storage_formats = proto.RepeatedField(proto.STRING, number=12,) + create_time = proto.Field( + proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, + ) deployed_models = proto.RepeatedField( proto.MESSAGE, number=15, message=deployed_model_ref.DeployedModelRef, ) - - etag = proto.Field(proto.STRING, number=16) - - labels = proto.MapField(proto.STRING, proto.STRING, number=17) - + etag = proto.Field(proto.STRING, number=16,) + labels = proto.MapField(proto.STRING, proto.STRING, number=17,) encryption_spec = proto.Field( proto.MESSAGE, number=24, message=gca_encryption_spec.EncryptionSpec, ) @@ -363,11 +344,9 @@ class PredictSchemata(proto.Message): where the user only has a read access. """ - instance_schema_uri = proto.Field(proto.STRING, number=1) - - parameters_schema_uri = proto.Field(proto.STRING, number=2) - - prediction_schema_uri = proto.Field(proto.STRING, number=3) + instance_schema_uri = proto.Field(proto.STRING, number=1,) + parameters_schema_uri = proto.Field(proto.STRING, number=2,) + prediction_schema_uri = proto.Field(proto.STRING, number=3,) class ModelContainerSpec(proto.Message): @@ -599,24 +578,17 @@ class ModelContainerSpec(proto.Message): environment variable.) """ - image_uri = proto.Field(proto.STRING, number=1) - - command = proto.RepeatedField(proto.STRING, number=2) - - args = proto.RepeatedField(proto.STRING, number=3) - + image_uri = proto.Field(proto.STRING, number=1,) + command = proto.RepeatedField(proto.STRING, number=2,) + args = proto.RepeatedField(proto.STRING, number=3,) env = proto.RepeatedField(proto.MESSAGE, number=4, message=env_var.EnvVar,) - ports = proto.RepeatedField(proto.MESSAGE, number=5, message="Port",) - - predict_route = proto.Field(proto.STRING, number=6) - - health_route = proto.Field(proto.STRING, number=7) + predict_route = proto.Field(proto.STRING, number=6,) + health_route = proto.Field(proto.STRING, number=7,) class Port(proto.Message): r"""Represents a network port in a container. - Attributes: container_port (int): The number of the port to expose on the pod's @@ -624,7 +596,7 @@ class Port(proto.Message): 1 and 65535 inclusive. """ - container_port = proto.Field(proto.INT32, number=3) + container_port = proto.Field(proto.INT32, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/model_evaluation.py b/google/cloud/aiplatform_v1/types/model_evaluation.py index 1d3502079f..51c11de4f2 100644 --- a/google/cloud/aiplatform_v1/types/model_evaluation.py +++ b/google/cloud/aiplatform_v1/types/model_evaluation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -59,15 +56,11 @@ class ModelEvaluation(proto.Message): request, in the form of ``slice.dimension = ``. """ - name = proto.Field(proto.STRING, number=1) - - metrics_schema_uri = proto.Field(proto.STRING, number=2) - - metrics = proto.Field(proto.MESSAGE, number=3, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - slice_dimensions = proto.RepeatedField(proto.STRING, number=5) + name = proto.Field(proto.STRING, number=1,) + metrics_schema_uri = proto.Field(proto.STRING, number=2,) + metrics = proto.Field(proto.MESSAGE, number=3, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + slice_dimensions = proto.RepeatedField(proto.STRING, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/model_evaluation_slice.py b/google/cloud/aiplatform_v1/types/model_evaluation_slice.py index 5a9e0268a5..4edf4acac3 100644 --- a/google/cloud/aiplatform_v1/types/model_evaluation_slice.py +++ b/google/cloud/aiplatform_v1/types/model_evaluation_slice.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -57,7 +54,6 @@ class ModelEvaluationSlice(proto.Message): class Slice(proto.Message): r"""Definition of a slice. - Attributes: dimension (str): Output only. The dimension of the slice. Well-known @@ -73,19 +69,14 @@ class Slice(proto.Message): this slice. """ - dimension = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.STRING, number=2) - - name = proto.Field(proto.STRING, number=1) + dimension = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.STRING, number=2,) + name = proto.Field(proto.STRING, number=1,) slice_ = proto.Field(proto.MESSAGE, number=2, message=Slice,) - - metrics_schema_uri = proto.Field(proto.STRING, number=3) - - metrics = proto.Field(proto.MESSAGE, number=4, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) + metrics_schema_uri = proto.Field(proto.STRING, number=3,) + metrics = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/model_service.py b/google/cloud/aiplatform_v1/types/model_service.py index 3cb791a739..aca2817dbe 100644 --- a/google/cloud/aiplatform_v1/types/model_service.py +++ b/google/cloud/aiplatform_v1/types/model_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import io from google.cloud.aiplatform_v1.types import model as gca_model from google.cloud.aiplatform_v1.types import model_evaluation from google.cloud.aiplatform_v1.types import model_evaluation_slice from google.cloud.aiplatform_v1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -63,8 +60,7 @@ class UploadModelRequest(proto.Message): Required. The Model to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) model = proto.Field(proto.MESSAGE, number=2, message=gca_model.Model,) @@ -94,7 +90,7 @@ class UploadModelResponse(proto.Message): ``projects/{project}/locations/{location}/models/{model}`` """ - model = proto.Field(proto.STRING, number=1) + model = proto.Field(proto.STRING, number=1,) class GetModelRequest(proto.Message): @@ -107,7 +103,7 @@ class GetModelRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListModelsRequest(proto.Message): @@ -161,17 +157,12 @@ class ListModelsRequest(proto.Message): Example: ``display_name, create_time desc``. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListModelsResponse(proto.Message): @@ -192,8 +183,7 @@ def raw_page(self): return self models = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_model.Model,) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateModelRequest(proto.Message): @@ -211,8 +201,9 @@ class UpdateModelRequest(proto.Message): """ model = proto.Field(proto.MESSAGE, number=1, message=gca_model.Model,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteModelRequest(proto.Message): @@ -226,7 +217,7 @@ class DeleteModelRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ExportModelRequest(proto.Message): @@ -244,7 +235,6 @@ class ExportModelRequest(proto.Message): class OutputConfig(proto.Message): r"""Output configuration for the Model export. - Attributes: export_format_id (str): The ID of the format in which the Model must be exported. @@ -271,18 +261,15 @@ class OutputConfig(proto.Message): ``IMAGE``. """ - export_format_id = proto.Field(proto.STRING, number=1) - + export_format_id = proto.Field(proto.STRING, number=1,) artifact_destination = proto.Field( proto.MESSAGE, number=3, message=io.GcsDestination, ) - image_destination = proto.Field( proto.MESSAGE, number=4, message=io.ContainerRegistryDestination, ) - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) output_config = proto.Field(proto.MESSAGE, number=2, message=OutputConfig,) @@ -316,14 +303,12 @@ class OutputInfo(proto.Message): image created. """ - artifact_output_uri = proto.Field(proto.STRING, number=2) - - image_output_uri = proto.Field(proto.STRING, number=3) + artifact_output_uri = proto.Field(proto.STRING, number=2,) + image_output_uri = proto.Field(proto.STRING, number=3,) generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - output_info = proto.Field(proto.MESSAGE, number=2, message=OutputInfo,) @@ -331,7 +316,7 @@ class ExportModelResponse(proto.Message): r"""Response message of [ModelService.ExportModel][google.cloud.aiplatform.v1.ModelService.ExportModel] operation. - """ + """ class GetModelEvaluationRequest(proto.Message): @@ -345,7 +330,7 @@ class GetModelEvaluationRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListModelEvaluationsRequest(proto.Message): @@ -371,15 +356,11 @@ class ListModelEvaluationsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListModelEvaluationsResponse(proto.Message): @@ -403,8 +384,7 @@ def raw_page(self): model_evaluations = proto.RepeatedField( proto.MESSAGE, number=1, message=model_evaluation.ModelEvaluation, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetModelEvaluationSliceRequest(proto.Message): @@ -419,7 +399,7 @@ class GetModelEvaluationSliceRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListModelEvaluationSlicesRequest(proto.Message): @@ -448,15 +428,11 @@ class ListModelEvaluationSlicesRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListModelEvaluationSlicesResponse(proto.Message): @@ -480,8 +456,7 @@ def raw_page(self): model_evaluation_slices = proto.RepeatedField( proto.MESSAGE, number=1, message=model_evaluation_slice.ModelEvaluationSlice, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/operation.py b/google/cloud/aiplatform_v1/types/operation.py index fe24030e79..4c28709808 100644 --- a/google/cloud/aiplatform_v1/types/operation.py +++ b/google/cloud/aiplatform_v1/types/operation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class GenericOperationMetadata(proto.Message): r"""Generic Metadata shared by all operations. - Attributes: partial_failures (Sequence[google.rpc.status_pb2.Status]): Output only. Partial failures encountered. @@ -49,17 +45,14 @@ class GenericOperationMetadata(proto.Message): """ partial_failures = proto.RepeatedField( - proto.MESSAGE, number=1, message=status.Status, + proto.MESSAGE, number=1, message=status_pb2.Status, ) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) class DeleteOperationMetadata(proto.Message): r"""Details of operations that perform deletes of any entities. - Attributes: generic_metadata (google.cloud.aiplatform_v1.types.GenericOperationMetadata): The common part of the operation metadata. diff --git a/google/cloud/aiplatform_v1/types/pipeline_service.py b/google/cloud/aiplatform_v1/types/pipeline_service.py index 98e9f6c190..0f659285e2 100644 --- a/google/cloud/aiplatform_v1/types/pipeline_service.py +++ b/google/cloud/aiplatform_v1/types/pipeline_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import training_pipeline as gca_training_pipeline -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -48,8 +45,7 @@ class CreateTrainingPipelineRequest(proto.Message): Required. The TrainingPipeline to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) training_pipeline = proto.Field( proto.MESSAGE, number=2, message=gca_training_pipeline.TrainingPipeline, ) @@ -66,7 +62,7 @@ class GetTrainingPipelineRequest(proto.Message): ``projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListTrainingPipelinesRequest(proto.Message): @@ -106,15 +102,11 @@ class ListTrainingPipelinesRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListTrainingPipelinesResponse(proto.Message): @@ -138,8 +130,7 @@ def raw_page(self): training_pipelines = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_training_pipeline.TrainingPipeline, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteTrainingPipelineRequest(proto.Message): @@ -154,7 +145,7 @@ class DeleteTrainingPipelineRequest(proto.Message): ``projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelTrainingPipelineRequest(proto.Message): @@ -169,7 +160,7 @@ class CancelTrainingPipelineRequest(proto.Message): ``projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/pipeline_state.py b/google/cloud/aiplatform_v1/types/pipeline_state.py index f6a885ae42..1966b4b033 100644 --- a/google/cloud/aiplatform_v1/types/pipeline_state.py +++ b/google/cloud/aiplatform_v1/types/pipeline_state.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore diff --git a/google/cloud/aiplatform_v1/types/prediction_service.py b/google/cloud/aiplatform_v1/types/prediction_service.py index d1d3ea3dd3..40b6aefd8e 100644 --- a/google/cloud/aiplatform_v1/types/prediction_service.py +++ b/google/cloud/aiplatform_v1/types/prediction_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore +from google.protobuf import struct_pb2 # type: ignore __protobuf__ = proto.module( @@ -56,11 +53,9 @@ class PredictRequest(proto.Message): [parameters_schema_uri][google.cloud.aiplatform.v1.PredictSchemata.parameters_schema_uri]. """ - endpoint = proto.Field(proto.STRING, number=1) - - instances = proto.RepeatedField(proto.MESSAGE, number=2, message=struct.Value,) - - parameters = proto.Field(proto.MESSAGE, number=3, message=struct.Value,) + endpoint = proto.Field(proto.STRING, number=1,) + instances = proto.RepeatedField(proto.MESSAGE, number=2, message=struct_pb2.Value,) + parameters = proto.Field(proto.MESSAGE, number=3, message=struct_pb2.Value,) class PredictResponse(proto.Message): @@ -80,9 +75,10 @@ class PredictResponse(proto.Message): served this prediction. """ - predictions = proto.RepeatedField(proto.MESSAGE, number=1, message=struct.Value,) - - deployed_model_id = proto.Field(proto.STRING, number=2) + predictions = proto.RepeatedField( + proto.MESSAGE, number=1, message=struct_pb2.Value, + ) + deployed_model_id = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/specialist_pool.py b/google/cloud/aiplatform_v1/types/specialist_pool.py index 6265316bd5..0f5de963fb 100644 --- a/google/cloud/aiplatform_v1/types/specialist_pool.py +++ b/google/cloud/aiplatform_v1/types/specialist_pool.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -54,15 +52,11 @@ class SpecialistPool(proto.Message): data labeling jobs. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - specialist_managers_count = proto.Field(proto.INT32, number=3) - - specialist_manager_emails = proto.RepeatedField(proto.STRING, number=4) - - pending_data_labeling_jobs = proto.RepeatedField(proto.STRING, number=5) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + specialist_managers_count = proto.Field(proto.INT32, number=3,) + specialist_manager_emails = proto.RepeatedField(proto.STRING, number=4,) + pending_data_labeling_jobs = proto.RepeatedField(proto.STRING, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/specialist_pool_service.py b/google/cloud/aiplatform_v1/types/specialist_pool_service.py index 7392d79f01..d7b5f33f75 100644 --- a/google/cloud/aiplatform_v1/types/specialist_pool_service.py +++ b/google/cloud/aiplatform_v1/types/specialist_pool_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import operation from google.cloud.aiplatform_v1.types import specialist_pool as gca_specialist_pool -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -51,8 +48,7 @@ class CreateSpecialistPoolRequest(proto.Message): Required. The SpecialistPool to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) specialist_pool = proto.Field( proto.MESSAGE, number=2, message=gca_specialist_pool.SpecialistPool, ) @@ -84,7 +80,7 @@ class GetSpecialistPoolRequest(proto.Message): ``projects/{project}/locations/{location}/specialistPools/{specialist_pool}``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListSpecialistPoolsRequest(proto.Message): @@ -108,13 +104,10 @@ class ListSpecialistPoolsRequest(proto.Message): FieldMask represents a set of """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - read_mask = proto.Field(proto.MESSAGE, number=4, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + read_mask = proto.Field(proto.MESSAGE, number=4, message=field_mask_pb2.FieldMask,) class ListSpecialistPoolsResponse(proto.Message): @@ -136,8 +129,7 @@ def raw_page(self): specialist_pools = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_specialist_pool.SpecialistPool, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteSpecialistPoolRequest(proto.Message): @@ -156,9 +148,8 @@ class DeleteSpecialistPoolRequest(proto.Message): SpecialistPool has no specialist managers.) """ - name = proto.Field(proto.STRING, number=1) - - force = proto.Field(proto.BOOL, number=2) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) class UpdateSpecialistPoolRequest(proto.Message): @@ -177,8 +168,9 @@ class UpdateSpecialistPoolRequest(proto.Message): specialist_pool = proto.Field( proto.MESSAGE, number=1, message=gca_specialist_pool.SpecialistPool, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class UpdateSpecialistPoolOperationMetadata(proto.Message): @@ -195,8 +187,7 @@ class UpdateSpecialistPoolOperationMetadata(proto.Message): The operation generic information. """ - specialist_pool = proto.Field(proto.STRING, number=1) - + specialist_pool = proto.Field(proto.STRING, number=1,) generic_metadata = proto.Field( proto.MESSAGE, number=2, message=operation.GenericOperationMetadata, ) diff --git a/google/cloud/aiplatform_v1/types/study.py b/google/cloud/aiplatform_v1/types/study.py index 99a688f045..40a6c84ce5 100644 --- a/google/cloud/aiplatform_v1/types/study.py +++ b/google/cloud/aiplatform_v1/types/study.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -66,7 +63,6 @@ class State(proto.Enum): class Parameter(proto.Message): r"""A message representing a parameter to be tuned. - Attributes: parameter_id (str): Output only. The ID of the parameter. The parameter should @@ -80,28 +76,20 @@ class Parameter(proto.Message): 'CATEGORICAL'. """ - parameter_id = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.MESSAGE, number=2, message=struct.Value,) - - id = proto.Field(proto.STRING, number=2) + parameter_id = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.MESSAGE, number=2, message=struct_pb2.Value,) + id = proto.Field(proto.STRING, number=2,) state = proto.Field(proto.ENUM, number=3, enum=State,) - parameters = proto.RepeatedField(proto.MESSAGE, number=4, message=Parameter,) - final_measurement = proto.Field(proto.MESSAGE, number=5, message="Measurement",) - - start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - custom_job = proto.Field(proto.STRING, number=11) + start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + custom_job = proto.Field(proto.STRING, number=11,) class StudySpec(proto.Message): r"""Represents specification of a Study. - Attributes: metrics (Sequence[google.cloud.aiplatform_v1.types.StudySpec.MetricSpec]): Required. Metric specs for the Study. @@ -154,7 +142,6 @@ class MeasurementSelectionType(proto.Enum): class MetricSpec(proto.Message): r"""Represents a metric to optimize. - Attributes: metric_id (str): Required. The ID of the metric. Must not @@ -171,13 +158,11 @@ class GoalType(proto.Enum): MAXIMIZE = 1 MINIMIZE = 2 - metric_id = proto.Field(proto.STRING, number=1) - + metric_id = proto.Field(proto.STRING, number=1,) goal = proto.Field(proto.ENUM, number=2, enum="StudySpec.MetricSpec.GoalType",) class ParameterSpec(proto.Message): r"""Represents a single parameter to optimize. - Attributes: double_value_spec (google.cloud.aiplatform_v1.types.StudySpec.ParameterSpec.DoubleValueSpec): The value spec for a 'DOUBLE' parameter. @@ -211,7 +196,6 @@ class ScaleType(proto.Enum): class DoubleValueSpec(proto.Message): r"""Value specification for a parameter in ``DOUBLE`` type. - Attributes: min_value (float): Required. Inclusive minimum value of the @@ -221,13 +205,11 @@ class DoubleValueSpec(proto.Message): parameter. """ - min_value = proto.Field(proto.DOUBLE, number=1) - - max_value = proto.Field(proto.DOUBLE, number=2) + min_value = proto.Field(proto.DOUBLE, number=1,) + max_value = proto.Field(proto.DOUBLE, number=2,) class IntegerValueSpec(proto.Message): r"""Value specification for a parameter in ``INTEGER`` type. - Attributes: min_value (int): Required. Inclusive minimum value of the @@ -237,23 +219,20 @@ class IntegerValueSpec(proto.Message): parameter. """ - min_value = proto.Field(proto.INT64, number=1) - - max_value = proto.Field(proto.INT64, number=2) + min_value = proto.Field(proto.INT64, number=1,) + max_value = proto.Field(proto.INT64, number=2,) class CategoricalValueSpec(proto.Message): r"""Value specification for a parameter in ``CATEGORICAL`` type. - Attributes: values (Sequence[str]): Required. The list of possible categories. """ - values = proto.RepeatedField(proto.STRING, number=1) + values = proto.RepeatedField(proto.STRING, number=1,) class DiscreteValueSpec(proto.Message): r"""Value specification for a parameter in ``DISCRETE`` type. - Attributes: values (Sequence[float]): Required. A list of possible values. @@ -264,7 +243,7 @@ class DiscreteValueSpec(proto.Message): 1,000 values. """ - values = proto.RepeatedField(proto.DOUBLE, number=1) + values = proto.RepeatedField(proto.DOUBLE, number=1,) class ConditionalParameterSpec(proto.Message): r"""Represents a parameter spec with condition from its parent @@ -298,7 +277,7 @@ class DiscreteValueCondition(proto.Message): The Epsilon of the value matching is 1e-10. """ - values = proto.RepeatedField(proto.DOUBLE, number=1) + values = proto.RepeatedField(proto.DOUBLE, number=1,) class IntValueCondition(proto.Message): r"""Represents the spec to match integer values from parent @@ -311,7 +290,7 @@ class IntValueCondition(proto.Message): ``integer_value_spec`` of parent parameter. """ - values = proto.RepeatedField(proto.INT64, number=1) + values = proto.RepeatedField(proto.INT64, number=1,) class CategoricalValueCondition(proto.Message): r"""Represents the spec to match categorical values from parent @@ -324,7 +303,7 @@ class CategoricalValueCondition(proto.Message): ``categorical_value_spec`` of parent parameter. """ - values = proto.RepeatedField(proto.STRING, number=1) + values = proto.RepeatedField(proto.STRING, number=1,) parent_discrete_values = proto.Field( proto.MESSAGE, @@ -332,21 +311,18 @@ class CategoricalValueCondition(proto.Message): oneof="parent_value_condition", message="StudySpec.ParameterSpec.ConditionalParameterSpec.DiscreteValueCondition", ) - parent_int_values = proto.Field( proto.MESSAGE, number=3, oneof="parent_value_condition", message="StudySpec.ParameterSpec.ConditionalParameterSpec.IntValueCondition", ) - parent_categorical_values = proto.Field( proto.MESSAGE, number=4, oneof="parent_value_condition", message="StudySpec.ParameterSpec.ConditionalParameterSpec.CategoricalValueCondition", ) - parameter_spec = proto.Field( proto.MESSAGE, number=1, message="StudySpec.ParameterSpec", ) @@ -357,34 +333,28 @@ class CategoricalValueCondition(proto.Message): oneof="parameter_value_spec", message="StudySpec.ParameterSpec.DoubleValueSpec", ) - integer_value_spec = proto.Field( proto.MESSAGE, number=3, oneof="parameter_value_spec", message="StudySpec.ParameterSpec.IntegerValueSpec", ) - categorical_value_spec = proto.Field( proto.MESSAGE, number=4, oneof="parameter_value_spec", message="StudySpec.ParameterSpec.CategoricalValueSpec", ) - discrete_value_spec = proto.Field( proto.MESSAGE, number=5, oneof="parameter_value_spec", message="StudySpec.ParameterSpec.DiscreteValueSpec", ) - - parameter_id = proto.Field(proto.STRING, number=1) - + parameter_id = proto.Field(proto.STRING, number=1,) scale_type = proto.Field( proto.ENUM, number=6, enum="StudySpec.ParameterSpec.ScaleType", ) - conditional_parameter_specs = proto.RepeatedField( proto.MESSAGE, number=10, @@ -392,13 +362,9 @@ class CategoricalValueCondition(proto.Message): ) metrics = proto.RepeatedField(proto.MESSAGE, number=1, message=MetricSpec,) - parameters = proto.RepeatedField(proto.MESSAGE, number=2, message=ParameterSpec,) - algorithm = proto.Field(proto.ENUM, number=3, enum=Algorithm,) - observation_noise = proto.Field(proto.ENUM, number=6, enum=ObservationNoise,) - measurement_selection_type = proto.Field( proto.ENUM, number=7, enum=MeasurementSelectionType, ) @@ -422,7 +388,6 @@ class Measurement(proto.Message): class Metric(proto.Message): r"""A message representing a metric in the measurement. - Attributes: metric_id (str): Output only. The ID of the Metric. The Metric should be @@ -432,12 +397,10 @@ class Metric(proto.Message): Output only. The value for this metric. """ - metric_id = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.DOUBLE, number=2) - - step_count = proto.Field(proto.INT64, number=2) + metric_id = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.DOUBLE, number=2,) + step_count = proto.Field(proto.INT64, number=2,) metrics = proto.RepeatedField(proto.MESSAGE, number=3, message=Metric,) diff --git a/google/cloud/aiplatform_v1/types/training_pipeline.py b/google/cloud/aiplatform_v1/types/training_pipeline.py index 0964e87cd4..acd18f7b2e 100644 --- a/google/cloud/aiplatform_v1/types/training_pipeline.py +++ b/google/cloud/aiplatform_v1/types/training_pipeline.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1.types import io from google.cloud.aiplatform_v1.types import model from google.cloud.aiplatform_v1.types import pipeline_state -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -150,34 +147,28 @@ class TrainingPipeline(proto.Message): is not set separately. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) input_data_config = proto.Field(proto.MESSAGE, number=3, message="InputDataConfig",) - - training_task_definition = proto.Field(proto.STRING, number=4) - - training_task_inputs = proto.Field(proto.MESSAGE, number=5, message=struct.Value,) - - training_task_metadata = proto.Field(proto.MESSAGE, number=6, message=struct.Value,) - + training_task_definition = proto.Field(proto.STRING, number=4,) + training_task_inputs = proto.Field( + proto.MESSAGE, number=5, message=struct_pb2.Value, + ) + training_task_metadata = proto.Field( + proto.MESSAGE, number=6, message=struct_pb2.Value, + ) model_to_upload = proto.Field(proto.MESSAGE, number=7, message=model.Model,) - state = proto.Field(proto.ENUM, number=9, enum=pipeline_state.PipelineState,) - - error = proto.Field(proto.MESSAGE, number=10, message=status.Status,) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=14, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=15) - + error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=15,) encryption_spec = proto.Field( proto.MESSAGE, number=18, message=gca_encryption_spec.EncryptionSpec, ) @@ -306,32 +297,24 @@ class InputDataConfig(proto.Message): fraction_split = proto.Field( proto.MESSAGE, number=2, oneof="split", message="FractionSplit", ) - filter_split = proto.Field( proto.MESSAGE, number=3, oneof="split", message="FilterSplit", ) - predefined_split = proto.Field( proto.MESSAGE, number=4, oneof="split", message="PredefinedSplit", ) - timestamp_split = proto.Field( proto.MESSAGE, number=5, oneof="split", message="TimestampSplit", ) - gcs_destination = proto.Field( proto.MESSAGE, number=8, oneof="destination", message=io.GcsDestination, ) - bigquery_destination = proto.Field( proto.MESSAGE, number=10, oneof="destination", message=io.BigQueryDestination, ) - - dataset_id = proto.Field(proto.STRING, number=1) - - annotations_filter = proto.Field(proto.STRING, number=6) - - annotation_schema_uri = proto.Field(proto.STRING, number=9) + dataset_id = proto.Field(proto.STRING, number=1,) + annotations_filter = proto.Field(proto.STRING, number=6,) + annotation_schema_uri = proto.Field(proto.STRING, number=9,) class FractionSplit(proto.Message): @@ -355,11 +338,9 @@ class FractionSplit(proto.Message): used to evaluate the Model. """ - training_fraction = proto.Field(proto.DOUBLE, number=1) - - validation_fraction = proto.Field(proto.DOUBLE, number=2) - - test_fraction = proto.Field(proto.DOUBLE, number=3) + training_fraction = proto.Field(proto.DOUBLE, number=1,) + validation_fraction = proto.Field(proto.DOUBLE, number=2,) + test_fraction = proto.Field(proto.DOUBLE, number=3,) class FilterSplit(proto.Message): @@ -402,11 +383,9 @@ class FilterSplit(proto.Message): test order. """ - training_filter = proto.Field(proto.STRING, number=1) - - validation_filter = proto.Field(proto.STRING, number=2) - - test_filter = proto.Field(proto.STRING, number=3) + training_filter = proto.Field(proto.STRING, number=1,) + validation_filter = proto.Field(proto.STRING, number=2,) + test_filter = proto.Field(proto.STRING, number=3,) class PredefinedSplit(proto.Message): @@ -426,7 +405,7 @@ class PredefinedSplit(proto.Message): ignored by the pipeline. """ - key = proto.Field(proto.STRING, number=1) + key = proto.Field(proto.STRING, number=1,) class TimestampSplit(proto.Message): @@ -455,13 +434,10 @@ class TimestampSplit(proto.Message): value, that piece is ignored by the pipeline. """ - training_fraction = proto.Field(proto.DOUBLE, number=1) - - validation_fraction = proto.Field(proto.DOUBLE, number=2) - - test_fraction = proto.Field(proto.DOUBLE, number=3) - - key = proto.Field(proto.STRING, number=4) + training_fraction = proto.Field(proto.DOUBLE, number=1,) + validation_fraction = proto.Field(proto.DOUBLE, number=2,) + test_fraction = proto.Field(proto.DOUBLE, number=3,) + key = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1/types/user_action_reference.py b/google/cloud/aiplatform_v1/types/user_action_reference.py index da59ac6ac6..203b604ae2 100644 --- a/google/cloud/aiplatform_v1/types/user_action_reference.py +++ b/google/cloud/aiplatform_v1/types/user_action_reference.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -44,11 +42,9 @@ class UserActionReference(proto.Message): "/google.cloud.aiplatform.v1alpha1.DatasetService.CreateDataset". """ - operation = proto.Field(proto.STRING, number=1, oneof="reference") - - data_labeling_job = proto.Field(proto.STRING, number=2, oneof="reference") - - method = proto.Field(proto.STRING, number=3) + operation = proto.Field(proto.STRING, number=1, oneof="reference",) + data_labeling_job = proto.Field(proto.STRING, number=2, oneof="reference",) + method = proto.Field(proto.STRING, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/__init__.py b/google/cloud/aiplatform_v1beta1/__init__.py index 4ffc71f682..a9c7df2b17 100644 --- a/google/cloud/aiplatform_v1beta1/__init__.py +++ b/google/cloud/aiplatform_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,22 +15,40 @@ # from .services.dataset_service import DatasetServiceClient +from .services.dataset_service import DatasetServiceAsyncClient from .services.endpoint_service import EndpointServiceClient +from .services.endpoint_service import EndpointServiceAsyncClient from .services.featurestore_online_serving_service import ( FeaturestoreOnlineServingServiceClient, ) +from .services.featurestore_online_serving_service import ( + FeaturestoreOnlineServingServiceAsyncClient, +) from .services.featurestore_service import FeaturestoreServiceClient +from .services.featurestore_service import FeaturestoreServiceAsyncClient from .services.index_endpoint_service import IndexEndpointServiceClient +from .services.index_endpoint_service import IndexEndpointServiceAsyncClient from .services.index_service import IndexServiceClient +from .services.index_service import IndexServiceAsyncClient from .services.job_service import JobServiceClient +from .services.job_service import JobServiceAsyncClient from .services.metadata_service import MetadataServiceClient +from .services.metadata_service import MetadataServiceAsyncClient from .services.migration_service import MigrationServiceClient +from .services.migration_service import MigrationServiceAsyncClient from .services.model_service import ModelServiceClient +from .services.model_service import ModelServiceAsyncClient from .services.pipeline_service import PipelineServiceClient +from .services.pipeline_service import PipelineServiceAsyncClient from .services.prediction_service import PredictionServiceClient +from .services.prediction_service import PredictionServiceAsyncClient from .services.specialist_pool_service import SpecialistPoolServiceClient +from .services.specialist_pool_service import SpecialistPoolServiceAsyncClient from .services.tensorboard_service import TensorboardServiceClient +from .services.tensorboard_service import TensorboardServiceAsyncClient from .services.vizier_service import VizierServiceClient +from .services.vizier_service import VizierServiceAsyncClient + from .types.accelerator_type import AcceleratorType from .types.annotation import Annotation from .types.annotation_spec import AnnotationSpec @@ -294,13 +311,13 @@ from .types.model_deployment_monitoring_job import ( ModelDeploymentMonitoringObjectiveConfig, ) -from .types.model_deployment_monitoring_job import ( - ModelDeploymentMonitoringObjectiveType, -) from .types.model_deployment_monitoring_job import ( ModelDeploymentMonitoringScheduleConfig, ) from .types.model_deployment_monitoring_job import ModelMonitoringStatsAnomalies +from .types.model_deployment_monitoring_job import ( + ModelDeploymentMonitoringObjectiveType, +) from .types.model_evaluation import ModelEvaluation from .types.model_evaluation_slice import ModelEvaluationSlice from .types.model_monitoring import ModelMonitoringAlertConfig @@ -388,10 +405,10 @@ from .types.tensorboard_service import ListTensorboardExperimentsResponse from .types.tensorboard_service import ListTensorboardRunsRequest from .types.tensorboard_service import ListTensorboardRunsResponse -from .types.tensorboard_service import ListTensorboardTimeSeriesRequest -from .types.tensorboard_service import ListTensorboardTimeSeriesResponse from .types.tensorboard_service import ListTensorboardsRequest from .types.tensorboard_service import ListTensorboardsResponse +from .types.tensorboard_service import ListTensorboardTimeSeriesRequest +from .types.tensorboard_service import ListTensorboardTimeSeriesResponse from .types.tensorboard_service import ReadTensorboardBlobDataRequest from .types.tensorboard_service import ReadTensorboardBlobDataResponse from .types.tensorboard_service import ReadTensorboardTimeSeriesDataRequest @@ -439,8 +456,22 @@ from .types.vizier_service import SuggestTrialsRequest from .types.vizier_service import SuggestTrialsResponse - __all__ = ( + "DatasetServiceAsyncClient", + "EndpointServiceAsyncClient", + "FeaturestoreOnlineServingServiceAsyncClient", + "FeaturestoreServiceAsyncClient", + "IndexEndpointServiceAsyncClient", + "IndexServiceAsyncClient", + "JobServiceAsyncClient", + "MetadataServiceAsyncClient", + "MigrationServiceAsyncClient", + "ModelServiceAsyncClient", + "PipelineServiceAsyncClient", + "PredictionServiceAsyncClient", + "SpecialistPoolServiceAsyncClient", + "TensorboardServiceAsyncClient", + "VizierServiceAsyncClient", "AcceleratorType", "ActiveLearningConfig", "AddContextArtifactsAndExecutionsRequest", @@ -849,9 +880,9 @@ "UploadModelResponse", "UserActionReference", "Value", + "VizierServiceClient", "WorkerPoolSpec", "WriteTensorboardRunDataRequest", "WriteTensorboardRunDataResponse", "XraiAttribution", - "VizierServiceClient", ) diff --git a/google/cloud/aiplatform_v1beta1/gapic_metadata.json b/google/cloud/aiplatform_v1beta1/gapic_metadata.json new file mode 100644 index 0000000000..605e95582d --- /dev/null +++ b/google/cloud/aiplatform_v1beta1/gapic_metadata.json @@ -0,0 +1,1949 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.aiplatform_v1beta1", + "protoPackage": "google.cloud.aiplatform.v1beta1", + "schema": "1.0", + "services": { + "DatasetService": { + "clients": { + "grpc": { + "libraryClient": "DatasetServiceClient", + "rpcs": { + "CreateDataset": { + "methods": [ + "create_dataset" + ] + }, + "DeleteDataset": { + "methods": [ + "delete_dataset" + ] + }, + "ExportData": { + "methods": [ + "export_data" + ] + }, + "GetAnnotationSpec": { + "methods": [ + "get_annotation_spec" + ] + }, + "GetDataset": { + "methods": [ + "get_dataset" + ] + }, + "ImportData": { + "methods": [ + "import_data" + ] + }, + "ListAnnotations": { + "methods": [ + "list_annotations" + ] + }, + "ListDataItems": { + "methods": [ + "list_data_items" + ] + }, + "ListDatasets": { + "methods": [ + "list_datasets" + ] + }, + "UpdateDataset": { + "methods": [ + "update_dataset" + ] + } + } + }, + "grpc-async": { + "libraryClient": "DatasetServiceAsyncClient", + "rpcs": { + "CreateDataset": { + "methods": [ + "create_dataset" + ] + }, + "DeleteDataset": { + "methods": [ + "delete_dataset" + ] + }, + "ExportData": { + "methods": [ + "export_data" + ] + }, + "GetAnnotationSpec": { + "methods": [ + "get_annotation_spec" + ] + }, + "GetDataset": { + "methods": [ + "get_dataset" + ] + }, + "ImportData": { + "methods": [ + "import_data" + ] + }, + "ListAnnotations": { + "methods": [ + "list_annotations" + ] + }, + "ListDataItems": { + "methods": [ + "list_data_items" + ] + }, + "ListDatasets": { + "methods": [ + "list_datasets" + ] + }, + "UpdateDataset": { + "methods": [ + "update_dataset" + ] + } + } + } + } + }, + "EndpointService": { + "clients": { + "grpc": { + "libraryClient": "EndpointServiceClient", + "rpcs": { + "CreateEndpoint": { + "methods": [ + "create_endpoint" + ] + }, + "DeleteEndpoint": { + "methods": [ + "delete_endpoint" + ] + }, + "DeployModel": { + "methods": [ + "deploy_model" + ] + }, + "GetEndpoint": { + "methods": [ + "get_endpoint" + ] + }, + "ListEndpoints": { + "methods": [ + "list_endpoints" + ] + }, + "UndeployModel": { + "methods": [ + "undeploy_model" + ] + }, + "UpdateEndpoint": { + "methods": [ + "update_endpoint" + ] + } + } + }, + "grpc-async": { + "libraryClient": "EndpointServiceAsyncClient", + "rpcs": { + "CreateEndpoint": { + "methods": [ + "create_endpoint" + ] + }, + "DeleteEndpoint": { + "methods": [ + "delete_endpoint" + ] + }, + "DeployModel": { + "methods": [ + "deploy_model" + ] + }, + "GetEndpoint": { + "methods": [ + "get_endpoint" + ] + }, + "ListEndpoints": { + "methods": [ + "list_endpoints" + ] + }, + "UndeployModel": { + "methods": [ + "undeploy_model" + ] + }, + "UpdateEndpoint": { + "methods": [ + "update_endpoint" + ] + } + } + } + } + }, + "FeaturestoreOnlineServingService": { + "clients": { + "grpc": { + "libraryClient": "FeaturestoreOnlineServingServiceClient", + "rpcs": { + "ReadFeatureValues": { + "methods": [ + "read_feature_values" + ] + }, + "StreamingReadFeatureValues": { + "methods": [ + "streaming_read_feature_values" + ] + } + } + }, + "grpc-async": { + "libraryClient": "FeaturestoreOnlineServingServiceAsyncClient", + "rpcs": { + "ReadFeatureValues": { + "methods": [ + "read_feature_values" + ] + }, + "StreamingReadFeatureValues": { + "methods": [ + "streaming_read_feature_values" + ] + } + } + } + } + }, + "FeaturestoreService": { + "clients": { + "grpc": { + "libraryClient": "FeaturestoreServiceClient", + "rpcs": { + "BatchCreateFeatures": { + "methods": [ + "batch_create_features" + ] + }, + "BatchReadFeatureValues": { + "methods": [ + "batch_read_feature_values" + ] + }, + "CreateEntityType": { + "methods": [ + "create_entity_type" + ] + }, + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "CreateFeaturestore": { + "methods": [ + "create_featurestore" + ] + }, + "DeleteEntityType": { + "methods": [ + "delete_entity_type" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "DeleteFeaturestore": { + "methods": [ + "delete_featurestore" + ] + }, + "ExportFeatureValues": { + "methods": [ + "export_feature_values" + ] + }, + "GetEntityType": { + "methods": [ + "get_entity_type" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "GetFeaturestore": { + "methods": [ + "get_featurestore" + ] + }, + "ImportFeatureValues": { + "methods": [ + "import_feature_values" + ] + }, + "ListEntityTypes": { + "methods": [ + "list_entity_types" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "ListFeaturestores": { + "methods": [ + "list_featurestores" + ] + }, + "SearchFeatures": { + "methods": [ + "search_features" + ] + }, + "UpdateEntityType": { + "methods": [ + "update_entity_type" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + }, + "UpdateFeaturestore": { + "methods": [ + "update_featurestore" + ] + } + } + }, + "grpc-async": { + "libraryClient": "FeaturestoreServiceAsyncClient", + "rpcs": { + "BatchCreateFeatures": { + "methods": [ + "batch_create_features" + ] + }, + "BatchReadFeatureValues": { + "methods": [ + "batch_read_feature_values" + ] + }, + "CreateEntityType": { + "methods": [ + "create_entity_type" + ] + }, + "CreateFeature": { + "methods": [ + "create_feature" + ] + }, + "CreateFeaturestore": { + "methods": [ + "create_featurestore" + ] + }, + "DeleteEntityType": { + "methods": [ + "delete_entity_type" + ] + }, + "DeleteFeature": { + "methods": [ + "delete_feature" + ] + }, + "DeleteFeaturestore": { + "methods": [ + "delete_featurestore" + ] + }, + "ExportFeatureValues": { + "methods": [ + "export_feature_values" + ] + }, + "GetEntityType": { + "methods": [ + "get_entity_type" + ] + }, + "GetFeature": { + "methods": [ + "get_feature" + ] + }, + "GetFeaturestore": { + "methods": [ + "get_featurestore" + ] + }, + "ImportFeatureValues": { + "methods": [ + "import_feature_values" + ] + }, + "ListEntityTypes": { + "methods": [ + "list_entity_types" + ] + }, + "ListFeatures": { + "methods": [ + "list_features" + ] + }, + "ListFeaturestores": { + "methods": [ + "list_featurestores" + ] + }, + "SearchFeatures": { + "methods": [ + "search_features" + ] + }, + "UpdateEntityType": { + "methods": [ + "update_entity_type" + ] + }, + "UpdateFeature": { + "methods": [ + "update_feature" + ] + }, + "UpdateFeaturestore": { + "methods": [ + "update_featurestore" + ] + } + } + } + } + }, + "IndexEndpointService": { + "clients": { + "grpc": { + "libraryClient": "IndexEndpointServiceClient", + "rpcs": { + "CreateIndexEndpoint": { + "methods": [ + "create_index_endpoint" + ] + }, + "DeleteIndexEndpoint": { + "methods": [ + "delete_index_endpoint" + ] + }, + "DeployIndex": { + "methods": [ + "deploy_index" + ] + }, + "GetIndexEndpoint": { + "methods": [ + "get_index_endpoint" + ] + }, + "ListIndexEndpoints": { + "methods": [ + "list_index_endpoints" + ] + }, + "UndeployIndex": { + "methods": [ + "undeploy_index" + ] + }, + "UpdateIndexEndpoint": { + "methods": [ + "update_index_endpoint" + ] + } + } + }, + "grpc-async": { + "libraryClient": "IndexEndpointServiceAsyncClient", + "rpcs": { + "CreateIndexEndpoint": { + "methods": [ + "create_index_endpoint" + ] + }, + "DeleteIndexEndpoint": { + "methods": [ + "delete_index_endpoint" + ] + }, + "DeployIndex": { + "methods": [ + "deploy_index" + ] + }, + "GetIndexEndpoint": { + "methods": [ + "get_index_endpoint" + ] + }, + "ListIndexEndpoints": { + "methods": [ + "list_index_endpoints" + ] + }, + "UndeployIndex": { + "methods": [ + "undeploy_index" + ] + }, + "UpdateIndexEndpoint": { + "methods": [ + "update_index_endpoint" + ] + } + } + } + } + }, + "IndexService": { + "clients": { + "grpc": { + "libraryClient": "IndexServiceClient", + "rpcs": { + "CreateIndex": { + "methods": [ + "create_index" + ] + }, + "DeleteIndex": { + "methods": [ + "delete_index" + ] + }, + "GetIndex": { + "methods": [ + "get_index" + ] + }, + "ListIndexes": { + "methods": [ + "list_indexes" + ] + }, + "UpdateIndex": { + "methods": [ + "update_index" + ] + } + } + }, + "grpc-async": { + "libraryClient": "IndexServiceAsyncClient", + "rpcs": { + "CreateIndex": { + "methods": [ + "create_index" + ] + }, + "DeleteIndex": { + "methods": [ + "delete_index" + ] + }, + "GetIndex": { + "methods": [ + "get_index" + ] + }, + "ListIndexes": { + "methods": [ + "list_indexes" + ] + }, + "UpdateIndex": { + "methods": [ + "update_index" + ] + } + } + } + } + }, + "JobService": { + "clients": { + "grpc": { + "libraryClient": "JobServiceClient", + "rpcs": { + "CancelBatchPredictionJob": { + "methods": [ + "cancel_batch_prediction_job" + ] + }, + "CancelCustomJob": { + "methods": [ + "cancel_custom_job" + ] + }, + "CancelDataLabelingJob": { + "methods": [ + "cancel_data_labeling_job" + ] + }, + "CancelHyperparameterTuningJob": { + "methods": [ + "cancel_hyperparameter_tuning_job" + ] + }, + "CreateBatchPredictionJob": { + "methods": [ + "create_batch_prediction_job" + ] + }, + "CreateCustomJob": { + "methods": [ + "create_custom_job" + ] + }, + "CreateDataLabelingJob": { + "methods": [ + "create_data_labeling_job" + ] + }, + "CreateHyperparameterTuningJob": { + "methods": [ + "create_hyperparameter_tuning_job" + ] + }, + "CreateModelDeploymentMonitoringJob": { + "methods": [ + "create_model_deployment_monitoring_job" + ] + }, + "DeleteBatchPredictionJob": { + "methods": [ + "delete_batch_prediction_job" + ] + }, + "DeleteCustomJob": { + "methods": [ + "delete_custom_job" + ] + }, + "DeleteDataLabelingJob": { + "methods": [ + "delete_data_labeling_job" + ] + }, + "DeleteHyperparameterTuningJob": { + "methods": [ + "delete_hyperparameter_tuning_job" + ] + }, + "DeleteModelDeploymentMonitoringJob": { + "methods": [ + "delete_model_deployment_monitoring_job" + ] + }, + "GetBatchPredictionJob": { + "methods": [ + "get_batch_prediction_job" + ] + }, + "GetCustomJob": { + "methods": [ + "get_custom_job" + ] + }, + "GetDataLabelingJob": { + "methods": [ + "get_data_labeling_job" + ] + }, + "GetHyperparameterTuningJob": { + "methods": [ + "get_hyperparameter_tuning_job" + ] + }, + "GetModelDeploymentMonitoringJob": { + "methods": [ + "get_model_deployment_monitoring_job" + ] + }, + "ListBatchPredictionJobs": { + "methods": [ + "list_batch_prediction_jobs" + ] + }, + "ListCustomJobs": { + "methods": [ + "list_custom_jobs" + ] + }, + "ListDataLabelingJobs": { + "methods": [ + "list_data_labeling_jobs" + ] + }, + "ListHyperparameterTuningJobs": { + "methods": [ + "list_hyperparameter_tuning_jobs" + ] + }, + "ListModelDeploymentMonitoringJobs": { + "methods": [ + "list_model_deployment_monitoring_jobs" + ] + }, + "PauseModelDeploymentMonitoringJob": { + "methods": [ + "pause_model_deployment_monitoring_job" + ] + }, + "ResumeModelDeploymentMonitoringJob": { + "methods": [ + "resume_model_deployment_monitoring_job" + ] + }, + "SearchModelDeploymentMonitoringStatsAnomalies": { + "methods": [ + "search_model_deployment_monitoring_stats_anomalies" + ] + }, + "UpdateModelDeploymentMonitoringJob": { + "methods": [ + "update_model_deployment_monitoring_job" + ] + } + } + }, + "grpc-async": { + "libraryClient": "JobServiceAsyncClient", + "rpcs": { + "CancelBatchPredictionJob": { + "methods": [ + "cancel_batch_prediction_job" + ] + }, + "CancelCustomJob": { + "methods": [ + "cancel_custom_job" + ] + }, + "CancelDataLabelingJob": { + "methods": [ + "cancel_data_labeling_job" + ] + }, + "CancelHyperparameterTuningJob": { + "methods": [ + "cancel_hyperparameter_tuning_job" + ] + }, + "CreateBatchPredictionJob": { + "methods": [ + "create_batch_prediction_job" + ] + }, + "CreateCustomJob": { + "methods": [ + "create_custom_job" + ] + }, + "CreateDataLabelingJob": { + "methods": [ + "create_data_labeling_job" + ] + }, + "CreateHyperparameterTuningJob": { + "methods": [ + "create_hyperparameter_tuning_job" + ] + }, + "CreateModelDeploymentMonitoringJob": { + "methods": [ + "create_model_deployment_monitoring_job" + ] + }, + "DeleteBatchPredictionJob": { + "methods": [ + "delete_batch_prediction_job" + ] + }, + "DeleteCustomJob": { + "methods": [ + "delete_custom_job" + ] + }, + "DeleteDataLabelingJob": { + "methods": [ + "delete_data_labeling_job" + ] + }, + "DeleteHyperparameterTuningJob": { + "methods": [ + "delete_hyperparameter_tuning_job" + ] + }, + "DeleteModelDeploymentMonitoringJob": { + "methods": [ + "delete_model_deployment_monitoring_job" + ] + }, + "GetBatchPredictionJob": { + "methods": [ + "get_batch_prediction_job" + ] + }, + "GetCustomJob": { + "methods": [ + "get_custom_job" + ] + }, + "GetDataLabelingJob": { + "methods": [ + "get_data_labeling_job" + ] + }, + "GetHyperparameterTuningJob": { + "methods": [ + "get_hyperparameter_tuning_job" + ] + }, + "GetModelDeploymentMonitoringJob": { + "methods": [ + "get_model_deployment_monitoring_job" + ] + }, + "ListBatchPredictionJobs": { + "methods": [ + "list_batch_prediction_jobs" + ] + }, + "ListCustomJobs": { + "methods": [ + "list_custom_jobs" + ] + }, + "ListDataLabelingJobs": { + "methods": [ + "list_data_labeling_jobs" + ] + }, + "ListHyperparameterTuningJobs": { + "methods": [ + "list_hyperparameter_tuning_jobs" + ] + }, + "ListModelDeploymentMonitoringJobs": { + "methods": [ + "list_model_deployment_monitoring_jobs" + ] + }, + "PauseModelDeploymentMonitoringJob": { + "methods": [ + "pause_model_deployment_monitoring_job" + ] + }, + "ResumeModelDeploymentMonitoringJob": { + "methods": [ + "resume_model_deployment_monitoring_job" + ] + }, + "SearchModelDeploymentMonitoringStatsAnomalies": { + "methods": [ + "search_model_deployment_monitoring_stats_anomalies" + ] + }, + "UpdateModelDeploymentMonitoringJob": { + "methods": [ + "update_model_deployment_monitoring_job" + ] + } + } + } + } + }, + "MetadataService": { + "clients": { + "grpc": { + "libraryClient": "MetadataServiceClient", + "rpcs": { + "AddContextArtifactsAndExecutions": { + "methods": [ + "add_context_artifacts_and_executions" + ] + }, + "AddContextChildren": { + "methods": [ + "add_context_children" + ] + }, + "AddExecutionEvents": { + "methods": [ + "add_execution_events" + ] + }, + "CreateArtifact": { + "methods": [ + "create_artifact" + ] + }, + "CreateContext": { + "methods": [ + "create_context" + ] + }, + "CreateExecution": { + "methods": [ + "create_execution" + ] + }, + "CreateMetadataSchema": { + "methods": [ + "create_metadata_schema" + ] + }, + "CreateMetadataStore": { + "methods": [ + "create_metadata_store" + ] + }, + "DeleteContext": { + "methods": [ + "delete_context" + ] + }, + "DeleteMetadataStore": { + "methods": [ + "delete_metadata_store" + ] + }, + "GetArtifact": { + "methods": [ + "get_artifact" + ] + }, + "GetContext": { + "methods": [ + "get_context" + ] + }, + "GetExecution": { + "methods": [ + "get_execution" + ] + }, + "GetMetadataSchema": { + "methods": [ + "get_metadata_schema" + ] + }, + "GetMetadataStore": { + "methods": [ + "get_metadata_store" + ] + }, + "ListArtifacts": { + "methods": [ + "list_artifacts" + ] + }, + "ListContexts": { + "methods": [ + "list_contexts" + ] + }, + "ListExecutions": { + "methods": [ + "list_executions" + ] + }, + "ListMetadataSchemas": { + "methods": [ + "list_metadata_schemas" + ] + }, + "ListMetadataStores": { + "methods": [ + "list_metadata_stores" + ] + }, + "QueryArtifactLineageSubgraph": { + "methods": [ + "query_artifact_lineage_subgraph" + ] + }, + "QueryContextLineageSubgraph": { + "methods": [ + "query_context_lineage_subgraph" + ] + }, + "QueryExecutionInputsAndOutputs": { + "methods": [ + "query_execution_inputs_and_outputs" + ] + }, + "UpdateArtifact": { + "methods": [ + "update_artifact" + ] + }, + "UpdateContext": { + "methods": [ + "update_context" + ] + }, + "UpdateExecution": { + "methods": [ + "update_execution" + ] + } + } + }, + "grpc-async": { + "libraryClient": "MetadataServiceAsyncClient", + "rpcs": { + "AddContextArtifactsAndExecutions": { + "methods": [ + "add_context_artifacts_and_executions" + ] + }, + "AddContextChildren": { + "methods": [ + "add_context_children" + ] + }, + "AddExecutionEvents": { + "methods": [ + "add_execution_events" + ] + }, + "CreateArtifact": { + "methods": [ + "create_artifact" + ] + }, + "CreateContext": { + "methods": [ + "create_context" + ] + }, + "CreateExecution": { + "methods": [ + "create_execution" + ] + }, + "CreateMetadataSchema": { + "methods": [ + "create_metadata_schema" + ] + }, + "CreateMetadataStore": { + "methods": [ + "create_metadata_store" + ] + }, + "DeleteContext": { + "methods": [ + "delete_context" + ] + }, + "DeleteMetadataStore": { + "methods": [ + "delete_metadata_store" + ] + }, + "GetArtifact": { + "methods": [ + "get_artifact" + ] + }, + "GetContext": { + "methods": [ + "get_context" + ] + }, + "GetExecution": { + "methods": [ + "get_execution" + ] + }, + "GetMetadataSchema": { + "methods": [ + "get_metadata_schema" + ] + }, + "GetMetadataStore": { + "methods": [ + "get_metadata_store" + ] + }, + "ListArtifacts": { + "methods": [ + "list_artifacts" + ] + }, + "ListContexts": { + "methods": [ + "list_contexts" + ] + }, + "ListExecutions": { + "methods": [ + "list_executions" + ] + }, + "ListMetadataSchemas": { + "methods": [ + "list_metadata_schemas" + ] + }, + "ListMetadataStores": { + "methods": [ + "list_metadata_stores" + ] + }, + "QueryArtifactLineageSubgraph": { + "methods": [ + "query_artifact_lineage_subgraph" + ] + }, + "QueryContextLineageSubgraph": { + "methods": [ + "query_context_lineage_subgraph" + ] + }, + "QueryExecutionInputsAndOutputs": { + "methods": [ + "query_execution_inputs_and_outputs" + ] + }, + "UpdateArtifact": { + "methods": [ + "update_artifact" + ] + }, + "UpdateContext": { + "methods": [ + "update_context" + ] + }, + "UpdateExecution": { + "methods": [ + "update_execution" + ] + } + } + } + } + }, + "MigrationService": { + "clients": { + "grpc": { + "libraryClient": "MigrationServiceClient", + "rpcs": { + "BatchMigrateResources": { + "methods": [ + "batch_migrate_resources" + ] + }, + "SearchMigratableResources": { + "methods": [ + "search_migratable_resources" + ] + } + } + }, + "grpc-async": { + "libraryClient": "MigrationServiceAsyncClient", + "rpcs": { + "BatchMigrateResources": { + "methods": [ + "batch_migrate_resources" + ] + }, + "SearchMigratableResources": { + "methods": [ + "search_migratable_resources" + ] + } + } + } + } + }, + "ModelService": { + "clients": { + "grpc": { + "libraryClient": "ModelServiceClient", + "rpcs": { + "DeleteModel": { + "methods": [ + "delete_model" + ] + }, + "ExportModel": { + "methods": [ + "export_model" + ] + }, + "GetModel": { + "methods": [ + "get_model" + ] + }, + "GetModelEvaluation": { + "methods": [ + "get_model_evaluation" + ] + }, + "GetModelEvaluationSlice": { + "methods": [ + "get_model_evaluation_slice" + ] + }, + "ListModelEvaluationSlices": { + "methods": [ + "list_model_evaluation_slices" + ] + }, + "ListModelEvaluations": { + "methods": [ + "list_model_evaluations" + ] + }, + "ListModels": { + "methods": [ + "list_models" + ] + }, + "UpdateModel": { + "methods": [ + "update_model" + ] + }, + "UploadModel": { + "methods": [ + "upload_model" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ModelServiceAsyncClient", + "rpcs": { + "DeleteModel": { + "methods": [ + "delete_model" + ] + }, + "ExportModel": { + "methods": [ + "export_model" + ] + }, + "GetModel": { + "methods": [ + "get_model" + ] + }, + "GetModelEvaluation": { + "methods": [ + "get_model_evaluation" + ] + }, + "GetModelEvaluationSlice": { + "methods": [ + "get_model_evaluation_slice" + ] + }, + "ListModelEvaluationSlices": { + "methods": [ + "list_model_evaluation_slices" + ] + }, + "ListModelEvaluations": { + "methods": [ + "list_model_evaluations" + ] + }, + "ListModels": { + "methods": [ + "list_models" + ] + }, + "UpdateModel": { + "methods": [ + "update_model" + ] + }, + "UploadModel": { + "methods": [ + "upload_model" + ] + } + } + } + } + }, + "PipelineService": { + "clients": { + "grpc": { + "libraryClient": "PipelineServiceClient", + "rpcs": { + "CancelPipelineJob": { + "methods": [ + "cancel_pipeline_job" + ] + }, + "CancelTrainingPipeline": { + "methods": [ + "cancel_training_pipeline" + ] + }, + "CreatePipelineJob": { + "methods": [ + "create_pipeline_job" + ] + }, + "CreateTrainingPipeline": { + "methods": [ + "create_training_pipeline" + ] + }, + "DeletePipelineJob": { + "methods": [ + "delete_pipeline_job" + ] + }, + "DeleteTrainingPipeline": { + "methods": [ + "delete_training_pipeline" + ] + }, + "GetPipelineJob": { + "methods": [ + "get_pipeline_job" + ] + }, + "GetTrainingPipeline": { + "methods": [ + "get_training_pipeline" + ] + }, + "ListPipelineJobs": { + "methods": [ + "list_pipeline_jobs" + ] + }, + "ListTrainingPipelines": { + "methods": [ + "list_training_pipelines" + ] + } + } + }, + "grpc-async": { + "libraryClient": "PipelineServiceAsyncClient", + "rpcs": { + "CancelPipelineJob": { + "methods": [ + "cancel_pipeline_job" + ] + }, + "CancelTrainingPipeline": { + "methods": [ + "cancel_training_pipeline" + ] + }, + "CreatePipelineJob": { + "methods": [ + "create_pipeline_job" + ] + }, + "CreateTrainingPipeline": { + "methods": [ + "create_training_pipeline" + ] + }, + "DeletePipelineJob": { + "methods": [ + "delete_pipeline_job" + ] + }, + "DeleteTrainingPipeline": { + "methods": [ + "delete_training_pipeline" + ] + }, + "GetPipelineJob": { + "methods": [ + "get_pipeline_job" + ] + }, + "GetTrainingPipeline": { + "methods": [ + "get_training_pipeline" + ] + }, + "ListPipelineJobs": { + "methods": [ + "list_pipeline_jobs" + ] + }, + "ListTrainingPipelines": { + "methods": [ + "list_training_pipelines" + ] + } + } + } + } + }, + "PredictionService": { + "clients": { + "grpc": { + "libraryClient": "PredictionServiceClient", + "rpcs": { + "Explain": { + "methods": [ + "explain" + ] + }, + "Predict": { + "methods": [ + "predict" + ] + } + } + }, + "grpc-async": { + "libraryClient": "PredictionServiceAsyncClient", + "rpcs": { + "Explain": { + "methods": [ + "explain" + ] + }, + "Predict": { + "methods": [ + "predict" + ] + } + } + } + } + }, + "SpecialistPoolService": { + "clients": { + "grpc": { + "libraryClient": "SpecialistPoolServiceClient", + "rpcs": { + "CreateSpecialistPool": { + "methods": [ + "create_specialist_pool" + ] + }, + "DeleteSpecialistPool": { + "methods": [ + "delete_specialist_pool" + ] + }, + "GetSpecialistPool": { + "methods": [ + "get_specialist_pool" + ] + }, + "ListSpecialistPools": { + "methods": [ + "list_specialist_pools" + ] + }, + "UpdateSpecialistPool": { + "methods": [ + "update_specialist_pool" + ] + } + } + }, + "grpc-async": { + "libraryClient": "SpecialistPoolServiceAsyncClient", + "rpcs": { + "CreateSpecialistPool": { + "methods": [ + "create_specialist_pool" + ] + }, + "DeleteSpecialistPool": { + "methods": [ + "delete_specialist_pool" + ] + }, + "GetSpecialistPool": { + "methods": [ + "get_specialist_pool" + ] + }, + "ListSpecialistPools": { + "methods": [ + "list_specialist_pools" + ] + }, + "UpdateSpecialistPool": { + "methods": [ + "update_specialist_pool" + ] + } + } + } + } + }, + "TensorboardService": { + "clients": { + "grpc": { + "libraryClient": "TensorboardServiceClient", + "rpcs": { + "CreateTensorboard": { + "methods": [ + "create_tensorboard" + ] + }, + "CreateTensorboardExperiment": { + "methods": [ + "create_tensorboard_experiment" + ] + }, + "CreateTensorboardRun": { + "methods": [ + "create_tensorboard_run" + ] + }, + "CreateTensorboardTimeSeries": { + "methods": [ + "create_tensorboard_time_series" + ] + }, + "DeleteTensorboard": { + "methods": [ + "delete_tensorboard" + ] + }, + "DeleteTensorboardExperiment": { + "methods": [ + "delete_tensorboard_experiment" + ] + }, + "DeleteTensorboardRun": { + "methods": [ + "delete_tensorboard_run" + ] + }, + "DeleteTensorboardTimeSeries": { + "methods": [ + "delete_tensorboard_time_series" + ] + }, + "ExportTensorboardTimeSeriesData": { + "methods": [ + "export_tensorboard_time_series_data" + ] + }, + "GetTensorboard": { + "methods": [ + "get_tensorboard" + ] + }, + "GetTensorboardExperiment": { + "methods": [ + "get_tensorboard_experiment" + ] + }, + "GetTensorboardRun": { + "methods": [ + "get_tensorboard_run" + ] + }, + "GetTensorboardTimeSeries": { + "methods": [ + "get_tensorboard_time_series" + ] + }, + "ListTensorboardExperiments": { + "methods": [ + "list_tensorboard_experiments" + ] + }, + "ListTensorboardRuns": { + "methods": [ + "list_tensorboard_runs" + ] + }, + "ListTensorboardTimeSeries": { + "methods": [ + "list_tensorboard_time_series" + ] + }, + "ListTensorboards": { + "methods": [ + "list_tensorboards" + ] + }, + "ReadTensorboardBlobData": { + "methods": [ + "read_tensorboard_blob_data" + ] + }, + "ReadTensorboardTimeSeriesData": { + "methods": [ + "read_tensorboard_time_series_data" + ] + }, + "UpdateTensorboard": { + "methods": [ + "update_tensorboard" + ] + }, + "UpdateTensorboardExperiment": { + "methods": [ + "update_tensorboard_experiment" + ] + }, + "UpdateTensorboardRun": { + "methods": [ + "update_tensorboard_run" + ] + }, + "UpdateTensorboardTimeSeries": { + "methods": [ + "update_tensorboard_time_series" + ] + }, + "WriteTensorboardRunData": { + "methods": [ + "write_tensorboard_run_data" + ] + } + } + }, + "grpc-async": { + "libraryClient": "TensorboardServiceAsyncClient", + "rpcs": { + "CreateTensorboard": { + "methods": [ + "create_tensorboard" + ] + }, + "CreateTensorboardExperiment": { + "methods": [ + "create_tensorboard_experiment" + ] + }, + "CreateTensorboardRun": { + "methods": [ + "create_tensorboard_run" + ] + }, + "CreateTensorboardTimeSeries": { + "methods": [ + "create_tensorboard_time_series" + ] + }, + "DeleteTensorboard": { + "methods": [ + "delete_tensorboard" + ] + }, + "DeleteTensorboardExperiment": { + "methods": [ + "delete_tensorboard_experiment" + ] + }, + "DeleteTensorboardRun": { + "methods": [ + "delete_tensorboard_run" + ] + }, + "DeleteTensorboardTimeSeries": { + "methods": [ + "delete_tensorboard_time_series" + ] + }, + "ExportTensorboardTimeSeriesData": { + "methods": [ + "export_tensorboard_time_series_data" + ] + }, + "GetTensorboard": { + "methods": [ + "get_tensorboard" + ] + }, + "GetTensorboardExperiment": { + "methods": [ + "get_tensorboard_experiment" + ] + }, + "GetTensorboardRun": { + "methods": [ + "get_tensorboard_run" + ] + }, + "GetTensorboardTimeSeries": { + "methods": [ + "get_tensorboard_time_series" + ] + }, + "ListTensorboardExperiments": { + "methods": [ + "list_tensorboard_experiments" + ] + }, + "ListTensorboardRuns": { + "methods": [ + "list_tensorboard_runs" + ] + }, + "ListTensorboardTimeSeries": { + "methods": [ + "list_tensorboard_time_series" + ] + }, + "ListTensorboards": { + "methods": [ + "list_tensorboards" + ] + }, + "ReadTensorboardBlobData": { + "methods": [ + "read_tensorboard_blob_data" + ] + }, + "ReadTensorboardTimeSeriesData": { + "methods": [ + "read_tensorboard_time_series_data" + ] + }, + "UpdateTensorboard": { + "methods": [ + "update_tensorboard" + ] + }, + "UpdateTensorboardExperiment": { + "methods": [ + "update_tensorboard_experiment" + ] + }, + "UpdateTensorboardRun": { + "methods": [ + "update_tensorboard_run" + ] + }, + "UpdateTensorboardTimeSeries": { + "methods": [ + "update_tensorboard_time_series" + ] + }, + "WriteTensorboardRunData": { + "methods": [ + "write_tensorboard_run_data" + ] + } + } + } + } + }, + "VizierService": { + "clients": { + "grpc": { + "libraryClient": "VizierServiceClient", + "rpcs": { + "AddTrialMeasurement": { + "methods": [ + "add_trial_measurement" + ] + }, + "CheckTrialEarlyStoppingState": { + "methods": [ + "check_trial_early_stopping_state" + ] + }, + "CompleteTrial": { + "methods": [ + "complete_trial" + ] + }, + "CreateStudy": { + "methods": [ + "create_study" + ] + }, + "CreateTrial": { + "methods": [ + "create_trial" + ] + }, + "DeleteStudy": { + "methods": [ + "delete_study" + ] + }, + "DeleteTrial": { + "methods": [ + "delete_trial" + ] + }, + "GetStudy": { + "methods": [ + "get_study" + ] + }, + "GetTrial": { + "methods": [ + "get_trial" + ] + }, + "ListOptimalTrials": { + "methods": [ + "list_optimal_trials" + ] + }, + "ListStudies": { + "methods": [ + "list_studies" + ] + }, + "ListTrials": { + "methods": [ + "list_trials" + ] + }, + "LookupStudy": { + "methods": [ + "lookup_study" + ] + }, + "StopTrial": { + "methods": [ + "stop_trial" + ] + }, + "SuggestTrials": { + "methods": [ + "suggest_trials" + ] + } + } + }, + "grpc-async": { + "libraryClient": "VizierServiceAsyncClient", + "rpcs": { + "AddTrialMeasurement": { + "methods": [ + "add_trial_measurement" + ] + }, + "CheckTrialEarlyStoppingState": { + "methods": [ + "check_trial_early_stopping_state" + ] + }, + "CompleteTrial": { + "methods": [ + "complete_trial" + ] + }, + "CreateStudy": { + "methods": [ + "create_study" + ] + }, + "CreateTrial": { + "methods": [ + "create_trial" + ] + }, + "DeleteStudy": { + "methods": [ + "delete_study" + ] + }, + "DeleteTrial": { + "methods": [ + "delete_trial" + ] + }, + "GetStudy": { + "methods": [ + "get_study" + ] + }, + "GetTrial": { + "methods": [ + "get_trial" + ] + }, + "ListOptimalTrials": { + "methods": [ + "list_optimal_trials" + ] + }, + "ListStudies": { + "methods": [ + "list_studies" + ] + }, + "ListTrials": { + "methods": [ + "list_trials" + ] + }, + "LookupStudy": { + "methods": [ + "lookup_study" + ] + }, + "StopTrial": { + "methods": [ + "stop_trial" + ] + }, + "SuggestTrials": { + "methods": [ + "suggest_trials" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/aiplatform_v1beta1/services/__init__.py b/google/cloud/aiplatform_v1beta1/services/__init__.py index 42ffdf2bc4..4de65971c2 100644 --- a/google/cloud/aiplatform_v1beta1/services/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/__init__.py index 597f654cb9..42adf5e5af 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import DatasetServiceClient from .async_client import DatasetServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/async_client.py index 5b3e917e98..1ef85adee3 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -39,11 +37,10 @@ from google.cloud.aiplatform_v1beta1.types import dataset_service from google.cloud.aiplatform_v1beta1.types import encryption_spec from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import DatasetServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import DatasetServiceGrpcAsyncIOTransport from .client import DatasetServiceClient @@ -67,31 +64,26 @@ class DatasetServiceAsyncClient: parse_data_item_path = staticmethod(DatasetServiceClient.parse_data_item_path) dataset_path = staticmethod(DatasetServiceClient.dataset_path) parse_dataset_path = staticmethod(DatasetServiceClient.parse_dataset_path) - common_billing_account_path = staticmethod( DatasetServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( DatasetServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(DatasetServiceClient.common_folder_path) parse_common_folder_path = staticmethod( DatasetServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( DatasetServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( DatasetServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(DatasetServiceClient.common_project_path) parse_common_project_path = staticmethod( DatasetServiceClient.parse_common_project_path ) - common_location_path = staticmethod(DatasetServiceClient.common_location_path) parse_common_location_path = staticmethod( DatasetServiceClient.parse_common_location_path @@ -145,7 +137,7 @@ def transport(self) -> DatasetServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, DatasetServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -182,7 +174,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = DatasetServiceClient( credentials=credentials, transport=transport, @@ -219,7 +210,6 @@ async def create_dataset( This corresponds to the ``dataset`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -249,7 +239,6 @@ async def create_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if dataset is not None: @@ -305,7 +294,6 @@ async def get_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -332,7 +320,6 @@ async def get_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -361,7 +348,7 @@ async def update_dataset( request: dataset_service.UpdateDatasetRequest = None, *, dataset: gca_dataset.Dataset = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -392,7 +379,6 @@ async def update_dataset( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -419,7 +405,6 @@ async def update_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if dataset is not None: request.dataset = dataset if update_mask is not None: @@ -469,7 +454,6 @@ async def list_datasets( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -499,7 +483,6 @@ async def list_datasets( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -552,7 +535,6 @@ async def delete_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -592,7 +574,6 @@ async def delete_dataset( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -617,7 +598,7 @@ async def delete_dataset( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -655,7 +636,6 @@ async def import_data( This corresponds to the ``import_configs`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -686,10 +666,8 @@ async def import_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name - if import_configs: request.import_configs.extend(import_configs) @@ -751,7 +729,6 @@ async def export_data( This corresponds to the ``export_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -782,7 +759,6 @@ async def export_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if export_config is not None: @@ -839,7 +815,6 @@ async def list_data_items( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -869,7 +844,6 @@ async def list_data_items( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -922,7 +896,6 @@ async def get_annotation_spec( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -949,7 +922,6 @@ async def get_annotation_spec( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -996,7 +968,6 @@ async def list_annotations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1026,7 +997,6 @@ async def list_annotations( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py index 4243557717..140646f861 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -43,11 +41,10 @@ from google.cloud.aiplatform_v1beta1.types import dataset_service from google.cloud.aiplatform_v1beta1.types import encryption_spec from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import DatasetServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import DatasetServiceGrpcTransport from .transports.grpc_asyncio import DatasetServiceGrpcAsyncIOTransport @@ -307,7 +304,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, DatasetServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -446,7 +443,6 @@ def create_dataset( This corresponds to the ``dataset`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -478,10 +474,8 @@ def create_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.CreateDatasetRequest): request = dataset_service.CreateDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if dataset is not None: @@ -533,7 +527,6 @@ def get_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -562,10 +555,8 @@ def get_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.GetDatasetRequest): request = dataset_service.GetDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -590,7 +581,7 @@ def update_dataset( request: dataset_service.UpdateDatasetRequest = None, *, dataset: gca_dataset.Dataset = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -621,7 +612,6 @@ def update_dataset( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -650,10 +640,8 @@ def update_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.UpdateDatasetRequest): request = dataset_service.UpdateDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if dataset is not None: request.dataset = dataset if update_mask is not None: @@ -699,7 +687,6 @@ def list_datasets( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -731,10 +718,8 @@ def list_datasets( # there are no flattened fields. if not isinstance(request, dataset_service.ListDatasetsRequest): request = dataset_service.ListDatasetsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -783,7 +768,6 @@ def delete_dataset( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -825,10 +809,8 @@ def delete_dataset( # there are no flattened fields. if not isinstance(request, dataset_service.DeleteDatasetRequest): request = dataset_service.DeleteDatasetRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -849,7 +831,7 @@ def delete_dataset( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -887,7 +869,6 @@ def import_data( This corresponds to the ``import_configs`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -920,10 +901,8 @@ def import_data( # there are no flattened fields. if not isinstance(request, dataset_service.ImportDataRequest): request = dataset_service.ImportDataRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if import_configs is not None: @@ -983,7 +962,6 @@ def export_data( This corresponds to the ``export_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1016,10 +994,8 @@ def export_data( # there are no flattened fields. if not isinstance(request, dataset_service.ExportDataRequest): request = dataset_service.ExportDataRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if export_config is not None: @@ -1072,7 +1048,6 @@ def list_data_items( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1104,10 +1079,8 @@ def list_data_items( # there are no flattened fields. if not isinstance(request, dataset_service.ListDataItemsRequest): request = dataset_service.ListDataItemsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1156,7 +1129,6 @@ def get_annotation_spec( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1185,10 +1157,8 @@ def get_annotation_spec( # there are no flattened fields. if not isinstance(request, dataset_service.GetAnnotationSpecRequest): request = dataset_service.GetAnnotationSpecRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1231,7 +1201,6 @@ def list_annotations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1263,10 +1232,8 @@ def list_annotations( # there are no flattened fields. if not isinstance(request, dataset_service.ListAnnotationsRequest): request = dataset_service.ListAnnotationsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/pagers.py index 63560b32ba..f57caea0a6 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__init__.py index a4461d2ced..902a4fb01f 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py index 75dc66a554..f7998abdf1 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import annotation_spec from google.cloud.aiplatform_v1beta1.types import dataset from google.cloud.aiplatform_v1beta1.types import dataset as gca_dataset from google.cloud.aiplatform_v1beta1.types import dataset_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -42,27 +41,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class DatasetServiceTransport(abc.ABC): """Abstract transport class for DatasetService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -71,7 +84,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -85,29 +98,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -151,38 +211,38 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.CreateDatasetRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.GetDatasetRequest], - typing.Union[dataset.Dataset, typing.Awaitable[dataset.Dataset]], + Union[dataset.Dataset, Awaitable[dataset.Dataset]], ]: raise NotImplementedError() @property def update_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.UpdateDatasetRequest], - typing.Union[gca_dataset.Dataset, typing.Awaitable[gca_dataset.Dataset]], + Union[gca_dataset.Dataset, Awaitable[gca_dataset.Dataset]], ]: raise NotImplementedError() @property def list_datasets( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ListDatasetsRequest], - typing.Union[ + Union[ dataset_service.ListDatasetsResponse, - typing.Awaitable[dataset_service.ListDatasetsResponse], + Awaitable[dataset_service.ListDatasetsResponse], ], ]: raise NotImplementedError() @@ -190,38 +250,38 @@ def list_datasets( @property def delete_dataset( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.DeleteDatasetRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def import_data( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ImportDataRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def export_data( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ExportDataRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_data_items( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ListDataItemsRequest], - typing.Union[ + Union[ dataset_service.ListDataItemsResponse, - typing.Awaitable[dataset_service.ListDataItemsResponse], + Awaitable[dataset_service.ListDataItemsResponse], ], ]: raise NotImplementedError() @@ -229,11 +289,10 @@ def list_data_items( @property def get_annotation_spec( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.GetAnnotationSpecRequest], - typing.Union[ - annotation_spec.AnnotationSpec, - typing.Awaitable[annotation_spec.AnnotationSpec], + Union[ + annotation_spec.AnnotationSpec, Awaitable[annotation_spec.AnnotationSpec] ], ]: raise NotImplementedError() @@ -241,11 +300,11 @@ def get_annotation_spec( @property def list_annotations( self, - ) -> typing.Callable[ + ) -> Callable[ [dataset_service.ListAnnotationsRequest], - typing.Union[ + Union[ dataset_service.ListAnnotationsResponse, - typing.Awaitable[dataset_service.ListAnnotationsResponse], + Awaitable[dataset_service.ListAnnotationsResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py index ca597a1e69..acadef836f 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -31,8 +29,7 @@ from google.cloud.aiplatform_v1beta1.types import dataset from google.cloud.aiplatform_v1beta1.types import dataset as gca_dataset from google.cloud.aiplatform_v1beta1.types import dataset_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DatasetServiceTransport, DEFAULT_CLIENT_INFO @@ -53,7 +50,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -67,7 +64,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -178,7 +176,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -209,13 +207,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -242,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_dataset( self, - ) -> Callable[[dataset_service.CreateDatasetRequest], operations.Operation]: + ) -> Callable[[dataset_service.CreateDatasetRequest], operations_pb2.Operation]: r"""Return a callable for the create dataset method over gRPC. Creates a Dataset. @@ -261,7 +261,7 @@ def create_dataset( self._stubs["create_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/CreateDataset", request_serializer=dataset_service.CreateDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset"] @@ -348,7 +348,7 @@ def list_datasets( @property def delete_dataset( self, - ) -> Callable[[dataset_service.DeleteDatasetRequest], operations.Operation]: + ) -> Callable[[dataset_service.DeleteDatasetRequest], operations_pb2.Operation]: r"""Return a callable for the delete dataset method over gRPC. Deletes a Dataset. @@ -367,14 +367,14 @@ def delete_dataset( self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/DeleteDataset", request_serializer=dataset_service.DeleteDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset"] @property def import_data( self, - ) -> Callable[[dataset_service.ImportDataRequest], operations.Operation]: + ) -> Callable[[dataset_service.ImportDataRequest], operations_pb2.Operation]: r"""Return a callable for the import data method over gRPC. Imports data into a Dataset. @@ -393,14 +393,14 @@ def import_data( self._stubs["import_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/ImportData", request_serializer=dataset_service.ImportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_data"] @property def export_data( self, - ) -> Callable[[dataset_service.ExportDataRequest], operations.Operation]: + ) -> Callable[[dataset_service.ExportDataRequest], operations_pb2.Operation]: r"""Return a callable for the export data method over gRPC. Exports data from a Dataset. @@ -419,7 +419,7 @@ def export_data( self._stubs["export_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/ExportData", request_serializer=dataset_service.ExportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_data"] diff --git a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py index f51fe3bf1b..adee8b98ea 100644 --- a/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -32,8 +30,7 @@ from google.cloud.aiplatform_v1beta1.types import dataset from google.cloud.aiplatform_v1beta1.types import dataset as gca_dataset from google.cloud.aiplatform_v1beta1.types import dataset_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DatasetServiceTransport, DEFAULT_CLIENT_INFO from .grpc import DatasetServiceGrpcTransport @@ -56,7 +53,7 @@ class DatasetServiceGrpcAsyncIOTransport(DatasetServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -83,13 +80,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -97,7 +96,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -111,7 +110,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -170,7 +170,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -249,7 +248,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: def create_dataset( self, ) -> Callable[ - [dataset_service.CreateDatasetRequest], Awaitable[operations.Operation] + [dataset_service.CreateDatasetRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create dataset method over gRPC. @@ -269,7 +268,7 @@ def create_dataset( self._stubs["create_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/CreateDataset", request_serializer=dataset_service.CreateDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_dataset"] @@ -360,7 +359,7 @@ def list_datasets( def delete_dataset( self, ) -> Callable[ - [dataset_service.DeleteDatasetRequest], Awaitable[operations.Operation] + [dataset_service.DeleteDatasetRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete dataset method over gRPC. @@ -380,14 +379,16 @@ def delete_dataset( self._stubs["delete_dataset"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/DeleteDataset", request_serializer=dataset_service.DeleteDatasetRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_dataset"] @property def import_data( self, - ) -> Callable[[dataset_service.ImportDataRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [dataset_service.ImportDataRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the import data method over gRPC. Imports data into a Dataset. @@ -406,14 +407,16 @@ def import_data( self._stubs["import_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/ImportData", request_serializer=dataset_service.ImportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_data"] @property def export_data( self, - ) -> Callable[[dataset_service.ExportDataRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [dataset_service.ExportDataRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the export data method over gRPC. Exports data from a Dataset. @@ -432,7 +435,7 @@ def export_data( self._stubs["export_data"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.DatasetService/ExportData", request_serializer=dataset_service.ExportDataRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_data"] diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/__init__.py index 035a5b2388..96fb4ad6d6 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import EndpointServiceClient from .async_client import EndpointServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/async_client.py index 1ca925e2d7..fc38381f98 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -36,10 +34,9 @@ from google.cloud.aiplatform_v1beta1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1beta1.types import endpoint_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import EndpointServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import EndpointServiceGrpcAsyncIOTransport from .client import EndpointServiceClient @@ -57,31 +54,26 @@ class EndpointServiceAsyncClient: parse_endpoint_path = staticmethod(EndpointServiceClient.parse_endpoint_path) model_path = staticmethod(EndpointServiceClient.model_path) parse_model_path = staticmethod(EndpointServiceClient.parse_model_path) - common_billing_account_path = staticmethod( EndpointServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( EndpointServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(EndpointServiceClient.common_folder_path) parse_common_folder_path = staticmethod( EndpointServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( EndpointServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( EndpointServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(EndpointServiceClient.common_project_path) parse_common_project_path = staticmethod( EndpointServiceClient.parse_common_project_path ) - common_location_path = staticmethod(EndpointServiceClient.common_location_path) parse_common_location_path = staticmethod( EndpointServiceClient.parse_common_location_path @@ -135,7 +127,7 @@ def transport(self) -> EndpointServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, EndpointServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -172,7 +164,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = EndpointServiceClient( credentials=credentials, transport=transport, @@ -209,7 +200,6 @@ async def create_endpoint( This corresponds to the ``endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -238,7 +228,6 @@ async def create_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if endpoint is not None: @@ -294,7 +283,6 @@ async def get_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -322,7 +310,6 @@ async def get_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -369,7 +356,6 @@ async def list_endpoints( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -399,7 +385,6 @@ async def list_endpoints( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -434,7 +419,7 @@ async def update_endpoint( request: endpoint_service.UpdateEndpointRequest = None, *, endpoint: gca_endpoint.Endpoint = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -459,7 +444,6 @@ async def update_endpoint( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -487,7 +471,6 @@ async def update_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if update_mask is not None: @@ -538,7 +521,6 @@ async def delete_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -578,7 +560,6 @@ async def delete_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -603,7 +584,7 @@ async def delete_endpoint( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -669,7 +650,6 @@ async def deploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -700,7 +680,6 @@ async def deploy_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model is not None: @@ -787,7 +766,6 @@ async def undeploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -818,7 +796,6 @@ async def undeploy_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model_id is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py index fa5add8a52..2b9b6b1146 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -40,10 +38,9 @@ from google.cloud.aiplatform_v1beta1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1beta1.types import endpoint_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import EndpointServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import EndpointServiceGrpcTransport from .transports.grpc_asyncio import EndpointServiceGrpcAsyncIOTransport @@ -258,7 +255,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, EndpointServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -397,7 +394,6 @@ def create_endpoint( This corresponds to the ``endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -428,10 +424,8 @@ def create_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.CreateEndpointRequest): request = endpoint_service.CreateEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if endpoint is not None: @@ -483,7 +477,6 @@ def get_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -513,10 +506,8 @@ def get_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.GetEndpointRequest): request = endpoint_service.GetEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -559,7 +550,6 @@ def list_endpoints( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -591,10 +581,8 @@ def list_endpoints( # there are no flattened fields. if not isinstance(request, endpoint_service.ListEndpointsRequest): request = endpoint_service.ListEndpointsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -625,7 +613,7 @@ def update_endpoint( request: endpoint_service.UpdateEndpointRequest = None, *, endpoint: gca_endpoint.Endpoint = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -650,7 +638,6 @@ def update_endpoint( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -680,10 +667,8 @@ def update_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.UpdateEndpointRequest): request = endpoint_service.UpdateEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if update_mask is not None: @@ -730,7 +715,6 @@ def delete_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -772,10 +756,8 @@ def delete_endpoint( # there are no flattened fields. if not isinstance(request, endpoint_service.DeleteEndpointRequest): request = endpoint_service.DeleteEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -796,7 +778,7 @@ def delete_endpoint( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -862,7 +844,6 @@ def deploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -895,10 +876,8 @@ def deploy_model( # there are no flattened fields. if not isinstance(request, endpoint_service.DeployModelRequest): request = endpoint_service.DeployModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model is not None: @@ -980,7 +959,6 @@ def undeploy_model( This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1013,10 +991,8 @@ def undeploy_model( # there are no flattened fields. if not isinstance(request, endpoint_service.UndeployModelRequest): request = endpoint_service.UndeployModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if deployed_model_id is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/pagers.py index db3172bcef..b16d1cf1a1 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/__init__.py index 3d0695461d..4d336c5875 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py index 9ff0668d04..12d5e3d32b 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import endpoint from google.cloud.aiplatform_v1beta1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1beta1.types import endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -41,27 +40,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class EndpointServiceTransport(abc.ABC): """Abstract transport class for EndpointService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -70,7 +83,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -84,29 +97,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -141,29 +201,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.CreateEndpointRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.GetEndpointRequest], - typing.Union[endpoint.Endpoint, typing.Awaitable[endpoint.Endpoint]], + Union[endpoint.Endpoint, Awaitable[endpoint.Endpoint]], ]: raise NotImplementedError() @property def list_endpoints( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.ListEndpointsRequest], - typing.Union[ + Union[ endpoint_service.ListEndpointsResponse, - typing.Awaitable[endpoint_service.ListEndpointsResponse], + Awaitable[endpoint_service.ListEndpointsResponse], ], ]: raise NotImplementedError() @@ -171,36 +231,36 @@ def list_endpoints( @property def update_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.UpdateEndpointRequest], - typing.Union[gca_endpoint.Endpoint, typing.Awaitable[gca_endpoint.Endpoint]], + Union[gca_endpoint.Endpoint, Awaitable[gca_endpoint.Endpoint]], ]: raise NotImplementedError() @property def delete_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.DeleteEndpointRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def deploy_model( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.DeployModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def undeploy_model( self, - ) -> typing.Callable[ + ) -> Callable[ [endpoint_service.UndeployModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py index 8943c2f3f0..be43928032 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -30,8 +28,7 @@ from google.cloud.aiplatform_v1beta1.types import endpoint from google.cloud.aiplatform_v1beta1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1beta1.types import endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import EndpointServiceTransport, DEFAULT_CLIENT_INFO @@ -52,7 +49,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -66,7 +63,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -177,7 +175,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -208,13 +206,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -241,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_endpoint( self, - ) -> Callable[[endpoint_service.CreateEndpointRequest], operations.Operation]: + ) -> Callable[[endpoint_service.CreateEndpointRequest], operations_pb2.Operation]: r"""Return a callable for the create endpoint method over gRPC. Creates an Endpoint. @@ -260,7 +260,7 @@ def create_endpoint( self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/CreateEndpoint", request_serializer=endpoint_service.CreateEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_endpoint"] @@ -347,7 +347,7 @@ def update_endpoint( @property def delete_endpoint( self, - ) -> Callable[[endpoint_service.DeleteEndpointRequest], operations.Operation]: + ) -> Callable[[endpoint_service.DeleteEndpointRequest], operations_pb2.Operation]: r"""Return a callable for the delete endpoint method over gRPC. Deletes an Endpoint. @@ -366,14 +366,14 @@ def delete_endpoint( self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/DeleteEndpoint", request_serializer=endpoint_service.DeleteEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_endpoint"] @property def deploy_model( self, - ) -> Callable[[endpoint_service.DeployModelRequest], operations.Operation]: + ) -> Callable[[endpoint_service.DeployModelRequest], operations_pb2.Operation]: r"""Return a callable for the deploy model method over gRPC. Deploys a Model into this Endpoint, creating a @@ -393,14 +393,14 @@ def deploy_model( self._stubs["deploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/DeployModel", request_serializer=endpoint_service.DeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_model"] @property def undeploy_model( self, - ) -> Callable[[endpoint_service.UndeployModelRequest], operations.Operation]: + ) -> Callable[[endpoint_service.UndeployModelRequest], operations_pb2.Operation]: r"""Return a callable for the undeploy model method over gRPC. Undeploys a Model from an Endpoint, removing a @@ -421,7 +421,7 @@ def undeploy_model( self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/UndeployModel", request_serializer=endpoint_service.UndeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_model"] diff --git a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py index 141168146d..d4273fd3be 100644 --- a/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/endpoint_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -31,8 +29,7 @@ from google.cloud.aiplatform_v1beta1.types import endpoint from google.cloud.aiplatform_v1beta1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1beta1.types import endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import EndpointServiceTransport, DEFAULT_CLIENT_INFO from .grpc import EndpointServiceGrpcTransport @@ -55,7 +52,7 @@ class EndpointServiceGrpcAsyncIOTransport(EndpointServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -82,13 +79,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -96,7 +95,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -110,7 +109,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -169,7 +169,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -248,7 +247,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: def create_endpoint( self, ) -> Callable[ - [endpoint_service.CreateEndpointRequest], Awaitable[operations.Operation] + [endpoint_service.CreateEndpointRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create endpoint method over gRPC. @@ -268,7 +267,7 @@ def create_endpoint( self._stubs["create_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/CreateEndpoint", request_serializer=endpoint_service.CreateEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_endpoint"] @@ -359,7 +358,7 @@ def update_endpoint( def delete_endpoint( self, ) -> Callable[ - [endpoint_service.DeleteEndpointRequest], Awaitable[operations.Operation] + [endpoint_service.DeleteEndpointRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete endpoint method over gRPC. @@ -379,7 +378,7 @@ def delete_endpoint( self._stubs["delete_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/DeleteEndpoint", request_serializer=endpoint_service.DeleteEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_endpoint"] @@ -387,7 +386,7 @@ def delete_endpoint( def deploy_model( self, ) -> Callable[ - [endpoint_service.DeployModelRequest], Awaitable[operations.Operation] + [endpoint_service.DeployModelRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the deploy model method over gRPC. @@ -408,7 +407,7 @@ def deploy_model( self._stubs["deploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/DeployModel", request_serializer=endpoint_service.DeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_model"] @@ -416,7 +415,7 @@ def deploy_model( def undeploy_model( self, ) -> Callable[ - [endpoint_service.UndeployModelRequest], Awaitable[operations.Operation] + [endpoint_service.UndeployModelRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the undeploy model method over gRPC. @@ -438,7 +437,7 @@ def undeploy_model( self._stubs["undeploy_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.EndpointService/UndeployModel", request_serializer=endpoint_service.UndeployModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_model"] diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/__init__.py index 8fca4944ab..d2acffa98a 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import FeaturestoreOnlineServingServiceClient from .async_client import FeaturestoreOnlineServingServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/async_client.py index cb29e164f7..270ad60e8f 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,14 +20,13 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.aiplatform_v1beta1.types import featurestore_online_service - from .transports.base import ( FeaturestoreOnlineServingServiceTransport, DEFAULT_CLIENT_INFO, @@ -54,35 +51,30 @@ class FeaturestoreOnlineServingServiceAsyncClient: parse_entity_type_path = staticmethod( FeaturestoreOnlineServingServiceClient.parse_entity_type_path ) - common_billing_account_path = staticmethod( FeaturestoreOnlineServingServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( FeaturestoreOnlineServingServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod( FeaturestoreOnlineServingServiceClient.common_folder_path ) parse_common_folder_path = staticmethod( FeaturestoreOnlineServingServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( FeaturestoreOnlineServingServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( FeaturestoreOnlineServingServiceClient.parse_common_organization_path ) - common_project_path = staticmethod( FeaturestoreOnlineServingServiceClient.common_project_path ) parse_common_project_path = staticmethod( FeaturestoreOnlineServingServiceClient.parse_common_project_path ) - common_location_path = staticmethod( FeaturestoreOnlineServingServiceClient.common_location_path ) @@ -139,7 +131,7 @@ def transport(self) -> FeaturestoreOnlineServingServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[ str, FeaturestoreOnlineServingServiceTransport ] = "grpc_asyncio", @@ -178,7 +170,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = FeaturestoreOnlineServingServiceClient( credentials=credentials, transport=transport, @@ -215,7 +206,6 @@ async def read_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -242,7 +232,6 @@ async def read_feature_values( # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type @@ -298,7 +287,6 @@ def streaming_read_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -325,7 +313,6 @@ def streaming_read_feature_values( # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py index 63acf92e7e..9389db9195 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,17 +21,16 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.aiplatform_v1beta1.types import featurestore_online_service - from .transports.base import ( FeaturestoreOnlineServingServiceTransport, DEFAULT_CLIENT_INFO, @@ -248,7 +245,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, FeaturestoreOnlineServingServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -387,7 +384,6 @@ def read_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -418,10 +414,8 @@ def read_feature_values( request, featurestore_online_service.ReadFeatureValuesRequest ): request = featurestore_online_service.ReadFeatureValuesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type @@ -471,7 +465,6 @@ def streaming_read_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -504,10 +497,8 @@ def streaming_read_feature_values( request = featurestore_online_service.StreamingReadFeatureValuesRequest( request ) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/__init__.py index fbb212cbc6..cc2c0278fb 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py index 7cdcd29858..b4e26a18c0 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,20 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import featurestore_online_service - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=pkg_resources.get_distribution( @@ -37,27 +36,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class FeaturestoreOnlineServingServiceTransport(abc.ABC): """Abstract transport class for FeaturestoreOnlineServingService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -66,7 +79,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -80,29 +93,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -119,11 +179,11 @@ def _prep_wrapped_messages(self, client_info): @property def read_feature_values( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_online_service.ReadFeatureValuesRequest], - typing.Union[ + Union[ featurestore_online_service.ReadFeatureValuesResponse, - typing.Awaitable[featurestore_online_service.ReadFeatureValuesResponse], + Awaitable[featurestore_online_service.ReadFeatureValuesResponse], ], ]: raise NotImplementedError() @@ -131,11 +191,11 @@ def read_feature_values( @property def streaming_read_feature_values( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_online_service.StreamingReadFeatureValuesRequest], - typing.Union[ + Union[ featurestore_online_service.ReadFeatureValuesResponse, - typing.Awaitable[featurestore_online_service.ReadFeatureValuesResponse], + Awaitable[featurestore_online_service.ReadFeatureValuesResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py index 97b31e4acc..d13e69eda0 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,20 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1beta1.types import featurestore_online_service - from .base import FeaturestoreOnlineServingServiceTransport, DEFAULT_CLIENT_INFO @@ -52,7 +49,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -66,7 +63,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -176,7 +174,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -207,13 +205,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py index 5f92a32ab6..229f6c7ce9 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_online_serving_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1beta1.types import featurestore_online_service - from .base import FeaturestoreOnlineServingServiceTransport, DEFAULT_CLIENT_INFO from .grpc import FeaturestoreOnlineServingServiceGrpcTransport @@ -55,7 +52,7 @@ class FeaturestoreOnlineServingServiceGrpcAsyncIOTransport( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -82,13 +79,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -96,7 +95,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -110,7 +109,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -168,7 +168,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/__init__.py index 86c61ed8cf..192c1fc2a0 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import FeaturestoreServiceClient from .async_client import FeaturestoreServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/async_client.py index e9425b2be1..6ab5b3cc7f 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -41,10 +39,9 @@ from google.cloud.aiplatform_v1beta1.types import featurestore_monitoring from google.cloud.aiplatform_v1beta1.types import featurestore_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import FeaturestoreServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import FeaturestoreServiceGrpcAsyncIOTransport from .client import FeaturestoreServiceClient @@ -70,31 +67,26 @@ class FeaturestoreServiceAsyncClient: parse_featurestore_path = staticmethod( FeaturestoreServiceClient.parse_featurestore_path ) - common_billing_account_path = staticmethod( FeaturestoreServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( FeaturestoreServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(FeaturestoreServiceClient.common_folder_path) parse_common_folder_path = staticmethod( FeaturestoreServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( FeaturestoreServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( FeaturestoreServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(FeaturestoreServiceClient.common_project_path) parse_common_project_path = staticmethod( FeaturestoreServiceClient.parse_common_project_path ) - common_location_path = staticmethod(FeaturestoreServiceClient.common_location_path) parse_common_location_path = staticmethod( FeaturestoreServiceClient.parse_common_location_path @@ -149,7 +141,7 @@ def transport(self) -> FeaturestoreServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, FeaturestoreServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -186,7 +178,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = FeaturestoreServiceClient( credentials=credentials, transport=transport, @@ -224,7 +215,6 @@ async def create_featurestore( This corresponds to the ``featurestore`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -255,7 +245,6 @@ async def create_featurestore( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if featurestore is not None: @@ -311,7 +300,6 @@ async def get_featurestore( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -339,7 +327,6 @@ async def get_featurestore( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -386,7 +373,6 @@ async def list_featurestores( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -416,7 +402,6 @@ async def list_featurestores( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -451,7 +436,7 @@ async def update_featurestore( request: featurestore_service.UpdateFeaturestoreRequest = None, *, featurestore: gca_featurestore.Featurestore = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -485,12 +470,11 @@ async def update_featurestore( - ``display_name`` - ``labels`` - ``online_serving_config.fixed_node_count`` - - ``online_serving_config.max_online_serving_size`` + - ``retention_policy.online_storage_ttl_days`` This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -521,7 +505,6 @@ async def update_featurestore( # If we have keyword arguments corresponding to fields on the # request, apply these. - if featurestore is not None: request.featurestore = featurestore if update_mask is not None: @@ -582,7 +565,6 @@ async def delete_featurestore( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -622,7 +604,6 @@ async def delete_featurestore( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -647,7 +628,7 @@ async def delete_featurestore( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -683,7 +664,6 @@ async def create_entity_type( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -714,7 +694,6 @@ async def create_entity_type( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if entity_type is not None: @@ -770,7 +749,6 @@ async def get_entity_type( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -801,7 +779,6 @@ async def get_entity_type( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -848,7 +825,6 @@ async def list_entity_types( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -878,7 +854,6 @@ async def list_entity_types( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -913,7 +888,7 @@ async def update_entity_type( request: featurestore_service.UpdateEntityTypeRequest = None, *, entity_type: gca_entity_type.EntityType = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -952,7 +927,6 @@ async def update_entity_type( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -983,7 +957,6 @@ async def update_entity_type( # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type if update_mask is not None: @@ -1036,7 +1009,6 @@ async def delete_entity_type( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1076,7 +1048,6 @@ async def delete_entity_type( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1101,7 +1072,7 @@ async def delete_entity_type( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1137,7 +1108,6 @@ async def create_feature( This corresponds to the ``feature`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1167,7 +1137,6 @@ async def create_feature( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if feature is not None: @@ -1236,7 +1205,6 @@ async def batch_create_features( This corresponds to the ``requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1267,10 +1235,8 @@ async def batch_create_features( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent - if requests: request.requests.extend(requests) @@ -1324,7 +1290,6 @@ async def get_feature( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1354,7 +1319,6 @@ async def get_feature( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1401,7 +1365,6 @@ async def list_features( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1431,7 +1394,6 @@ async def list_features( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1466,7 +1428,7 @@ async def update_feature( request: featurestore_service.UpdateFeatureRequest = None, *, feature: gca_feature.Feature = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1505,7 +1467,6 @@ async def update_feature( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1535,7 +1496,6 @@ async def update_feature( # If we have keyword arguments corresponding to fields on the # request, apply these. - if feature is not None: request.feature = feature if update_mask is not None: @@ -1586,7 +1546,6 @@ async def delete_feature( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1626,7 +1585,6 @@ async def delete_feature( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1651,7 +1609,7 @@ async def delete_feature( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1702,7 +1660,6 @@ async def import_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1733,7 +1690,6 @@ async def import_feature_values( # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type @@ -1796,7 +1752,6 @@ async def batch_read_feature_values( This corresponds to the ``featurestore`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1827,7 +1782,6 @@ async def batch_read_feature_values( # If we have keyword arguments corresponding to fields on the # request, apply these. - if featurestore is not None: request.featurestore = featurestore @@ -1885,7 +1839,6 @@ async def export_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1916,7 +1869,6 @@ async def export_feature_values( # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type @@ -1974,7 +1926,6 @@ async def search_features( This corresponds to the ``location`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2004,7 +1955,6 @@ async def search_features( # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py index 89406353ea..97d26b0d3f 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -45,10 +43,9 @@ from google.cloud.aiplatform_v1beta1.types import featurestore_monitoring from google.cloud.aiplatform_v1beta1.types import featurestore_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import FeaturestoreServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import FeaturestoreServiceGrpcTransport from .transports.grpc_asyncio import FeaturestoreServiceGrpcAsyncIOTransport @@ -294,7 +291,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, FeaturestoreServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -434,7 +431,6 @@ def create_featurestore( This corresponds to the ``featurestore`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -467,10 +463,8 @@ def create_featurestore( # there are no flattened fields. if not isinstance(request, featurestore_service.CreateFeaturestoreRequest): request = featurestore_service.CreateFeaturestoreRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if featurestore is not None: @@ -522,7 +516,6 @@ def get_featurestore( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -552,10 +545,8 @@ def get_featurestore( # there are no flattened fields. if not isinstance(request, featurestore_service.GetFeaturestoreRequest): request = featurestore_service.GetFeaturestoreRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -598,7 +589,6 @@ def list_featurestores( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -630,10 +620,8 @@ def list_featurestores( # there are no flattened fields. if not isinstance(request, featurestore_service.ListFeaturestoresRequest): request = featurestore_service.ListFeaturestoresRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -664,7 +652,7 @@ def update_featurestore( request: featurestore_service.UpdateFeaturestoreRequest = None, *, featurestore: gca_featurestore.Featurestore = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -698,12 +686,11 @@ def update_featurestore( - ``display_name`` - ``labels`` - ``online_serving_config.fixed_node_count`` - - ``online_serving_config.max_online_serving_size`` + - ``retention_policy.online_storage_ttl_days`` This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -736,10 +723,8 @@ def update_featurestore( # there are no flattened fields. if not isinstance(request, featurestore_service.UpdateFeaturestoreRequest): request = featurestore_service.UpdateFeaturestoreRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if featurestore is not None: request.featurestore = featurestore if update_mask is not None: @@ -796,7 +781,6 @@ def delete_featurestore( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -838,10 +822,8 @@ def delete_featurestore( # there are no flattened fields. if not isinstance(request, featurestore_service.DeleteFeaturestoreRequest): request = featurestore_service.DeleteFeaturestoreRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -862,7 +844,7 @@ def delete_featurestore( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -898,7 +880,6 @@ def create_entity_type( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -931,10 +912,8 @@ def create_entity_type( # there are no flattened fields. if not isinstance(request, featurestore_service.CreateEntityTypeRequest): request = featurestore_service.CreateEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if entity_type is not None: @@ -986,7 +965,6 @@ def get_entity_type( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1019,10 +997,8 @@ def get_entity_type( # there are no flattened fields. if not isinstance(request, featurestore_service.GetEntityTypeRequest): request = featurestore_service.GetEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1065,7 +1041,6 @@ def list_entity_types( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1097,10 +1072,8 @@ def list_entity_types( # there are no flattened fields. if not isinstance(request, featurestore_service.ListEntityTypesRequest): request = featurestore_service.ListEntityTypesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1131,7 +1104,7 @@ def update_entity_type( request: featurestore_service.UpdateEntityTypeRequest = None, *, entity_type: gca_entity_type.EntityType = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1170,7 +1143,6 @@ def update_entity_type( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1203,10 +1175,8 @@ def update_entity_type( # there are no flattened fields. if not isinstance(request, featurestore_service.UpdateEntityTypeRequest): request = featurestore_service.UpdateEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type if update_mask is not None: @@ -1255,7 +1225,6 @@ def delete_entity_type( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1297,10 +1266,8 @@ def delete_entity_type( # there are no flattened fields. if not isinstance(request, featurestore_service.DeleteEntityTypeRequest): request = featurestore_service.DeleteEntityTypeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1321,7 +1288,7 @@ def delete_entity_type( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1357,7 +1324,6 @@ def create_feature( This corresponds to the ``feature`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1389,10 +1355,8 @@ def create_feature( # there are no flattened fields. if not isinstance(request, featurestore_service.CreateFeatureRequest): request = featurestore_service.CreateFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if feature is not None: @@ -1457,7 +1421,6 @@ def batch_create_features( This corresponds to the ``requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1490,10 +1453,8 @@ def batch_create_features( # there are no flattened fields. if not isinstance(request, featurestore_service.BatchCreateFeaturesRequest): request = featurestore_service.BatchCreateFeaturesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if requests is not None: @@ -1545,7 +1506,6 @@ def get_feature( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1577,10 +1537,8 @@ def get_feature( # there are no flattened fields. if not isinstance(request, featurestore_service.GetFeatureRequest): request = featurestore_service.GetFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1623,7 +1581,6 @@ def list_features( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1655,10 +1612,8 @@ def list_features( # there are no flattened fields. if not isinstance(request, featurestore_service.ListFeaturesRequest): request = featurestore_service.ListFeaturesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1689,7 +1644,7 @@ def update_feature( request: featurestore_service.UpdateFeatureRequest = None, *, feature: gca_feature.Feature = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1728,7 +1683,6 @@ def update_feature( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1760,10 +1714,8 @@ def update_feature( # there are no flattened fields. if not isinstance(request, featurestore_service.UpdateFeatureRequest): request = featurestore_service.UpdateFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if feature is not None: request.feature = feature if update_mask is not None: @@ -1810,7 +1762,6 @@ def delete_feature( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1852,10 +1803,8 @@ def delete_feature( # there are no flattened fields. if not isinstance(request, featurestore_service.DeleteFeatureRequest): request = featurestore_service.DeleteFeatureRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1876,7 +1825,7 @@ def delete_feature( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1927,7 +1876,6 @@ def import_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1960,10 +1908,8 @@ def import_feature_values( # there are no flattened fields. if not isinstance(request, featurestore_service.ImportFeatureValuesRequest): request = featurestore_service.ImportFeatureValuesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type @@ -2022,7 +1968,6 @@ def batch_read_feature_values( This corresponds to the ``featurestore`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2055,10 +2000,8 @@ def batch_read_feature_values( # there are no flattened fields. if not isinstance(request, featurestore_service.BatchReadFeatureValuesRequest): request = featurestore_service.BatchReadFeatureValuesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if featurestore is not None: request.featurestore = featurestore @@ -2114,7 +2057,6 @@ def export_feature_values( This corresponds to the ``entity_type`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2147,10 +2089,8 @@ def export_feature_values( # there are no flattened fields. if not isinstance(request, featurestore_service.ExportFeatureValuesRequest): request = featurestore_service.ExportFeatureValuesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if entity_type is not None: request.entity_type = entity_type @@ -2204,7 +2144,6 @@ def search_features( This corresponds to the ``location`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2236,10 +2175,8 @@ def search_features( # there are no flattened fields. if not isinstance(request, featurestore_service.SearchFeaturesRequest): request = featurestore_service.SearchFeaturesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/pagers.py index 98e6d56e17..26ba8e31d2 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/__init__.py index 8f1772f264..5c30b22b43 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py index f47c31f203..7d9162a2fa 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import entity_type from google.cloud.aiplatform_v1beta1.types import entity_type as gca_entity_type @@ -32,8 +32,7 @@ from google.cloud.aiplatform_v1beta1.types import feature as gca_feature from google.cloud.aiplatform_v1beta1.types import featurestore from google.cloud.aiplatform_v1beta1.types import featurestore_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -44,27 +43,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class FeaturestoreServiceTransport(abc.ABC): """Abstract transport class for FeaturestoreService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -73,7 +86,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -87,29 +100,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -191,31 +251,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_featurestore( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.CreateFeaturestoreRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_featurestore( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.GetFeaturestoreRequest], - typing.Union[ - featurestore.Featurestore, typing.Awaitable[featurestore.Featurestore] - ], + Union[featurestore.Featurestore, Awaitable[featurestore.Featurestore]], ]: raise NotImplementedError() @property def list_featurestores( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.ListFeaturestoresRequest], - typing.Union[ + Union[ featurestore_service.ListFeaturestoresResponse, - typing.Awaitable[featurestore_service.ListFeaturestoresResponse], + Awaitable[featurestore_service.ListFeaturestoresResponse], ], ]: raise NotImplementedError() @@ -223,47 +281,47 @@ def list_featurestores( @property def update_featurestore( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.UpdateFeaturestoreRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_featurestore( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.DeleteFeaturestoreRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_entity_type( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.CreateEntityTypeRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_entity_type( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.GetEntityTypeRequest], - typing.Union[entity_type.EntityType, typing.Awaitable[entity_type.EntityType]], + Union[entity_type.EntityType, Awaitable[entity_type.EntityType]], ]: raise NotImplementedError() @property def list_entity_types( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.ListEntityTypesRequest], - typing.Union[ + Union[ featurestore_service.ListEntityTypesResponse, - typing.Awaitable[featurestore_service.ListEntityTypesResponse], + Awaitable[featurestore_service.ListEntityTypesResponse], ], ]: raise NotImplementedError() @@ -271,58 +329,56 @@ def list_entity_types( @property def update_entity_type( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.UpdateEntityTypeRequest], - typing.Union[ - gca_entity_type.EntityType, typing.Awaitable[gca_entity_type.EntityType] - ], + Union[gca_entity_type.EntityType, Awaitable[gca_entity_type.EntityType]], ]: raise NotImplementedError() @property def delete_entity_type( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.DeleteEntityTypeRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_feature( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.CreateFeatureRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def batch_create_features( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.BatchCreateFeaturesRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_feature( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.GetFeatureRequest], - typing.Union[feature.Feature, typing.Awaitable[feature.Feature]], + Union[feature.Feature, Awaitable[feature.Feature]], ]: raise NotImplementedError() @property def list_features( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.ListFeaturesRequest], - typing.Union[ + Union[ featurestore_service.ListFeaturesResponse, - typing.Awaitable[featurestore_service.ListFeaturesResponse], + Awaitable[featurestore_service.ListFeaturesResponse], ], ]: raise NotImplementedError() @@ -330,56 +386,56 @@ def list_features( @property def update_feature( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.UpdateFeatureRequest], - typing.Union[gca_feature.Feature, typing.Awaitable[gca_feature.Feature]], + Union[gca_feature.Feature, Awaitable[gca_feature.Feature]], ]: raise NotImplementedError() @property def delete_feature( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.DeleteFeatureRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def import_feature_values( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.ImportFeatureValuesRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def batch_read_feature_values( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.BatchReadFeatureValuesRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def export_feature_values( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.ExportFeatureValuesRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def search_features( self, - ) -> typing.Callable[ + ) -> Callable[ [featurestore_service.SearchFeaturesRequest], - typing.Union[ + Union[ featurestore_service.SearchFeaturesResponse, - typing.Awaitable[featurestore_service.SearchFeaturesResponse], + Awaitable[featurestore_service.SearchFeaturesResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py index 27c255d8a6..4eb99eab64 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -33,8 +31,7 @@ from google.cloud.aiplatform_v1beta1.types import feature as gca_feature from google.cloud.aiplatform_v1beta1.types import featurestore from google.cloud.aiplatform_v1beta1.types import featurestore_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import FeaturestoreServiceTransport, DEFAULT_CLIENT_INFO @@ -58,7 +55,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -72,7 +69,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -183,7 +181,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -214,13 +212,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -248,7 +248,7 @@ def operations_client(self) -> operations_v1.OperationsClient: def create_featurestore( self, ) -> Callable[ - [featurestore_service.CreateFeaturestoreRequest], operations.Operation + [featurestore_service.CreateFeaturestoreRequest], operations_pb2.Operation ]: r"""Return a callable for the create featurestore method over gRPC. @@ -269,7 +269,7 @@ def create_featurestore( self._stubs["create_featurestore"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/CreateFeaturestore", request_serializer=featurestore_service.CreateFeaturestoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_featurestore"] @@ -334,7 +334,7 @@ def list_featurestores( def update_featurestore( self, ) -> Callable[ - [featurestore_service.UpdateFeaturestoreRequest], operations.Operation + [featurestore_service.UpdateFeaturestoreRequest], operations_pb2.Operation ]: r"""Return a callable for the update featurestore method over gRPC. @@ -354,7 +354,7 @@ def update_featurestore( self._stubs["update_featurestore"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/UpdateFeaturestore", request_serializer=featurestore_service.UpdateFeaturestoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_featurestore"] @@ -362,7 +362,7 @@ def update_featurestore( def delete_featurestore( self, ) -> Callable[ - [featurestore_service.DeleteFeaturestoreRequest], operations.Operation + [featurestore_service.DeleteFeaturestoreRequest], operations_pb2.Operation ]: r"""Return a callable for the delete featurestore method over gRPC. @@ -384,14 +384,16 @@ def delete_featurestore( self._stubs["delete_featurestore"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/DeleteFeaturestore", request_serializer=featurestore_service.DeleteFeaturestoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_featurestore"] @property def create_entity_type( self, - ) -> Callable[[featurestore_service.CreateEntityTypeRequest], operations.Operation]: + ) -> Callable[ + [featurestore_service.CreateEntityTypeRequest], operations_pb2.Operation + ]: r"""Return a callable for the create entity type method over gRPC. Creates a new EntityType in a given Featurestore. @@ -410,7 +412,7 @@ def create_entity_type( self._stubs["create_entity_type"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/CreateEntityType", request_serializer=featurestore_service.CreateEntityTypeRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_entity_type"] @@ -500,7 +502,9 @@ def update_entity_type( @property def delete_entity_type( self, - ) -> Callable[[featurestore_service.DeleteEntityTypeRequest], operations.Operation]: + ) -> Callable[ + [featurestore_service.DeleteEntityTypeRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete entity type method over gRPC. Deletes a single EntityType. The EntityType must not have any @@ -521,14 +525,16 @@ def delete_entity_type( self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/DeleteEntityType", request_serializer=featurestore_service.DeleteEntityTypeRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_entity_type"] @property def create_feature( self, - ) -> Callable[[featurestore_service.CreateFeatureRequest], operations.Operation]: + ) -> Callable[ + [featurestore_service.CreateFeatureRequest], operations_pb2.Operation + ]: r"""Return a callable for the create feature method over gRPC. Creates a new Feature in a given EntityType. @@ -547,7 +553,7 @@ def create_feature( self._stubs["create_feature"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/CreateFeature", request_serializer=featurestore_service.CreateFeatureRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_feature"] @@ -555,7 +561,7 @@ def create_feature( def batch_create_features( self, ) -> Callable[ - [featurestore_service.BatchCreateFeaturesRequest], operations.Operation + [featurestore_service.BatchCreateFeaturesRequest], operations_pb2.Operation ]: r"""Return a callable for the batch create features method over gRPC. @@ -575,7 +581,7 @@ def batch_create_features( self._stubs["batch_create_features"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/BatchCreateFeatures", request_serializer=featurestore_service.BatchCreateFeaturesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_create_features"] @@ -663,7 +669,9 @@ def update_feature( @property def delete_feature( self, - ) -> Callable[[featurestore_service.DeleteFeatureRequest], operations.Operation]: + ) -> Callable[ + [featurestore_service.DeleteFeatureRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete feature method over gRPC. Deletes a single Feature. @@ -682,7 +690,7 @@ def delete_feature( self._stubs["delete_feature"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/DeleteFeature", request_serializer=featurestore_service.DeleteFeatureRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_feature"] @@ -690,7 +698,7 @@ def delete_feature( def import_feature_values( self, ) -> Callable[ - [featurestore_service.ImportFeatureValuesRequest], operations.Operation + [featurestore_service.ImportFeatureValuesRequest], operations_pb2.Operation ]: r"""Return a callable for the import feature values method over gRPC. @@ -730,7 +738,7 @@ def import_feature_values( self._stubs["import_feature_values"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/ImportFeatureValues", request_serializer=featurestore_service.ImportFeatureValuesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_feature_values"] @@ -738,7 +746,7 @@ def import_feature_values( def batch_read_feature_values( self, ) -> Callable[ - [featurestore_service.BatchReadFeatureValuesRequest], operations.Operation + [featurestore_service.BatchReadFeatureValuesRequest], operations_pb2.Operation ]: r"""Return a callable for the batch read feature values method over gRPC. @@ -763,7 +771,7 @@ def batch_read_feature_values( self._stubs["batch_read_feature_values"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/BatchReadFeatureValues", request_serializer=featurestore_service.BatchReadFeatureValuesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_read_feature_values"] @@ -771,7 +779,7 @@ def batch_read_feature_values( def export_feature_values( self, ) -> Callable[ - [featurestore_service.ExportFeatureValuesRequest], operations.Operation + [featurestore_service.ExportFeatureValuesRequest], operations_pb2.Operation ]: r"""Return a callable for the export feature values method over gRPC. @@ -792,7 +800,7 @@ def export_feature_values( self._stubs["export_feature_values"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/ExportFeatureValues", request_serializer=featurestore_service.ExportFeatureValuesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_feature_values"] diff --git a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py index 148ac3c1a9..3c4cb14910 100644 --- a/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/featurestore_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -34,8 +32,7 @@ from google.cloud.aiplatform_v1beta1.types import feature as gca_feature from google.cloud.aiplatform_v1beta1.types import featurestore from google.cloud.aiplatform_v1beta1.types import featurestore_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import FeaturestoreServiceTransport, DEFAULT_CLIENT_INFO from .grpc import FeaturestoreServiceGrpcTransport @@ -61,7 +58,7 @@ class FeaturestoreServiceGrpcAsyncIOTransport(FeaturestoreServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -88,13 +85,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -102,7 +101,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -116,7 +115,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -175,7 +175,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -255,7 +254,7 @@ def create_featurestore( self, ) -> Callable[ [featurestore_service.CreateFeaturestoreRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create featurestore method over gRPC. @@ -276,7 +275,7 @@ def create_featurestore( self._stubs["create_featurestore"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/CreateFeaturestore", request_serializer=featurestore_service.CreateFeaturestoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_featurestore"] @@ -343,7 +342,7 @@ def update_featurestore( self, ) -> Callable[ [featurestore_service.UpdateFeaturestoreRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update featurestore method over gRPC. @@ -363,7 +362,7 @@ def update_featurestore( self._stubs["update_featurestore"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/UpdateFeaturestore", request_serializer=featurestore_service.UpdateFeaturestoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_featurestore"] @@ -372,7 +371,7 @@ def delete_featurestore( self, ) -> Callable[ [featurestore_service.DeleteFeaturestoreRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete featurestore method over gRPC. @@ -394,7 +393,7 @@ def delete_featurestore( self._stubs["delete_featurestore"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/DeleteFeaturestore", request_serializer=featurestore_service.DeleteFeaturestoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_featurestore"] @@ -402,7 +401,8 @@ def delete_featurestore( def create_entity_type( self, ) -> Callable[ - [featurestore_service.CreateEntityTypeRequest], Awaitable[operations.Operation] + [featurestore_service.CreateEntityTypeRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create entity type method over gRPC. @@ -422,7 +422,7 @@ def create_entity_type( self._stubs["create_entity_type"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/CreateEntityType", request_serializer=featurestore_service.CreateEntityTypeRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_entity_type"] @@ -516,7 +516,8 @@ def update_entity_type( def delete_entity_type( self, ) -> Callable[ - [featurestore_service.DeleteEntityTypeRequest], Awaitable[operations.Operation] + [featurestore_service.DeleteEntityTypeRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete entity type method over gRPC. @@ -538,7 +539,7 @@ def delete_entity_type( self._stubs["delete_entity_type"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/DeleteEntityType", request_serializer=featurestore_service.DeleteEntityTypeRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_entity_type"] @@ -546,7 +547,7 @@ def delete_entity_type( def create_feature( self, ) -> Callable[ - [featurestore_service.CreateFeatureRequest], Awaitable[operations.Operation] + [featurestore_service.CreateFeatureRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create feature method over gRPC. @@ -566,7 +567,7 @@ def create_feature( self._stubs["create_feature"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/CreateFeature", request_serializer=featurestore_service.CreateFeatureRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_feature"] @@ -575,7 +576,7 @@ def batch_create_features( self, ) -> Callable[ [featurestore_service.BatchCreateFeaturesRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the batch create features method over gRPC. @@ -595,7 +596,7 @@ def batch_create_features( self._stubs["batch_create_features"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/BatchCreateFeatures", request_serializer=featurestore_service.BatchCreateFeaturesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_create_features"] @@ -686,7 +687,7 @@ def update_feature( def delete_feature( self, ) -> Callable[ - [featurestore_service.DeleteFeatureRequest], Awaitable[operations.Operation] + [featurestore_service.DeleteFeatureRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete feature method over gRPC. @@ -706,7 +707,7 @@ def delete_feature( self._stubs["delete_feature"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/DeleteFeature", request_serializer=featurestore_service.DeleteFeatureRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_feature"] @@ -715,7 +716,7 @@ def import_feature_values( self, ) -> Callable[ [featurestore_service.ImportFeatureValuesRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the import feature values method over gRPC. @@ -755,7 +756,7 @@ def import_feature_values( self._stubs["import_feature_values"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/ImportFeatureValues", request_serializer=featurestore_service.ImportFeatureValuesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["import_feature_values"] @@ -764,7 +765,7 @@ def batch_read_feature_values( self, ) -> Callable[ [featurestore_service.BatchReadFeatureValuesRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the batch read feature values method over gRPC. @@ -789,7 +790,7 @@ def batch_read_feature_values( self._stubs["batch_read_feature_values"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/BatchReadFeatureValues", request_serializer=featurestore_service.BatchReadFeatureValuesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_read_feature_values"] @@ -798,7 +799,7 @@ def export_feature_values( self, ) -> Callable[ [featurestore_service.ExportFeatureValuesRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the export feature values method over gRPC. @@ -819,7 +820,7 @@ def export_feature_values( self._stubs["export_feature_values"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.FeaturestoreService/ExportFeatureValues", request_serializer=featurestore_service.ExportFeatureValuesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_feature_values"] diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/__init__.py index 1eeda9dcdd..499311d96c 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import IndexEndpointServiceClient from .async_client import IndexEndpointServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/async_client.py index 8f2ffd8555..ef4ee399c0 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -35,10 +33,9 @@ from google.cloud.aiplatform_v1beta1.types import index_endpoint as gca_index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import IndexEndpointServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import IndexEndpointServiceGrpcAsyncIOTransport from .client import IndexEndpointServiceClient @@ -58,31 +55,26 @@ class IndexEndpointServiceAsyncClient: parse_index_endpoint_path = staticmethod( IndexEndpointServiceClient.parse_index_endpoint_path ) - common_billing_account_path = staticmethod( IndexEndpointServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( IndexEndpointServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(IndexEndpointServiceClient.common_folder_path) parse_common_folder_path = staticmethod( IndexEndpointServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( IndexEndpointServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( IndexEndpointServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(IndexEndpointServiceClient.common_project_path) parse_common_project_path = staticmethod( IndexEndpointServiceClient.parse_common_project_path ) - common_location_path = staticmethod(IndexEndpointServiceClient.common_location_path) parse_common_location_path = staticmethod( IndexEndpointServiceClient.parse_common_location_path @@ -137,7 +129,7 @@ def transport(self) -> IndexEndpointServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, IndexEndpointServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -174,7 +166,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = IndexEndpointServiceClient( credentials=credentials, transport=transport, @@ -213,7 +204,6 @@ async def create_index_endpoint( This corresponds to the ``index_endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -242,7 +232,6 @@ async def create_index_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if index_endpoint is not None: @@ -299,7 +288,6 @@ async def get_index_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -327,7 +315,6 @@ async def get_index_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -374,7 +361,6 @@ async def list_index_endpoints( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -404,7 +390,6 @@ async def list_index_endpoints( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -439,7 +424,7 @@ async def update_index_endpoint( request: index_endpoint_service.UpdateIndexEndpointRequest = None, *, index_endpoint: gca_index_endpoint.IndexEndpoint = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -464,7 +449,6 @@ async def update_index_endpoint( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -492,7 +476,6 @@ async def update_index_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if index_endpoint is not None: request.index_endpoint = index_endpoint if update_mask is not None: @@ -543,7 +526,6 @@ async def delete_index_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -583,7 +565,6 @@ async def delete_index_endpoint( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -608,7 +589,7 @@ async def delete_index_endpoint( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -648,7 +629,6 @@ async def deploy_index( This corresponds to the ``deployed_index`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -679,7 +659,6 @@ async def deploy_index( # If we have keyword arguments corresponding to fields on the # request, apply these. - if index_endpoint is not None: request.index_endpoint = index_endpoint if deployed_index is not None: @@ -748,7 +727,6 @@ async def undeploy_index( This corresponds to the ``deployed_index_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -779,7 +757,6 @@ async def undeploy_index( # If we have keyword arguments corresponding to fields on the # request, apply these. - if index_endpoint is not None: request.index_endpoint = index_endpoint if deployed_index_id is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py index 8c1d4626d6..6d37fc13fd 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -39,10 +37,9 @@ from google.cloud.aiplatform_v1beta1.types import index_endpoint as gca_index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import IndexEndpointServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import IndexEndpointServiceGrpcTransport from .transports.grpc_asyncio import IndexEndpointServiceGrpcAsyncIOTransport @@ -259,7 +256,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, IndexEndpointServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -400,7 +397,6 @@ def create_index_endpoint( This corresponds to the ``index_endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -431,10 +427,8 @@ def create_index_endpoint( # there are no flattened fields. if not isinstance(request, index_endpoint_service.CreateIndexEndpointRequest): request = index_endpoint_service.CreateIndexEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if index_endpoint is not None: @@ -487,7 +481,6 @@ def get_index_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -517,10 +510,8 @@ def get_index_endpoint( # there are no flattened fields. if not isinstance(request, index_endpoint_service.GetIndexEndpointRequest): request = index_endpoint_service.GetIndexEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -563,7 +554,6 @@ def list_index_endpoints( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -595,10 +585,8 @@ def list_index_endpoints( # there are no flattened fields. if not isinstance(request, index_endpoint_service.ListIndexEndpointsRequest): request = index_endpoint_service.ListIndexEndpointsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -629,7 +617,7 @@ def update_index_endpoint( request: index_endpoint_service.UpdateIndexEndpointRequest = None, *, index_endpoint: gca_index_endpoint.IndexEndpoint = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -654,7 +642,6 @@ def update_index_endpoint( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -684,10 +671,8 @@ def update_index_endpoint( # there are no flattened fields. if not isinstance(request, index_endpoint_service.UpdateIndexEndpointRequest): request = index_endpoint_service.UpdateIndexEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if index_endpoint is not None: request.index_endpoint = index_endpoint if update_mask is not None: @@ -734,7 +719,6 @@ def delete_index_endpoint( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -776,10 +760,8 @@ def delete_index_endpoint( # there are no flattened fields. if not isinstance(request, index_endpoint_service.DeleteIndexEndpointRequest): request = index_endpoint_service.DeleteIndexEndpointRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -800,7 +782,7 @@ def delete_index_endpoint( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -840,7 +822,6 @@ def deploy_index( This corresponds to the ``deployed_index`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -873,10 +854,8 @@ def deploy_index( # there are no flattened fields. if not isinstance(request, index_endpoint_service.DeployIndexRequest): request = index_endpoint_service.DeployIndexRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if index_endpoint is not None: request.index_endpoint = index_endpoint if deployed_index is not None: @@ -941,7 +920,6 @@ def undeploy_index( This corresponds to the ``deployed_index_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -974,10 +952,8 @@ def undeploy_index( # there are no flattened fields. if not isinstance(request, index_endpoint_service.UndeployIndexRequest): request = index_endpoint_service.UndeployIndexRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if index_endpoint is not None: request.index_endpoint = index_endpoint if deployed_index_id is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/pagers.py index ae7b2cdbf9..f85618275b 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/__init__.py index 9ce68726cf..cae6e2f624 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py index 4f73f79d73..cbc16d1221 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint as gca_index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -41,27 +40,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class IndexEndpointServiceTransport(abc.ABC): """Abstract transport class for IndexEndpointService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -70,7 +83,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -84,29 +97,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -147,31 +207,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_index_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [index_endpoint_service.CreateIndexEndpointRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_index_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [index_endpoint_service.GetIndexEndpointRequest], - typing.Union[ - index_endpoint.IndexEndpoint, typing.Awaitable[index_endpoint.IndexEndpoint] - ], + Union[index_endpoint.IndexEndpoint, Awaitable[index_endpoint.IndexEndpoint]], ]: raise NotImplementedError() @property def list_index_endpoints( self, - ) -> typing.Callable[ + ) -> Callable[ [index_endpoint_service.ListIndexEndpointsRequest], - typing.Union[ + Union[ index_endpoint_service.ListIndexEndpointsResponse, - typing.Awaitable[index_endpoint_service.ListIndexEndpointsResponse], + Awaitable[index_endpoint_service.ListIndexEndpointsResponse], ], ]: raise NotImplementedError() @@ -179,11 +237,11 @@ def list_index_endpoints( @property def update_index_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [index_endpoint_service.UpdateIndexEndpointRequest], - typing.Union[ + Union[ gca_index_endpoint.IndexEndpoint, - typing.Awaitable[gca_index_endpoint.IndexEndpoint], + Awaitable[gca_index_endpoint.IndexEndpoint], ], ]: raise NotImplementedError() @@ -191,27 +249,27 @@ def update_index_endpoint( @property def delete_index_endpoint( self, - ) -> typing.Callable[ + ) -> Callable[ [index_endpoint_service.DeleteIndexEndpointRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def deploy_index( self, - ) -> typing.Callable[ + ) -> Callable[ [index_endpoint_service.DeployIndexRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def undeploy_index( self, - ) -> typing.Callable[ + ) -> Callable[ [index_endpoint_service.UndeployIndexRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py index a41e483a61..7bd67d7b25 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -30,8 +28,7 @@ from google.cloud.aiplatform_v1beta1.types import index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint as gca_index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import IndexEndpointServiceTransport, DEFAULT_CLIENT_INFO @@ -54,7 +51,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -68,7 +65,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -179,7 +177,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -210,13 +208,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -244,7 +244,7 @@ def operations_client(self) -> operations_v1.OperationsClient: def create_index_endpoint( self, ) -> Callable[ - [index_endpoint_service.CreateIndexEndpointRequest], operations.Operation + [index_endpoint_service.CreateIndexEndpointRequest], operations_pb2.Operation ]: r"""Return a callable for the create index endpoint method over gRPC. @@ -264,7 +264,7 @@ def create_index_endpoint( self._stubs["create_index_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/CreateIndexEndpoint", request_serializer=index_endpoint_service.CreateIndexEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_index_endpoint"] @@ -358,7 +358,7 @@ def update_index_endpoint( def delete_index_endpoint( self, ) -> Callable[ - [index_endpoint_service.DeleteIndexEndpointRequest], operations.Operation + [index_endpoint_service.DeleteIndexEndpointRequest], operations_pb2.Operation ]: r"""Return a callable for the delete index endpoint method over gRPC. @@ -378,14 +378,16 @@ def delete_index_endpoint( self._stubs["delete_index_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/DeleteIndexEndpoint", request_serializer=index_endpoint_service.DeleteIndexEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_index_endpoint"] @property def deploy_index( self, - ) -> Callable[[index_endpoint_service.DeployIndexRequest], operations.Operation]: + ) -> Callable[ + [index_endpoint_service.DeployIndexRequest], operations_pb2.Operation + ]: r"""Return a callable for the deploy index method over gRPC. Deploys an Index into this IndexEndpoint, creating a @@ -406,14 +408,16 @@ def deploy_index( self._stubs["deploy_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/DeployIndex", request_serializer=index_endpoint_service.DeployIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_index"] @property def undeploy_index( self, - ) -> Callable[[index_endpoint_service.UndeployIndexRequest], operations.Operation]: + ) -> Callable[ + [index_endpoint_service.UndeployIndexRequest], operations_pb2.Operation + ]: r"""Return a callable for the undeploy index method over gRPC. Undeploys an Index from an IndexEndpoint, removing a @@ -434,7 +438,7 @@ def undeploy_index( self._stubs["undeploy_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/UndeployIndex", request_serializer=index_endpoint_service.UndeployIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_index"] diff --git a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py index a34337a84f..81891f2497 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/index_endpoint_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -31,8 +29,7 @@ from google.cloud.aiplatform_v1beta1.types import index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint as gca_index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import IndexEndpointServiceTransport, DEFAULT_CLIENT_INFO from .grpc import IndexEndpointServiceGrpcTransport @@ -57,7 +54,7 @@ class IndexEndpointServiceGrpcAsyncIOTransport(IndexEndpointServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -84,13 +81,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -98,7 +97,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -112,7 +111,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -171,7 +171,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -251,7 +250,7 @@ def create_index_endpoint( self, ) -> Callable[ [index_endpoint_service.CreateIndexEndpointRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create index endpoint method over gRPC. @@ -271,7 +270,7 @@ def create_index_endpoint( self._stubs["create_index_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/CreateIndexEndpoint", request_serializer=index_endpoint_service.CreateIndexEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_index_endpoint"] @@ -367,7 +366,7 @@ def delete_index_endpoint( self, ) -> Callable[ [index_endpoint_service.DeleteIndexEndpointRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete index endpoint method over gRPC. @@ -387,7 +386,7 @@ def delete_index_endpoint( self._stubs["delete_index_endpoint"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/DeleteIndexEndpoint", request_serializer=index_endpoint_service.DeleteIndexEndpointRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_index_endpoint"] @@ -395,7 +394,7 @@ def delete_index_endpoint( def deploy_index( self, ) -> Callable[ - [index_endpoint_service.DeployIndexRequest], Awaitable[operations.Operation] + [index_endpoint_service.DeployIndexRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the deploy index method over gRPC. @@ -417,7 +416,7 @@ def deploy_index( self._stubs["deploy_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/DeployIndex", request_serializer=index_endpoint_service.DeployIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["deploy_index"] @@ -425,7 +424,8 @@ def deploy_index( def undeploy_index( self, ) -> Callable[ - [index_endpoint_service.UndeployIndexRequest], Awaitable[operations.Operation] + [index_endpoint_service.UndeployIndexRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the undeploy index method over gRPC. @@ -447,7 +447,7 @@ def undeploy_index( self._stubs["undeploy_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexEndpointService/UndeployIndex", request_serializer=index_endpoint_service.UndeployIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undeploy_index"] diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/index_service/__init__.py index bf9cebd517..c7eb9ed32d 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import IndexServiceClient from .async_client import IndexServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/index_service/async_client.py index 0d1a875910..6dc98adec8 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -36,11 +34,10 @@ from google.cloud.aiplatform_v1beta1.types import index as gca_index from google.cloud.aiplatform_v1beta1.types import index_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import IndexServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import IndexServiceGrpcAsyncIOTransport from .client import IndexServiceClient @@ -62,27 +59,22 @@ class IndexServiceAsyncClient: parse_index_endpoint_path = staticmethod( IndexServiceClient.parse_index_endpoint_path ) - common_billing_account_path = staticmethod( IndexServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( IndexServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(IndexServiceClient.common_folder_path) parse_common_folder_path = staticmethod(IndexServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(IndexServiceClient.common_organization_path) parse_common_organization_path = staticmethod( IndexServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(IndexServiceClient.common_project_path) parse_common_project_path = staticmethod( IndexServiceClient.parse_common_project_path ) - common_location_path = staticmethod(IndexServiceClient.common_location_path) parse_common_location_path = staticmethod( IndexServiceClient.parse_common_location_path @@ -136,7 +128,7 @@ def transport(self) -> IndexServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, IndexServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -173,7 +165,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = IndexServiceClient( credentials=credentials, transport=transport, @@ -210,7 +201,6 @@ async def create_index( This corresponds to the ``index`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -240,7 +230,6 @@ async def create_index( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if index is not None: @@ -296,7 +285,6 @@ async def get_index( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -325,7 +313,6 @@ async def get_index( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -372,7 +359,6 @@ async def list_indexes( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -402,7 +388,6 @@ async def list_indexes( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -437,7 +422,7 @@ async def update_index( request: index_service.UpdateIndexRequest = None, *, index: gca_index.Index = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -463,7 +448,6 @@ async def update_index( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -493,7 +477,6 @@ async def update_index( # If we have keyword arguments corresponding to fields on the # request, apply these. - if index is not None: request.index = index if update_mask is not None: @@ -554,7 +537,6 @@ async def delete_index( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -594,7 +576,6 @@ async def delete_index( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -619,7 +600,7 @@ async def delete_index( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/client.py b/google/cloud/aiplatform_v1beta1/services/index_service/client.py index a5cf4e15a3..d30489ea3f 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -40,11 +38,10 @@ from google.cloud.aiplatform_v1beta1.types import index as gca_index from google.cloud.aiplatform_v1beta1.types import index_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import IndexServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import IndexServiceGrpcTransport from .transports.grpc_asyncio import IndexServiceGrpcAsyncIOTransport @@ -259,7 +256,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, IndexServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -398,7 +395,6 @@ def create_index( This corresponds to the ``index`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -430,10 +426,8 @@ def create_index( # there are no flattened fields. if not isinstance(request, index_service.CreateIndexRequest): request = index_service.CreateIndexRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if index is not None: @@ -485,7 +479,6 @@ def get_index( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -516,10 +509,8 @@ def get_index( # there are no flattened fields. if not isinstance(request, index_service.GetIndexRequest): request = index_service.GetIndexRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -562,7 +553,6 @@ def list_indexes( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -594,10 +584,8 @@ def list_indexes( # there are no flattened fields. if not isinstance(request, index_service.ListIndexesRequest): request = index_service.ListIndexesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -628,7 +616,7 @@ def update_index( request: index_service.UpdateIndexRequest = None, *, index: gca_index.Index = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -654,7 +642,6 @@ def update_index( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -686,10 +673,8 @@ def update_index( # there are no flattened fields. if not isinstance(request, index_service.UpdateIndexRequest): request = index_service.UpdateIndexRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if index is not None: request.index = index if update_mask is not None: @@ -746,7 +731,6 @@ def delete_index( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -788,10 +772,8 @@ def delete_index( # there are no flattened fields. if not isinstance(request, index_service.DeleteIndexRequest): request = index_service.DeleteIndexRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -812,7 +794,7 @@ def delete_index( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/index_service/pagers.py index 18b3cea2f7..010745adb4 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/__init__.py index f9345ef29c..3d0c32ac92 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py index c634a71107..731cd90024 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import index from google.cloud.aiplatform_v1beta1.types import index_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -40,27 +39,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class IndexServiceTransport(abc.ABC): """Abstract transport class for IndexService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -69,7 +82,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -83,29 +96,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -134,29 +194,28 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_index( self, - ) -> typing.Callable[ + ) -> Callable[ [index_service.CreateIndexRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_index( self, - ) -> typing.Callable[ - [index_service.GetIndexRequest], - typing.Union[index.Index, typing.Awaitable[index.Index]], + ) -> Callable[ + [index_service.GetIndexRequest], Union[index.Index, Awaitable[index.Index]] ]: raise NotImplementedError() @property def list_indexes( self, - ) -> typing.Callable[ + ) -> Callable[ [index_service.ListIndexesRequest], - typing.Union[ + Union[ index_service.ListIndexesResponse, - typing.Awaitable[index_service.ListIndexesResponse], + Awaitable[index_service.ListIndexesResponse], ], ]: raise NotImplementedError() @@ -164,18 +223,18 @@ def list_indexes( @property def update_index( self, - ) -> typing.Callable[ + ) -> Callable[ [index_service.UpdateIndexRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_index( self, - ) -> typing.Callable[ + ) -> Callable[ [index_service.DeleteIndexRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py index 4bb35d18d6..9178f1d61a 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1beta1.types import index from google.cloud.aiplatform_v1beta1.types import index_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import IndexServiceTransport, DEFAULT_CLIENT_INFO @@ -54,7 +51,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -68,7 +65,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -179,7 +177,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -210,13 +208,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -243,7 +243,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_index( self, - ) -> Callable[[index_service.CreateIndexRequest], operations.Operation]: + ) -> Callable[[index_service.CreateIndexRequest], operations_pb2.Operation]: r"""Return a callable for the create index method over gRPC. Creates an Index. @@ -262,7 +262,7 @@ def create_index( self._stubs["create_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexService/CreateIndex", request_serializer=index_service.CreateIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_index"] @@ -321,7 +321,7 @@ def list_indexes( @property def update_index( self, - ) -> Callable[[index_service.UpdateIndexRequest], operations.Operation]: + ) -> Callable[[index_service.UpdateIndexRequest], operations_pb2.Operation]: r"""Return a callable for the update index method over gRPC. Updates an Index. @@ -340,14 +340,14 @@ def update_index( self._stubs["update_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexService/UpdateIndex", request_serializer=index_service.UpdateIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_index"] @property def delete_index( self, - ) -> Callable[[index_service.DeleteIndexRequest], operations.Operation]: + ) -> Callable[[index_service.DeleteIndexRequest], operations_pb2.Operation]: r"""Return a callable for the delete index method over gRPC. Deletes an Index. An Index can only be deleted when all its @@ -368,7 +368,7 @@ def delete_index( self._stubs["delete_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexService/DeleteIndex", request_serializer=index_service.DeleteIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_index"] diff --git a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py index cbcf84110e..c17e033b7c 100644 --- a/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/index_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1beta1.types import index from google.cloud.aiplatform_v1beta1.types import index_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import IndexServiceTransport, DEFAULT_CLIENT_INFO from .grpc import IndexServiceGrpcTransport @@ -57,7 +54,7 @@ class IndexServiceGrpcAsyncIOTransport(IndexServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -84,13 +81,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -98,7 +97,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -112,7 +111,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -171,7 +171,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -249,7 +248,9 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: @property def create_index( self, - ) -> Callable[[index_service.CreateIndexRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [index_service.CreateIndexRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the create index method over gRPC. Creates an Index. @@ -268,7 +269,7 @@ def create_index( self._stubs["create_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexService/CreateIndex", request_serializer=index_service.CreateIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_index"] @@ -329,7 +330,9 @@ def list_indexes( @property def update_index( self, - ) -> Callable[[index_service.UpdateIndexRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [index_service.UpdateIndexRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the update index method over gRPC. Updates an Index. @@ -348,14 +351,16 @@ def update_index( self._stubs["update_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexService/UpdateIndex", request_serializer=index_service.UpdateIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_index"] @property def delete_index( self, - ) -> Callable[[index_service.DeleteIndexRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [index_service.DeleteIndexRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete index method over gRPC. Deletes an Index. An Index can only be deleted when all its @@ -376,7 +381,7 @@ def delete_index( self._stubs["delete_index"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.IndexService/DeleteIndex", request_serializer=index_service.DeleteIndexRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_index"] diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/job_service/__init__.py index 5f157047f5..3d8d94dbd8 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import JobServiceClient from .async_client import JobServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/job_service/async_client.py index e736d5de17..0396f4db64 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -60,14 +58,13 @@ from google.cloud.aiplatform_v1beta1.types import model_monitoring from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.cloud.aiplatform_v1beta1.types import study -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport from .client import JobServiceClient @@ -115,25 +112,20 @@ class JobServiceAsyncClient: parse_tensorboard_path = staticmethod(JobServiceClient.parse_tensorboard_path) trial_path = staticmethod(JobServiceClient.trial_path) parse_trial_path = staticmethod(JobServiceClient.parse_trial_path) - common_billing_account_path = staticmethod( JobServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( JobServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(JobServiceClient.common_folder_path) parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(JobServiceClient.common_organization_path) parse_common_organization_path = staticmethod( JobServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(JobServiceClient.common_project_path) parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) - common_location_path = staticmethod(JobServiceClient.common_location_path) parse_common_location_path = staticmethod( JobServiceClient.parse_common_location_path @@ -187,7 +179,7 @@ def transport(self) -> JobServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, JobServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -224,7 +216,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = JobServiceClient( credentials=credentials, transport=transport, @@ -262,7 +253,6 @@ async def create_custom_job( This corresponds to the ``custom_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -295,7 +285,6 @@ async def create_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if custom_job is not None: @@ -343,7 +332,6 @@ async def get_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -376,7 +364,6 @@ async def get_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -423,7 +410,6 @@ async def list_custom_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -453,7 +439,6 @@ async def list_custom_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -506,7 +491,6 @@ async def delete_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -546,7 +530,6 @@ async def delete_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -571,7 +554,7 @@ async def delete_custom_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -612,7 +595,6 @@ async def cancel_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -633,7 +615,6 @@ async def cancel_custom_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -686,7 +667,6 @@ async def create_data_labeling_job( This corresponds to the ``data_labeling_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -714,7 +694,6 @@ async def create_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if data_labeling_job is not None: @@ -762,7 +741,6 @@ async def get_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -790,7 +768,6 @@ async def get_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -836,7 +813,6 @@ async def list_data_labeling_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -866,7 +842,6 @@ async def list_data_labeling_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -919,7 +894,6 @@ async def delete_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -959,7 +933,6 @@ async def delete_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -984,7 +957,7 @@ async def delete_data_labeling_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1014,7 +987,6 @@ async def cancel_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1035,7 +1007,6 @@ async def cancel_data_labeling_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1089,7 +1060,6 @@ async def create_hyperparameter_tuning_job( This corresponds to the ``hyperparameter_tuning_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1118,7 +1088,6 @@ async def create_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if hyperparameter_tuning_job is not None: @@ -1167,7 +1136,6 @@ async def get_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1196,7 +1164,6 @@ async def get_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1243,7 +1210,6 @@ async def list_hyperparameter_tuning_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1273,7 +1239,6 @@ async def list_hyperparameter_tuning_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1326,7 +1291,6 @@ async def delete_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1366,7 +1330,6 @@ async def delete_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1391,7 +1354,7 @@ async def delete_hyperparameter_tuning_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1434,7 +1397,6 @@ async def cancel_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1455,7 +1417,6 @@ async def cancel_hyperparameter_tuning_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1510,7 +1471,6 @@ async def create_batch_prediction_job( This corresponds to the ``batch_prediction_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1541,7 +1501,6 @@ async def create_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if batch_prediction_job is not None: @@ -1590,7 +1549,6 @@ async def get_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1621,7 +1579,6 @@ async def get_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1668,7 +1625,6 @@ async def list_batch_prediction_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1698,7 +1654,6 @@ async def list_batch_prediction_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1752,7 +1707,6 @@ async def delete_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1792,7 +1746,6 @@ async def delete_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1817,7 +1770,7 @@ async def delete_batch_prediction_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1858,7 +1811,6 @@ async def cancel_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1879,7 +1831,6 @@ async def cancel_batch_prediction_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1934,7 +1885,6 @@ async def create_model_deployment_monitoring_job( This corresponds to the ``model_deployment_monitoring_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1964,7 +1914,6 @@ async def create_model_deployment_monitoring_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if model_deployment_monitoring_job is not None: @@ -2022,7 +1971,6 @@ async def search_model_deployment_monitoring_stats_anomalies( This corresponds to the ``deployed_model_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2054,7 +2002,6 @@ async def search_model_deployment_monitoring_stats_anomalies( # If we have keyword arguments corresponding to fields on the # request, apply these. - if model_deployment_monitoring_job is not None: request.model_deployment_monitoring_job = model_deployment_monitoring_job if deployed_model_id is not None: @@ -2116,7 +2063,6 @@ async def get_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2146,7 +2092,6 @@ async def get_model_deployment_monitoring_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2193,7 +2138,6 @@ async def list_model_deployment_monitoring_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2223,7 +2167,6 @@ async def list_model_deployment_monitoring_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2258,7 +2201,7 @@ async def update_model_deployment_monitoring_job( request: job_service.UpdateModelDeploymentMonitoringJobRequest = None, *, model_deployment_monitoring_job: gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2284,7 +2227,6 @@ async def update_model_deployment_monitoring_job( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2314,7 +2256,6 @@ async def update_model_deployment_monitoring_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if model_deployment_monitoring_job is not None: request.model_deployment_monitoring_job = model_deployment_monitoring_job if update_mask is not None: @@ -2378,7 +2319,6 @@ async def delete_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2418,7 +2358,6 @@ async def delete_model_deployment_monitoring_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2443,7 +2382,7 @@ async def delete_model_deployment_monitoring_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -2476,7 +2415,6 @@ async def pause_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2497,7 +2435,6 @@ async def pause_model_deployment_monitoring_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2545,7 +2482,6 @@ async def resume_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2566,7 +2502,6 @@ async def resume_model_deployment_monitoring_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/client.py b/google/cloud/aiplatform_v1beta1/services/job_service/client.py index 6764071e9e..c802dfd25a 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -64,14 +62,13 @@ from google.cloud.aiplatform_v1beta1.types import model_monitoring from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.cloud.aiplatform_v1beta1.types import study -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore from .transports.base import JobServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import JobServiceGrpcTransport from .transports.grpc_asyncio import JobServiceGrpcAsyncIOTransport @@ -441,7 +438,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, JobServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -581,7 +578,6 @@ def create_custom_job( This corresponds to the ``custom_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -616,10 +612,8 @@ def create_custom_job( # there are no flattened fields. if not isinstance(request, job_service.CreateCustomJobRequest): request = job_service.CreateCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if custom_job is not None: @@ -663,7 +657,6 @@ def get_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -698,10 +691,8 @@ def get_custom_job( # there are no flattened fields. if not isinstance(request, job_service.GetCustomJobRequest): request = job_service.GetCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -744,7 +735,6 @@ def list_custom_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -776,10 +766,8 @@ def list_custom_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListCustomJobsRequest): request = job_service.ListCustomJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -828,7 +816,6 @@ def delete_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -870,10 +857,8 @@ def delete_custom_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteCustomJobRequest): request = job_service.DeleteCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -894,7 +879,7 @@ def delete_custom_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -935,7 +920,6 @@ def cancel_custom_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -958,10 +942,8 @@ def cancel_custom_job( # there are no flattened fields. if not isinstance(request, job_service.CancelCustomJobRequest): request = job_service.CancelCustomJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1010,7 +992,6 @@ def create_data_labeling_job( This corresponds to the ``data_labeling_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1040,10 +1021,8 @@ def create_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.CreateDataLabelingJobRequest): request = job_service.CreateDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if data_labeling_job is not None: @@ -1087,7 +1066,6 @@ def get_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1117,10 +1095,8 @@ def get_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.GetDataLabelingJobRequest): request = job_service.GetDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1162,7 +1138,6 @@ def list_data_labeling_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1194,10 +1169,8 @@ def list_data_labeling_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListDataLabelingJobsRequest): request = job_service.ListDataLabelingJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1246,7 +1219,6 @@ def delete_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1288,10 +1260,8 @@ def delete_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteDataLabelingJobRequest): request = job_service.DeleteDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1312,7 +1282,7 @@ def delete_data_labeling_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1342,7 +1312,6 @@ def cancel_data_labeling_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1365,10 +1334,8 @@ def cancel_data_labeling_job( # there are no flattened fields. if not isinstance(request, job_service.CancelDataLabelingJobRequest): request = job_service.CancelDataLabelingJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1418,7 +1385,6 @@ def create_hyperparameter_tuning_job( This corresponds to the ``hyperparameter_tuning_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1449,10 +1415,8 @@ def create_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.CreateHyperparameterTuningJobRequest): request = job_service.CreateHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if hyperparameter_tuning_job is not None: @@ -1499,7 +1463,6 @@ def get_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1530,10 +1493,8 @@ def get_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.GetHyperparameterTuningJobRequest): request = job_service.GetHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1578,7 +1539,6 @@ def list_hyperparameter_tuning_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1610,10 +1570,8 @@ def list_hyperparameter_tuning_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListHyperparameterTuningJobsRequest): request = job_service.ListHyperparameterTuningJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1664,7 +1622,6 @@ def delete_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1706,10 +1663,8 @@ def delete_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteHyperparameterTuningJobRequest): request = job_service.DeleteHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1732,7 +1687,7 @@ def delete_hyperparameter_tuning_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1775,7 +1730,6 @@ def cancel_hyperparameter_tuning_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1798,10 +1752,8 @@ def cancel_hyperparameter_tuning_job( # there are no flattened fields. if not isinstance(request, job_service.CancelHyperparameterTuningJobRequest): request = job_service.CancelHyperparameterTuningJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1854,7 +1806,6 @@ def create_batch_prediction_job( This corresponds to the ``batch_prediction_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1887,10 +1838,8 @@ def create_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.CreateBatchPredictionJobRequest): request = job_service.CreateBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if batch_prediction_job is not None: @@ -1937,7 +1886,6 @@ def get_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1970,10 +1918,8 @@ def get_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.GetBatchPredictionJobRequest): request = job_service.GetBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2016,7 +1962,6 @@ def list_batch_prediction_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2048,10 +1993,8 @@ def list_batch_prediction_jobs( # there are no flattened fields. if not isinstance(request, job_service.ListBatchPredictionJobsRequest): request = job_service.ListBatchPredictionJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2103,7 +2046,6 @@ def delete_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2145,10 +2087,8 @@ def delete_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.DeleteBatchPredictionJobRequest): request = job_service.DeleteBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2171,7 +2111,7 @@ def delete_batch_prediction_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -2212,7 +2152,6 @@ def cancel_batch_prediction_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2235,10 +2174,8 @@ def cancel_batch_prediction_job( # there are no flattened fields. if not isinstance(request, job_service.CancelBatchPredictionJobRequest): request = job_service.CancelBatchPredictionJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2291,7 +2228,6 @@ def create_model_deployment_monitoring_job( This corresponds to the ``model_deployment_monitoring_job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2325,10 +2261,8 @@ def create_model_deployment_monitoring_job( request, job_service.CreateModelDeploymentMonitoringJobRequest ): request = job_service.CreateModelDeploymentMonitoringJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if model_deployment_monitoring_job is not None: @@ -2386,7 +2320,6 @@ def search_model_deployment_monitoring_stats_anomalies( This corresponds to the ``deployed_model_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2422,10 +2355,8 @@ def search_model_deployment_monitoring_stats_anomalies( request = job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest( request ) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if model_deployment_monitoring_job is not None: request.model_deployment_monitoring_job = ( model_deployment_monitoring_job @@ -2487,7 +2418,6 @@ def get_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2519,10 +2449,8 @@ def get_model_deployment_monitoring_job( # there are no flattened fields. if not isinstance(request, job_service.GetModelDeploymentMonitoringJobRequest): request = job_service.GetModelDeploymentMonitoringJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2567,7 +2495,6 @@ def list_model_deployment_monitoring_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2601,10 +2528,8 @@ def list_model_deployment_monitoring_jobs( request, job_service.ListModelDeploymentMonitoringJobsRequest ): request = job_service.ListModelDeploymentMonitoringJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2637,7 +2562,7 @@ def update_model_deployment_monitoring_job( request: job_service.UpdateModelDeploymentMonitoringJobRequest = None, *, model_deployment_monitoring_job: gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2663,7 +2588,6 @@ def update_model_deployment_monitoring_job( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2697,10 +2621,8 @@ def update_model_deployment_monitoring_job( request, job_service.UpdateModelDeploymentMonitoringJobRequest ): request = job_service.UpdateModelDeploymentMonitoringJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if model_deployment_monitoring_job is not None: request.model_deployment_monitoring_job = ( model_deployment_monitoring_job @@ -2764,7 +2686,6 @@ def delete_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2808,10 +2729,8 @@ def delete_model_deployment_monitoring_job( request, job_service.DeleteModelDeploymentMonitoringJobRequest ): request = job_service.DeleteModelDeploymentMonitoringJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2834,7 +2753,7 @@ def delete_model_deployment_monitoring_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -2867,7 +2786,6 @@ def pause_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2892,10 +2810,8 @@ def pause_model_deployment_monitoring_job( request, job_service.PauseModelDeploymentMonitoringJobRequest ): request = job_service.PauseModelDeploymentMonitoringJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2941,7 +2857,6 @@ def resume_model_deployment_monitoring_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2966,10 +2881,8 @@ def resume_model_deployment_monitoring_job( request, job_service.ResumeModelDeploymentMonitoringJobRequest ): request = job_service.ResumeModelDeploymentMonitoringJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/job_service/pagers.py index 2ccecac0eb..cc1d17b38b 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/__init__.py index 349bfbcdea..c512946de1 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py index fbe6938185..f4adf20483 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import batch_prediction_job from google.cloud.aiplatform_v1beta1.types import ( @@ -45,9 +45,8 @@ from google.cloud.aiplatform_v1beta1.types import ( model_deployment_monitoring_job as gca_model_deployment_monitoring_job, ) -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -58,27 +57,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class JobServiceTransport(abc.ABC): """Abstract transport class for JobService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -87,7 +100,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -101,29 +114,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -267,31 +327,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateCustomJobRequest], - typing.Union[ - gca_custom_job.CustomJob, typing.Awaitable[gca_custom_job.CustomJob] - ], + Union[gca_custom_job.CustomJob, Awaitable[gca_custom_job.CustomJob]], ]: raise NotImplementedError() @property def get_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetCustomJobRequest], - typing.Union[custom_job.CustomJob, typing.Awaitable[custom_job.CustomJob]], + Union[custom_job.CustomJob, Awaitable[custom_job.CustomJob]], ]: raise NotImplementedError() @property def list_custom_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListCustomJobsRequest], - typing.Union[ + Union[ job_service.ListCustomJobsResponse, - typing.Awaitable[job_service.ListCustomJobsResponse], + Awaitable[job_service.ListCustomJobsResponse], ], ]: raise NotImplementedError() @@ -299,29 +357,29 @@ def list_custom_jobs( @property def delete_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteCustomJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_custom_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelCustomJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateDataLabelingJobRequest], - typing.Union[ + Union[ gca_data_labeling_job.DataLabelingJob, - typing.Awaitable[gca_data_labeling_job.DataLabelingJob], + Awaitable[gca_data_labeling_job.DataLabelingJob], ], ]: raise NotImplementedError() @@ -329,11 +387,11 @@ def create_data_labeling_job( @property def get_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetDataLabelingJobRequest], - typing.Union[ + Union[ data_labeling_job.DataLabelingJob, - typing.Awaitable[data_labeling_job.DataLabelingJob], + Awaitable[data_labeling_job.DataLabelingJob], ], ]: raise NotImplementedError() @@ -341,11 +399,11 @@ def get_data_labeling_job( @property def list_data_labeling_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListDataLabelingJobsRequest], - typing.Union[ + Union[ job_service.ListDataLabelingJobsResponse, - typing.Awaitable[job_service.ListDataLabelingJobsResponse], + Awaitable[job_service.ListDataLabelingJobsResponse], ], ]: raise NotImplementedError() @@ -353,29 +411,29 @@ def list_data_labeling_jobs( @property def delete_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteDataLabelingJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_data_labeling_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelDataLabelingJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateHyperparameterTuningJobRequest], - typing.Union[ + Union[ gca_hyperparameter_tuning_job.HyperparameterTuningJob, - typing.Awaitable[gca_hyperparameter_tuning_job.HyperparameterTuningJob], + Awaitable[gca_hyperparameter_tuning_job.HyperparameterTuningJob], ], ]: raise NotImplementedError() @@ -383,11 +441,11 @@ def create_hyperparameter_tuning_job( @property def get_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetHyperparameterTuningJobRequest], - typing.Union[ + Union[ hyperparameter_tuning_job.HyperparameterTuningJob, - typing.Awaitable[hyperparameter_tuning_job.HyperparameterTuningJob], + Awaitable[hyperparameter_tuning_job.HyperparameterTuningJob], ], ]: raise NotImplementedError() @@ -395,11 +453,11 @@ def get_hyperparameter_tuning_job( @property def list_hyperparameter_tuning_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListHyperparameterTuningJobsRequest], - typing.Union[ + Union[ job_service.ListHyperparameterTuningJobsResponse, - typing.Awaitable[job_service.ListHyperparameterTuningJobsResponse], + Awaitable[job_service.ListHyperparameterTuningJobsResponse], ], ]: raise NotImplementedError() @@ -407,29 +465,29 @@ def list_hyperparameter_tuning_jobs( @property def delete_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteHyperparameterTuningJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_hyperparameter_tuning_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelHyperparameterTuningJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateBatchPredictionJobRequest], - typing.Union[ + Union[ gca_batch_prediction_job.BatchPredictionJob, - typing.Awaitable[gca_batch_prediction_job.BatchPredictionJob], + Awaitable[gca_batch_prediction_job.BatchPredictionJob], ], ]: raise NotImplementedError() @@ -437,11 +495,11 @@ def create_batch_prediction_job( @property def get_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetBatchPredictionJobRequest], - typing.Union[ + Union[ batch_prediction_job.BatchPredictionJob, - typing.Awaitable[batch_prediction_job.BatchPredictionJob], + Awaitable[batch_prediction_job.BatchPredictionJob], ], ]: raise NotImplementedError() @@ -449,11 +507,11 @@ def get_batch_prediction_job( @property def list_batch_prediction_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListBatchPredictionJobsRequest], - typing.Union[ + Union[ job_service.ListBatchPredictionJobsResponse, - typing.Awaitable[job_service.ListBatchPredictionJobsResponse], + Awaitable[job_service.ListBatchPredictionJobsResponse], ], ]: raise NotImplementedError() @@ -461,31 +519,29 @@ def list_batch_prediction_jobs( @property def delete_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteBatchPredictionJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_batch_prediction_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CancelBatchPredictionJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_model_deployment_monitoring_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.CreateModelDeploymentMonitoringJobRequest], - typing.Union[ + Union[ gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob, - typing.Awaitable[ - gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob - ], + Awaitable[gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob], ], ]: raise NotImplementedError() @@ -493,11 +549,11 @@ def create_model_deployment_monitoring_job( @property def search_model_deployment_monitoring_stats_anomalies( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest], - typing.Union[ + Union[ job_service.SearchModelDeploymentMonitoringStatsAnomaliesResponse, - typing.Awaitable[ + Awaitable[ job_service.SearchModelDeploymentMonitoringStatsAnomaliesResponse ], ], @@ -507,13 +563,11 @@ def search_model_deployment_monitoring_stats_anomalies( @property def get_model_deployment_monitoring_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.GetModelDeploymentMonitoringJobRequest], - typing.Union[ + Union[ model_deployment_monitoring_job.ModelDeploymentMonitoringJob, - typing.Awaitable[ - model_deployment_monitoring_job.ModelDeploymentMonitoringJob - ], + Awaitable[model_deployment_monitoring_job.ModelDeploymentMonitoringJob], ], ]: raise NotImplementedError() @@ -521,11 +575,11 @@ def get_model_deployment_monitoring_job( @property def list_model_deployment_monitoring_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ListModelDeploymentMonitoringJobsRequest], - typing.Union[ + Union[ job_service.ListModelDeploymentMonitoringJobsResponse, - typing.Awaitable[job_service.ListModelDeploymentMonitoringJobsResponse], + Awaitable[job_service.ListModelDeploymentMonitoringJobsResponse], ], ]: raise NotImplementedError() @@ -533,36 +587,36 @@ def list_model_deployment_monitoring_jobs( @property def update_model_deployment_monitoring_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.UpdateModelDeploymentMonitoringJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_model_deployment_monitoring_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.DeleteModelDeploymentMonitoringJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def pause_model_deployment_monitoring_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.PauseModelDeploymentMonitoringJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def resume_model_deployment_monitoring_job( self, - ) -> typing.Callable[ + ) -> Callable[ [job_service.ResumeModelDeploymentMonitoringJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py index 50a54d468f..797420d74a 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -46,9 +44,8 @@ from google.cloud.aiplatform_v1beta1.types import ( model_deployment_monitoring_job as gca_model_deployment_monitoring_job, ) -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import JobServiceTransport, DEFAULT_CLIENT_INFO @@ -71,7 +68,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -85,7 +82,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -196,7 +194,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -227,13 +225,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -341,7 +341,7 @@ def list_custom_jobs( @property def delete_custom_job( self, - ) -> Callable[[job_service.DeleteCustomJobRequest], operations.Operation]: + ) -> Callable[[job_service.DeleteCustomJobRequest], operations_pb2.Operation]: r"""Return a callable for the delete custom job method over gRPC. Deletes a CustomJob. @@ -360,14 +360,14 @@ def delete_custom_job( self._stubs["delete_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteCustomJob", request_serializer=job_service.DeleteCustomJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_custom_job"] @property def cancel_custom_job( self, - ) -> Callable[[job_service.CancelCustomJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelCustomJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel custom job method over gRPC. Cancels a CustomJob. Starts asynchronous cancellation on the @@ -398,7 +398,7 @@ def cancel_custom_job( self._stubs["cancel_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelCustomJob", request_serializer=job_service.CancelCustomJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_custom_job"] @@ -491,7 +491,7 @@ def list_data_labeling_jobs( @property def delete_data_labeling_job( self, - ) -> Callable[[job_service.DeleteDataLabelingJobRequest], operations.Operation]: + ) -> Callable[[job_service.DeleteDataLabelingJobRequest], operations_pb2.Operation]: r"""Return a callable for the delete data labeling job method over gRPC. Deletes a DataLabelingJob. @@ -510,14 +510,14 @@ def delete_data_labeling_job( self._stubs["delete_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteDataLabelingJob", request_serializer=job_service.DeleteDataLabelingJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_data_labeling_job"] @property def cancel_data_labeling_job( self, - ) -> Callable[[job_service.CancelDataLabelingJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelDataLabelingJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel data labeling job method over gRPC. Cancels a DataLabelingJob. Success of cancellation is @@ -537,7 +537,7 @@ def cancel_data_labeling_job( self._stubs["cancel_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelDataLabelingJob", request_serializer=job_service.CancelDataLabelingJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_data_labeling_job"] @@ -640,7 +640,7 @@ def list_hyperparameter_tuning_jobs( def delete_hyperparameter_tuning_job( self, ) -> Callable[ - [job_service.DeleteHyperparameterTuningJobRequest], operations.Operation + [job_service.DeleteHyperparameterTuningJobRequest], operations_pb2.Operation ]: r"""Return a callable for the delete hyperparameter tuning job method over gRPC. @@ -663,14 +663,14 @@ def delete_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteHyperparameterTuningJob", request_serializer=job_service.DeleteHyperparameterTuningJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_hyperparameter_tuning_job"] @property def cancel_hyperparameter_tuning_job( self, - ) -> Callable[[job_service.CancelHyperparameterTuningJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelHyperparameterTuningJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel hyperparameter tuning job method over gRPC. @@ -705,7 +705,7 @@ def cancel_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelHyperparameterTuningJob", request_serializer=job_service.CancelHyperparameterTuningJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_hyperparameter_tuning_job"] @@ -800,7 +800,9 @@ def list_batch_prediction_jobs( @property def delete_batch_prediction_job( self, - ) -> Callable[[job_service.DeleteBatchPredictionJobRequest], operations.Operation]: + ) -> Callable[ + [job_service.DeleteBatchPredictionJobRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete batch prediction job method over gRPC. Deletes a BatchPredictionJob. Can only be called on @@ -820,14 +822,14 @@ def delete_batch_prediction_job( self._stubs["delete_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteBatchPredictionJob", request_serializer=job_service.DeleteBatchPredictionJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_batch_prediction_job"] @property def cancel_batch_prediction_job( self, - ) -> Callable[[job_service.CancelBatchPredictionJobRequest], empty.Empty]: + ) -> Callable[[job_service.CancelBatchPredictionJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel batch prediction job method over gRPC. Cancels a BatchPredictionJob. @@ -857,7 +859,7 @@ def cancel_batch_prediction_job( self._stubs["cancel_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelBatchPredictionJob", request_serializer=job_service.CancelBatchPredictionJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_batch_prediction_job"] @@ -995,7 +997,8 @@ def list_model_deployment_monitoring_jobs( def update_model_deployment_monitoring_job( self, ) -> Callable[ - [job_service.UpdateModelDeploymentMonitoringJobRequest], operations.Operation + [job_service.UpdateModelDeploymentMonitoringJobRequest], + operations_pb2.Operation, ]: r"""Return a callable for the update model deployment monitoring job method over gRPC. @@ -1018,7 +1021,7 @@ def update_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/UpdateModelDeploymentMonitoringJob", request_serializer=job_service.UpdateModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_model_deployment_monitoring_job"] @@ -1026,7 +1029,8 @@ def update_model_deployment_monitoring_job( def delete_model_deployment_monitoring_job( self, ) -> Callable[ - [job_service.DeleteModelDeploymentMonitoringJobRequest], operations.Operation + [job_service.DeleteModelDeploymentMonitoringJobRequest], + operations_pb2.Operation, ]: r"""Return a callable for the delete model deployment monitoring job method over gRPC. @@ -1049,14 +1053,16 @@ def delete_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteModelDeploymentMonitoringJob", request_serializer=job_service.DeleteModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_model_deployment_monitoring_job"] @property def pause_model_deployment_monitoring_job( self, - ) -> Callable[[job_service.PauseModelDeploymentMonitoringJobRequest], empty.Empty]: + ) -> Callable[ + [job_service.PauseModelDeploymentMonitoringJobRequest], empty_pb2.Empty + ]: r"""Return a callable for the pause model deployment monitoring job method over gRPC. @@ -1081,14 +1087,16 @@ def pause_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/PauseModelDeploymentMonitoringJob", request_serializer=job_service.PauseModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["pause_model_deployment_monitoring_job"] @property def resume_model_deployment_monitoring_job( self, - ) -> Callable[[job_service.ResumeModelDeploymentMonitoringJobRequest], empty.Empty]: + ) -> Callable[ + [job_service.ResumeModelDeploymentMonitoringJobRequest], empty_pb2.Empty + ]: r"""Return a callable for the resume model deployment monitoring job method over gRPC. @@ -1112,7 +1120,7 @@ def resume_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/ResumeModelDeploymentMonitoringJob", request_serializer=job_service.ResumeModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["resume_model_deployment_monitoring_job"] diff --git a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py index b16a2c7cc7..93f5416555 100644 --- a/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/job_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -47,9 +45,8 @@ from google.cloud.aiplatform_v1beta1.types import ( model_deployment_monitoring_job as gca_model_deployment_monitoring_job, ) -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import JobServiceTransport, DEFAULT_CLIENT_INFO from .grpc import JobServiceGrpcTransport @@ -74,7 +71,7 @@ class JobServiceGrpcAsyncIOTransport(JobServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -101,13 +98,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -115,7 +114,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -129,7 +128,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -188,7 +188,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -351,7 +350,7 @@ def list_custom_jobs( def delete_custom_job( self, ) -> Callable[ - [job_service.DeleteCustomJobRequest], Awaitable[operations.Operation] + [job_service.DeleteCustomJobRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete custom job method over gRPC. @@ -371,14 +370,14 @@ def delete_custom_job( self._stubs["delete_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteCustomJob", request_serializer=job_service.DeleteCustomJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_custom_job"] @property def cancel_custom_job( self, - ) -> Callable[[job_service.CancelCustomJobRequest], Awaitable[empty.Empty]]: + ) -> Callable[[job_service.CancelCustomJobRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the cancel custom job method over gRPC. Cancels a CustomJob. Starts asynchronous cancellation on the @@ -409,7 +408,7 @@ def cancel_custom_job( self._stubs["cancel_custom_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelCustomJob", request_serializer=job_service.CancelCustomJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_custom_job"] @@ -504,7 +503,7 @@ def list_data_labeling_jobs( def delete_data_labeling_job( self, ) -> Callable[ - [job_service.DeleteDataLabelingJobRequest], Awaitable[operations.Operation] + [job_service.DeleteDataLabelingJobRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete data labeling job method over gRPC. @@ -524,14 +523,16 @@ def delete_data_labeling_job( self._stubs["delete_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteDataLabelingJob", request_serializer=job_service.DeleteDataLabelingJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_data_labeling_job"] @property def cancel_data_labeling_job( self, - ) -> Callable[[job_service.CancelDataLabelingJobRequest], Awaitable[empty.Empty]]: + ) -> Callable[ + [job_service.CancelDataLabelingJobRequest], Awaitable[empty_pb2.Empty] + ]: r"""Return a callable for the cancel data labeling job method over gRPC. Cancels a DataLabelingJob. Success of cancellation is @@ -551,7 +552,7 @@ def cancel_data_labeling_job( self._stubs["cancel_data_labeling_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelDataLabelingJob", request_serializer=job_service.CancelDataLabelingJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_data_labeling_job"] @@ -655,7 +656,7 @@ def delete_hyperparameter_tuning_job( self, ) -> Callable[ [job_service.DeleteHyperparameterTuningJobRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete hyperparameter tuning job method over gRPC. @@ -678,7 +679,7 @@ def delete_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteHyperparameterTuningJob", request_serializer=job_service.DeleteHyperparameterTuningJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_hyperparameter_tuning_job"] @@ -686,7 +687,7 @@ def delete_hyperparameter_tuning_job( def cancel_hyperparameter_tuning_job( self, ) -> Callable[ - [job_service.CancelHyperparameterTuningJobRequest], Awaitable[empty.Empty] + [job_service.CancelHyperparameterTuningJobRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the cancel hyperparameter tuning job method over gRPC. @@ -722,7 +723,7 @@ def cancel_hyperparameter_tuning_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelHyperparameterTuningJob", request_serializer=job_service.CancelHyperparameterTuningJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_hyperparameter_tuning_job"] @@ -818,7 +819,8 @@ def list_batch_prediction_jobs( def delete_batch_prediction_job( self, ) -> Callable[ - [job_service.DeleteBatchPredictionJobRequest], Awaitable[operations.Operation] + [job_service.DeleteBatchPredictionJobRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete batch prediction job method over gRPC. @@ -839,7 +841,7 @@ def delete_batch_prediction_job( self._stubs["delete_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteBatchPredictionJob", request_serializer=job_service.DeleteBatchPredictionJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_batch_prediction_job"] @@ -847,7 +849,7 @@ def delete_batch_prediction_job( def cancel_batch_prediction_job( self, ) -> Callable[ - [job_service.CancelBatchPredictionJobRequest], Awaitable[empty.Empty] + [job_service.CancelBatchPredictionJobRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the cancel batch prediction job method over gRPC. @@ -878,7 +880,7 @@ def cancel_batch_prediction_job( self._stubs["cancel_batch_prediction_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/CancelBatchPredictionJob", request_serializer=job_service.CancelBatchPredictionJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_batch_prediction_job"] @@ -1017,7 +1019,7 @@ def update_model_deployment_monitoring_job( self, ) -> Callable[ [job_service.UpdateModelDeploymentMonitoringJobRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update model deployment monitoring job method over gRPC. @@ -1040,7 +1042,7 @@ def update_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/UpdateModelDeploymentMonitoringJob", request_serializer=job_service.UpdateModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_model_deployment_monitoring_job"] @@ -1049,7 +1051,7 @@ def delete_model_deployment_monitoring_job( self, ) -> Callable[ [job_service.DeleteModelDeploymentMonitoringJobRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete model deployment monitoring job method over gRPC. @@ -1072,7 +1074,7 @@ def delete_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/DeleteModelDeploymentMonitoringJob", request_serializer=job_service.DeleteModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_model_deployment_monitoring_job"] @@ -1080,7 +1082,8 @@ def delete_model_deployment_monitoring_job( def pause_model_deployment_monitoring_job( self, ) -> Callable[ - [job_service.PauseModelDeploymentMonitoringJobRequest], Awaitable[empty.Empty] + [job_service.PauseModelDeploymentMonitoringJobRequest], + Awaitable[empty_pb2.Empty], ]: r"""Return a callable for the pause model deployment monitoring job method over gRPC. @@ -1106,7 +1109,7 @@ def pause_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/PauseModelDeploymentMonitoringJob", request_serializer=job_service.PauseModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["pause_model_deployment_monitoring_job"] @@ -1114,7 +1117,8 @@ def pause_model_deployment_monitoring_job( def resume_model_deployment_monitoring_job( self, ) -> Callable[ - [job_service.ResumeModelDeploymentMonitoringJobRequest], Awaitable[empty.Empty] + [job_service.ResumeModelDeploymentMonitoringJobRequest], + Awaitable[empty_pb2.Empty], ]: r"""Return a callable for the resume model deployment monitoring job method over gRPC. @@ -1139,7 +1143,7 @@ def resume_model_deployment_monitoring_job( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.JobService/ResumeModelDeploymentMonitoringJob", request_serializer=job_service.ResumeModelDeploymentMonitoringJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["resume_model_deployment_monitoring_job"] diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/__init__.py index 8e9c09c94d..656a64511b 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import MetadataServiceClient from .async_client import MetadataServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/async_client.py index 42246f3130..18488133ce 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -46,11 +44,10 @@ from google.cloud.aiplatform_v1beta1.types import metadata_store from google.cloud.aiplatform_v1beta1.types import metadata_store as gca_metadata_store from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import MetadataServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import MetadataServiceGrpcAsyncIOTransport from .client import MetadataServiceClient @@ -78,31 +75,26 @@ class MetadataServiceAsyncClient: parse_metadata_store_path = staticmethod( MetadataServiceClient.parse_metadata_store_path ) - common_billing_account_path = staticmethod( MetadataServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( MetadataServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(MetadataServiceClient.common_folder_path) parse_common_folder_path = staticmethod( MetadataServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( MetadataServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( MetadataServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(MetadataServiceClient.common_project_path) parse_common_project_path = staticmethod( MetadataServiceClient.parse_common_project_path ) - common_location_path = staticmethod(MetadataServiceClient.common_location_path) parse_common_location_path = staticmethod( MetadataServiceClient.parse_common_location_path @@ -156,7 +148,7 @@ def transport(self) -> MetadataServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, MetadataServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -193,7 +185,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = MetadataServiceClient( credentials=credentials, transport=transport, @@ -250,7 +241,6 @@ async def create_metadata_store( This corresponds to the ``metadata_store_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -279,7 +269,6 @@ async def create_metadata_store( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if metadata_store is not None: @@ -338,7 +327,6 @@ async def get_metadata_store( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -366,7 +354,6 @@ async def get_metadata_store( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -413,7 +400,6 @@ async def list_metadata_stores( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -443,7 +429,6 @@ async def list_metadata_stores( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -496,7 +481,6 @@ async def delete_metadata_store( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -536,7 +520,6 @@ async def delete_metadata_store( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -561,7 +544,7 @@ async def delete_metadata_store( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=metadata_service.DeleteMetadataStoreOperationMetadata, ) @@ -614,7 +597,6 @@ async def create_artifact( This corresponds to the ``artifact_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -639,7 +621,6 @@ async def create_artifact( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if artifact is not None: @@ -690,7 +671,6 @@ async def get_artifact( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -715,7 +695,6 @@ async def get_artifact( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -762,7 +741,6 @@ async def list_artifacts( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -792,7 +770,6 @@ async def list_artifacts( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -827,7 +804,7 @@ async def update_artifact( request: metadata_service.UpdateArtifactRequest = None, *, artifact: gca_artifact.Artifact = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -856,7 +833,6 @@ async def update_artifact( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -881,7 +857,6 @@ async def update_artifact( # If we have keyword arguments corresponding to fields on the # request, apply these. - if artifact is not None: request.artifact = artifact if update_mask is not None: @@ -955,7 +930,6 @@ async def create_context( This corresponds to the ``context_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -980,7 +954,6 @@ async def create_context( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if context is not None: @@ -1031,7 +1004,6 @@ async def get_context( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1056,7 +1028,6 @@ async def get_context( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1103,7 +1074,6 @@ async def list_contexts( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1133,7 +1103,6 @@ async def list_contexts( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1168,7 +1137,7 @@ async def update_context( request: metadata_service.UpdateContextRequest = None, *, context: gca_context.Context = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1196,7 +1165,6 @@ async def update_context( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1221,7 +1189,6 @@ async def update_context( # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context if update_mask is not None: @@ -1272,7 +1239,6 @@ async def delete_context( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1312,7 +1278,6 @@ async def delete_context( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1337,7 +1302,7 @@ async def delete_context( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1386,7 +1351,6 @@ async def add_context_artifacts_and_executions( This corresponds to the ``executions`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1413,10 +1377,8 @@ async def add_context_artifacts_and_executions( # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context - if artifacts: request.artifacts.extend(artifacts) if executions: @@ -1477,7 +1439,6 @@ async def add_context_children( This corresponds to the ``child_contexts`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1504,10 +1465,8 @@ async def add_context_children( # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context - if child_contexts: request.child_contexts.extend(child_contexts) @@ -1562,7 +1521,6 @@ async def query_context_lineage_subgraph( This corresponds to the ``context`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1590,7 +1548,6 @@ async def query_context_lineage_subgraph( # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context @@ -1660,7 +1617,6 @@ async def create_execution( This corresponds to the ``execution_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1685,7 +1641,6 @@ async def create_execution( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if execution is not None: @@ -1736,7 +1691,6 @@ async def get_execution( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1761,7 +1715,6 @@ async def get_execution( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1808,7 +1761,6 @@ async def list_executions( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1838,7 +1790,6 @@ async def list_executions( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1873,7 +1824,7 @@ async def update_execution( request: metadata_service.UpdateExecutionRequest = None, *, execution: gca_execution.Execution = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1902,7 +1853,6 @@ async def update_execution( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1927,7 +1877,6 @@ async def update_execution( # If we have keyword arguments corresponding to fields on the # request, apply these. - if execution is not None: request.execution = execution if update_mask is not None: @@ -1988,7 +1937,6 @@ async def add_execution_events( This corresponds to the ``events`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2015,10 +1963,8 @@ async def add_execution_events( # If we have keyword arguments corresponding to fields on the # request, apply these. - if execution is not None: request.execution = execution - if events: request.events.extend(events) @@ -2071,7 +2017,6 @@ async def query_execution_inputs_and_outputs( This corresponds to the ``execution`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2099,7 +2044,6 @@ async def query_execution_inputs_and_outputs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if execution is not None: request.execution = execution @@ -2173,7 +2117,6 @@ async def create_metadata_schema( This corresponds to the ``metadata_schema_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2198,7 +2141,6 @@ async def create_metadata_schema( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if metadata_schema is not None: @@ -2249,7 +2191,6 @@ async def get_metadata_schema( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2274,7 +2215,6 @@ async def get_metadata_schema( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2322,7 +2262,6 @@ async def list_metadata_schemas( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2352,7 +2291,6 @@ async def list_metadata_schemas( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2413,7 +2351,6 @@ async def query_artifact_lineage_subgraph( This corresponds to the ``artifact`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2441,7 +2378,6 @@ async def query_artifact_lineage_subgraph( # If we have keyword arguments corresponding to fields on the # request, apply these. - if artifact is not None: request.artifact = artifact diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py index dc1e9c74ba..5c3a8871cc 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -50,11 +48,10 @@ from google.cloud.aiplatform_v1beta1.types import metadata_store from google.cloud.aiplatform_v1beta1.types import metadata_store as gca_metadata_store from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import MetadataServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import MetadataServiceGrpcTransport from .transports.grpc_asyncio import MetadataServiceGrpcAsyncIOTransport @@ -337,7 +334,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, MetadataServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -496,7 +493,6 @@ def create_metadata_store( This corresponds to the ``metadata_store_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -527,10 +523,8 @@ def create_metadata_store( # there are no flattened fields. if not isinstance(request, metadata_service.CreateMetadataStoreRequest): request = metadata_service.CreateMetadataStoreRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if metadata_store is not None: @@ -585,7 +579,6 @@ def get_metadata_store( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -615,10 +608,8 @@ def get_metadata_store( # there are no flattened fields. if not isinstance(request, metadata_service.GetMetadataStoreRequest): request = metadata_service.GetMetadataStoreRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -661,7 +652,6 @@ def list_metadata_stores( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -693,10 +683,8 @@ def list_metadata_stores( # there are no flattened fields. if not isinstance(request, metadata_service.ListMetadataStoresRequest): request = metadata_service.ListMetadataStoresRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -745,7 +733,6 @@ def delete_metadata_store( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -787,10 +774,8 @@ def delete_metadata_store( # there are no flattened fields. if not isinstance(request, metadata_service.DeleteMetadataStoreRequest): request = metadata_service.DeleteMetadataStoreRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -811,7 +796,7 @@ def delete_metadata_store( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=metadata_service.DeleteMetadataStoreOperationMetadata, ) @@ -864,7 +849,6 @@ def create_artifact( This corresponds to the ``artifact_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -891,10 +875,8 @@ def create_artifact( # there are no flattened fields. if not isinstance(request, metadata_service.CreateArtifactRequest): request = metadata_service.CreateArtifactRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if artifact is not None: @@ -941,7 +923,6 @@ def get_artifact( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -968,10 +949,8 @@ def get_artifact( # there are no flattened fields. if not isinstance(request, metadata_service.GetArtifactRequest): request = metadata_service.GetArtifactRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1014,7 +993,6 @@ def list_artifacts( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1046,10 +1024,8 @@ def list_artifacts( # there are no flattened fields. if not isinstance(request, metadata_service.ListArtifactsRequest): request = metadata_service.ListArtifactsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1080,7 +1056,7 @@ def update_artifact( request: metadata_service.UpdateArtifactRequest = None, *, artifact: gca_artifact.Artifact = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1109,7 +1085,6 @@ def update_artifact( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1136,10 +1111,8 @@ def update_artifact( # there are no flattened fields. if not isinstance(request, metadata_service.UpdateArtifactRequest): request = metadata_service.UpdateArtifactRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if artifact is not None: request.artifact = artifact if update_mask is not None: @@ -1209,7 +1182,6 @@ def create_context( This corresponds to the ``context_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1236,10 +1208,8 @@ def create_context( # there are no flattened fields. if not isinstance(request, metadata_service.CreateContextRequest): request = metadata_service.CreateContextRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if context is not None: @@ -1286,7 +1256,6 @@ def get_context( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1313,10 +1282,8 @@ def get_context( # there are no flattened fields. if not isinstance(request, metadata_service.GetContextRequest): request = metadata_service.GetContextRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1359,7 +1326,6 @@ def list_contexts( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1391,10 +1357,8 @@ def list_contexts( # there are no flattened fields. if not isinstance(request, metadata_service.ListContextsRequest): request = metadata_service.ListContextsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1425,7 +1389,7 @@ def update_context( request: metadata_service.UpdateContextRequest = None, *, context: gca_context.Context = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1453,7 +1417,6 @@ def update_context( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1480,10 +1443,8 @@ def update_context( # there are no flattened fields. if not isinstance(request, metadata_service.UpdateContextRequest): request = metadata_service.UpdateContextRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context if update_mask is not None: @@ -1530,7 +1491,6 @@ def delete_context( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1572,10 +1532,8 @@ def delete_context( # there are no flattened fields. if not isinstance(request, metadata_service.DeleteContextRequest): request = metadata_service.DeleteContextRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1596,7 +1554,7 @@ def delete_context( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1645,7 +1603,6 @@ def add_context_artifacts_and_executions( This corresponds to the ``executions`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1676,10 +1633,8 @@ def add_context_artifacts_and_executions( request, metadata_service.AddContextArtifactsAndExecutionsRequest ): request = metadata_service.AddContextArtifactsAndExecutionsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context if artifacts is not None: @@ -1740,7 +1695,6 @@ def add_context_children( This corresponds to the ``child_contexts`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1769,10 +1723,8 @@ def add_context_children( # there are no flattened fields. if not isinstance(request, metadata_service.AddContextChildrenRequest): request = metadata_service.AddContextChildrenRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context if child_contexts is not None: @@ -1825,7 +1777,6 @@ def query_context_lineage_subgraph( This corresponds to the ``context`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1855,10 +1806,8 @@ def query_context_lineage_subgraph( # there are no flattened fields. if not isinstance(request, metadata_service.QueryContextLineageSubgraphRequest): request = metadata_service.QueryContextLineageSubgraphRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if context is not None: request.context = context @@ -1926,7 +1875,6 @@ def create_execution( This corresponds to the ``execution_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1953,10 +1901,8 @@ def create_execution( # there are no flattened fields. if not isinstance(request, metadata_service.CreateExecutionRequest): request = metadata_service.CreateExecutionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if execution is not None: @@ -2003,7 +1949,6 @@ def get_execution( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2030,10 +1975,8 @@ def get_execution( # there are no flattened fields. if not isinstance(request, metadata_service.GetExecutionRequest): request = metadata_service.GetExecutionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2076,7 +2019,6 @@ def list_executions( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2108,10 +2050,8 @@ def list_executions( # there are no flattened fields. if not isinstance(request, metadata_service.ListExecutionsRequest): request = metadata_service.ListExecutionsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2142,7 +2082,7 @@ def update_execution( request: metadata_service.UpdateExecutionRequest = None, *, execution: gca_execution.Execution = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2171,7 +2111,6 @@ def update_execution( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2198,10 +2137,8 @@ def update_execution( # there are no flattened fields. if not isinstance(request, metadata_service.UpdateExecutionRequest): request = metadata_service.UpdateExecutionRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if execution is not None: request.execution = execution if update_mask is not None: @@ -2258,7 +2195,6 @@ def add_execution_events( This corresponds to the ``events`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2287,10 +2223,8 @@ def add_execution_events( # there are no flattened fields. if not isinstance(request, metadata_service.AddExecutionEventsRequest): request = metadata_service.AddExecutionEventsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if execution is not None: request.execution = execution if events is not None: @@ -2341,7 +2275,6 @@ def query_execution_inputs_and_outputs( This corresponds to the ``execution`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2373,10 +2306,8 @@ def query_execution_inputs_and_outputs( request, metadata_service.QueryExecutionInputsAndOutputsRequest ): request = metadata_service.QueryExecutionInputsAndOutputsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if execution is not None: request.execution = execution @@ -2448,7 +2379,6 @@ def create_metadata_schema( This corresponds to the ``metadata_schema_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2475,10 +2405,8 @@ def create_metadata_schema( # there are no flattened fields. if not isinstance(request, metadata_service.CreateMetadataSchemaRequest): request = metadata_service.CreateMetadataSchemaRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if metadata_schema is not None: @@ -2525,7 +2453,6 @@ def get_metadata_schema( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2552,10 +2479,8 @@ def get_metadata_schema( # there are no flattened fields. if not isinstance(request, metadata_service.GetMetadataSchemaRequest): request = metadata_service.GetMetadataSchemaRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2599,7 +2524,6 @@ def list_metadata_schemas( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2631,10 +2555,8 @@ def list_metadata_schemas( # there are no flattened fields. if not isinstance(request, metadata_service.ListMetadataSchemasRequest): request = metadata_service.ListMetadataSchemasRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2691,7 +2613,6 @@ def query_artifact_lineage_subgraph( This corresponds to the ``artifact`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2723,10 +2644,8 @@ def query_artifact_lineage_subgraph( request, metadata_service.QueryArtifactLineageSubgraphRequest ): request = metadata_service.QueryArtifactLineageSubgraphRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if artifact is not None: request.artifact = artifact diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/pagers.py index 979c99e4e8..1366829837 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/__init__.py index a01e7ca986..f9e669122a 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py index 5bf2b38261..284a96558e 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import artifact from google.cloud.aiplatform_v1beta1.types import artifact as gca_artifact @@ -37,8 +37,7 @@ from google.cloud.aiplatform_v1beta1.types import metadata_schema as gca_metadata_schema from google.cloud.aiplatform_v1beta1.types import metadata_service from google.cloud.aiplatform_v1beta1.types import metadata_store -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -49,27 +48,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class MetadataServiceTransport(abc.ABC): """Abstract transport class for MetadataService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -78,7 +91,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -92,29 +105,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -222,31 +282,29 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_metadata_store( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.CreateMetadataStoreRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_metadata_store( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.GetMetadataStoreRequest], - typing.Union[ - metadata_store.MetadataStore, typing.Awaitable[metadata_store.MetadataStore] - ], + Union[metadata_store.MetadataStore, Awaitable[metadata_store.MetadataStore]], ]: raise NotImplementedError() @property def list_metadata_stores( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.ListMetadataStoresRequest], - typing.Union[ + Union[ metadata_service.ListMetadataStoresResponse, - typing.Awaitable[metadata_service.ListMetadataStoresResponse], + Awaitable[metadata_service.ListMetadataStoresResponse], ], ]: raise NotImplementedError() @@ -254,38 +312,38 @@ def list_metadata_stores( @property def delete_metadata_store( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.DeleteMetadataStoreRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_artifact( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.CreateArtifactRequest], - typing.Union[gca_artifact.Artifact, typing.Awaitable[gca_artifact.Artifact]], + Union[gca_artifact.Artifact, Awaitable[gca_artifact.Artifact]], ]: raise NotImplementedError() @property def get_artifact( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.GetArtifactRequest], - typing.Union[artifact.Artifact, typing.Awaitable[artifact.Artifact]], + Union[artifact.Artifact, Awaitable[artifact.Artifact]], ]: raise NotImplementedError() @property def list_artifacts( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.ListArtifactsRequest], - typing.Union[ + Union[ metadata_service.ListArtifactsResponse, - typing.Awaitable[metadata_service.ListArtifactsResponse], + Awaitable[metadata_service.ListArtifactsResponse], ], ]: raise NotImplementedError() @@ -293,38 +351,38 @@ def list_artifacts( @property def update_artifact( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.UpdateArtifactRequest], - typing.Union[gca_artifact.Artifact, typing.Awaitable[gca_artifact.Artifact]], + Union[gca_artifact.Artifact, Awaitable[gca_artifact.Artifact]], ]: raise NotImplementedError() @property def create_context( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.CreateContextRequest], - typing.Union[gca_context.Context, typing.Awaitable[gca_context.Context]], + Union[gca_context.Context, Awaitable[gca_context.Context]], ]: raise NotImplementedError() @property def get_context( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.GetContextRequest], - typing.Union[context.Context, typing.Awaitable[context.Context]], + Union[context.Context, Awaitable[context.Context]], ]: raise NotImplementedError() @property def list_contexts( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.ListContextsRequest], - typing.Union[ + Union[ metadata_service.ListContextsResponse, - typing.Awaitable[metadata_service.ListContextsResponse], + Awaitable[metadata_service.ListContextsResponse], ], ]: raise NotImplementedError() @@ -332,29 +390,29 @@ def list_contexts( @property def update_context( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.UpdateContextRequest], - typing.Union[gca_context.Context, typing.Awaitable[gca_context.Context]], + Union[gca_context.Context, Awaitable[gca_context.Context]], ]: raise NotImplementedError() @property def delete_context( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.DeleteContextRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def add_context_artifacts_and_executions( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.AddContextArtifactsAndExecutionsRequest], - typing.Union[ + Union[ metadata_service.AddContextArtifactsAndExecutionsResponse, - typing.Awaitable[metadata_service.AddContextArtifactsAndExecutionsResponse], + Awaitable[metadata_service.AddContextArtifactsAndExecutionsResponse], ], ]: raise NotImplementedError() @@ -362,11 +420,11 @@ def add_context_artifacts_and_executions( @property def add_context_children( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.AddContextChildrenRequest], - typing.Union[ + Union[ metadata_service.AddContextChildrenResponse, - typing.Awaitable[metadata_service.AddContextChildrenResponse], + Awaitable[metadata_service.AddContextChildrenResponse], ], ]: raise NotImplementedError() @@ -374,11 +432,11 @@ def add_context_children( @property def query_context_lineage_subgraph( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.QueryContextLineageSubgraphRequest], - typing.Union[ + Union[ lineage_subgraph.LineageSubgraph, - typing.Awaitable[lineage_subgraph.LineageSubgraph], + Awaitable[lineage_subgraph.LineageSubgraph], ], ]: raise NotImplementedError() @@ -386,31 +444,29 @@ def query_context_lineage_subgraph( @property def create_execution( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.CreateExecutionRequest], - typing.Union[ - gca_execution.Execution, typing.Awaitable[gca_execution.Execution] - ], + Union[gca_execution.Execution, Awaitable[gca_execution.Execution]], ]: raise NotImplementedError() @property def get_execution( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.GetExecutionRequest], - typing.Union[execution.Execution, typing.Awaitable[execution.Execution]], + Union[execution.Execution, Awaitable[execution.Execution]], ]: raise NotImplementedError() @property def list_executions( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.ListExecutionsRequest], - typing.Union[ + Union[ metadata_service.ListExecutionsResponse, - typing.Awaitable[metadata_service.ListExecutionsResponse], + Awaitable[metadata_service.ListExecutionsResponse], ], ]: raise NotImplementedError() @@ -418,22 +474,20 @@ def list_executions( @property def update_execution( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.UpdateExecutionRequest], - typing.Union[ - gca_execution.Execution, typing.Awaitable[gca_execution.Execution] - ], + Union[gca_execution.Execution, Awaitable[gca_execution.Execution]], ]: raise NotImplementedError() @property def add_execution_events( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.AddExecutionEventsRequest], - typing.Union[ + Union[ metadata_service.AddExecutionEventsResponse, - typing.Awaitable[metadata_service.AddExecutionEventsResponse], + Awaitable[metadata_service.AddExecutionEventsResponse], ], ]: raise NotImplementedError() @@ -441,11 +495,11 @@ def add_execution_events( @property def query_execution_inputs_and_outputs( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.QueryExecutionInputsAndOutputsRequest], - typing.Union[ + Union[ lineage_subgraph.LineageSubgraph, - typing.Awaitable[lineage_subgraph.LineageSubgraph], + Awaitable[lineage_subgraph.LineageSubgraph], ], ]: raise NotImplementedError() @@ -453,11 +507,11 @@ def query_execution_inputs_and_outputs( @property def create_metadata_schema( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.CreateMetadataSchemaRequest], - typing.Union[ + Union[ gca_metadata_schema.MetadataSchema, - typing.Awaitable[gca_metadata_schema.MetadataSchema], + Awaitable[gca_metadata_schema.MetadataSchema], ], ]: raise NotImplementedError() @@ -465,11 +519,10 @@ def create_metadata_schema( @property def get_metadata_schema( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.GetMetadataSchemaRequest], - typing.Union[ - metadata_schema.MetadataSchema, - typing.Awaitable[metadata_schema.MetadataSchema], + Union[ + metadata_schema.MetadataSchema, Awaitable[metadata_schema.MetadataSchema] ], ]: raise NotImplementedError() @@ -477,11 +530,11 @@ def get_metadata_schema( @property def list_metadata_schemas( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.ListMetadataSchemasRequest], - typing.Union[ + Union[ metadata_service.ListMetadataSchemasResponse, - typing.Awaitable[metadata_service.ListMetadataSchemasResponse], + Awaitable[metadata_service.ListMetadataSchemasResponse], ], ]: raise NotImplementedError() @@ -489,11 +542,11 @@ def list_metadata_schemas( @property def query_artifact_lineage_subgraph( self, - ) -> typing.Callable[ + ) -> Callable[ [metadata_service.QueryArtifactLineageSubgraphRequest], - typing.Union[ + Union[ lineage_subgraph.LineageSubgraph, - typing.Awaitable[lineage_subgraph.LineageSubgraph], + Awaitable[lineage_subgraph.LineageSubgraph], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py index 2ae1992f1b..0ad440d8c6 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -38,8 +36,7 @@ from google.cloud.aiplatform_v1beta1.types import metadata_schema as gca_metadata_schema from google.cloud.aiplatform_v1beta1.types import metadata_service from google.cloud.aiplatform_v1beta1.types import metadata_store -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import MetadataServiceTransport, DEFAULT_CLIENT_INFO @@ -62,7 +59,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -76,7 +73,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -187,7 +185,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -218,13 +216,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -251,7 +251,9 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_metadata_store( self, - ) -> Callable[[metadata_service.CreateMetadataStoreRequest], operations.Operation]: + ) -> Callable[ + [metadata_service.CreateMetadataStoreRequest], operations_pb2.Operation + ]: r"""Return a callable for the create metadata store method over gRPC. Initializes a MetadataStore, including allocation of @@ -271,7 +273,7 @@ def create_metadata_store( self._stubs["create_metadata_store"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MetadataService/CreateMetadataStore", request_serializer=metadata_service.CreateMetadataStoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_metadata_store"] @@ -335,7 +337,9 @@ def list_metadata_stores( @property def delete_metadata_store( self, - ) -> Callable[[metadata_service.DeleteMetadataStoreRequest], operations.Operation]: + ) -> Callable[ + [metadata_service.DeleteMetadataStoreRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete metadata store method over gRPC. Deletes a single MetadataStore. @@ -354,7 +358,7 @@ def delete_metadata_store( self._stubs["delete_metadata_store"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MetadataService/DeleteMetadataStore", request_serializer=metadata_service.DeleteMetadataStoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_metadata_store"] @@ -573,7 +577,7 @@ def update_context( @property def delete_context( self, - ) -> Callable[[metadata_service.DeleteContextRequest], operations.Operation]: + ) -> Callable[[metadata_service.DeleteContextRequest], operations_pb2.Operation]: r"""Return a callable for the delete context method over gRPC. Deletes a stored Context. @@ -592,7 +596,7 @@ def delete_context( self._stubs["delete_context"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MetadataService/DeleteContext", request_serializer=metadata_service.DeleteContextRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_context"] diff --git a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py index 2cd00db999..c9020e1101 100644 --- a/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/metadata_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -39,8 +37,7 @@ from google.cloud.aiplatform_v1beta1.types import metadata_schema as gca_metadata_schema from google.cloud.aiplatform_v1beta1.types import metadata_service from google.cloud.aiplatform_v1beta1.types import metadata_store -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import MetadataServiceTransport, DEFAULT_CLIENT_INFO from .grpc import MetadataServiceGrpcTransport @@ -65,7 +62,7 @@ class MetadataServiceGrpcAsyncIOTransport(MetadataServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -92,13 +89,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -106,7 +105,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -120,7 +119,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -179,7 +179,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -258,7 +257,8 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: def create_metadata_store( self, ) -> Callable[ - [metadata_service.CreateMetadataStoreRequest], Awaitable[operations.Operation] + [metadata_service.CreateMetadataStoreRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create metadata store method over gRPC. @@ -279,7 +279,7 @@ def create_metadata_store( self._stubs["create_metadata_store"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MetadataService/CreateMetadataStore", request_serializer=metadata_service.CreateMetadataStoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_metadata_store"] @@ -345,7 +345,8 @@ def list_metadata_stores( def delete_metadata_store( self, ) -> Callable[ - [metadata_service.DeleteMetadataStoreRequest], Awaitable[operations.Operation] + [metadata_service.DeleteMetadataStoreRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete metadata store method over gRPC. @@ -365,7 +366,7 @@ def delete_metadata_store( self._stubs["delete_metadata_store"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MetadataService/DeleteMetadataStore", request_serializer=metadata_service.DeleteMetadataStoreRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_metadata_store"] @@ -595,7 +596,7 @@ def update_context( def delete_context( self, ) -> Callable[ - [metadata_service.DeleteContextRequest], Awaitable[operations.Operation] + [metadata_service.DeleteContextRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete context method over gRPC. @@ -615,7 +616,7 @@ def delete_context( self._stubs["delete_context"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MetadataService/DeleteContext", request_serializer=metadata_service.DeleteContextRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_context"] diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/migration_service/__init__.py index 1d6216d1f7..5af6b09eb3 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import MigrationServiceClient from .async_client import MigrationServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/migration_service/async_client.py index 4e53b6cb5a..5549e1c870 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore @@ -33,7 +31,6 @@ from google.cloud.aiplatform_v1beta1.services.migration_service import pagers from google.cloud.aiplatform_v1beta1.types import migratable_resource from google.cloud.aiplatform_v1beta1.types import migration_service - from .transports.base import MigrationServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import MigrationServiceGrpcAsyncIOTransport from .client import MigrationServiceClient @@ -66,31 +63,26 @@ class MigrationServiceAsyncClient: parse_model_path = staticmethod(MigrationServiceClient.parse_model_path) version_path = staticmethod(MigrationServiceClient.version_path) parse_version_path = staticmethod(MigrationServiceClient.parse_version_path) - common_billing_account_path = staticmethod( MigrationServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( MigrationServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(MigrationServiceClient.common_folder_path) parse_common_folder_path = staticmethod( MigrationServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( MigrationServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( MigrationServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(MigrationServiceClient.common_project_path) parse_common_project_path = staticmethod( MigrationServiceClient.parse_common_project_path ) - common_location_path = staticmethod(MigrationServiceClient.common_location_path) parse_common_location_path = staticmethod( MigrationServiceClient.parse_common_location_path @@ -144,7 +136,7 @@ def transport(self) -> MigrationServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, MigrationServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -181,7 +173,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = MigrationServiceClient( credentials=credentials, transport=transport, @@ -217,7 +208,6 @@ async def search_migratable_resources( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -247,7 +237,6 @@ async def search_migratable_resources( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -315,7 +304,6 @@ async def batch_migrate_resources( This corresponds to the ``migrate_resource_requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -346,10 +334,8 @@ async def batch_migrate_resources( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent - if migrate_resource_requests: request.migrate_resource_requests.extend(migrate_resource_requests) diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/client.py b/google/cloud/aiplatform_v1beta1/services/migration_service/client.py index 064fd4b341..7167f186ae 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -37,7 +35,6 @@ from google.cloud.aiplatform_v1beta1.services.migration_service import pagers from google.cloud.aiplatform_v1beta1.types import migratable_resource from google.cloud.aiplatform_v1beta1.types import migration_service - from .transports.base import MigrationServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import MigrationServiceGrpcTransport from .transports.grpc_asyncio import MigrationServiceGrpcAsyncIOTransport @@ -334,7 +331,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, MigrationServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -472,7 +469,6 @@ def search_migratable_resources( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -504,10 +500,8 @@ def search_migratable_resources( # there are no flattened fields. if not isinstance(request, migration_service.SearchMigratableResourcesRequest): request = migration_service.SearchMigratableResourcesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -573,7 +567,6 @@ def batch_migrate_resources( This corresponds to the ``migrate_resource_requests`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -606,10 +599,8 @@ def batch_migrate_resources( # there are no flattened fields. if not isinstance(request, migration_service.BatchMigrateResourcesRequest): request = migration_service.BatchMigrateResourcesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if migrate_resource_requests is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/migration_service/pagers.py index f0a1dfa43f..0756f5b1c4 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/__init__.py index 38c72756f6..565048f2a3 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py index f3324f22c6..d2b54f2c66 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import migration_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -39,27 +38,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class MigrationServiceTransport(abc.ABC): """Abstract transport class for MigrationService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -68,7 +81,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -82,29 +95,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -128,11 +188,11 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def search_migratable_resources( self, - ) -> typing.Callable[ + ) -> Callable[ [migration_service.SearchMigratableResourcesRequest], - typing.Union[ + Union[ migration_service.SearchMigratableResourcesResponse, - typing.Awaitable[migration_service.SearchMigratableResourcesResponse], + Awaitable[migration_service.SearchMigratableResourcesResponse], ], ]: raise NotImplementedError() @@ -140,9 +200,9 @@ def search_migratable_resources( @property def batch_migrate_resources( self, - ) -> typing.Callable[ + ) -> Callable[ [migration_service.BatchMigrateResourcesRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py index 7c63224a7a..372e413534 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1beta1.types import migration_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import MigrationServiceTransport, DEFAULT_CLIENT_INFO @@ -54,7 +51,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -68,7 +65,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -179,7 +177,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -210,13 +208,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -276,7 +276,7 @@ def search_migratable_resources( def batch_migrate_resources( self, ) -> Callable[ - [migration_service.BatchMigrateResourcesRequest], operations.Operation + [migration_service.BatchMigrateResourcesRequest], operations_pb2.Operation ]: r"""Return a callable for the batch migrate resources method over gRPC. @@ -298,7 +298,7 @@ def batch_migrate_resources( self._stubs["batch_migrate_resources"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MigrationService/BatchMigrateResources", request_serializer=migration_service.BatchMigrateResourcesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_migrate_resources"] diff --git a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py index 100739ea7e..e98ea4d789 100644 --- a/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/migration_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1beta1.types import migration_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import MigrationServiceTransport, DEFAULT_CLIENT_INFO from .grpc import MigrationServiceGrpcTransport @@ -57,7 +54,7 @@ class MigrationServiceGrpcAsyncIOTransport(MigrationServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -84,13 +81,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -98,7 +97,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -112,7 +111,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -171,7 +171,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -283,7 +282,7 @@ def batch_migrate_resources( self, ) -> Callable[ [migration_service.BatchMigrateResourcesRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the batch migrate resources method over gRPC. @@ -305,7 +304,7 @@ def batch_migrate_resources( self._stubs["batch_migrate_resources"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.MigrationService/BatchMigrateResources", request_serializer=migration_service.BatchMigrateResourcesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["batch_migrate_resources"] diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/model_service/__init__.py index b39295ebfe..7395b28fcb 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import ModelServiceClient from .async_client import ModelServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py index 6a5c7fb1af..d4b8081ed8 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -40,11 +38,10 @@ from google.cloud.aiplatform_v1beta1.types import model_evaluation_slice from google.cloud.aiplatform_v1beta1.types import model_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ModelServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport from .client import ModelServiceClient @@ -76,27 +73,22 @@ class ModelServiceAsyncClient: parse_training_pipeline_path = staticmethod( ModelServiceClient.parse_training_pipeline_path ) - common_billing_account_path = staticmethod( ModelServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( ModelServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(ModelServiceClient.common_folder_path) parse_common_folder_path = staticmethod(ModelServiceClient.parse_common_folder_path) - common_organization_path = staticmethod(ModelServiceClient.common_organization_path) parse_common_organization_path = staticmethod( ModelServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(ModelServiceClient.common_project_path) parse_common_project_path = staticmethod( ModelServiceClient.parse_common_project_path ) - common_location_path = staticmethod(ModelServiceClient.common_location_path) parse_common_location_path = staticmethod( ModelServiceClient.parse_common_location_path @@ -150,7 +142,7 @@ def transport(self) -> ModelServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, ModelServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -187,7 +179,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = ModelServiceClient( credentials=credentials, transport=transport, @@ -224,7 +215,6 @@ async def upload_model( This corresponds to the ``model`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -256,7 +246,6 @@ async def upload_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if model is not None: @@ -312,7 +301,6 @@ async def get_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -337,7 +325,6 @@ async def get_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -384,7 +371,6 @@ async def list_models( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -414,7 +400,6 @@ async def list_models( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -449,7 +434,7 @@ async def update_model( request: model_service.UpdateModelRequest = None, *, model: gca_model.Model = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -475,7 +460,6 @@ async def update_model( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -500,7 +484,6 @@ async def update_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if model is not None: request.model = model if update_mask is not None: @@ -553,7 +536,6 @@ async def delete_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -593,7 +575,6 @@ async def delete_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -618,7 +599,7 @@ async def delete_model( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -659,7 +640,6 @@ async def export_model( This corresponds to the ``output_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -691,7 +671,6 @@ async def export_model( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if output_config is not None: @@ -748,7 +727,6 @@ async def get_model_evaluation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -777,7 +755,6 @@ async def get_model_evaluation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -824,7 +801,6 @@ async def list_model_evaluations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -854,7 +830,6 @@ async def list_model_evaluations( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -907,7 +882,6 @@ async def get_model_evaluation_slice( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -936,7 +910,6 @@ async def get_model_evaluation_slice( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -983,7 +956,6 @@ async def list_model_evaluation_slices( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1013,7 +985,6 @@ async def list_model_evaluation_slices( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/client.py b/google/cloud/aiplatform_v1beta1/services/model_service/client.py index f43371ac72..413426bcba 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -44,11 +42,10 @@ from google.cloud.aiplatform_v1beta1.types import model_evaluation_slice from google.cloud.aiplatform_v1beta1.types import model_service from google.cloud.aiplatform_v1beta1.types import operation as gca_operation -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ModelServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import ModelServiceGrpcTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport @@ -319,7 +316,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, ModelServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -458,7 +455,6 @@ def upload_model( This corresponds to the ``model`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -492,10 +488,8 @@ def upload_model( # there are no flattened fields. if not isinstance(request, model_service.UploadModelRequest): request = model_service.UploadModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if model is not None: @@ -547,7 +541,6 @@ def get_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -574,10 +567,8 @@ def get_model( # there are no flattened fields. if not isinstance(request, model_service.GetModelRequest): request = model_service.GetModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -620,7 +611,6 @@ def list_models( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -652,10 +642,8 @@ def list_models( # there are no flattened fields. if not isinstance(request, model_service.ListModelsRequest): request = model_service.ListModelsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -686,7 +674,7 @@ def update_model( request: model_service.UpdateModelRequest = None, *, model: gca_model.Model = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -712,7 +700,6 @@ def update_model( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -739,10 +726,8 @@ def update_model( # there are no flattened fields. if not isinstance(request, model_service.UpdateModelRequest): request = model_service.UpdateModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if model is not None: request.model = model if update_mask is not None: @@ -791,7 +776,6 @@ def delete_model( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -833,10 +817,8 @@ def delete_model( # there are no flattened fields. if not isinstance(request, model_service.DeleteModelRequest): request = model_service.DeleteModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -857,7 +839,7 @@ def delete_model( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -898,7 +880,6 @@ def export_model( This corresponds to the ``output_config`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -932,10 +913,8 @@ def export_model( # there are no flattened fields. if not isinstance(request, model_service.ExportModelRequest): request = model_service.ExportModelRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if output_config is not None: @@ -988,7 +967,6 @@ def get_model_evaluation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1019,10 +997,8 @@ def get_model_evaluation( # there are no flattened fields. if not isinstance(request, model_service.GetModelEvaluationRequest): request = model_service.GetModelEvaluationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1065,7 +1041,6 @@ def list_model_evaluations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1097,10 +1072,8 @@ def list_model_evaluations( # there are no flattened fields. if not isinstance(request, model_service.ListModelEvaluationsRequest): request = model_service.ListModelEvaluationsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1149,7 +1122,6 @@ def get_model_evaluation_slice( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1180,10 +1152,8 @@ def get_model_evaluation_slice( # there are no flattened fields. if not isinstance(request, model_service.GetModelEvaluationSliceRequest): request = model_service.GetModelEvaluationSliceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1228,7 +1198,6 @@ def list_model_evaluation_slices( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1260,10 +1229,8 @@ def list_model_evaluation_slices( # there are no flattened fields. if not isinstance(request, model_service.ListModelEvaluationSlicesRequest): request = model_service.ListModelEvaluationSlicesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/model_service/pagers.py index eb547a5f9f..ea9f49f5ab 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/__init__.py index 5d1cb51abc..656b644033 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py index 37d2b7a4e7..3dd6e890c7 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,25 +13,25 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import model from google.cloud.aiplatform_v1beta1.types import model as gca_model from google.cloud.aiplatform_v1beta1.types import model_evaluation from google.cloud.aiplatform_v1beta1.types import model_evaluation_slice from google.cloud.aiplatform_v1beta1.types import model_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -43,27 +42,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class ModelServiceTransport(abc.ABC): """Abstract transport class for ModelService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -72,7 +85,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -86,29 +99,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -158,29 +218,28 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def upload_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.UploadModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_model( self, - ) -> typing.Callable[ - [model_service.GetModelRequest], - typing.Union[model.Model, typing.Awaitable[model.Model]], + ) -> Callable[ + [model_service.GetModelRequest], Union[model.Model, Awaitable[model.Model]] ]: raise NotImplementedError() @property def list_models( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ListModelsRequest], - typing.Union[ + Union[ model_service.ListModelsResponse, - typing.Awaitable[model_service.ListModelsResponse], + Awaitable[model_service.ListModelsResponse], ], ]: raise NotImplementedError() @@ -188,38 +247,38 @@ def list_models( @property def update_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.UpdateModelRequest], - typing.Union[gca_model.Model, typing.Awaitable[gca_model.Model]], + Union[gca_model.Model, Awaitable[gca_model.Model]], ]: raise NotImplementedError() @property def delete_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.DeleteModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def export_model( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ExportModelRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_model_evaluation( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.GetModelEvaluationRequest], - typing.Union[ + Union[ model_evaluation.ModelEvaluation, - typing.Awaitable[model_evaluation.ModelEvaluation], + Awaitable[model_evaluation.ModelEvaluation], ], ]: raise NotImplementedError() @@ -227,11 +286,11 @@ def get_model_evaluation( @property def list_model_evaluations( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ListModelEvaluationsRequest], - typing.Union[ + Union[ model_service.ListModelEvaluationsResponse, - typing.Awaitable[model_service.ListModelEvaluationsResponse], + Awaitable[model_service.ListModelEvaluationsResponse], ], ]: raise NotImplementedError() @@ -239,11 +298,11 @@ def list_model_evaluations( @property def get_model_evaluation_slice( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.GetModelEvaluationSliceRequest], - typing.Union[ + Union[ model_evaluation_slice.ModelEvaluationSlice, - typing.Awaitable[model_evaluation_slice.ModelEvaluationSlice], + Awaitable[model_evaluation_slice.ModelEvaluationSlice], ], ]: raise NotImplementedError() @@ -251,11 +310,11 @@ def get_model_evaluation_slice( @property def list_model_evaluation_slices( self, - ) -> typing.Callable[ + ) -> Callable[ [model_service.ListModelEvaluationSlicesRequest], - typing.Union[ + Union[ model_service.ListModelEvaluationSlicesResponse, - typing.Awaitable[model_service.ListModelEvaluationSlicesResponse], + Awaitable[model_service.ListModelEvaluationSlicesResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py index 2cbac70e87..1fe74c535e 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -32,8 +30,7 @@ from google.cloud.aiplatform_v1beta1.types import model_evaluation from google.cloud.aiplatform_v1beta1.types import model_evaluation_slice from google.cloud.aiplatform_v1beta1.types import model_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ModelServiceTransport, DEFAULT_CLIENT_INFO @@ -56,7 +53,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -70,7 +67,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -181,7 +179,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -212,13 +210,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -245,7 +245,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def upload_model( self, - ) -> Callable[[model_service.UploadModelRequest], operations.Operation]: + ) -> Callable[[model_service.UploadModelRequest], operations_pb2.Operation]: r"""Return a callable for the upload model method over gRPC. Uploads a Model artifact into AI Platform. @@ -264,7 +264,7 @@ def upload_model( self._stubs["upload_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.ModelService/UploadModel", request_serializer=model_service.UploadModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["upload_model"] @@ -347,7 +347,7 @@ def update_model( @property def delete_model( self, - ) -> Callable[[model_service.DeleteModelRequest], operations.Operation]: + ) -> Callable[[model_service.DeleteModelRequest], operations_pb2.Operation]: r"""Return a callable for the delete model method over gRPC. Deletes a Model. @@ -368,14 +368,14 @@ def delete_model( self._stubs["delete_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_model"] @property def export_model( self, - ) -> Callable[[model_service.ExportModelRequest], operations.Operation]: + ) -> Callable[[model_service.ExportModelRequest], operations_pb2.Operation]: r"""Return a callable for the export model method over gRPC. Exports a trained, exportable, Model to a location specified by @@ -397,7 +397,7 @@ def export_model( self._stubs["export_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.ModelService/ExportModel", request_serializer=model_service.ExportModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_model"] diff --git a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py index 700014be02..3e56398431 100644 --- a/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/model_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -33,8 +31,7 @@ from google.cloud.aiplatform_v1beta1.types import model_evaluation from google.cloud.aiplatform_v1beta1.types import model_evaluation_slice from google.cloud.aiplatform_v1beta1.types import model_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ModelServiceTransport, DEFAULT_CLIENT_INFO from .grpc import ModelServiceGrpcTransport @@ -59,7 +56,7 @@ class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -86,13 +83,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -100,7 +99,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -114,7 +113,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -173,7 +173,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -251,7 +250,9 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: @property def upload_model( self, - ) -> Callable[[model_service.UploadModelRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [model_service.UploadModelRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the upload model method over gRPC. Uploads a Model artifact into AI Platform. @@ -270,7 +271,7 @@ def upload_model( self._stubs["upload_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.ModelService/UploadModel", request_serializer=model_service.UploadModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["upload_model"] @@ -357,7 +358,9 @@ def update_model( @property def delete_model( self, - ) -> Callable[[model_service.DeleteModelRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [model_service.DeleteModelRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete model method over gRPC. Deletes a Model. @@ -378,14 +381,16 @@ def delete_model( self._stubs["delete_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.ModelService/DeleteModel", request_serializer=model_service.DeleteModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_model"] @property def export_model( self, - ) -> Callable[[model_service.ExportModelRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [model_service.ExportModelRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the export model method over gRPC. Exports a trained, exportable, Model to a location specified by @@ -407,7 +412,7 @@ def export_model( self._stubs["export_model"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.ModelService/ExportModel", request_serializer=model_service.ExportModelRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_model"] diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/__init__.py index 7f02b47358..f6234690cb 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import PipelineServiceClient from .async_client import PipelineServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/async_client.py index b09fbe5746..9c368150ab 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -42,11 +40,10 @@ from google.cloud.aiplatform_v1beta1.types import ( training_pipeline as gca_training_pipeline, ) -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore from .transports.base import PipelineServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import PipelineServiceGrpcAsyncIOTransport from .client import PipelineServiceClient @@ -82,31 +79,26 @@ class PipelineServiceAsyncClient: parse_training_pipeline_path = staticmethod( PipelineServiceClient.parse_training_pipeline_path ) - common_billing_account_path = staticmethod( PipelineServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( PipelineServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(PipelineServiceClient.common_folder_path) parse_common_folder_path = staticmethod( PipelineServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( PipelineServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( PipelineServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(PipelineServiceClient.common_project_path) parse_common_project_path = staticmethod( PipelineServiceClient.parse_common_project_path ) - common_location_path = staticmethod(PipelineServiceClient.common_location_path) parse_common_location_path = staticmethod( PipelineServiceClient.parse_common_location_path @@ -160,7 +152,7 @@ def transport(self) -> PipelineServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, PipelineServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -197,7 +189,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = PipelineServiceClient( credentials=credentials, transport=transport, @@ -237,7 +228,6 @@ async def create_training_pipeline( This corresponds to the ``training_pipeline`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -268,7 +258,6 @@ async def create_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if training_pipeline is not None: @@ -317,7 +306,6 @@ async def get_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -348,7 +336,6 @@ async def get_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -395,7 +382,6 @@ async def list_training_pipelines( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -425,7 +411,6 @@ async def list_training_pipelines( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -478,7 +463,6 @@ async def delete_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -518,7 +502,6 @@ async def delete_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -543,7 +526,7 @@ async def delete_training_pipeline( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -585,7 +568,6 @@ async def cancel_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -606,7 +588,6 @@ async def cancel_training_pipeline( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -671,7 +652,6 @@ async def create_pipeline_job( This corresponds to the ``pipeline_job_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -698,7 +678,6 @@ async def create_pipeline_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if pipeline_job is not None: @@ -748,7 +727,6 @@ async def get_pipeline_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -775,7 +753,6 @@ async def get_pipeline_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -822,7 +799,6 @@ async def list_pipeline_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -852,7 +828,6 @@ async def list_pipeline_jobs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -905,7 +880,6 @@ async def delete_pipeline_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -945,7 +919,6 @@ async def delete_pipeline_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -970,7 +943,7 @@ async def delete_pipeline_job( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1011,7 +984,6 @@ async def cancel_pipeline_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1032,7 +1004,6 @@ async def cancel_pipeline_job( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py index b9d6019ce7..106452a82b 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -46,11 +44,10 @@ from google.cloud.aiplatform_v1beta1.types import ( training_pipeline as gca_training_pipeline, ) -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore from .transports.base import PipelineServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import PipelineServiceGrpcTransport from .transports.grpc_asyncio import PipelineServiceGrpcAsyncIOTransport @@ -393,7 +390,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, PipelineServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -535,7 +532,6 @@ def create_training_pipeline( This corresponds to the ``training_pipeline`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -568,10 +564,8 @@ def create_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.CreateTrainingPipelineRequest): request = pipeline_service.CreateTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if training_pipeline is not None: @@ -616,7 +610,6 @@ def get_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -649,10 +642,8 @@ def get_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.GetTrainingPipelineRequest): request = pipeline_service.GetTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -695,7 +686,6 @@ def list_training_pipelines( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -727,10 +717,8 @@ def list_training_pipelines( # there are no flattened fields. if not isinstance(request, pipeline_service.ListTrainingPipelinesRequest): request = pipeline_service.ListTrainingPipelinesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -779,7 +767,6 @@ def delete_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -821,10 +808,8 @@ def delete_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.DeleteTrainingPipelineRequest): request = pipeline_service.DeleteTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -845,7 +830,7 @@ def delete_training_pipeline( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -887,7 +872,6 @@ def cancel_training_pipeline( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -910,10 +894,8 @@ def cancel_training_pipeline( # there are no flattened fields. if not isinstance(request, pipeline_service.CancelTrainingPipelineRequest): request = pipeline_service.CancelTrainingPipelineRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -974,7 +956,6 @@ def create_pipeline_job( This corresponds to the ``pipeline_job_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1003,10 +984,8 @@ def create_pipeline_job( # there are no flattened fields. if not isinstance(request, pipeline_service.CreatePipelineJobRequest): request = pipeline_service.CreatePipelineJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if pipeline_job is not None: @@ -1052,7 +1031,6 @@ def get_pipeline_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1081,10 +1059,8 @@ def get_pipeline_job( # there are no flattened fields. if not isinstance(request, pipeline_service.GetPipelineJobRequest): request = pipeline_service.GetPipelineJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1127,7 +1103,6 @@ def list_pipeline_jobs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1159,10 +1134,8 @@ def list_pipeline_jobs( # there are no flattened fields. if not isinstance(request, pipeline_service.ListPipelineJobsRequest): request = pipeline_service.ListPipelineJobsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1211,7 +1184,6 @@ def delete_pipeline_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1253,10 +1225,8 @@ def delete_pipeline_job( # there are no flattened fields. if not isinstance(request, pipeline_service.DeletePipelineJobRequest): request = pipeline_service.DeletePipelineJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1277,7 +1247,7 @@ def delete_pipeline_job( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1318,7 +1288,6 @@ def cancel_pipeline_job( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1341,10 +1310,8 @@ def cancel_pipeline_job( # there are no flattened fields. if not isinstance(request, pipeline_service.CancelPipelineJobRequest): request = pipeline_service.CancelPipelineJobRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/pagers.py index 0a4aa3bbc5..c56f01985c 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/__init__.py index 9d4610087a..c7a40586e8 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py index 70ad468804..cc09aa7551 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import pipeline_job from google.cloud.aiplatform_v1beta1.types import pipeline_job as gca_pipeline_job @@ -33,9 +33,8 @@ from google.cloud.aiplatform_v1beta1.types import ( training_pipeline as gca_training_pipeline, ) -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -46,27 +45,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class PipelineServiceTransport(abc.ABC): """Abstract transport class for PipelineService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -75,7 +88,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -89,29 +102,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -165,11 +225,11 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.CreateTrainingPipelineRequest], - typing.Union[ + Union[ gca_training_pipeline.TrainingPipeline, - typing.Awaitable[gca_training_pipeline.TrainingPipeline], + Awaitable[gca_training_pipeline.TrainingPipeline], ], ]: raise NotImplementedError() @@ -177,11 +237,11 @@ def create_training_pipeline( @property def get_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.GetTrainingPipelineRequest], - typing.Union[ + Union[ training_pipeline.TrainingPipeline, - typing.Awaitable[training_pipeline.TrainingPipeline], + Awaitable[training_pipeline.TrainingPipeline], ], ]: raise NotImplementedError() @@ -189,11 +249,11 @@ def get_training_pipeline( @property def list_training_pipelines( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.ListTrainingPipelinesRequest], - typing.Union[ + Union[ pipeline_service.ListTrainingPipelinesResponse, - typing.Awaitable[pipeline_service.ListTrainingPipelinesResponse], + Awaitable[pipeline_service.ListTrainingPipelinesResponse], ], ]: raise NotImplementedError() @@ -201,51 +261,47 @@ def list_training_pipelines( @property def delete_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.DeleteTrainingPipelineRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_training_pipeline( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.CancelTrainingPipelineRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def create_pipeline_job( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.CreatePipelineJobRequest], - typing.Union[ - gca_pipeline_job.PipelineJob, typing.Awaitable[gca_pipeline_job.PipelineJob] - ], + Union[gca_pipeline_job.PipelineJob, Awaitable[gca_pipeline_job.PipelineJob]], ]: raise NotImplementedError() @property def get_pipeline_job( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.GetPipelineJobRequest], - typing.Union[ - pipeline_job.PipelineJob, typing.Awaitable[pipeline_job.PipelineJob] - ], + Union[pipeline_job.PipelineJob, Awaitable[pipeline_job.PipelineJob]], ]: raise NotImplementedError() @property def list_pipeline_jobs( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.ListPipelineJobsRequest], - typing.Union[ + Union[ pipeline_service.ListPipelineJobsResponse, - typing.Awaitable[pipeline_service.ListPipelineJobsResponse], + Awaitable[pipeline_service.ListPipelineJobsResponse], ], ]: raise NotImplementedError() @@ -253,18 +309,18 @@ def list_pipeline_jobs( @property def delete_pipeline_job( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.DeletePipelineJobRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def cancel_pipeline_job( self, - ) -> typing.Callable[ + ) -> Callable[ [pipeline_service.CancelPipelineJobRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py index d05a753e82..029bd62656 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -34,9 +32,8 @@ from google.cloud.aiplatform_v1beta1.types import ( training_pipeline as gca_training_pipeline, ) -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import PipelineServiceTransport, DEFAULT_CLIENT_INFO @@ -59,7 +56,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -73,7 +70,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -184,7 +182,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -215,13 +213,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -337,7 +337,7 @@ def list_training_pipelines( def delete_training_pipeline( self, ) -> Callable[ - [pipeline_service.DeleteTrainingPipelineRequest], operations.Operation + [pipeline_service.DeleteTrainingPipelineRequest], operations_pb2.Operation ]: r"""Return a callable for the delete training pipeline method over gRPC. @@ -357,14 +357,14 @@ def delete_training_pipeline( self._stubs["delete_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/DeleteTrainingPipeline", request_serializer=pipeline_service.DeleteTrainingPipelineRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_training_pipeline"] @property def cancel_training_pipeline( self, - ) -> Callable[[pipeline_service.CancelTrainingPipelineRequest], empty.Empty]: + ) -> Callable[[pipeline_service.CancelTrainingPipelineRequest], empty_pb2.Empty]: r"""Return a callable for the cancel training pipeline method over gRPC. Cancels a TrainingPipeline. Starts asynchronous cancellation on @@ -395,7 +395,7 @@ def cancel_training_pipeline( self._stubs["cancel_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/CancelTrainingPipeline", request_serializer=pipeline_service.CancelTrainingPipelineRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_training_pipeline"] @@ -486,7 +486,9 @@ def list_pipeline_jobs( @property def delete_pipeline_job( self, - ) -> Callable[[pipeline_service.DeletePipelineJobRequest], operations.Operation]: + ) -> Callable[ + [pipeline_service.DeletePipelineJobRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete pipeline job method over gRPC. Deletes a PipelineJob. @@ -505,14 +507,14 @@ def delete_pipeline_job( self._stubs["delete_pipeline_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/DeletePipelineJob", request_serializer=pipeline_service.DeletePipelineJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_pipeline_job"] @property def cancel_pipeline_job( self, - ) -> Callable[[pipeline_service.CancelPipelineJobRequest], empty.Empty]: + ) -> Callable[[pipeline_service.CancelPipelineJobRequest], empty_pb2.Empty]: r"""Return a callable for the cancel pipeline job method over gRPC. Cancels a PipelineJob. Starts asynchronous cancellation on the @@ -543,7 +545,7 @@ def cancel_pipeline_job( self._stubs["cancel_pipeline_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/CancelPipelineJob", request_serializer=pipeline_service.CancelPipelineJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_pipeline_job"] diff --git a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py index 6c74b1d05a..c12da6ea8c 100644 --- a/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/pipeline_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -35,9 +33,8 @@ from google.cloud.aiplatform_v1beta1.types import ( training_pipeline as gca_training_pipeline, ) -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import PipelineServiceTransport, DEFAULT_CLIENT_INFO from .grpc import PipelineServiceGrpcTransport @@ -62,7 +59,7 @@ class PipelineServiceGrpcAsyncIOTransport(PipelineServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -89,13 +86,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -103,7 +102,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -117,7 +116,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -176,7 +176,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -344,7 +343,7 @@ def delete_training_pipeline( self, ) -> Callable[ [pipeline_service.DeleteTrainingPipelineRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete training pipeline method over gRPC. @@ -364,7 +363,7 @@ def delete_training_pipeline( self._stubs["delete_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/DeleteTrainingPipeline", request_serializer=pipeline_service.DeleteTrainingPipelineRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_training_pipeline"] @@ -372,7 +371,7 @@ def delete_training_pipeline( def cancel_training_pipeline( self, ) -> Callable[ - [pipeline_service.CancelTrainingPipelineRequest], Awaitable[empty.Empty] + [pipeline_service.CancelTrainingPipelineRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the cancel training pipeline method over gRPC. @@ -404,7 +403,7 @@ def cancel_training_pipeline( self._stubs["cancel_training_pipeline"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/CancelTrainingPipeline", request_serializer=pipeline_service.CancelTrainingPipelineRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_training_pipeline"] @@ -499,7 +498,7 @@ def list_pipeline_jobs( def delete_pipeline_job( self, ) -> Callable[ - [pipeline_service.DeletePipelineJobRequest], Awaitable[operations.Operation] + [pipeline_service.DeletePipelineJobRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete pipeline job method over gRPC. @@ -519,14 +518,16 @@ def delete_pipeline_job( self._stubs["delete_pipeline_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/DeletePipelineJob", request_serializer=pipeline_service.DeletePipelineJobRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_pipeline_job"] @property def cancel_pipeline_job( self, - ) -> Callable[[pipeline_service.CancelPipelineJobRequest], Awaitable[empty.Empty]]: + ) -> Callable[ + [pipeline_service.CancelPipelineJobRequest], Awaitable[empty_pb2.Empty] + ]: r"""Return a callable for the cancel pipeline job method over gRPC. Cancels a PipelineJob. Starts asynchronous cancellation on the @@ -557,7 +558,7 @@ def cancel_pipeline_job( self._stubs["cancel_pipeline_job"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.PipelineService/CancelPipelineJob", request_serializer=pipeline_service.CancelPipelineJobRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["cancel_pipeline_job"] diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/__init__.py index 0c847693e0..12491bb171 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import PredictionServiceClient from .async_client import PredictionServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/async_client.py index 2d651938f6..9872aa3fb3 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,16 +20,15 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.cloud.aiplatform_v1beta1.types import explanation from google.cloud.aiplatform_v1beta1.types import prediction_service -from google.protobuf import struct_pb2 as struct # type: ignore - +from google.protobuf import struct_pb2 # type: ignore from .transports.base import PredictionServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport from .client import PredictionServiceClient @@ -47,31 +44,26 @@ class PredictionServiceAsyncClient: endpoint_path = staticmethod(PredictionServiceClient.endpoint_path) parse_endpoint_path = staticmethod(PredictionServiceClient.parse_endpoint_path) - common_billing_account_path = staticmethod( PredictionServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( PredictionServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(PredictionServiceClient.common_folder_path) parse_common_folder_path = staticmethod( PredictionServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( PredictionServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( PredictionServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(PredictionServiceClient.common_project_path) parse_common_project_path = staticmethod( PredictionServiceClient.parse_common_project_path ) - common_location_path = staticmethod(PredictionServiceClient.common_location_path) parse_common_location_path = staticmethod( PredictionServiceClient.parse_common_location_path @@ -125,7 +117,7 @@ def transport(self) -> PredictionServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, PredictionServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -162,7 +154,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = PredictionServiceClient( credentials=credentials, transport=transport, @@ -175,8 +166,8 @@ async def predict( request: prediction_service.PredictRequest = None, *, endpoint: str = None, - instances: Sequence[struct.Value] = None, - parameters: struct.Value = None, + instances: Sequence[struct_pb2.Value] = None, + parameters: struct_pb2.Value = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -222,7 +213,6 @@ async def predict( This corresponds to the ``parameters`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -249,12 +239,10 @@ async def predict( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if parameters is not None: request.parameters = parameters - if instances: request.instances.extend(instances) @@ -283,8 +271,8 @@ async def explain( request: prediction_service.ExplainRequest = None, *, endpoint: str = None, - instances: Sequence[struct.Value] = None, - parameters: struct.Value = None, + instances: Sequence[struct_pb2.Value] = None, + parameters: struct_pb2.Value = None, deployed_model_id: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, @@ -350,7 +338,6 @@ async def explain( This corresponds to the ``deployed_model_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -377,14 +364,12 @@ async def explain( # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if parameters is not None: request.parameters = parameters if deployed_model_id is not None: request.deployed_model_id = deployed_model_id - if instances: request.instances.extend(instances) diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py index 72f8c1541d..c7852e2805 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -34,8 +32,7 @@ from google.cloud.aiplatform_v1beta1.types import explanation from google.cloud.aiplatform_v1beta1.types import prediction_service -from google.protobuf import struct_pb2 as struct # type: ignore - +from google.protobuf import struct_pb2 # type: ignore from .transports.base import PredictionServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import PredictionServiceGrpcTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport @@ -236,7 +233,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, PredictionServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -351,8 +348,8 @@ def predict( request: prediction_service.PredictRequest = None, *, endpoint: str = None, - instances: Sequence[struct.Value] = None, - parameters: struct.Value = None, + instances: Sequence[struct_pb2.Value] = None, + parameters: struct_pb2.Value = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -398,7 +395,6 @@ def predict( This corresponds to the ``parameters`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -427,10 +423,8 @@ def predict( # there are no flattened fields. if not isinstance(request, prediction_service.PredictRequest): request = prediction_service.PredictRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if instances is not None: @@ -459,8 +453,8 @@ def explain( request: prediction_service.ExplainRequest = None, *, endpoint: str = None, - instances: Sequence[struct.Value] = None, - parameters: struct.Value = None, + instances: Sequence[struct_pb2.Value] = None, + parameters: struct_pb2.Value = None, deployed_model_id: str = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, @@ -526,7 +520,6 @@ def explain( This corresponds to the ``deployed_model_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -555,10 +548,8 @@ def explain( # there are no flattened fields. if not isinstance(request, prediction_service.ExplainRequest): request = prediction_service.ExplainRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if endpoint is not None: request.endpoint = endpoint if instances is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/__init__.py index 9ec1369a05..86d2e8a7f3 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py index df601f6bdd..9006c8335a 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,20 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import prediction_service - try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=pkg_resources.get_distribution( @@ -37,27 +36,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class PredictionServiceTransport(abc.ABC): """Abstract transport class for PredictionService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -66,7 +79,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -80,29 +93,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -117,11 +177,11 @@ def _prep_wrapped_messages(self, client_info): @property def predict( self, - ) -> typing.Callable[ + ) -> Callable[ [prediction_service.PredictRequest], - typing.Union[ + Union[ prediction_service.PredictResponse, - typing.Awaitable[prediction_service.PredictResponse], + Awaitable[prediction_service.PredictResponse], ], ]: raise NotImplementedError() @@ -129,11 +189,11 @@ def predict( @property def explain( self, - ) -> typing.Callable[ + ) -> Callable[ [prediction_service.ExplainRequest], - typing.Union[ + Union[ prediction_service.ExplainResponse, - typing.Awaitable[prediction_service.ExplainResponse], + Awaitable[prediction_service.ExplainResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py index cd3390b5b9..1abce01400 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,20 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1beta1.types import prediction_service - from .base import PredictionServiceTransport, DEFAULT_CLIENT_INFO @@ -50,7 +47,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -64,7 +61,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -174,7 +172,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -205,13 +203,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) diff --git a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py index a918f991f5..631b0d7ec4 100644 --- a/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1beta1.types import prediction_service - from .base import PredictionServiceTransport, DEFAULT_CLIENT_INFO from .grpc import PredictionServiceGrpcTransport @@ -53,7 +50,7 @@ class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -80,13 +77,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -94,7 +93,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -108,7 +107,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -166,7 +166,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/__init__.py index 49e9cdf0a0..dea5d1cc17 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import SpecialistPoolServiceClient from .async_client import SpecialistPoolServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/async_client.py index c87486e729..9bbde22def 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -35,9 +33,8 @@ from google.cloud.aiplatform_v1beta1.types import specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool as gca_specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool_service -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore from .transports.base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import SpecialistPoolServiceGrpcAsyncIOTransport from .client import SpecialistPoolServiceClient @@ -63,31 +60,26 @@ class SpecialistPoolServiceAsyncClient: parse_specialist_pool_path = staticmethod( SpecialistPoolServiceClient.parse_specialist_pool_path ) - common_billing_account_path = staticmethod( SpecialistPoolServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( SpecialistPoolServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(SpecialistPoolServiceClient.common_folder_path) parse_common_folder_path = staticmethod( SpecialistPoolServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( SpecialistPoolServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( SpecialistPoolServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(SpecialistPoolServiceClient.common_project_path) parse_common_project_path = staticmethod( SpecialistPoolServiceClient.parse_common_project_path ) - common_location_path = staticmethod( SpecialistPoolServiceClient.common_location_path ) @@ -144,7 +136,7 @@ def transport(self) -> SpecialistPoolServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, SpecialistPoolServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -181,7 +173,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = SpecialistPoolServiceClient( credentials=credentials, transport=transport, @@ -220,7 +211,6 @@ async def create_specialist_pool( This corresponds to the ``specialist_pool`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -255,7 +245,6 @@ async def create_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if specialist_pool is not None: @@ -312,7 +301,6 @@ async def get_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -348,7 +336,6 @@ async def get_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -395,7 +382,6 @@ async def list_specialist_pools( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -425,7 +411,6 @@ async def list_specialist_pools( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -479,7 +464,6 @@ async def delete_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -519,7 +503,6 @@ async def delete_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -544,7 +527,7 @@ async def delete_specialist_pool( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -556,7 +539,7 @@ async def update_specialist_pool( request: specialist_pool_service.UpdateSpecialistPoolRequest = None, *, specialist_pool: gca_specialist_pool.SpecialistPool = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -581,7 +564,6 @@ async def update_specialist_pool( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -616,7 +598,6 @@ async def update_specialist_pool( # If we have keyword arguments corresponding to fields on the # request, apply these. - if specialist_pool is not None: request.specialist_pool = specialist_pool if update_mask is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py index c3f95f54ae..8b5a23c39f 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -39,9 +37,8 @@ from google.cloud.aiplatform_v1beta1.types import specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool as gca_specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool_service -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore from .transports.base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import SpecialistPoolServiceGrpcTransport from .transports.grpc_asyncio import SpecialistPoolServiceGrpcAsyncIOTransport @@ -248,7 +245,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, SpecialistPoolServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -389,7 +386,6 @@ def create_specialist_pool( This corresponds to the ``specialist_pool`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -426,10 +422,8 @@ def create_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.CreateSpecialistPoolRequest): request = specialist_pool_service.CreateSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if specialist_pool is not None: @@ -482,7 +476,6 @@ def get_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -520,10 +513,8 @@ def get_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.GetSpecialistPoolRequest): request = specialist_pool_service.GetSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -566,7 +557,6 @@ def list_specialist_pools( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -598,10 +588,8 @@ def list_specialist_pools( # there are no flattened fields. if not isinstance(request, specialist_pool_service.ListSpecialistPoolsRequest): request = specialist_pool_service.ListSpecialistPoolsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -651,7 +639,6 @@ def delete_specialist_pool( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -693,10 +680,8 @@ def delete_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.DeleteSpecialistPoolRequest): request = specialist_pool_service.DeleteSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -717,7 +702,7 @@ def delete_specialist_pool( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -729,7 +714,7 @@ def update_specialist_pool( request: specialist_pool_service.UpdateSpecialistPoolRequest = None, *, specialist_pool: gca_specialist_pool.SpecialistPool = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -754,7 +739,6 @@ def update_specialist_pool( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -791,10 +775,8 @@ def update_specialist_pool( # there are no flattened fields. if not isinstance(request, specialist_pool_service.UpdateSpecialistPoolRequest): request = specialist_pool_service.UpdateSpecialistPoolRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if specialist_pool is not None: request.specialist_pool = specialist_pool if update_mask is not None: diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/pagers.py index 976bcf55b8..cba513a4b9 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/__init__.py index 1bb2fbf22a..cfdda56eda 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py index 48ee079a5c..cbb0dee1cf 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -40,27 +39,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class SpecialistPoolServiceTransport(abc.ABC): """Abstract transport class for SpecialistPoolService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -69,7 +82,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -83,29 +96,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -142,20 +202,19 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.CreateSpecialistPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.GetSpecialistPoolRequest], - typing.Union[ - specialist_pool.SpecialistPool, - typing.Awaitable[specialist_pool.SpecialistPool], + Union[ + specialist_pool.SpecialistPool, Awaitable[specialist_pool.SpecialistPool] ], ]: raise NotImplementedError() @@ -163,11 +222,11 @@ def get_specialist_pool( @property def list_specialist_pools( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.ListSpecialistPoolsRequest], - typing.Union[ + Union[ specialist_pool_service.ListSpecialistPoolsResponse, - typing.Awaitable[specialist_pool_service.ListSpecialistPoolsResponse], + Awaitable[specialist_pool_service.ListSpecialistPoolsResponse], ], ]: raise NotImplementedError() @@ -175,18 +234,18 @@ def list_specialist_pools( @property def delete_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.DeleteSpecialistPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_specialist_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [specialist_pool_service.UpdateSpecialistPoolRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py index c1f9300de8..07f6bb1665 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.aiplatform_v1beta1.types import specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO @@ -58,7 +55,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -72,7 +69,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -183,7 +181,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -214,13 +212,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -248,7 +248,7 @@ def operations_client(self) -> operations_v1.OperationsClient: def create_specialist_pool( self, ) -> Callable[ - [specialist_pool_service.CreateSpecialistPoolRequest], operations.Operation + [specialist_pool_service.CreateSpecialistPoolRequest], operations_pb2.Operation ]: r"""Return a callable for the create specialist pool method over gRPC. @@ -268,7 +268,7 @@ def create_specialist_pool( self._stubs["create_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.SpecialistPoolService/CreateSpecialistPool", request_serializer=specialist_pool_service.CreateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_specialist_pool"] @@ -334,7 +334,7 @@ def list_specialist_pools( def delete_specialist_pool( self, ) -> Callable[ - [specialist_pool_service.DeleteSpecialistPoolRequest], operations.Operation + [specialist_pool_service.DeleteSpecialistPoolRequest], operations_pb2.Operation ]: r"""Return a callable for the delete specialist pool method over gRPC. @@ -355,7 +355,7 @@ def delete_specialist_pool( self._stubs["delete_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.SpecialistPoolService/DeleteSpecialistPool", request_serializer=specialist_pool_service.DeleteSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_specialist_pool"] @@ -363,7 +363,7 @@ def delete_specialist_pool( def update_specialist_pool( self, ) -> Callable[ - [specialist_pool_service.UpdateSpecialistPoolRequest], operations.Operation + [specialist_pool_service.UpdateSpecialistPoolRequest], operations_pb2.Operation ]: r"""Return a callable for the update specialist pool method over gRPC. @@ -383,7 +383,7 @@ def update_specialist_pool( self._stubs["update_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.SpecialistPoolService/UpdateSpecialistPool", request_serializer=specialist_pool_service.UpdateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_specialist_pool"] diff --git a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py index 592776b792..d2fb93a822 100644 --- a/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/specialist_pool_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.aiplatform_v1beta1.types import specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool_service -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import SpecialistPoolServiceTransport, DEFAULT_CLIENT_INFO from .grpc import SpecialistPoolServiceGrpcTransport @@ -61,7 +58,7 @@ class SpecialistPoolServiceGrpcAsyncIOTransport(SpecialistPoolServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -88,13 +85,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -102,7 +101,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -116,7 +115,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -175,7 +175,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -255,7 +254,7 @@ def create_specialist_pool( self, ) -> Callable[ [specialist_pool_service.CreateSpecialistPoolRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create specialist pool method over gRPC. @@ -275,7 +274,7 @@ def create_specialist_pool( self._stubs["create_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.SpecialistPoolService/CreateSpecialistPool", request_serializer=specialist_pool_service.CreateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_specialist_pool"] @@ -342,7 +341,7 @@ def delete_specialist_pool( self, ) -> Callable[ [specialist_pool_service.DeleteSpecialistPoolRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete specialist pool method over gRPC. @@ -363,7 +362,7 @@ def delete_specialist_pool( self._stubs["delete_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.SpecialistPoolService/DeleteSpecialistPool", request_serializer=specialist_pool_service.DeleteSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_specialist_pool"] @@ -372,7 +371,7 @@ def update_specialist_pool( self, ) -> Callable[ [specialist_pool_service.UpdateSpecialistPoolRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update specialist pool method over gRPC. @@ -392,7 +391,7 @@ def update_specialist_pool( self._stubs["update_specialist_pool"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.SpecialistPoolService/UpdateSpecialistPool", request_serializer=specialist_pool_service.UpdateSpecialistPoolRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_specialist_pool"] diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/__init__.py index 70277571f7..5a3d5fc22e 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import TensorboardServiceClient from .async_client import TensorboardServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/async_client.py index 9370a0ada6..347535c785 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation as gac_operation # type: ignore @@ -47,10 +45,9 @@ from google.cloud.aiplatform_v1beta1.types import ( tensorboard_time_series as gca_tensorboard_time_series, ) -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import TensorboardServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import TensorboardServiceGrpcAsyncIOTransport from .client import TensorboardServiceClient @@ -84,31 +81,26 @@ class TensorboardServiceAsyncClient: parse_tensorboard_time_series_path = staticmethod( TensorboardServiceClient.parse_tensorboard_time_series_path ) - common_billing_account_path = staticmethod( TensorboardServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( TensorboardServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(TensorboardServiceClient.common_folder_path) parse_common_folder_path = staticmethod( TensorboardServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( TensorboardServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( TensorboardServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(TensorboardServiceClient.common_project_path) parse_common_project_path = staticmethod( TensorboardServiceClient.parse_common_project_path ) - common_location_path = staticmethod(TensorboardServiceClient.common_location_path) parse_common_location_path = staticmethod( TensorboardServiceClient.parse_common_location_path @@ -163,7 +155,7 @@ def transport(self) -> TensorboardServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, TensorboardServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -200,7 +192,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = TensorboardServiceClient( credentials=credentials, transport=transport, @@ -237,7 +228,6 @@ async def create_tensorboard( This corresponds to the ``tensorboard`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -248,7 +238,7 @@ async def create_tensorboard( google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users’ training metrics. + The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in their projects. @@ -268,7 +258,6 @@ async def create_tensorboard( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard is not None: @@ -324,7 +313,6 @@ async def get_tensorboard( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -334,7 +322,7 @@ async def get_tensorboard( Returns: google.cloud.aiplatform_v1beta1.types.Tensorboard: Tensorboard is a physical database - that stores users’ training metrics. A + that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in @@ -355,7 +343,6 @@ async def get_tensorboard( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -384,7 +371,7 @@ async def update_tensorboard( request: tensorboard_service.UpdateTensorboardRequest = None, *, tensorboard: gca_tensorboard.Tensorboard = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -415,7 +402,6 @@ async def update_tensorboard( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -426,7 +412,7 @@ async def update_tensorboard( google.api_core.operation_async.AsyncOperation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users’ training metrics. + The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in their projects. @@ -446,7 +432,6 @@ async def update_tensorboard( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard is not None: request.tensorboard = tensorboard if update_mask is not None: @@ -505,7 +490,6 @@ async def list_tensorboards( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -535,7 +519,6 @@ async def list_tensorboards( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -588,7 +571,6 @@ async def delete_tensorboard( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -628,7 +610,6 @@ async def delete_tensorboard( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -653,7 +634,7 @@ async def delete_tensorboard( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -701,7 +682,6 @@ async def create_tensorboard_experiment( This corresponds to the ``tensorboard_experiment_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -732,7 +712,6 @@ async def create_tensorboard_experiment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard_experiment is not None: @@ -783,7 +762,6 @@ async def get_tensorboard_experiment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -812,7 +790,6 @@ async def get_tensorboard_experiment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -841,7 +818,7 @@ async def update_tensorboard_experiment( request: tensorboard_service.UpdateTensorboardExperimentRequest = None, *, tensorboard_experiment: gca_tensorboard_experiment.TensorboardExperiment = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -873,7 +850,6 @@ async def update_tensorboard_experiment( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -902,7 +878,6 @@ async def update_tensorboard_experiment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_experiment is not None: request.tensorboard_experiment = tensorboard_experiment if update_mask is not None: @@ -954,7 +929,6 @@ async def list_tensorboard_experiments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -984,7 +958,6 @@ async def list_tensorboard_experiments( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1037,7 +1010,6 @@ async def delete_tensorboard_experiment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1077,7 +1049,6 @@ async def delete_tensorboard_experiment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1102,7 +1073,7 @@ async def delete_tensorboard_experiment( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1152,7 +1123,6 @@ async def create_tensorboard_run( This corresponds to the ``tensorboard_run_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1181,7 +1151,6 @@ async def create_tensorboard_run( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard_run is not None: @@ -1232,7 +1201,6 @@ async def get_tensorboard_run( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1261,7 +1229,6 @@ async def get_tensorboard_run( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1290,7 +1257,7 @@ async def update_tensorboard_run( request: tensorboard_service.UpdateTensorboardRunRequest = None, *, tensorboard_run: gca_tensorboard_run.TensorboardRun = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1321,7 +1288,6 @@ async def update_tensorboard_run( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1350,7 +1316,6 @@ async def update_tensorboard_run( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_run is not None: request.tensorboard_run = tensorboard_run if update_mask is not None: @@ -1402,7 +1367,6 @@ async def list_tensorboard_runs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1432,7 +1396,6 @@ async def list_tensorboard_runs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1485,7 +1448,6 @@ async def delete_tensorboard_run( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1525,7 +1487,6 @@ async def delete_tensorboard_run( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1550,7 +1511,7 @@ async def delete_tensorboard_run( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1588,7 +1549,6 @@ async def create_tensorboard_time_series( This corresponds to the ``tensorboard_time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1615,7 +1575,6 @@ async def create_tensorboard_time_series( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard_time_series is not None: @@ -1664,7 +1623,6 @@ async def get_tensorboard_time_series( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1691,7 +1649,6 @@ async def get_tensorboard_time_series( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1720,7 +1677,7 @@ async def update_tensorboard_time_series( request: tensorboard_service.UpdateTensorboardTimeSeriesRequest = None, *, tensorboard_time_series: gca_tensorboard_time_series.TensorboardTimeSeries = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1752,7 +1709,6 @@ async def update_tensorboard_time_series( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1779,7 +1735,6 @@ async def update_tensorboard_time_series( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_time_series is not None: request.tensorboard_time_series = tensorboard_time_series if update_mask is not None: @@ -1836,7 +1791,6 @@ async def list_tensorboard_time_series( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1866,7 +1820,6 @@ async def list_tensorboard_time_series( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1919,7 +1872,6 @@ async def delete_tensorboard_time_series( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1959,7 +1911,6 @@ async def delete_tensorboard_time_series( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1984,7 +1935,7 @@ async def delete_tensorboard_time_series( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -2019,7 +1970,6 @@ async def read_tensorboard_time_series_data( This corresponds to the ``tensorboard_time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2046,7 +1996,6 @@ async def read_tensorboard_time_series_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_time_series is not None: request.tensorboard_time_series = tensorboard_time_series @@ -2098,7 +2047,6 @@ def read_tensorboard_blob_data( This corresponds to the ``time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2125,7 +2073,6 @@ def read_tensorboard_blob_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if time_series is not None: request.time_series = time_series @@ -2190,7 +2137,6 @@ async def write_tensorboard_run_data( This corresponds to the ``time_series_data`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2217,10 +2163,8 @@ async def write_tensorboard_run_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_run is not None: request.tensorboard_run = tensorboard_run - if time_series_data: request.time_series_data.extend(time_series_data) @@ -2270,7 +2214,6 @@ async def export_tensorboard_time_series_data( This corresponds to the ``tensorboard_time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2300,7 +2243,6 @@ async def export_tensorboard_time_series_data( # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_time_series is not None: request.tensorboard_time_series = tensorboard_time_series diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py index 8395be0b16..4899e0e60c 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -51,10 +49,9 @@ from google.cloud.aiplatform_v1beta1.types import ( tensorboard_time_series as gca_tensorboard_time_series, ) -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import TensorboardServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import TensorboardServiceGrpcTransport from .transports.grpc_asyncio import TensorboardServiceGrpcAsyncIOTransport @@ -326,7 +323,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, TensorboardServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -465,7 +462,6 @@ def create_tensorboard( This corresponds to the ``tensorboard`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -476,7 +472,7 @@ def create_tensorboard( google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users’ training metrics. + The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in their projects. @@ -498,10 +494,8 @@ def create_tensorboard( # there are no flattened fields. if not isinstance(request, tensorboard_service.CreateTensorboardRequest): request = tensorboard_service.CreateTensorboardRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard is not None: @@ -553,7 +547,6 @@ def get_tensorboard( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -563,7 +556,7 @@ def get_tensorboard( Returns: google.cloud.aiplatform_v1beta1.types.Tensorboard: Tensorboard is a physical database - that stores users’ training metrics. A + that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in @@ -586,10 +579,8 @@ def get_tensorboard( # there are no flattened fields. if not isinstance(request, tensorboard_service.GetTensorboardRequest): request = tensorboard_service.GetTensorboardRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -614,7 +605,7 @@ def update_tensorboard( request: tensorboard_service.UpdateTensorboardRequest = None, *, tensorboard: gca_tensorboard.Tensorboard = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -645,7 +636,6 @@ def update_tensorboard( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -656,7 +646,7 @@ def update_tensorboard( google.api_core.operation.Operation: An object representing a long-running operation. - The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users’ training metrics. + The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.Tensorboard` Tensorboard is a physical database that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in their projects. @@ -678,10 +668,8 @@ def update_tensorboard( # there are no flattened fields. if not isinstance(request, tensorboard_service.UpdateTensorboardRequest): request = tensorboard_service.UpdateTensorboardRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard is not None: request.tensorboard = tensorboard if update_mask is not None: @@ -736,7 +724,6 @@ def list_tensorboards( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -768,10 +755,8 @@ def list_tensorboards( # there are no flattened fields. if not isinstance(request, tensorboard_service.ListTensorboardsRequest): request = tensorboard_service.ListTensorboardsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -820,7 +805,6 @@ def delete_tensorboard( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -862,10 +846,8 @@ def delete_tensorboard( # there are no flattened fields. if not isinstance(request, tensorboard_service.DeleteTensorboardRequest): request = tensorboard_service.DeleteTensorboardRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -886,7 +868,7 @@ def delete_tensorboard( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -934,7 +916,6 @@ def create_tensorboard_experiment( This corresponds to the ``tensorboard_experiment_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -969,10 +950,8 @@ def create_tensorboard_experiment( request, tensorboard_service.CreateTensorboardExperimentRequest ): request = tensorboard_service.CreateTensorboardExperimentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard_experiment is not None: @@ -1021,7 +1000,6 @@ def get_tensorboard_experiment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1052,10 +1030,8 @@ def get_tensorboard_experiment( # there are no flattened fields. if not isinstance(request, tensorboard_service.GetTensorboardExperimentRequest): request = tensorboard_service.GetTensorboardExperimentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1082,7 +1058,7 @@ def update_tensorboard_experiment( request: tensorboard_service.UpdateTensorboardExperimentRequest = None, *, tensorboard_experiment: gca_tensorboard_experiment.TensorboardExperiment = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1114,7 +1090,6 @@ def update_tensorboard_experiment( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1147,10 +1122,8 @@ def update_tensorboard_experiment( request, tensorboard_service.UpdateTensorboardExperimentRequest ): request = tensorboard_service.UpdateTensorboardExperimentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_experiment is not None: request.tensorboard_experiment = tensorboard_experiment if update_mask is not None: @@ -1200,7 +1173,6 @@ def list_tensorboard_experiments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1234,10 +1206,8 @@ def list_tensorboard_experiments( request, tensorboard_service.ListTensorboardExperimentsRequest ): request = tensorboard_service.ListTensorboardExperimentsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1288,7 +1258,6 @@ def delete_tensorboard_experiment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1332,10 +1301,8 @@ def delete_tensorboard_experiment( request, tensorboard_service.DeleteTensorboardExperimentRequest ): request = tensorboard_service.DeleteTensorboardExperimentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1358,7 +1325,7 @@ def delete_tensorboard_experiment( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1408,7 +1375,6 @@ def create_tensorboard_run( This corresponds to the ``tensorboard_run_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1439,10 +1405,8 @@ def create_tensorboard_run( # there are no flattened fields. if not isinstance(request, tensorboard_service.CreateTensorboardRunRequest): request = tensorboard_service.CreateTensorboardRunRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard_run is not None: @@ -1489,7 +1453,6 @@ def get_tensorboard_run( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1520,10 +1483,8 @@ def get_tensorboard_run( # there are no flattened fields. if not isinstance(request, tensorboard_service.GetTensorboardRunRequest): request = tensorboard_service.GetTensorboardRunRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1548,7 +1509,7 @@ def update_tensorboard_run( request: tensorboard_service.UpdateTensorboardRunRequest = None, *, tensorboard_run: gca_tensorboard_run.TensorboardRun = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1579,7 +1540,6 @@ def update_tensorboard_run( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1610,10 +1570,8 @@ def update_tensorboard_run( # there are no flattened fields. if not isinstance(request, tensorboard_service.UpdateTensorboardRunRequest): request = tensorboard_service.UpdateTensorboardRunRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_run is not None: request.tensorboard_run = tensorboard_run if update_mask is not None: @@ -1661,7 +1619,6 @@ def list_tensorboard_runs( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1693,10 +1650,8 @@ def list_tensorboard_runs( # there are no flattened fields. if not isinstance(request, tensorboard_service.ListTensorboardRunsRequest): request = tensorboard_service.ListTensorboardRunsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1745,7 +1700,6 @@ def delete_tensorboard_run( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1787,10 +1741,8 @@ def delete_tensorboard_run( # there are no flattened fields. if not isinstance(request, tensorboard_service.DeleteTensorboardRunRequest): request = tensorboard_service.DeleteTensorboardRunRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1811,7 +1763,7 @@ def delete_tensorboard_run( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -1849,7 +1801,6 @@ def create_tensorboard_time_series( This corresponds to the ``tensorboard_time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1880,10 +1831,8 @@ def create_tensorboard_time_series( request, tensorboard_service.CreateTensorboardTimeSeriesRequest ): request = tensorboard_service.CreateTensorboardTimeSeriesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if tensorboard_time_series is not None: @@ -1930,7 +1879,6 @@ def get_tensorboard_time_series( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1959,10 +1907,8 @@ def get_tensorboard_time_series( # there are no flattened fields. if not isinstance(request, tensorboard_service.GetTensorboardTimeSeriesRequest): request = tensorboard_service.GetTensorboardTimeSeriesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1989,7 +1935,7 @@ def update_tensorboard_time_series( request: tensorboard_service.UpdateTensorboardTimeSeriesRequest = None, *, tensorboard_time_series: gca_tensorboard_time_series.TensorboardTimeSeries = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2021,7 +1967,6 @@ def update_tensorboard_time_series( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2052,10 +1997,8 @@ def update_tensorboard_time_series( request, tensorboard_service.UpdateTensorboardTimeSeriesRequest ): request = tensorboard_service.UpdateTensorboardTimeSeriesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_time_series is not None: request.tensorboard_time_series = tensorboard_time_series if update_mask is not None: @@ -2110,7 +2053,6 @@ def list_tensorboard_time_series( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2144,10 +2086,8 @@ def list_tensorboard_time_series( request, tensorboard_service.ListTensorboardTimeSeriesRequest ): request = tensorboard_service.ListTensorboardTimeSeriesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -2198,7 +2138,6 @@ def delete_tensorboard_time_series( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2242,10 +2181,8 @@ def delete_tensorboard_time_series( request, tensorboard_service.DeleteTensorboardTimeSeriesRequest ): request = tensorboard_service.DeleteTensorboardTimeSeriesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2268,7 +2205,7 @@ def delete_tensorboard_time_series( response = gac_operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=gca_operation.DeleteOperationMetadata, ) @@ -2303,7 +2240,6 @@ def read_tensorboard_time_series_data( This corresponds to the ``tensorboard_time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2334,10 +2270,8 @@ def read_tensorboard_time_series_data( request, tensorboard_service.ReadTensorboardTimeSeriesDataRequest ): request = tensorboard_service.ReadTensorboardTimeSeriesDataRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_time_series is not None: request.tensorboard_time_series = tensorboard_time_series @@ -2387,7 +2321,6 @@ def read_tensorboard_blob_data( This corresponds to the ``time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2416,10 +2349,8 @@ def read_tensorboard_blob_data( # there are no flattened fields. if not isinstance(request, tensorboard_service.ReadTensorboardBlobDataRequest): request = tensorboard_service.ReadTensorboardBlobDataRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if time_series is not None: request.time_series = time_series @@ -2482,7 +2413,6 @@ def write_tensorboard_run_data( This corresponds to the ``time_series_data`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2511,10 +2441,8 @@ def write_tensorboard_run_data( # there are no flattened fields. if not isinstance(request, tensorboard_service.WriteTensorboardRunDataRequest): request = tensorboard_service.WriteTensorboardRunDataRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_run is not None: request.tensorboard_run = tensorboard_run if time_series_data is not None: @@ -2564,7 +2492,6 @@ def export_tensorboard_time_series_data( This corresponds to the ``tensorboard_time_series`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2600,10 +2527,8 @@ def export_tensorboard_time_series_data( request = tensorboard_service.ExportTensorboardTimeSeriesDataRequest( request ) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if tensorboard_time_series is not None: request.tensorboard_time_series = tensorboard_time_series diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/pagers.py index acc2c40676..8200c9c237 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/__init__.py index 86ffc7d6b2..50612ea154 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py index 2e2dea1764..71b612167c 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import tensorboard from google.cloud.aiplatform_v1beta1.types import tensorboard_experiment @@ -38,8 +38,7 @@ from google.cloud.aiplatform_v1beta1.types import ( tensorboard_time_series as gca_tensorboard_time_series, ) -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -50,27 +49,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class TensorboardServiceTransport(abc.ABC): """Abstract transport class for TensorboardService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -79,7 +92,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -93,29 +106,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -237,40 +297,38 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_tensorboard( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.CreateTensorboardRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_tensorboard( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.GetTensorboardRequest], - typing.Union[ - tensorboard.Tensorboard, typing.Awaitable[tensorboard.Tensorboard] - ], + Union[tensorboard.Tensorboard, Awaitable[tensorboard.Tensorboard]], ]: raise NotImplementedError() @property def update_tensorboard( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.UpdateTensorboardRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_tensorboards( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.ListTensorboardsRequest], - typing.Union[ + Union[ tensorboard_service.ListTensorboardsResponse, - typing.Awaitable[tensorboard_service.ListTensorboardsResponse], + Awaitable[tensorboard_service.ListTensorboardsResponse], ], ]: raise NotImplementedError() @@ -278,20 +336,20 @@ def list_tensorboards( @property def delete_tensorboard( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.DeleteTensorboardRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_tensorboard_experiment( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.CreateTensorboardExperimentRequest], - typing.Union[ + Union[ gca_tensorboard_experiment.TensorboardExperiment, - typing.Awaitable[gca_tensorboard_experiment.TensorboardExperiment], + Awaitable[gca_tensorboard_experiment.TensorboardExperiment], ], ]: raise NotImplementedError() @@ -299,11 +357,11 @@ def create_tensorboard_experiment( @property def get_tensorboard_experiment( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.GetTensorboardExperimentRequest], - typing.Union[ + Union[ tensorboard_experiment.TensorboardExperiment, - typing.Awaitable[tensorboard_experiment.TensorboardExperiment], + Awaitable[tensorboard_experiment.TensorboardExperiment], ], ]: raise NotImplementedError() @@ -311,11 +369,11 @@ def get_tensorboard_experiment( @property def update_tensorboard_experiment( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.UpdateTensorboardExperimentRequest], - typing.Union[ + Union[ gca_tensorboard_experiment.TensorboardExperiment, - typing.Awaitable[gca_tensorboard_experiment.TensorboardExperiment], + Awaitable[gca_tensorboard_experiment.TensorboardExperiment], ], ]: raise NotImplementedError() @@ -323,11 +381,11 @@ def update_tensorboard_experiment( @property def list_tensorboard_experiments( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.ListTensorboardExperimentsRequest], - typing.Union[ + Union[ tensorboard_service.ListTensorboardExperimentsResponse, - typing.Awaitable[tensorboard_service.ListTensorboardExperimentsResponse], + Awaitable[tensorboard_service.ListTensorboardExperimentsResponse], ], ]: raise NotImplementedError() @@ -335,20 +393,20 @@ def list_tensorboard_experiments( @property def delete_tensorboard_experiment( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.DeleteTensorboardExperimentRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_tensorboard_run( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.CreateTensorboardRunRequest], - typing.Union[ + Union[ gca_tensorboard_run.TensorboardRun, - typing.Awaitable[gca_tensorboard_run.TensorboardRun], + Awaitable[gca_tensorboard_run.TensorboardRun], ], ]: raise NotImplementedError() @@ -356,11 +414,10 @@ def create_tensorboard_run( @property def get_tensorboard_run( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.GetTensorboardRunRequest], - typing.Union[ - tensorboard_run.TensorboardRun, - typing.Awaitable[tensorboard_run.TensorboardRun], + Union[ + tensorboard_run.TensorboardRun, Awaitable[tensorboard_run.TensorboardRun] ], ]: raise NotImplementedError() @@ -368,11 +425,11 @@ def get_tensorboard_run( @property def update_tensorboard_run( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.UpdateTensorboardRunRequest], - typing.Union[ + Union[ gca_tensorboard_run.TensorboardRun, - typing.Awaitable[gca_tensorboard_run.TensorboardRun], + Awaitable[gca_tensorboard_run.TensorboardRun], ], ]: raise NotImplementedError() @@ -380,11 +437,11 @@ def update_tensorboard_run( @property def list_tensorboard_runs( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.ListTensorboardRunsRequest], - typing.Union[ + Union[ tensorboard_service.ListTensorboardRunsResponse, - typing.Awaitable[tensorboard_service.ListTensorboardRunsResponse], + Awaitable[tensorboard_service.ListTensorboardRunsResponse], ], ]: raise NotImplementedError() @@ -392,20 +449,20 @@ def list_tensorboard_runs( @property def delete_tensorboard_run( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.DeleteTensorboardRunRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_tensorboard_time_series( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.CreateTensorboardTimeSeriesRequest], - typing.Union[ + Union[ gca_tensorboard_time_series.TensorboardTimeSeries, - typing.Awaitable[gca_tensorboard_time_series.TensorboardTimeSeries], + Awaitable[gca_tensorboard_time_series.TensorboardTimeSeries], ], ]: raise NotImplementedError() @@ -413,11 +470,11 @@ def create_tensorboard_time_series( @property def get_tensorboard_time_series( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.GetTensorboardTimeSeriesRequest], - typing.Union[ + Union[ tensorboard_time_series.TensorboardTimeSeries, - typing.Awaitable[tensorboard_time_series.TensorboardTimeSeries], + Awaitable[tensorboard_time_series.TensorboardTimeSeries], ], ]: raise NotImplementedError() @@ -425,11 +482,11 @@ def get_tensorboard_time_series( @property def update_tensorboard_time_series( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.UpdateTensorboardTimeSeriesRequest], - typing.Union[ + Union[ gca_tensorboard_time_series.TensorboardTimeSeries, - typing.Awaitable[gca_tensorboard_time_series.TensorboardTimeSeries], + Awaitable[gca_tensorboard_time_series.TensorboardTimeSeries], ], ]: raise NotImplementedError() @@ -437,11 +494,11 @@ def update_tensorboard_time_series( @property def list_tensorboard_time_series( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.ListTensorboardTimeSeriesRequest], - typing.Union[ + Union[ tensorboard_service.ListTensorboardTimeSeriesResponse, - typing.Awaitable[tensorboard_service.ListTensorboardTimeSeriesResponse], + Awaitable[tensorboard_service.ListTensorboardTimeSeriesResponse], ], ]: raise NotImplementedError() @@ -449,20 +506,20 @@ def list_tensorboard_time_series( @property def delete_tensorboard_time_series( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.DeleteTensorboardTimeSeriesRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def read_tensorboard_time_series_data( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.ReadTensorboardTimeSeriesDataRequest], - typing.Union[ + Union[ tensorboard_service.ReadTensorboardTimeSeriesDataResponse, - typing.Awaitable[tensorboard_service.ReadTensorboardTimeSeriesDataResponse], + Awaitable[tensorboard_service.ReadTensorboardTimeSeriesDataResponse], ], ]: raise NotImplementedError() @@ -470,11 +527,11 @@ def read_tensorboard_time_series_data( @property def read_tensorboard_blob_data( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.ReadTensorboardBlobDataRequest], - typing.Union[ + Union[ tensorboard_service.ReadTensorboardBlobDataResponse, - typing.Awaitable[tensorboard_service.ReadTensorboardBlobDataResponse], + Awaitable[tensorboard_service.ReadTensorboardBlobDataResponse], ], ]: raise NotImplementedError() @@ -482,11 +539,11 @@ def read_tensorboard_blob_data( @property def write_tensorboard_run_data( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.WriteTensorboardRunDataRequest], - typing.Union[ + Union[ tensorboard_service.WriteTensorboardRunDataResponse, - typing.Awaitable[tensorboard_service.WriteTensorboardRunDataResponse], + Awaitable[tensorboard_service.WriteTensorboardRunDataResponse], ], ]: raise NotImplementedError() @@ -494,13 +551,11 @@ def write_tensorboard_run_data( @property def export_tensorboard_time_series_data( self, - ) -> typing.Callable[ + ) -> Callable[ [tensorboard_service.ExportTensorboardTimeSeriesDataRequest], - typing.Union[ + Union[ tensorboard_service.ExportTensorboardTimeSeriesDataResponse, - typing.Awaitable[ - tensorboard_service.ExportTensorboardTimeSeriesDataResponse - ], + Awaitable[tensorboard_service.ExportTensorboardTimeSeriesDataResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py index 02f697b2ae..c2490cf083 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -39,8 +37,7 @@ from google.cloud.aiplatform_v1beta1.types import ( tensorboard_time_series as gca_tensorboard_time_series, ) -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import TensorboardServiceTransport, DEFAULT_CLIENT_INFO @@ -63,7 +60,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -77,7 +74,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -188,7 +186,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -219,13 +217,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -252,7 +252,9 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_tensorboard( self, - ) -> Callable[[tensorboard_service.CreateTensorboardRequest], operations.Operation]: + ) -> Callable[ + [tensorboard_service.CreateTensorboardRequest], operations_pb2.Operation + ]: r"""Return a callable for the create tensorboard method over gRPC. Creates a Tensorboard. @@ -271,7 +273,7 @@ def create_tensorboard( self._stubs["create_tensorboard"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/CreateTensorboard", request_serializer=tensorboard_service.CreateTensorboardRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_tensorboard"] @@ -304,7 +306,9 @@ def get_tensorboard( @property def update_tensorboard( self, - ) -> Callable[[tensorboard_service.UpdateTensorboardRequest], operations.Operation]: + ) -> Callable[ + [tensorboard_service.UpdateTensorboardRequest], operations_pb2.Operation + ]: r"""Return a callable for the update tensorboard method over gRPC. Updates a Tensorboard. @@ -323,7 +327,7 @@ def update_tensorboard( self._stubs["update_tensorboard"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/UpdateTensorboard", request_serializer=tensorboard_service.UpdateTensorboardRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_tensorboard"] @@ -359,7 +363,9 @@ def list_tensorboards( @property def delete_tensorboard( self, - ) -> Callable[[tensorboard_service.DeleteTensorboardRequest], operations.Operation]: + ) -> Callable[ + [tensorboard_service.DeleteTensorboardRequest], operations_pb2.Operation + ]: r"""Return a callable for the delete tensorboard method over gRPC. Deletes a Tensorboard. @@ -378,7 +384,7 @@ def delete_tensorboard( self._stubs["delete_tensorboard"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboard", request_serializer=tensorboard_service.DeleteTensorboardRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard"] @@ -506,7 +512,8 @@ def list_tensorboard_experiments( def delete_tensorboard_experiment( self, ) -> Callable[ - [tensorboard_service.DeleteTensorboardExperimentRequest], operations.Operation + [tensorboard_service.DeleteTensorboardExperimentRequest], + operations_pb2.Operation, ]: r"""Return a callable for the delete tensorboard experiment method over gRPC. @@ -528,7 +535,7 @@ def delete_tensorboard_experiment( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboardExperiment", request_serializer=tensorboard_service.DeleteTensorboardExperimentRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard_experiment"] @@ -651,7 +658,7 @@ def list_tensorboard_runs( def delete_tensorboard_run( self, ) -> Callable[ - [tensorboard_service.DeleteTensorboardRunRequest], operations.Operation + [tensorboard_service.DeleteTensorboardRunRequest], operations_pb2.Operation ]: r"""Return a callable for the delete tensorboard run method over gRPC. @@ -671,7 +678,7 @@ def delete_tensorboard_run( self._stubs["delete_tensorboard_run"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboardRun", request_serializer=tensorboard_service.DeleteTensorboardRunRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard_run"] @@ -799,7 +806,8 @@ def list_tensorboard_time_series( def delete_tensorboard_time_series( self, ) -> Callable[ - [tensorboard_service.DeleteTensorboardTimeSeriesRequest], operations.Operation + [tensorboard_service.DeleteTensorboardTimeSeriesRequest], + operations_pb2.Operation, ]: r"""Return a callable for the delete tensorboard time series method over gRPC. @@ -821,7 +829,7 @@ def delete_tensorboard_time_series( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboardTimeSeries", request_serializer=tensorboard_service.DeleteTensorboardTimeSeriesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard_time_series"] diff --git a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py index d49895cdad..6824b6ebdf 100644 --- a/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/tensorboard_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -40,8 +38,7 @@ from google.cloud.aiplatform_v1beta1.types import ( tensorboard_time_series as gca_tensorboard_time_series, ) -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import TensorboardServiceTransport, DEFAULT_CLIENT_INFO from .grpc import TensorboardServiceGrpcTransport @@ -66,7 +63,7 @@ class TensorboardServiceGrpcAsyncIOTransport(TensorboardServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -93,13 +90,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -107,7 +106,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -121,7 +120,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -180,7 +180,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -259,7 +258,8 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: def create_tensorboard( self, ) -> Callable[ - [tensorboard_service.CreateTensorboardRequest], Awaitable[operations.Operation] + [tensorboard_service.CreateTensorboardRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create tensorboard method over gRPC. @@ -279,7 +279,7 @@ def create_tensorboard( self._stubs["create_tensorboard"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/CreateTensorboard", request_serializer=tensorboard_service.CreateTensorboardRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_tensorboard"] @@ -315,7 +315,8 @@ def get_tensorboard( def update_tensorboard( self, ) -> Callable[ - [tensorboard_service.UpdateTensorboardRequest], Awaitable[operations.Operation] + [tensorboard_service.UpdateTensorboardRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update tensorboard method over gRPC. @@ -335,7 +336,7 @@ def update_tensorboard( self._stubs["update_tensorboard"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/UpdateTensorboard", request_serializer=tensorboard_service.UpdateTensorboardRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_tensorboard"] @@ -372,7 +373,8 @@ def list_tensorboards( def delete_tensorboard( self, ) -> Callable[ - [tensorboard_service.DeleteTensorboardRequest], Awaitable[operations.Operation] + [tensorboard_service.DeleteTensorboardRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete tensorboard method over gRPC. @@ -392,7 +394,7 @@ def delete_tensorboard( self._stubs["delete_tensorboard"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboard", request_serializer=tensorboard_service.DeleteTensorboardRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard"] @@ -521,7 +523,7 @@ def delete_tensorboard_experiment( self, ) -> Callable[ [tensorboard_service.DeleteTensorboardExperimentRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete tensorboard experiment method over gRPC. @@ -543,7 +545,7 @@ def delete_tensorboard_experiment( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboardExperiment", request_serializer=tensorboard_service.DeleteTensorboardExperimentRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard_experiment"] @@ -668,7 +670,7 @@ def delete_tensorboard_run( self, ) -> Callable[ [tensorboard_service.DeleteTensorboardRunRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete tensorboard run method over gRPC. @@ -688,7 +690,7 @@ def delete_tensorboard_run( self._stubs["delete_tensorboard_run"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboardRun", request_serializer=tensorboard_service.DeleteTensorboardRunRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard_run"] @@ -817,7 +819,7 @@ def delete_tensorboard_time_series( self, ) -> Callable[ [tensorboard_service.DeleteTensorboardTimeSeriesRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete tensorboard time series method over gRPC. @@ -839,7 +841,7 @@ def delete_tensorboard_time_series( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.TensorboardService/DeleteTensorboardTimeSeries", request_serializer=tensorboard_service.DeleteTensorboardTimeSeriesRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_tensorboard_time_series"] diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/__init__.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/__init__.py index 5c312868f1..5586edbbe2 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import VizierServiceClient from .async_client import VizierServiceAsyncClient diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/async_client.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/async_client.py index 6c29a31eb4..d76f7aa64e 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/async_client.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore @@ -34,8 +32,7 @@ from google.cloud.aiplatform_v1beta1.types import study from google.cloud.aiplatform_v1beta1.types import study as gca_study from google.cloud.aiplatform_v1beta1.types import vizier_service -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import VizierServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import VizierServiceGrpcAsyncIOTransport from .client import VizierServiceClient @@ -59,31 +56,26 @@ class VizierServiceAsyncClient: parse_study_path = staticmethod(VizierServiceClient.parse_study_path) trial_path = staticmethod(VizierServiceClient.trial_path) parse_trial_path = staticmethod(VizierServiceClient.parse_trial_path) - common_billing_account_path = staticmethod( VizierServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( VizierServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(VizierServiceClient.common_folder_path) parse_common_folder_path = staticmethod( VizierServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( VizierServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( VizierServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(VizierServiceClient.common_project_path) parse_common_project_path = staticmethod( VizierServiceClient.parse_common_project_path ) - common_location_path = staticmethod(VizierServiceClient.common_location_path) parse_common_location_path = staticmethod( VizierServiceClient.parse_common_location_path @@ -137,7 +129,7 @@ def transport(self) -> VizierServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, VizierServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -174,7 +166,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = VizierServiceClient( credentials=credentials, transport=transport, @@ -214,7 +205,6 @@ async def create_study( This corresponds to the ``study`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -239,7 +229,6 @@ async def create_study( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if study is not None: @@ -287,7 +276,6 @@ async def get_study( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -312,7 +300,6 @@ async def get_study( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -360,7 +347,6 @@ async def list_studies( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -390,7 +376,6 @@ async def list_studies( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -443,7 +428,6 @@ async def delete_study( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -464,7 +448,6 @@ async def delete_study( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -511,7 +494,6 @@ async def lookup_study( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -536,7 +518,6 @@ async def lookup_study( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -578,7 +559,6 @@ async def suggest_trials( request (:class:`google.cloud.aiplatform_v1beta1.types.SuggestTrialsRequest`): The request object. Request message for [VizierService.SuggestTrials][google.cloud.aiplatform.v1beta1.VizierService.SuggestTrials]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -596,7 +576,6 @@ async def suggest_trials( """ # Create or coerce a protobuf request object. - request = vizier_service.SuggestTrialsRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -656,7 +635,6 @@ async def create_trial( This corresponds to the ``trial`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -686,7 +664,6 @@ async def create_trial( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if trial is not None: @@ -734,7 +711,6 @@ async def get_trial( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -764,7 +740,6 @@ async def get_trial( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -811,7 +786,6 @@ async def list_trials( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -841,7 +815,6 @@ async def list_trials( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -887,7 +860,6 @@ async def add_trial_measurement( request (:class:`google.cloud.aiplatform_v1beta1.types.AddTrialMeasurementRequest`): The request object. Request message for [VizierService.AddTrialMeasurement][google.cloud.aiplatform.v1beta1.VizierService.AddTrialMeasurement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -904,7 +876,6 @@ async def add_trial_measurement( """ # Create or coerce a protobuf request object. - request = vizier_service.AddTrialMeasurementRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -943,7 +914,6 @@ async def complete_trial( request (:class:`google.cloud.aiplatform_v1beta1.types.CompleteTrialRequest`): The request object. Request message for [VizierService.CompleteTrial][google.cloud.aiplatform.v1beta1.VizierService.CompleteTrial]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -960,7 +930,6 @@ async def complete_trial( """ # Create or coerce a protobuf request object. - request = vizier_service.CompleteTrialRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1005,7 +974,6 @@ async def delete_trial( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1026,7 +994,6 @@ async def delete_trial( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1066,7 +1033,6 @@ async def check_trial_early_stopping_state( request (:class:`google.cloud.aiplatform_v1beta1.types.CheckTrialEarlyStoppingStateRequest`): The request object. Request message for [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1beta1.VizierService.CheckTrialEarlyStoppingState]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1084,7 +1050,6 @@ async def check_trial_early_stopping_state( """ # Create or coerce a protobuf request object. - request = vizier_service.CheckTrialEarlyStoppingStateRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1131,7 +1096,6 @@ async def stop_trial( request (:class:`google.cloud.aiplatform_v1beta1.types.StopTrialRequest`): The request object. Request message for [VizierService.StopTrial][google.cloud.aiplatform.v1beta1.VizierService.StopTrial]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1148,7 +1112,6 @@ async def stop_trial( """ # Create or coerce a protobuf request object. - request = vizier_service.StopTrialRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1196,7 +1159,6 @@ async def list_optimal_trials( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1223,7 +1185,6 @@ async def list_optimal_trials( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py index 23d7091c9c..c6f834add7 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -38,8 +36,7 @@ from google.cloud.aiplatform_v1beta1.types import study from google.cloud.aiplatform_v1beta1.types import study as gca_study from google.cloud.aiplatform_v1beta1.types import vizier_service -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import VizierServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import VizierServiceGrpcTransport from .transports.grpc_asyncio import VizierServiceGrpcAsyncIOTransport @@ -272,7 +269,7 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, VizierServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, @@ -414,7 +411,6 @@ def create_study( This corresponds to the ``study`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -441,10 +437,8 @@ def create_study( # there are no flattened fields. if not isinstance(request, vizier_service.CreateStudyRequest): request = vizier_service.CreateStudyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if study is not None: @@ -488,7 +482,6 @@ def get_study( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -515,10 +508,8 @@ def get_study( # there are no flattened fields. if not isinstance(request, vizier_service.GetStudyRequest): request = vizier_service.GetStudyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -562,7 +553,6 @@ def list_studies( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -594,10 +584,8 @@ def list_studies( # there are no flattened fields. if not isinstance(request, vizier_service.ListStudiesRequest): request = vizier_service.ListStudiesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -646,7 +634,6 @@ def delete_study( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -669,10 +656,8 @@ def delete_study( # there are no flattened fields. if not isinstance(request, vizier_service.DeleteStudyRequest): request = vizier_service.DeleteStudyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -715,7 +700,6 @@ def lookup_study( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -742,10 +726,8 @@ def lookup_study( # there are no flattened fields. if not isinstance(request, vizier_service.LookupStudyRequest): request = vizier_service.LookupStudyRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -783,7 +765,6 @@ def suggest_trials( request (google.cloud.aiplatform_v1beta1.types.SuggestTrialsRequest): The request object. Request message for [VizierService.SuggestTrials][google.cloud.aiplatform.v1beta1.VizierService.SuggestTrials]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -801,7 +782,6 @@ def suggest_trials( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a vizier_service.SuggestTrialsRequest. # There's no risk of modifying the input as we've already verified @@ -862,7 +842,6 @@ def create_trial( This corresponds to the ``trial`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -894,10 +873,8 @@ def create_trial( # there are no flattened fields. if not isinstance(request, vizier_service.CreateTrialRequest): request = vizier_service.CreateTrialRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if trial is not None: @@ -941,7 +918,6 @@ def get_trial( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -973,10 +949,8 @@ def get_trial( # there are no flattened fields. if not isinstance(request, vizier_service.GetTrialRequest): request = vizier_service.GetTrialRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1019,7 +993,6 @@ def list_trials( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1051,10 +1024,8 @@ def list_trials( # there are no flattened fields. if not isinstance(request, vizier_service.ListTrialsRequest): request = vizier_service.ListTrialsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1096,7 +1067,6 @@ def add_trial_measurement( request (google.cloud.aiplatform_v1beta1.types.AddTrialMeasurementRequest): The request object. Request message for [VizierService.AddTrialMeasurement][google.cloud.aiplatform.v1beta1.VizierService.AddTrialMeasurement]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1113,7 +1083,6 @@ def add_trial_measurement( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a vizier_service.AddTrialMeasurementRequest. # There's no risk of modifying the input as we've already verified @@ -1153,7 +1122,6 @@ def complete_trial( request (google.cloud.aiplatform_v1beta1.types.CompleteTrialRequest): The request object. Request message for [VizierService.CompleteTrial][google.cloud.aiplatform.v1beta1.VizierService.CompleteTrial]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1170,7 +1138,6 @@ def complete_trial( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a vizier_service.CompleteTrialRequest. # There's no risk of modifying the input as we've already verified @@ -1216,7 +1183,6 @@ def delete_trial( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1239,10 +1205,8 @@ def delete_trial( # there are no flattened fields. if not isinstance(request, vizier_service.DeleteTrialRequest): request = vizier_service.DeleteTrialRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1278,7 +1242,6 @@ def check_trial_early_stopping_state( request (google.cloud.aiplatform_v1beta1.types.CheckTrialEarlyStoppingStateRequest): The request object. Request message for [VizierService.CheckTrialEarlyStoppingState][google.cloud.aiplatform.v1beta1.VizierService.CheckTrialEarlyStoppingState]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1296,7 +1259,6 @@ def check_trial_early_stopping_state( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a vizier_service.CheckTrialEarlyStoppingStateRequest. # There's no risk of modifying the input as we've already verified @@ -1346,7 +1308,6 @@ def stop_trial( request (google.cloud.aiplatform_v1beta1.types.StopTrialRequest): The request object. Request message for [VizierService.StopTrial][google.cloud.aiplatform.v1beta1.VizierService.StopTrial]. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1363,7 +1324,6 @@ def stop_trial( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a vizier_service.StopTrialRequest. # There's no risk of modifying the input as we've already verified @@ -1412,7 +1372,6 @@ def list_optimal_trials( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1441,10 +1400,8 @@ def list_optimal_trials( # there are no flattened fields. if not isinstance(request, vizier_service.ListOptimalTrialsRequest): request = vizier_service.ListOptimalTrialsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/pagers.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/pagers.py index c6e4fcdf63..39d956e6be 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/pagers.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/__init__.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/__init__.py index 3ed347a603..4fdc0272ee 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/__init__.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py index f09cd934b7..45cd82c0ab 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.aiplatform_v1beta1.types import study from google.cloud.aiplatform_v1beta1.types import study as gca_study from google.cloud.aiplatform_v1beta1.types import vizier_service -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -42,27 +41,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class VizierServiceTransport(abc.ABC): """Abstract transport class for VizierService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "aiplatform.googleapis.com" + def __init__( self, *, - host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -71,7 +84,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -85,29 +98,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -170,29 +230,28 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_study( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.CreateStudyRequest], - typing.Union[gca_study.Study, typing.Awaitable[gca_study.Study]], + Union[gca_study.Study, Awaitable[gca_study.Study]], ]: raise NotImplementedError() @property def get_study( self, - ) -> typing.Callable[ - [vizier_service.GetStudyRequest], - typing.Union[study.Study, typing.Awaitable[study.Study]], + ) -> Callable[ + [vizier_service.GetStudyRequest], Union[study.Study, Awaitable[study.Study]] ]: raise NotImplementedError() @property def list_studies( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.ListStudiesRequest], - typing.Union[ + Union[ vizier_service.ListStudiesResponse, - typing.Awaitable[vizier_service.ListStudiesResponse], + Awaitable[vizier_service.ListStudiesResponse], ], ]: raise NotImplementedError() @@ -200,56 +259,53 @@ def list_studies( @property def delete_study( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.DeleteStudyRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def lookup_study( self, - ) -> typing.Callable[ - [vizier_service.LookupStudyRequest], - typing.Union[study.Study, typing.Awaitable[study.Study]], + ) -> Callable[ + [vizier_service.LookupStudyRequest], Union[study.Study, Awaitable[study.Study]] ]: raise NotImplementedError() @property def suggest_trials( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.SuggestTrialsRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_trial( self, - ) -> typing.Callable[ - [vizier_service.CreateTrialRequest], - typing.Union[study.Trial, typing.Awaitable[study.Trial]], + ) -> Callable[ + [vizier_service.CreateTrialRequest], Union[study.Trial, Awaitable[study.Trial]] ]: raise NotImplementedError() @property def get_trial( self, - ) -> typing.Callable[ - [vizier_service.GetTrialRequest], - typing.Union[study.Trial, typing.Awaitable[study.Trial]], + ) -> Callable[ + [vizier_service.GetTrialRequest], Union[study.Trial, Awaitable[study.Trial]] ]: raise NotImplementedError() @property def list_trials( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.ListTrialsRequest], - typing.Union[ + Union[ vizier_service.ListTrialsResponse, - typing.Awaitable[vizier_service.ListTrialsResponse], + Awaitable[vizier_service.ListTrialsResponse], ], ]: raise NotImplementedError() @@ -257,56 +313,55 @@ def list_trials( @property def add_trial_measurement( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.AddTrialMeasurementRequest], - typing.Union[study.Trial, typing.Awaitable[study.Trial]], + Union[study.Trial, Awaitable[study.Trial]], ]: raise NotImplementedError() @property def complete_trial( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.CompleteTrialRequest], - typing.Union[study.Trial, typing.Awaitable[study.Trial]], + Union[study.Trial, Awaitable[study.Trial]], ]: raise NotImplementedError() @property def delete_trial( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.DeleteTrialRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def check_trial_early_stopping_state( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.CheckTrialEarlyStoppingStateRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def stop_trial( self, - ) -> typing.Callable[ - [vizier_service.StopTrialRequest], - typing.Union[study.Trial, typing.Awaitable[study.Trial]], + ) -> Callable[ + [vizier_service.StopTrialRequest], Union[study.Trial, Awaitable[study.Trial]] ]: raise NotImplementedError() @property def list_optimal_trials( self, - ) -> typing.Callable[ + ) -> Callable[ [vizier_service.ListOptimalTrialsRequest], - typing.Union[ + Union[ vizier_service.ListOptimalTrialsResponse, - typing.Awaitable[vizier_service.ListOptimalTrialsResponse], + Awaitable[vizier_service.ListOptimalTrialsResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py index 2e569f1248..48aac6a6c1 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import operations_v1 # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore @@ -30,9 +28,8 @@ from google.cloud.aiplatform_v1beta1.types import study from google.cloud.aiplatform_v1beta1.types import study as gca_study from google.cloud.aiplatform_v1beta1.types import vizier_service -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import VizierServiceTransport, DEFAULT_CLIENT_INFO @@ -58,7 +55,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -72,7 +69,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -183,7 +181,7 @@ def __init__( def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -214,13 +212,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -327,7 +327,7 @@ def list_studies( @property def delete_study( self, - ) -> Callable[[vizier_service.DeleteStudyRequest], empty.Empty]: + ) -> Callable[[vizier_service.DeleteStudyRequest], empty_pb2.Empty]: r"""Return a callable for the delete study method over gRPC. Deletes a Study. @@ -346,7 +346,7 @@ def delete_study( self._stubs["delete_study"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/DeleteStudy", request_serializer=vizier_service.DeleteStudyRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_study"] @@ -380,7 +380,7 @@ def lookup_study( @property def suggest_trials( self, - ) -> Callable[[vizier_service.SuggestTrialsRequest], operations.Operation]: + ) -> Callable[[vizier_service.SuggestTrialsRequest], operations_pb2.Operation]: r"""Return a callable for the suggest trials method over gRPC. Adds one or more Trials to a Study, with parameter values @@ -403,7 +403,7 @@ def suggest_trials( self._stubs["suggest_trials"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/SuggestTrials", request_serializer=vizier_service.SuggestTrialsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["suggest_trials"] @@ -542,7 +542,7 @@ def complete_trial( @property def delete_trial( self, - ) -> Callable[[vizier_service.DeleteTrialRequest], empty.Empty]: + ) -> Callable[[vizier_service.DeleteTrialRequest], empty_pb2.Empty]: r"""Return a callable for the delete trial method over gRPC. Deletes a Trial. @@ -561,7 +561,7 @@ def delete_trial( self._stubs["delete_trial"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/DeleteTrial", request_serializer=vizier_service.DeleteTrialRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_trial"] @@ -569,7 +569,7 @@ def delete_trial( def check_trial_early_stopping_state( self, ) -> Callable[ - [vizier_service.CheckTrialEarlyStoppingStateRequest], operations.Operation + [vizier_service.CheckTrialEarlyStoppingStateRequest], operations_pb2.Operation ]: r"""Return a callable for the check trial early stopping state method over gRPC. @@ -595,7 +595,7 @@ def check_trial_early_stopping_state( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/CheckTrialEarlyStoppingState", request_serializer=vizier_service.CheckTrialEarlyStoppingStateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["check_trial_early_stopping_state"] diff --git a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py index 64bcc08c34..f26ef1a02c 100644 --- a/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py +++ b/google/cloud/aiplatform_v1beta1/services/vizier_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore from google.api_core import operations_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -31,9 +29,8 @@ from google.cloud.aiplatform_v1beta1.types import study from google.cloud.aiplatform_v1beta1.types import study as gca_study from google.cloud.aiplatform_v1beta1.types import vizier_service -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import VizierServiceTransport, DEFAULT_CLIENT_INFO from .grpc import VizierServiceGrpcTransport @@ -61,7 +58,7 @@ class VizierServiceGrpcAsyncIOTransport(VizierServiceTransport): def create_channel( cls, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -88,13 +85,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -102,7 +101,7 @@ def __init__( self, *, host: str = "aiplatform.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -116,7 +115,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -175,7 +175,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -336,7 +335,7 @@ def list_studies( @property def delete_study( self, - ) -> Callable[[vizier_service.DeleteStudyRequest], Awaitable[empty.Empty]]: + ) -> Callable[[vizier_service.DeleteStudyRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete study method over gRPC. Deletes a Study. @@ -355,7 +354,7 @@ def delete_study( self._stubs["delete_study"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/DeleteStudy", request_serializer=vizier_service.DeleteStudyRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_study"] @@ -390,7 +389,7 @@ def lookup_study( def suggest_trials( self, ) -> Callable[ - [vizier_service.SuggestTrialsRequest], Awaitable[operations.Operation] + [vizier_service.SuggestTrialsRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the suggest trials method over gRPC. @@ -414,7 +413,7 @@ def suggest_trials( self._stubs["suggest_trials"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/SuggestTrials", request_serializer=vizier_service.SuggestTrialsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["suggest_trials"] @@ -555,7 +554,7 @@ def complete_trial( @property def delete_trial( self, - ) -> Callable[[vizier_service.DeleteTrialRequest], Awaitable[empty.Empty]]: + ) -> Callable[[vizier_service.DeleteTrialRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete trial method over gRPC. Deletes a Trial. @@ -574,7 +573,7 @@ def delete_trial( self._stubs["delete_trial"] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/DeleteTrial", request_serializer=vizier_service.DeleteTrialRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_trial"] @@ -583,7 +582,7 @@ def check_trial_early_stopping_state( self, ) -> Callable[ [vizier_service.CheckTrialEarlyStoppingStateRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the check trial early stopping state method over gRPC. @@ -609,7 +608,7 @@ def check_trial_early_stopping_state( ] = self.grpc_channel.unary_unary( "/google.cloud.aiplatform.v1beta1.VizierService/CheckTrialEarlyStoppingState", request_serializer=vizier_service.CheckTrialEarlyStoppingStateRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["check_trial_early_stopping_state"] diff --git a/google/cloud/aiplatform_v1beta1/types/__init__.py b/google/cloud/aiplatform_v1beta1/types/__init__.py index 0b02ac1777..7b54b4f06d 100644 --- a/google/cloud/aiplatform_v1beta1/types/__init__.py +++ b/google/cloud/aiplatform_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .annotation import Annotation from .annotation_spec import AnnotationSpec from .artifact import Artifact diff --git a/google/cloud/aiplatform_v1beta1/types/accelerator_type.py b/google/cloud/aiplatform_v1beta1/types/accelerator_type.py index 8c6968952c..6fb2d8899d 100644 --- a/google/cloud/aiplatform_v1beta1/types/accelerator_type.py +++ b/google/cloud/aiplatform_v1beta1/types/accelerator_type.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -31,6 +29,7 @@ class AcceleratorType(proto.Enum): NVIDIA_TESLA_V100 = 3 NVIDIA_TESLA_P4 = 4 NVIDIA_TESLA_T4 = 5 + NVIDIA_TESLA_A100 = 8 __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/annotation.py b/google/cloud/aiplatform_v1beta1/types/annotation.py index 3af3aa73eb..07c5769df3 100644 --- a/google/cloud/aiplatform_v1beta1/types/annotation.py +++ b/google/cloud/aiplatform_v1beta1/types/annotation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import user_action_reference -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -87,23 +84,16 @@ class Annotation(proto.Message): title. """ - name = proto.Field(proto.STRING, number=1) - - payload_schema_uri = proto.Field(proto.STRING, number=2) - - payload = proto.Field(proto.MESSAGE, number=3, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=8) - + name = proto.Field(proto.STRING, number=1,) + payload_schema_uri = proto.Field(proto.STRING, number=2,) + payload = proto.Field(proto.MESSAGE, number=3, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=8,) annotation_source = proto.Field( proto.MESSAGE, number=5, message=user_action_reference.UserActionReference, ) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/annotation_spec.py b/google/cloud/aiplatform_v1beta1/types/annotation_spec.py index e921e25971..9cd90b4dc1 100644 --- a/google/cloud/aiplatform_v1beta1/types/annotation_spec.py +++ b/google/cloud/aiplatform_v1beta1/types/annotation_spec.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -51,15 +48,11 @@ class AnnotationSpec(proto.Message): "overwrite" update happens. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=5) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/artifact.py b/google/cloud/aiplatform_v1beta1/types/artifact.py index 1246ac443b..88914edc58 100644 --- a/google/cloud/aiplatform_v1beta1/types/artifact.py +++ b/google/cloud/aiplatform_v1beta1/types/artifact.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -29,7 +26,6 @@ class Artifact(proto.Message): r"""Instance of a general artifact. - Attributes: name (str): Output only. The resource name of the @@ -95,29 +91,22 @@ class State(proto.Enum): PENDING = 1 LIVE = 2 - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - uri = proto.Field(proto.STRING, number=6) - - etag = proto.Field(proto.STRING, number=9) - - labels = proto.MapField(proto.STRING, proto.STRING, number=10) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + uri = proto.Field(proto.STRING, number=6,) + etag = proto.Field(proto.STRING, number=9,) + labels = proto.MapField(proto.STRING, proto.STRING, number=10,) + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) state = proto.Field(proto.ENUM, number=13, enum=State,) - - schema_title = proto.Field(proto.STRING, number=14) - - schema_version = proto.Field(proto.STRING, number=15) - - metadata = proto.Field(proto.MESSAGE, number=16, message=struct.Struct,) - - description = proto.Field(proto.STRING, number=17) + schema_title = proto.Field(proto.STRING, number=14,) + schema_version = proto.Field(proto.STRING, number=15,) + metadata = proto.Field(proto.MESSAGE, number=16, message=struct_pb2.Struct,) + description = proto.Field(proto.STRING, number=17,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py b/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py index 8d85090929..1e0d364c4f 100644 --- a/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py +++ b/google/cloud/aiplatform_v1beta1/types/batch_prediction_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import ( completion_stats as gca_completion_stats, ) @@ -29,9 +26,9 @@ from google.cloud.aiplatform_v1beta1.types import ( manual_batch_tuning_parameters as gca_manual_batch_tuning_parameters, ) -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -221,12 +218,10 @@ class InputConfig(proto.Message): gcs_source = proto.Field( proto.MESSAGE, number=2, oneof="source", message=io.GcsSource, ) - bigquery_source = proto.Field( proto.MESSAGE, number=3, oneof="source", message=io.BigQuerySource, ) - - instances_format = proto.Field(proto.STRING, number=1) + instances_format = proto.Field(proto.STRING, number=1,) class OutputConfig(proto.Message): r"""Configures the output of @@ -296,15 +291,13 @@ class OutputConfig(proto.Message): gcs_destination = proto.Field( proto.MESSAGE, number=2, oneof="destination", message=io.GcsDestination, ) - bigquery_destination = proto.Field( proto.MESSAGE, number=3, oneof="destination", message=io.BigQueryDestination, ) - - predictions_format = proto.Field(proto.STRING, number=1) + predictions_format = proto.Field(proto.STRING, number=1,) class OutputInfo(proto.Message): r"""Further describes this job's output. Supplements @@ -322,69 +315,51 @@ class OutputInfo(proto.Message): """ gcs_output_directory = proto.Field( - proto.STRING, number=1, oneof="output_location" + proto.STRING, number=1, oneof="output_location", ) - bigquery_output_dataset = proto.Field( - proto.STRING, number=2, oneof="output_location" + proto.STRING, number=2, oneof="output_location", ) - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - model = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + model = proto.Field(proto.STRING, number=3,) input_config = proto.Field(proto.MESSAGE, number=4, message=InputConfig,) - - model_parameters = proto.Field(proto.MESSAGE, number=5, message=struct.Value,) - + model_parameters = proto.Field(proto.MESSAGE, number=5, message=struct_pb2.Value,) output_config = proto.Field(proto.MESSAGE, number=6, message=OutputConfig,) - dedicated_resources = proto.Field( proto.MESSAGE, number=7, message=machine_resources.BatchDedicatedResources, ) - manual_batch_tuning_parameters = proto.Field( proto.MESSAGE, number=8, message=gca_manual_batch_tuning_parameters.ManualBatchTuningParameters, ) - - generate_explanation = proto.Field(proto.BOOL, number=23) - + generate_explanation = proto.Field(proto.BOOL, number=23,) explanation_spec = proto.Field( proto.MESSAGE, number=25, message=explanation.ExplanationSpec, ) - output_info = proto.Field(proto.MESSAGE, number=9, message=OutputInfo,) - state = proto.Field(proto.ENUM, number=10, enum=job_state.JobState,) - - error = proto.Field(proto.MESSAGE, number=11, message=status.Status,) - + error = proto.Field(proto.MESSAGE, number=11, message=status_pb2.Status,) partial_failures = proto.RepeatedField( - proto.MESSAGE, number=12, message=status.Status, + proto.MESSAGE, number=12, message=status_pb2.Status, ) - resources_consumed = proto.Field( proto.MESSAGE, number=13, message=machine_resources.ResourcesConsumed, ) - completion_stats = proto.Field( proto.MESSAGE, number=14, message=gca_completion_stats.CompletionStats, ) - - create_time = proto.Field(proto.MESSAGE, number=15, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=16, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=17, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=18, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=19) - + create_time = proto.Field( + proto.MESSAGE, number=15, message=timestamp_pb2.Timestamp, + ) + start_time = proto.Field(proto.MESSAGE, number=16, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=17, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=18, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=19,) encryption_spec = proto.Field( proto.MESSAGE, number=24, message=gca_encryption_spec.EncryptionSpec, ) diff --git a/google/cloud/aiplatform_v1beta1/types/completion_stats.py b/google/cloud/aiplatform_v1beta1/types/completion_stats.py index 165be59634..9cee99a5a8 100644 --- a/google/cloud/aiplatform_v1beta1/types/completion_stats.py +++ b/google/cloud/aiplatform_v1beta1/types/completion_stats.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -45,11 +43,9 @@ class CompletionStats(proto.Message): number could be collected). """ - successful_count = proto.Field(proto.INT64, number=1) - - failed_count = proto.Field(proto.INT64, number=2) - - incomplete_count = proto.Field(proto.INT64, number=3) + successful_count = proto.Field(proto.INT64, number=1,) + failed_count = proto.Field(proto.INT64, number=2,) + incomplete_count = proto.Field(proto.INT64, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/context.py b/google/cloud/aiplatform_v1beta1/types/context.py index 5adaf07f3c..412b6b462a 100644 --- a/google/cloud/aiplatform_v1beta1/types/context.py +++ b/google/cloud/aiplatform_v1beta1/types/context.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -29,7 +26,6 @@ class Context(proto.Message): r"""Instance of a general context. - Attributes: name (str): Output only. The resource name of the @@ -82,27 +78,21 @@ class Context(proto.Message): Description of the Context """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - etag = proto.Field(proto.STRING, number=8) - - labels = proto.MapField(proto.STRING, proto.STRING, number=9) - - create_time = proto.Field(proto.MESSAGE, number=10, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - parent_contexts = proto.RepeatedField(proto.STRING, number=12) - - schema_title = proto.Field(proto.STRING, number=13) - - schema_version = proto.Field(proto.STRING, number=14) - - metadata = proto.Field(proto.MESSAGE, number=15, message=struct.Struct,) - - description = proto.Field(proto.STRING, number=16) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + etag = proto.Field(proto.STRING, number=8,) + labels = proto.MapField(proto.STRING, proto.STRING, number=9,) + create_time = proto.Field( + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + parent_contexts = proto.RepeatedField(proto.STRING, number=12,) + schema_title = proto.Field(proto.STRING, number=13,) + schema_version = proto.Field(proto.STRING, number=14,) + metadata = proto.Field(proto.MESSAGE, number=15, message=struct_pb2.Struct,) + description = proto.Field(proto.STRING, number=16,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/custom_job.py b/google/cloud/aiplatform_v1beta1/types/custom_job.py index aa7fe5aa77..3900a6bd26 100644 --- a/google/cloud/aiplatform_v1beta1/types/custom_job.py +++ b/google/cloud/aiplatform_v1beta1/types/custom_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import io from google.cloud.aiplatform_v1beta1.types import job_state from google.cloud.aiplatform_v1beta1.types import machine_resources -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -91,26 +88,16 @@ class CustomJob(proto.Message): the provided encryption key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) job_spec = proto.Field(proto.MESSAGE, number=4, message="CustomJobSpec",) - state = proto.Field(proto.ENUM, number=5, enum=job_state.JobState,) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - - error = proto.Field(proto.MESSAGE, number=10, message=status.Status,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=11) - + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) + error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) + labels = proto.MapField(proto.STRING, proto.STRING, number=11,) encryption_spec = proto.Field( proto.MESSAGE, number=12, message=gca_encryption_spec.EncryptionSpec, ) @@ -118,7 +105,6 @@ class CustomJob(proto.Message): class CustomJobSpec(proto.Message): r"""Represents the spec of a CustomJob. - Attributes: worker_pool_specs (Sequence[google.cloud.aiplatform_v1beta1.types.WorkerPoolSpec]): Required. The spec of the worker pools @@ -186,23 +172,17 @@ class CustomJobSpec(proto.Message): worker_pool_specs = proto.RepeatedField( proto.MESSAGE, number=1, message="WorkerPoolSpec", ) - scheduling = proto.Field(proto.MESSAGE, number=3, message="Scheduling",) - - service_account = proto.Field(proto.STRING, number=4) - - network = proto.Field(proto.STRING, number=5) - + service_account = proto.Field(proto.STRING, number=4,) + network = proto.Field(proto.STRING, number=5,) base_output_directory = proto.Field( proto.MESSAGE, number=6, message=io.GcsDestination, ) - - tensorboard = proto.Field(proto.STRING, number=7) + tensorboard = proto.Field(proto.STRING, number=7,) class WorkerPoolSpec(proto.Message): r"""Represents the spec of a worker pool in a job. - Attributes: container_spec (google.cloud.aiplatform_v1beta1.types.ContainerSpec): The custom container task. @@ -221,17 +201,13 @@ class WorkerPoolSpec(proto.Message): container_spec = proto.Field( proto.MESSAGE, number=6, oneof="task", message="ContainerSpec", ) - python_package_spec = proto.Field( proto.MESSAGE, number=7, oneof="task", message="PythonPackageSpec", ) - machine_spec = proto.Field( proto.MESSAGE, number=1, message=machine_resources.MachineSpec, ) - - replica_count = proto.Field(proto.INT64, number=2) - + replica_count = proto.Field(proto.INT64, number=2,) disk_spec = proto.Field( proto.MESSAGE, number=5, message=machine_resources.DiskSpec, ) @@ -239,7 +215,6 @@ class WorkerPoolSpec(proto.Message): class ContainerSpec(proto.Message): r"""The spec of a Container. - Attributes: image_uri (str): Required. The URI of a container image in the @@ -254,16 +229,13 @@ class ContainerSpec(proto.Message): container. """ - image_uri = proto.Field(proto.STRING, number=1) - - command = proto.RepeatedField(proto.STRING, number=2) - - args = proto.RepeatedField(proto.STRING, number=3) + image_uri = proto.Field(proto.STRING, number=1,) + command = proto.RepeatedField(proto.STRING, number=2,) + args = proto.RepeatedField(proto.STRING, number=3,) class PythonPackageSpec(proto.Message): r"""The spec of a Python packaged code. - Attributes: executor_image_uri (str): Required. The URI of a container image in Artifact Registry @@ -286,13 +258,10 @@ class PythonPackageSpec(proto.Message): Python task. """ - executor_image_uri = proto.Field(proto.STRING, number=1) - - package_uris = proto.RepeatedField(proto.STRING, number=2) - - python_module = proto.Field(proto.STRING, number=3) - - args = proto.RepeatedField(proto.STRING, number=4) + executor_image_uri = proto.Field(proto.STRING, number=1,) + package_uris = proto.RepeatedField(proto.STRING, number=2,) + python_module = proto.Field(proto.STRING, number=3,) + args = proto.RepeatedField(proto.STRING, number=4,) class Scheduling(proto.Message): @@ -310,9 +279,8 @@ class Scheduling(proto.Message): to workers leaving and joining a job. """ - timeout = proto.Field(proto.MESSAGE, number=1, message=duration.Duration,) - - restart_job_on_worker_restart = proto.Field(proto.BOOL, number=3) + timeout = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + restart_job_on_worker_restart = proto.Field(proto.BOOL, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/data_item.py b/google/cloud/aiplatform_v1beta1/types/data_item.py index a12776f06c..8d43b2b478 100644 --- a/google/cloud/aiplatform_v1beta1/types/data_item.py +++ b/google/cloud/aiplatform_v1beta1/types/data_item.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -68,17 +65,12 @@ class DataItem(proto.Message): "overwrite" update happens. """ - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=3) - - payload = proto.Field(proto.MESSAGE, number=4, message=struct.Value,) - - etag = proto.Field(proto.STRING, number=7) + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=3,) + payload = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Value,) + etag = proto.Field(proto.STRING, number=7,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/data_labeling_job.py b/google/cloud/aiplatform_v1beta1/types/data_labeling_job.py index 08b63ca73e..1e541afe71 100644 --- a/google/cloud/aiplatform_v1beta1/types/data_labeling_job.py +++ b/google/cloud/aiplatform_v1beta1/types/data_labeling_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import job_state -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore __protobuf__ = proto.module( @@ -140,42 +137,27 @@ class DataLabelingJob(proto.Message): on the sampling strategy. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - datasets = proto.RepeatedField(proto.STRING, number=3) - - annotation_labels = proto.MapField(proto.STRING, proto.STRING, number=12) - - labeler_count = proto.Field(proto.INT32, number=4) - - instruction_uri = proto.Field(proto.STRING, number=5) - - inputs_schema_uri = proto.Field(proto.STRING, number=6) - - inputs = proto.Field(proto.MESSAGE, number=7, message=struct.Value,) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + datasets = proto.RepeatedField(proto.STRING, number=3,) + annotation_labels = proto.MapField(proto.STRING, proto.STRING, number=12,) + labeler_count = proto.Field(proto.INT32, number=4,) + instruction_uri = proto.Field(proto.STRING, number=5,) + inputs_schema_uri = proto.Field(proto.STRING, number=6,) + inputs = proto.Field(proto.MESSAGE, number=7, message=struct_pb2.Value,) state = proto.Field(proto.ENUM, number=8, enum=job_state.JobState,) - - labeling_progress = proto.Field(proto.INT32, number=13) - - current_spend = proto.Field(proto.MESSAGE, number=14, message=money.Money,) - - create_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=10, message=timestamp.Timestamp,) - - error = proto.Field(proto.MESSAGE, number=22, message=status.Status,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=11) - - specialist_pools = proto.RepeatedField(proto.STRING, number=16) - + labeling_progress = proto.Field(proto.INT32, number=13,) + current_spend = proto.Field(proto.MESSAGE, number=14, message=money_pb2.Money,) + create_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, + ) + error = proto.Field(proto.MESSAGE, number=22, message=status_pb2.Status,) + labels = proto.MapField(proto.STRING, proto.STRING, number=11,) + specialist_pools = proto.RepeatedField(proto.STRING, number=16,) encryption_spec = proto.Field( proto.MESSAGE, number=20, message=gca_encryption_spec.EncryptionSpec, ) - active_learning_config = proto.Field( proto.MESSAGE, number=21, message="ActiveLearningConfig", ) @@ -207,15 +189,12 @@ class ActiveLearningConfig(proto.Message): """ max_data_item_count = proto.Field( - proto.INT64, number=1, oneof="human_labeling_budget" + proto.INT64, number=1, oneof="human_labeling_budget", ) - max_data_item_percentage = proto.Field( - proto.INT32, number=2, oneof="human_labeling_budget" + proto.INT32, number=2, oneof="human_labeling_budget", ) - sample_config = proto.Field(proto.MESSAGE, number=3, message="SampleConfig",) - training_config = proto.Field(proto.MESSAGE, number=4, message="TrainingConfig",) @@ -246,13 +225,11 @@ class SampleStrategy(proto.Enum): UNCERTAINTY = 1 initial_batch_sample_percentage = proto.Field( - proto.INT32, number=1, oneof="initial_batch_sample_size" + proto.INT32, number=1, oneof="initial_batch_sample_size", ) - following_batch_sample_percentage = proto.Field( - proto.INT32, number=3, oneof="following_batch_sample_size" + proto.INT32, number=3, oneof="following_batch_sample_size", ) - sample_strategy = proto.Field(proto.ENUM, number=5, enum=SampleStrategy,) @@ -269,7 +246,7 @@ class TrainingConfig(proto.Message): this field means 1 hour. """ - timeout_training_milli_hours = proto.Field(proto.INT64, number=1) + timeout_training_milli_hours = proto.Field(proto.INT64, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/dataset.py b/google/cloud/aiplatform_v1beta1/types/dataset.py index 492889a6f5..1d659c3bd0 100644 --- a/google/cloud/aiplatform_v1beta1/types/dataset.py +++ b/google/cloud/aiplatform_v1beta1/types/dataset.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,14 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import io -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -32,7 +29,6 @@ class Dataset(proto.Message): r"""A collection of DataItems and Annotations on them. - Attributes: name (str): Output only. The resource name of the @@ -88,22 +84,14 @@ class Dataset(proto.Message): this key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - metadata_schema_uri = proto.Field(proto.STRING, number=3) - - metadata = proto.Field(proto.MESSAGE, number=8, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=6) - - labels = proto.MapField(proto.STRING, proto.STRING, number=7) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + metadata_schema_uri = proto.Field(proto.STRING, number=3,) + metadata = proto.Field(proto.MESSAGE, number=8, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=6,) + labels = proto.MapField(proto.STRING, proto.STRING, number=7,) encryption_spec = proto.Field( proto.MESSAGE, number=11, message=gca_encryption_spec.EncryptionSpec, ) @@ -144,10 +132,8 @@ class ImportDataConfig(proto.Message): gcs_source = proto.Field( proto.MESSAGE, number=1, oneof="source", message=io.GcsSource, ) - - data_item_labels = proto.MapField(proto.STRING, proto.STRING, number=2) - - import_schema_uri = proto.Field(proto.STRING, number=4) + data_item_labels = proto.MapField(proto.STRING, proto.STRING, number=2,) + import_schema_uri = proto.Field(proto.STRING, number=4,) class ExportDataConfig(proto.Message): @@ -178,8 +164,7 @@ class ExportDataConfig(proto.Message): gcs_destination = proto.Field( proto.MESSAGE, number=1, oneof="destination", message=io.GcsDestination, ) - - annotations_filter = proto.Field(proto.STRING, number=2) + annotations_filter = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/dataset_service.py b/google/cloud/aiplatform_v1beta1/types/dataset_service.py index 8a068a2911..b1458c7a78 100644 --- a/google/cloud/aiplatform_v1beta1/types/dataset_service.py +++ b/google/cloud/aiplatform_v1beta1/types/dataset_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import annotation from google.cloud.aiplatform_v1beta1.types import data_item from google.cloud.aiplatform_v1beta1.types import dataset as gca_dataset from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -63,8 +60,7 @@ class CreateDatasetRequest(proto.Message): Required. The Dataset to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) dataset = proto.Field(proto.MESSAGE, number=2, message=gca_dataset.Dataset,) @@ -93,9 +89,8 @@ class GetDatasetRequest(proto.Message): Mask specifying which fields to read. """ - name = proto.Field(proto.STRING, number=1) - - read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + name = proto.Field(proto.STRING, number=1,) + read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) class UpdateDatasetRequest(proto.Message): @@ -118,8 +113,9 @@ class UpdateDatasetRequest(proto.Message): """ dataset = proto.Field(proto.MESSAGE, number=1, message=gca_dataset.Dataset,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class ListDatasetsRequest(proto.Message): @@ -163,17 +159,12 @@ class ListDatasetsRequest(proto.Message): - ``update_time`` """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListDatasetsResponse(proto.Message): @@ -195,8 +186,7 @@ def raw_page(self): datasets = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_dataset.Dataset, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteDatasetRequest(proto.Message): @@ -210,7 +200,7 @@ class DeleteDatasetRequest(proto.Message): ``projects/{project}/locations/{location}/datasets/{dataset}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ImportDataRequest(proto.Message): @@ -227,8 +217,7 @@ class ImportDataRequest(proto.Message): in one batch. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) import_configs = proto.RepeatedField( proto.MESSAGE, number=2, message=gca_dataset.ImportDataConfig, ) @@ -237,7 +226,7 @@ class ImportDataRequest(proto.Message): class ImportDataResponse(proto.Message): r"""Response message for [DatasetService.ImportData][google.cloud.aiplatform.v1beta1.DatasetService.ImportData]. - """ + """ class ImportDataOperationMetadata(proto.Message): @@ -266,8 +255,7 @@ class ExportDataRequest(proto.Message): Required. The desired output location. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) export_config = proto.Field( proto.MESSAGE, number=2, message=gca_dataset.ExportDataConfig, ) @@ -283,7 +271,7 @@ class ExportDataResponse(proto.Message): export operation. """ - exported_files = proto.RepeatedField(proto.STRING, number=1) + exported_files = proto.RepeatedField(proto.STRING, number=1,) class ExportDataOperationMetadata(proto.Message): @@ -302,8 +290,7 @@ class ExportDataOperationMetadata(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - - gcs_output_directory = proto.Field(proto.STRING, number=2) + gcs_output_directory = proto.Field(proto.STRING, number=2,) class ListDataItemsRequest(proto.Message): @@ -329,17 +316,12 @@ class ListDataItemsRequest(proto.Message): field name for descending. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListDataItemsResponse(proto.Message): @@ -361,8 +343,7 @@ def raw_page(self): data_items = proto.RepeatedField( proto.MESSAGE, number=1, message=data_item.DataItem, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetAnnotationSpecRequest(proto.Message): @@ -377,9 +358,8 @@ class GetAnnotationSpecRequest(proto.Message): Mask specifying which fields to read. """ - name = proto.Field(proto.STRING, number=1) - - read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + name = proto.Field(proto.STRING, number=1,) + read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) class ListAnnotationsRequest(proto.Message): @@ -405,17 +385,12 @@ class ListAnnotationsRequest(proto.Message): field name for descending. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListAnnotationsResponse(proto.Message): @@ -437,8 +412,7 @@ def raw_page(self): annotations = proto.RepeatedField( proto.MESSAGE, number=1, message=annotation.Annotation, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/deployed_index_ref.py b/google/cloud/aiplatform_v1beta1/types/deployed_index_ref.py index e6881865ca..aa7f6edb67 100644 --- a/google/cloud/aiplatform_v1beta1/types/deployed_index_ref.py +++ b/google/cloud/aiplatform_v1beta1/types/deployed_index_ref.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -25,7 +23,6 @@ class DeployedIndexRef(proto.Message): r"""Points to a DeployedIndex. - Attributes: index_endpoint (str): Immutable. A resource name of the @@ -35,9 +32,8 @@ class DeployedIndexRef(proto.Message): above IndexEndpoint. """ - index_endpoint = proto.Field(proto.STRING, number=1) - - deployed_index_id = proto.Field(proto.STRING, number=2) + index_endpoint = proto.Field(proto.STRING, number=1,) + deployed_index_id = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/deployed_model_ref.py b/google/cloud/aiplatform_v1beta1/types/deployed_model_ref.py index b0ec7010a2..da7e8bf211 100644 --- a/google/cloud/aiplatform_v1beta1/types/deployed_model_ref.py +++ b/google/cloud/aiplatform_v1beta1/types/deployed_model_ref.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -25,7 +23,6 @@ class DeployedModelRef(proto.Message): r"""Points to a DeployedModel. - Attributes: endpoint (str): Immutable. A resource name of an Endpoint. @@ -34,9 +31,8 @@ class DeployedModelRef(proto.Message): above Endpoint. """ - endpoint = proto.Field(proto.STRING, number=1) - - deployed_model_id = proto.Field(proto.STRING, number=2) + endpoint = proto.Field(proto.STRING, number=1,) + deployed_model_id = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/encryption_spec.py b/google/cloud/aiplatform_v1beta1/types/encryption_spec.py index 0d41d39a0b..afe91ca5ac 100644 --- a/google/cloud/aiplatform_v1beta1/types/encryption_spec.py +++ b/google/cloud/aiplatform_v1beta1/types/encryption_spec.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -37,7 +35,7 @@ class EncryptionSpec(proto.Message): resource is created. """ - kms_key_name = proto.Field(proto.STRING, number=1) + kms_key_name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/endpoint.py b/google/cloud/aiplatform_v1beta1/types/endpoint.py index fb8b12af12..7b35657bcc 100644 --- a/google/cloud/aiplatform_v1beta1/types/endpoint.py +++ b/google/cloud/aiplatform_v1beta1/types/endpoint.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,14 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import explanation from google.cloud.aiplatform_v1beta1.types import machine_resources -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -87,26 +84,17 @@ class Endpoint(proto.Message): this key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) deployed_models = proto.RepeatedField( proto.MESSAGE, number=4, message="DeployedModel", ) - - traffic_split = proto.MapField(proto.STRING, proto.INT32, number=5) - - etag = proto.Field(proto.STRING, number=6) - - labels = proto.MapField(proto.STRING, proto.STRING, number=7) - - create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp.Timestamp,) - + traffic_split = proto.MapField(proto.STRING, proto.INT32, number=5,) + etag = proto.Field(proto.STRING, number=6,) + labels = proto.MapField(proto.STRING, proto.STRING, number=7,) + create_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=9, message=timestamp_pb2.Timestamp,) encryption_spec = proto.Field( proto.MESSAGE, number=10, message=gca_encryption_spec.EncryptionSpec, ) @@ -190,31 +178,22 @@ class DeployedModel(proto.Message): oneof="prediction_resources", message=machine_resources.DedicatedResources, ) - automatic_resources = proto.Field( proto.MESSAGE, number=8, oneof="prediction_resources", message=machine_resources.AutomaticResources, ) - - id = proto.Field(proto.STRING, number=1) - - model = proto.Field(proto.STRING, number=2) - - display_name = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - + id = proto.Field(proto.STRING, number=1,) + model = proto.Field(proto.STRING, number=2,) + display_name = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) explanation_spec = proto.Field( proto.MESSAGE, number=9, message=explanation.ExplanationSpec, ) - - service_account = proto.Field(proto.STRING, number=11) - - enable_container_logging = proto.Field(proto.BOOL, number=12) - - enable_access_logging = proto.Field(proto.BOOL, number=13) + service_account = proto.Field(proto.STRING, number=11,) + enable_container_logging = proto.Field(proto.BOOL, number=12,) + enable_access_logging = proto.Field(proto.BOOL, number=13,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/endpoint_service.py b/google/cloud/aiplatform_v1beta1/types/endpoint_service.py index a67bbafd7c..943c05c6e8 100644 --- a/google/cloud/aiplatform_v1beta1/types/endpoint_service.py +++ b/google/cloud/aiplatform_v1beta1/types/endpoint_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import endpoint as gca_endpoint from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -56,8 +53,7 @@ class CreateEndpointRequest(proto.Message): Required. The Endpoint to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) endpoint = proto.Field(proto.MESSAGE, number=2, message=gca_endpoint.Endpoint,) @@ -85,7 +81,7 @@ class GetEndpointRequest(proto.Message): ``projects/{project}/locations/{location}/endpoints/{endpoint}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListEndpointsRequest(proto.Message): @@ -133,15 +129,11 @@ class ListEndpointsRequest(proto.Message): read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListEndpointsResponse(proto.Message): @@ -164,8 +156,7 @@ def raw_page(self): endpoints = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_endpoint.Endpoint, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateEndpointRequest(proto.Message): @@ -182,8 +173,9 @@ class UpdateEndpointRequest(proto.Message): """ endpoint = proto.Field(proto.MESSAGE, number=1, message=gca_endpoint.Endpoint,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteEndpointRequest(proto.Message): @@ -197,7 +189,7 @@ class DeleteEndpointRequest(proto.Message): ``projects/{project}/locations/{location}/endpoints/{endpoint}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeployModelRequest(proto.Message): @@ -234,13 +226,11 @@ class DeployModelRequest(proto.Message): is not updated. """ - endpoint = proto.Field(proto.STRING, number=1) - + endpoint = proto.Field(proto.STRING, number=1,) deployed_model = proto.Field( proto.MESSAGE, number=2, message=gca_endpoint.DeployedModel, ) - - traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3) + traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3,) class DeployModelResponse(proto.Message): @@ -295,17 +285,15 @@ class UndeployModelRequest(proto.Message): executes, or if this field unassigns any traffic to it. """ - endpoint = proto.Field(proto.STRING, number=1) - - deployed_model_id = proto.Field(proto.STRING, number=2) - - traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3) + endpoint = proto.Field(proto.STRING, number=1,) + deployed_model_id = proto.Field(proto.STRING, number=2,) + traffic_split = proto.MapField(proto.STRING, proto.INT32, number=3,) class UndeployModelResponse(proto.Message): r"""Response message for [EndpointService.UndeployModel][google.cloud.aiplatform.v1beta1.EndpointService.UndeployModel]. - """ + """ class UndeployModelOperationMetadata(proto.Message): diff --git a/google/cloud/aiplatform_v1beta1/types/entity_type.py b/google/cloud/aiplatform_v1beta1/types/entity_type.py index c1e599c569..2900f05fae 100644 --- a/google/cloud/aiplatform_v1beta1/types/entity_type.py +++ b/google/cloud/aiplatform_v1beta1/types/entity_type.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import featurestore_monitoring -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -79,18 +76,12 @@ class EntityType(proto.Message): Otherwise, snapshot analysis monitoring is disabled. """ - name = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) - - etag = proto.Field(proto.STRING, number=7) - + name = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) + etag = proto.Field(proto.STRING, number=7,) monitoring_config = proto.Field( proto.MESSAGE, number=8, diff --git a/google/cloud/aiplatform_v1beta1/types/env_var.py b/google/cloud/aiplatform_v1beta1/types/env_var.py index 0d2c3769ff..ae40154685 100644 --- a/google/cloud/aiplatform_v1beta1/types/env_var.py +++ b/google/cloud/aiplatform_v1beta1/types/env_var.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -42,9 +40,8 @@ class EnvVar(proto.Message): variable exists or not. """ - name = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/event.py b/google/cloud/aiplatform_v1beta1/types/event.py index 52bf55e074..fc48ff6710 100644 --- a/google/cloud/aiplatform_v1beta1/types/event.py +++ b/google/cloud/aiplatform_v1beta1/types/event.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -66,15 +63,11 @@ class Type(proto.Enum): INPUT = 1 OUTPUT = 2 - artifact = proto.Field(proto.STRING, number=1) - - execution = proto.Field(proto.STRING, number=2) - - event_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - + artifact = proto.Field(proto.STRING, number=1,) + execution = proto.Field(proto.STRING, number=2,) + event_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) type_ = proto.Field(proto.ENUM, number=4, enum=Type,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=5) + labels = proto.MapField(proto.STRING, proto.STRING, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/execution.py b/google/cloud/aiplatform_v1beta1/types/execution.py index 6b401db1f6..a564e1122b 100644 --- a/google/cloud/aiplatform_v1beta1/types/execution.py +++ b/google/cloud/aiplatform_v1beta1/types/execution.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -29,7 +26,6 @@ class Execution(proto.Message): r"""Instance of a general execution. - Attributes: name (str): Output only. The resource name of the @@ -93,27 +89,21 @@ class State(proto.Enum): COMPLETE = 3 FAILED = 4 - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) state = proto.Field(proto.ENUM, number=6, enum=State,) - - etag = proto.Field(proto.STRING, number=9) - - labels = proto.MapField(proto.STRING, proto.STRING, number=10) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - - schema_title = proto.Field(proto.STRING, number=13) - - schema_version = proto.Field(proto.STRING, number=14) - - metadata = proto.Field(proto.MESSAGE, number=15, message=struct.Struct,) - - description = proto.Field(proto.STRING, number=16) + etag = proto.Field(proto.STRING, number=9,) + labels = proto.MapField(proto.STRING, proto.STRING, number=10,) + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) + schema_title = proto.Field(proto.STRING, number=13,) + schema_version = proto.Field(proto.STRING, number=14,) + metadata = proto.Field(proto.MESSAGE, number=15, message=struct_pb2.Struct,) + description = proto.Field(proto.STRING, number=16,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/explanation.py b/google/cloud/aiplatform_v1beta1/types/explanation.py index 5d4ebbdceb..d1c94d1d83 100644 --- a/google/cloud/aiplatform_v1beta1/types/explanation.py +++ b/google/cloud/aiplatform_v1beta1/types/explanation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import explanation_metadata -from google.protobuf import struct_pb2 as struct # type: ignore +from google.protobuf import struct_pb2 # type: ignore __protobuf__ = proto.module( @@ -117,7 +114,6 @@ class ModelExplanation(proto.Message): class Attribution(proto.Message): r"""Attribution that explains a particular prediction output. - Attributes: baseline_output_value (float): Output only. Model predicted output if the input instance is @@ -231,24 +227,19 @@ class Attribution(proto.Message): [ExplanationMetadata.outputs][google.cloud.aiplatform.v1beta1.ExplanationMetadata.outputs]. """ - baseline_output_value = proto.Field(proto.DOUBLE, number=1) - - instance_output_value = proto.Field(proto.DOUBLE, number=2) - - feature_attributions = proto.Field(proto.MESSAGE, number=3, message=struct.Value,) - - output_index = proto.RepeatedField(proto.INT32, number=4) - - output_display_name = proto.Field(proto.STRING, number=5) - - approximation_error = proto.Field(proto.DOUBLE, number=6) - - output_name = proto.Field(proto.STRING, number=7) + baseline_output_value = proto.Field(proto.DOUBLE, number=1,) + instance_output_value = proto.Field(proto.DOUBLE, number=2,) + feature_attributions = proto.Field( + proto.MESSAGE, number=3, message=struct_pb2.Value, + ) + output_index = proto.RepeatedField(proto.INT32, number=4,) + output_display_name = proto.Field(proto.STRING, number=5,) + approximation_error = proto.Field(proto.DOUBLE, number=6,) + output_name = proto.Field(proto.STRING, number=7,) class ExplanationSpec(proto.Message): r"""Specification of Model explanation. - Attributes: parameters (google.cloud.aiplatform_v1beta1.types.ExplanationParameters): Required. Parameters that configure @@ -259,7 +250,6 @@ class ExplanationSpec(proto.Message): """ parameters = proto.Field(proto.MESSAGE, number=1, message="ExplanationParameters",) - metadata = proto.Field( proto.MESSAGE, number=2, message=explanation_metadata.ExplanationMetadata, ) @@ -267,7 +257,6 @@ class ExplanationSpec(proto.Message): class ExplanationParameters(proto.Message): r"""Parameters to configure explaining for Model's predictions. - Attributes: sampled_shapley_attribution (google.cloud.aiplatform_v1beta1.types.SampledShapleyAttribution): An attribution method that approximates @@ -321,21 +310,17 @@ class ExplanationParameters(proto.Message): sampled_shapley_attribution = proto.Field( proto.MESSAGE, number=1, oneof="method", message="SampledShapleyAttribution", ) - integrated_gradients_attribution = proto.Field( proto.MESSAGE, number=2, oneof="method", message="IntegratedGradientsAttribution", ) - xrai_attribution = proto.Field( proto.MESSAGE, number=3, oneof="method", message="XraiAttribution", ) - - top_k = proto.Field(proto.INT32, number=4) - - output_indices = proto.Field(proto.MESSAGE, number=5, message=struct.ListValue,) + top_k = proto.Field(proto.INT32, number=4,) + output_indices = proto.Field(proto.MESSAGE, number=5, message=struct_pb2.ListValue,) class SampledShapleyAttribution(proto.Message): @@ -352,7 +337,7 @@ class SampledShapleyAttribution(proto.Message): Valid range of its value is [1, 50], inclusively. """ - path_count = proto.Field(proto.INT32, number=1) + path_count = proto.Field(proto.INT32, number=1,) class IntegratedGradientsAttribution(proto.Message): @@ -380,8 +365,7 @@ class IntegratedGradientsAttribution(proto.Message): https://arxiv.org/pdf/1706.03825.pdf """ - step_count = proto.Field(proto.INT32, number=1) - + step_count = proto.Field(proto.INT32, number=1,) smooth_grad_config = proto.Field( proto.MESSAGE, number=2, message="SmoothGradConfig", ) @@ -414,8 +398,7 @@ class XraiAttribution(proto.Message): https://arxiv.org/pdf/1706.03825.pdf """ - step_count = proto.Field(proto.INT32, number=1) - + step_count = proto.Field(proto.INT32, number=1,) smooth_grad_config = proto.Field( proto.MESSAGE, number=2, message="SmoothGradConfig", ) @@ -462,16 +445,14 @@ class SmoothGradConfig(proto.Message): Valid range of its value is [1, 50]. Defaults to 3. """ - noise_sigma = proto.Field(proto.FLOAT, number=1, oneof="GradientNoiseSigma") - + noise_sigma = proto.Field(proto.FLOAT, number=1, oneof="GradientNoiseSigma",) feature_noise_sigma = proto.Field( proto.MESSAGE, number=2, oneof="GradientNoiseSigma", message="FeatureNoiseSigma", ) - - noisy_sample_count = proto.Field(proto.INT32, number=3) + noisy_sample_count = proto.Field(proto.INT32, number=3,) class FeatureNoiseSigma(proto.Message): @@ -487,7 +468,6 @@ class FeatureNoiseSigma(proto.Message): class NoiseSigmaForFeature(proto.Message): r"""Noise sigma for a single feature. - Attributes: name (str): The name of the input feature for which noise sigma is @@ -502,9 +482,8 @@ class NoiseSigmaForFeature(proto.Message): Defaults to 0.1. """ - name = proto.Field(proto.STRING, number=1) - - sigma = proto.Field(proto.FLOAT, number=2) + name = proto.Field(proto.STRING, number=1,) + sigma = proto.Field(proto.FLOAT, number=2,) noise_sigma = proto.RepeatedField( proto.MESSAGE, number=1, message=NoiseSigmaForFeature, @@ -530,7 +509,6 @@ class ExplanationSpecOverride(proto.Message): """ parameters = proto.Field(proto.MESSAGE, number=1, message="ExplanationParameters",) - metadata = proto.Field( proto.MESSAGE, number=2, message="ExplanationMetadataOverride", ) @@ -571,7 +549,7 @@ class InputMetadataOverride(proto.Message): """ input_baselines = proto.RepeatedField( - proto.MESSAGE, number=1, message=struct.Value, + proto.MESSAGE, number=1, message=struct_pb2.Value, ) inputs = proto.MapField( diff --git a/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py b/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py index 4b5eca5241..70f1a5339c 100644 --- a/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py +++ b/google/cloud/aiplatform_v1beta1/types/explanation_metadata.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore +from google.protobuf import struct_pb2 # type: ignore __protobuf__ = proto.module( @@ -199,17 +196,13 @@ class FeatureValueDomain(proto.Message): deviation of the domain prior to normalization. """ - min_value = proto.Field(proto.FLOAT, number=1) - - max_value = proto.Field(proto.FLOAT, number=2) - - original_mean = proto.Field(proto.FLOAT, number=3) - - original_stddev = proto.Field(proto.FLOAT, number=4) + min_value = proto.Field(proto.FLOAT, number=1,) + max_value = proto.Field(proto.FLOAT, number=2,) + original_mean = proto.Field(proto.FLOAT, number=3,) + original_stddev = proto.Field(proto.FLOAT, number=4,) class Visualization(proto.Message): r"""Visualization configurations for image explanation. - Attributes: type_ (google.cloud.aiplatform_v1beta1.types.ExplanationMetadata.InputMetadata.Visualization.Type): Type of the image visualization. Only applicable to @@ -292,23 +285,18 @@ class OverlayType(proto.Enum): number=1, enum="ExplanationMetadata.InputMetadata.Visualization.Type", ) - polarity = proto.Field( proto.ENUM, number=2, enum="ExplanationMetadata.InputMetadata.Visualization.Polarity", ) - color_map = proto.Field( proto.ENUM, number=3, enum="ExplanationMetadata.InputMetadata.Visualization.ColorMap", ) - - clip_percent_upperbound = proto.Field(proto.FLOAT, number=4) - - clip_percent_lowerbound = proto.Field(proto.FLOAT, number=5) - + clip_percent_upperbound = proto.Field(proto.FLOAT, number=4,) + clip_percent_lowerbound = proto.Field(proto.FLOAT, number=5,) overlay_type = proto.Field( proto.ENUM, number=6, @@ -316,46 +304,34 @@ class OverlayType(proto.Enum): ) input_baselines = proto.RepeatedField( - proto.MESSAGE, number=1, message=struct.Value, + proto.MESSAGE, number=1, message=struct_pb2.Value, ) - - input_tensor_name = proto.Field(proto.STRING, number=2) - + input_tensor_name = proto.Field(proto.STRING, number=2,) encoding = proto.Field( proto.ENUM, number=3, enum="ExplanationMetadata.InputMetadata.Encoding", ) - - modality = proto.Field(proto.STRING, number=4) - + modality = proto.Field(proto.STRING, number=4,) feature_value_domain = proto.Field( proto.MESSAGE, number=5, message="ExplanationMetadata.InputMetadata.FeatureValueDomain", ) - - indices_tensor_name = proto.Field(proto.STRING, number=6) - - dense_shape_tensor_name = proto.Field(proto.STRING, number=7) - - index_feature_mapping = proto.RepeatedField(proto.STRING, number=8) - - encoded_tensor_name = proto.Field(proto.STRING, number=9) - + indices_tensor_name = proto.Field(proto.STRING, number=6,) + dense_shape_tensor_name = proto.Field(proto.STRING, number=7,) + index_feature_mapping = proto.RepeatedField(proto.STRING, number=8,) + encoded_tensor_name = proto.Field(proto.STRING, number=9,) encoded_baselines = proto.RepeatedField( - proto.MESSAGE, number=10, message=struct.Value, + proto.MESSAGE, number=10, message=struct_pb2.Value, ) - visualization = proto.Field( proto.MESSAGE, number=11, message="ExplanationMetadata.InputMetadata.Visualization", ) - - group_name = proto.Field(proto.STRING, number=12) + group_name = proto.Field(proto.STRING, number=12,) class OutputMetadata(proto.Message): r"""Metadata of the prediction output to be explained. - Attributes: index_display_name_mapping (google.protobuf.struct_pb2.Value): Static mapping between the index and display name. @@ -391,24 +367,23 @@ class OutputMetadata(proto.Message): """ index_display_name_mapping = proto.Field( - proto.MESSAGE, number=1, oneof="display_name_mapping", message=struct.Value, + proto.MESSAGE, + number=1, + oneof="display_name_mapping", + message=struct_pb2.Value, ) - display_name_mapping_key = proto.Field( - proto.STRING, number=2, oneof="display_name_mapping" + proto.STRING, number=2, oneof="display_name_mapping", ) - - output_tensor_name = proto.Field(proto.STRING, number=3) + output_tensor_name = proto.Field(proto.STRING, number=3,) inputs = proto.MapField( proto.STRING, proto.MESSAGE, number=1, message=InputMetadata, ) - outputs = proto.MapField( proto.STRING, proto.MESSAGE, number=2, message=OutputMetadata, ) - - feature_attributions_schema_uri = proto.Field(proto.STRING, number=3) + feature_attributions_schema_uri = proto.Field(proto.STRING, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/feature.py b/google/cloud/aiplatform_v1beta1/types/feature.py index 6c71f32536..448b972cba 100644 --- a/google/cloud/aiplatform_v1beta1/types/feature.py +++ b/google/cloud/aiplatform_v1beta1/types/feature.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import feature_monitoring_stats from google.cloud.aiplatform_v1beta1.types import featurestore_monitoring -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -104,26 +101,18 @@ class ValueType(proto.Enum): STRING_ARRAY = 12 BYTES = 13 - name = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=2,) value_type = proto.Field(proto.ENUM, number=3, enum=ValueType,) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) - - etag = proto.Field(proto.STRING, number=7) - + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) + etag = proto.Field(proto.STRING, number=7,) monitoring_config = proto.Field( proto.MESSAGE, number=9, message=featurestore_monitoring.FeaturestoreMonitoringConfig, ) - monitoring_stats = proto.RepeatedField( proto.MESSAGE, number=10, message=feature_monitoring_stats.FeatureStatsAnomaly, ) diff --git a/google/cloud/aiplatform_v1beta1/types/feature_monitoring_stats.py b/google/cloud/aiplatform_v1beta1/types/feature_monitoring_stats.py index 5fa2c45a8d..b966a5edb9 100644 --- a/google/cloud/aiplatform_v1beta1/types/feature_monitoring_stats.py +++ b/google/cloud/aiplatform_v1beta1/types/feature_monitoring_stats.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -89,19 +86,13 @@ class FeatureStatsAnomaly(proto.Message): we take snapshots for feature values). """ - score = proto.Field(proto.DOUBLE, number=1) - - stats_uri = proto.Field(proto.STRING, number=3) - - anomaly_uri = proto.Field(proto.STRING, number=4) - - distribution_deviation = proto.Field(proto.DOUBLE, number=5) - - anomaly_detection_threshold = proto.Field(proto.DOUBLE, number=9) - - start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) + score = proto.Field(proto.DOUBLE, number=1,) + stats_uri = proto.Field(proto.STRING, number=3,) + anomaly_uri = proto.Field(proto.STRING, number=4,) + distribution_deviation = proto.Field(proto.DOUBLE, number=5,) + anomaly_detection_threshold = proto.Field(proto.DOUBLE, number=9,) + start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/feature_selector.py b/google/cloud/aiplatform_v1beta1/types/feature_selector.py index cda0ff6713..f876c43103 100644 --- a/google/cloud/aiplatform_v1beta1/types/feature_selector.py +++ b/google/cloud/aiplatform_v1beta1/types/feature_selector.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class IdMatcher(proto.Message): r"""Matcher for Features of an EntityType by Feature ID. - Attributes: ids (Sequence[str]): Required. The following are accepted as ``ids``: @@ -37,12 +34,11 @@ class IdMatcher(proto.Message): Features with those IDs in the target EntityType. """ - ids = proto.RepeatedField(proto.STRING, number=1) + ids = proto.RepeatedField(proto.STRING, number=1,) class FeatureSelector(proto.Message): r"""Selector for Features of an EntityType. - Attributes: id_matcher (google.cloud.aiplatform_v1beta1.types.IdMatcher): Required. Matches Features based on ID. diff --git a/google/cloud/aiplatform_v1beta1/types/featurestore.py b/google/cloud/aiplatform_v1beta1/types/featurestore.py index 670453f362..9a3e71157e 100644 --- a/google/cloud/aiplatform_v1beta1/types/featurestore.py +++ b/google/cloud/aiplatform_v1beta1/types/featurestore.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -34,13 +31,6 @@ class Featurestore(proto.Message): name (str): Output only. Name of the Featurestore. Format: ``projects/{project}/locations/{location}/featurestores/{featurestore}`` - display_name (str): - Required. The user-defined name of the - Featurestore. The name can be up to 128 - characters long and can consist of any UTF-8 - characters. - Display name of a Featurestore must be unique - within a single Project and Location Pair. create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. Timestamp when this Featurestore was created. @@ -90,24 +80,16 @@ class OnlineServingConfig(proto.Message): providing different values when updating. """ - fixed_node_count = proto.Field(proto.INT32, number=2) - - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=5) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) + fixed_node_count = proto.Field(proto.INT32, number=2,) + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=5,) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) online_serving_config = proto.Field( proto.MESSAGE, number=7, message=OnlineServingConfig, ) - state = proto.Field(proto.ENUM, number=8, enum=State,) diff --git a/google/cloud/aiplatform_v1beta1/types/featurestore_monitoring.py b/google/cloud/aiplatform_v1beta1/types/featurestore_monitoring.py index 815faaa6fb..76e6f6b5a4 100644 --- a/google/cloud/aiplatform_v1beta1/types/featurestore_monitoring.py +++ b/google/cloud/aiplatform_v1beta1/types/featurestore_monitoring.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore +from google.protobuf import duration_pb2 # type: ignore __protobuf__ = proto.module( @@ -29,7 +26,6 @@ class FeaturestoreMonitoringConfig(proto.Message): r"""Configuration of how features in Featurestore are monitored. - Attributes: snapshot_analysis (google.cloud.aiplatform_v1beta1.types.FeaturestoreMonitoringConfig.SnapshotAnalysis): The config for Snapshot Analysis Based @@ -61,10 +57,9 @@ class SnapshotAnalysis(proto.Message): is rolled up to full day. """ - disabled = proto.Field(proto.BOOL, number=1) - + disabled = proto.Field(proto.BOOL, number=1,) monitoring_interval = proto.Field( - proto.MESSAGE, number=2, message=duration.Duration, + proto.MESSAGE, number=2, message=duration_pb2.Duration, ) snapshot_analysis = proto.Field(proto.MESSAGE, number=1, message=SnapshotAnalysis,) diff --git a/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py b/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py index 064b1ba2cd..87688e56e5 100644 --- a/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py +++ b/google/cloud/aiplatform_v1beta1/types/featurestore_online_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import ( feature_selector as gca_feature_selector, ) from google.cloud.aiplatform_v1beta1.types import types -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -57,10 +54,8 @@ class ReadFeatureValuesRequest(proto.Message): target EntityType. """ - entity_type = proto.Field(proto.STRING, number=1) - - entity_id = proto.Field(proto.STRING, number=2) - + entity_type = proto.Field(proto.STRING, number=1,) + entity_id = proto.Field(proto.STRING, number=2,) feature_selector = proto.Field( proto.MESSAGE, number=3, message=gca_feature_selector.FeatureSelector, ) @@ -83,13 +78,12 @@ class ReadFeatureValuesResponse(proto.Message): class FeatureDescriptor(proto.Message): r"""Metadata for requested Features. - Attributes: id (str): Feature ID. """ - id = proto.Field(proto.STRING, number=1) + id = proto.Field(proto.STRING, number=1,) class Header(proto.Message): r"""Response header with metadata for the requested @@ -107,8 +101,7 @@ class Header(proto.Message): [ReadFeatureValuesResponse.data][]. """ - entity_type = proto.Field(proto.STRING, number=1) - + entity_type = proto.Field(proto.STRING, number=1,) feature_descriptors = proto.RepeatedField( proto.MESSAGE, number=2, @@ -117,7 +110,6 @@ class Header(proto.Message): class EntityView(proto.Message): r"""Entity view with Feature values. - Attributes: entity_id (str): ID of the requested entity. @@ -148,13 +140,11 @@ class Data(proto.Message): value = proto.Field( proto.MESSAGE, number=1, oneof="data", message="FeatureValue", ) - values = proto.Field( proto.MESSAGE, number=2, oneof="data", message="FeatureValueList", ) - entity_id = proto.Field(proto.STRING, number=1) - + entity_id = proto.Field(proto.STRING, number=1,) data = proto.RepeatedField( proto.MESSAGE, number=2, @@ -162,7 +152,6 @@ class Data(proto.Message): ) header = proto.Field(proto.MESSAGE, number=1, message=Header,) - entity_view = proto.Field(proto.MESSAGE, number=2, message=EntityView,) @@ -186,10 +175,8 @@ class StreamingReadFeatureValuesRequest(proto.Message): target EntityType. """ - entity_type = proto.Field(proto.STRING, number=1) - - entity_ids = proto.RepeatedField(proto.STRING, number=2) - + entity_type = proto.Field(proto.STRING, number=1,) + entity_ids = proto.RepeatedField(proto.STRING, number=2,) feature_selector = proto.Field( proto.MESSAGE, number=3, message=gca_feature_selector.FeatureSelector, ) @@ -224,7 +211,6 @@ class FeatureValue(proto.Message): class Metadata(proto.Message): r"""Metadata of feature value. - Attributes: generate_time (google.protobuf.timestamp_pb2.Timestamp): Feature generation timestamp. Typically, it @@ -235,41 +221,31 @@ class Metadata(proto.Message): """ generate_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp.Timestamp, + proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) - bool_value = proto.Field(proto.BOOL, number=1, oneof="value") - - double_value = proto.Field(proto.DOUBLE, number=2, oneof="value") - - int64_value = proto.Field(proto.INT64, number=5, oneof="value") - - string_value = proto.Field(proto.STRING, number=6, oneof="value") - + bool_value = proto.Field(proto.BOOL, number=1, oneof="value",) + double_value = proto.Field(proto.DOUBLE, number=2, oneof="value",) + int64_value = proto.Field(proto.INT64, number=5, oneof="value",) + string_value = proto.Field(proto.STRING, number=6, oneof="value",) bool_array_value = proto.Field( proto.MESSAGE, number=7, oneof="value", message=types.BoolArray, ) - double_array_value = proto.Field( proto.MESSAGE, number=8, oneof="value", message=types.DoubleArray, ) - int64_array_value = proto.Field( proto.MESSAGE, number=11, oneof="value", message=types.Int64Array, ) - string_array_value = proto.Field( proto.MESSAGE, number=12, oneof="value", message=types.StringArray, ) - - bytes_value = proto.Field(proto.BYTES, number=13, oneof="value") - + bytes_value = proto.Field(proto.BYTES, number=13, oneof="value",) metadata = proto.Field(proto.MESSAGE, number=14, message=Metadata,) class FeatureValueList(proto.Message): r"""Container for list of values. - Attributes: values (Sequence[google.cloud.aiplatform_v1beta1.types.FeatureValue]): A list of feature values. All of them should diff --git a/google/cloud/aiplatform_v1beta1/types/featurestore_service.py b/google/cloud/aiplatform_v1beta1/types/featurestore_service.py index 46b91f45d4..747a588046 100644 --- a/google/cloud/aiplatform_v1beta1/types/featurestore_service.py +++ b/google/cloud/aiplatform_v1beta1/types/featurestore_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import entity_type as gca_entity_type from google.cloud.aiplatform_v1beta1.types import feature as gca_feature from google.cloud.aiplatform_v1beta1.types import ( @@ -26,8 +23,8 @@ from google.cloud.aiplatform_v1beta1.types import featurestore as gca_featurestore from google.cloud.aiplatform_v1beta1.types import io from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -97,13 +94,11 @@ class CreateFeaturestoreRequest(proto.Message): The value must be unique within the project and location. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) featurestore = proto.Field( proto.MESSAGE, number=2, message=gca_featurestore.Featurestore, ) - - featurestore_id = proto.Field(proto.STRING, number=3) + featurestore_id = proto.Field(proto.STRING, number=3,) class GetFeaturestoreRequest(proto.Message): @@ -116,7 +111,7 @@ class GetFeaturestoreRequest(proto.Message): resource. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListFeaturestoresRequest(proto.Message): @@ -174,17 +169,12 @@ class ListFeaturestoresRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) - - read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) + read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask_pb2.FieldMask,) class ListFeaturestoresResponse(proto.Message): @@ -208,8 +198,7 @@ def raw_page(self): featurestores = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_featurestore.Featurestore, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateFeaturestoreRequest(proto.Message): @@ -236,14 +225,15 @@ class UpdateFeaturestoreRequest(proto.Message): - ``display_name`` - ``labels`` - ``online_serving_config.fixed_node_count`` - - ``online_serving_config.max_online_serving_size`` + - ``retention_policy.online_storage_ttl_days`` """ featurestore = proto.Field( proto.MESSAGE, number=1, message=gca_featurestore.Featurestore, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteFeaturestoreRequest(proto.Message): @@ -262,9 +252,8 @@ class DeleteFeaturestoreRequest(proto.Message): Featurestore has no EntityTypes.) """ - name = proto.Field(proto.STRING, number=1) - - force = proto.Field(proto.BOOL, number=2) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) class ImportFeatureValuesRequest(proto.Message): @@ -316,7 +305,6 @@ class ImportFeatureValuesRequest(proto.Message): class FeatureSpec(proto.Message): r"""Defines the Feature value(s) to import. - Attributes: id (str): Required. ID of the Feature to import values @@ -328,42 +316,32 @@ class FeatureSpec(proto.Message): as the Feature ID. """ - id = proto.Field(proto.STRING, number=1) - - source_field = proto.Field(proto.STRING, number=2) + id = proto.Field(proto.STRING, number=1,) + source_field = proto.Field(proto.STRING, number=2,) avro_source = proto.Field( proto.MESSAGE, number=2, oneof="source", message=io.AvroSource, ) - bigquery_source = proto.Field( proto.MESSAGE, number=3, oneof="source", message=io.BigQuerySource, ) - csv_source = proto.Field( proto.MESSAGE, number=4, oneof="source", message=io.CsvSource, ) - feature_time_field = proto.Field( - proto.STRING, number=6, oneof="feature_time_source" + proto.STRING, number=6, oneof="feature_time_source", ) - feature_time = proto.Field( proto.MESSAGE, number=7, oneof="feature_time_source", - message=timestamp.Timestamp, + message=timestamp_pb2.Timestamp, ) - - entity_type = proto.Field(proto.STRING, number=1) - - entity_id_field = proto.Field(proto.STRING, number=5) - + entity_type = proto.Field(proto.STRING, number=1,) + entity_id_field = proto.Field(proto.STRING, number=5,) feature_specs = proto.RepeatedField(proto.MESSAGE, number=8, message=FeatureSpec,) - - disable_online_serving = proto.Field(proto.BOOL, number=9) - - worker_count = proto.Field(proto.INT32, number=11) + disable_online_serving = proto.Field(proto.BOOL, number=9,) + worker_count = proto.Field(proto.INT32, number=11,) class ImportFeatureValuesResponse(proto.Message): @@ -377,11 +355,19 @@ class ImportFeatureValuesResponse(proto.Message): imported_feature_value_count (int): Number of Feature values that have been imported by the operation. + invalid_row_count (int): + The number of rows in input source that weren't imported due + to either + + - Not having any featureValues. + - Having a null entityId. + - Having a null timestamp. + - Not being parsable (applicable for CSV sources). """ - imported_entity_count = proto.Field(proto.INT64, number=1) - - imported_feature_value_count = proto.Field(proto.INT64, number=2) + imported_entity_count = proto.Field(proto.INT64, number=1,) + imported_feature_value_count = proto.Field(proto.INT64, number=2,) + invalid_row_count = proto.Field(proto.INT64, number=6,) class BatchReadFeatureValuesRequest(proto.Message): @@ -446,12 +432,10 @@ class EntityTypeSpec(proto.Message): Per-Feature settings for the batch read. """ - entity_type_id = proto.Field(proto.STRING, number=1) - + entity_type_id = proto.Field(proto.STRING, number=1,) feature_selector = proto.Field( proto.MESSAGE, number=2, message=gca_feature_selector.FeatureSelector, ) - settings = proto.RepeatedField( proto.MESSAGE, number=3, message="DestinationFeatureSetting", ) @@ -459,13 +443,10 @@ class EntityTypeSpec(proto.Message): csv_read_instances = proto.Field( proto.MESSAGE, number=3, oneof="read_option", message=io.CsvSource, ) - - featurestore = proto.Field(proto.STRING, number=1) - + featurestore = proto.Field(proto.STRING, number=1,) destination = proto.Field( proto.MESSAGE, number=4, message="FeatureValueDestination", ) - entity_type_specs = proto.RepeatedField( proto.MESSAGE, number=7, message=EntityTypeSpec, ) @@ -506,23 +487,19 @@ class SnapshotExport(proto.Message): """ snapshot_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp.Timestamp, + proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) snapshot_export = proto.Field( proto.MESSAGE, number=3, oneof="mode", message=SnapshotExport, ) - - entity_type = proto.Field(proto.STRING, number=1) - + entity_type = proto.Field(proto.STRING, number=1,) destination = proto.Field( proto.MESSAGE, number=4, message="FeatureValueDestination", ) - feature_selector = proto.Field( proto.MESSAGE, number=5, message=gca_feature_selector.FeatureSelector, ) - settings = proto.RepeatedField( proto.MESSAGE, number=6, message="DestinationFeatureSetting", ) @@ -530,7 +507,6 @@ class SnapshotExport(proto.Message): class DestinationFeatureSetting(proto.Message): r""" - Attributes: feature_id (str): Required. The ID of the Feature to apply the @@ -541,14 +517,12 @@ class DestinationFeatureSetting(proto.Message): used. """ - feature_id = proto.Field(proto.STRING, number=1) - - destination_field = proto.Field(proto.STRING, number=2) + feature_id = proto.Field(proto.STRING, number=1,) + destination_field = proto.Field(proto.STRING, number=2,) class FeatureValueDestination(proto.Message): r"""A destination location for Feature values and format. - Attributes: bigquery_destination (google.cloud.aiplatform_v1beta1.types.BigQueryDestination): Output in BigQuery format. @@ -578,11 +552,9 @@ class FeatureValueDestination(proto.Message): bigquery_destination = proto.Field( proto.MESSAGE, number=1, oneof="destination", message=io.BigQueryDestination, ) - tfrecord_destination = proto.Field( proto.MESSAGE, number=2, oneof="destination", message=io.TFRecordDestination, ) - csv_destination = proto.Field( proto.MESSAGE, number=3, oneof="destination", message=io.CsvDestination, ) @@ -591,13 +563,13 @@ class FeatureValueDestination(proto.Message): class ExportFeatureValuesResponse(proto.Message): r"""Response message for [FeaturestoreService.ExportFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.ExportFeatureValues]. - """ + """ class BatchReadFeatureValuesResponse(proto.Message): r"""Response message for [FeaturestoreService.BatchReadFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.BatchReadFeatureValues]. - """ + """ class CreateEntityTypeRequest(proto.Message): @@ -622,13 +594,11 @@ class CreateEntityTypeRequest(proto.Message): The value must be unique within a featurestore. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) entity_type = proto.Field( proto.MESSAGE, number=2, message=gca_entity_type.EntityType, ) - - entity_type_id = proto.Field(proto.STRING, number=3) + entity_type_id = proto.Field(proto.STRING, number=3,) class GetEntityTypeRequest(proto.Message): @@ -641,7 +611,7 @@ class GetEntityTypeRequest(proto.Message): ``projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListEntityTypesRequest(proto.Message): @@ -702,17 +672,12 @@ class ListEntityTypesRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) - - read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) + read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask_pb2.FieldMask,) class ListEntityTypesResponse(proto.Message): @@ -736,8 +701,7 @@ def raw_page(self): entity_types = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_entity_type.EntityType, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateEntityTypeRequest(proto.Message): @@ -770,13 +734,13 @@ class UpdateEntityTypeRequest(proto.Message): entity_type = proto.Field( proto.MESSAGE, number=1, message=gca_entity_type.EntityType, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteEntityTypeRequest(proto.Message): r"""Request message for [FeaturestoreService.DeleteEntityTypes][]. - Attributes: name (str): Required. The name of the EntityType to be deleted. Format: @@ -788,9 +752,8 @@ class DeleteEntityTypeRequest(proto.Message): Features.) """ - name = proto.Field(proto.STRING, number=1) - - force = proto.Field(proto.BOOL, number=2) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) class CreateFeatureRequest(proto.Message): @@ -814,11 +777,9 @@ class CreateFeatureRequest(proto.Message): The value must be unique within an EntityType. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) feature = proto.Field(proto.MESSAGE, number=2, message=gca_feature.Feature,) - - feature_id = proto.Field(proto.STRING, number=3) + feature_id = proto.Field(proto.STRING, number=3,) class BatchCreateFeaturesRequest(proto.Message): @@ -839,8 +800,7 @@ class BatchCreateFeaturesRequest(proto.Message): this request message. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) requests = proto.RepeatedField( proto.MESSAGE, number=2, message="CreateFeatureRequest", ) @@ -870,7 +830,7 @@ class GetFeatureRequest(proto.Message): ``projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListFeaturesRequest(proto.Message): @@ -940,19 +900,13 @@ class ListFeaturesRequest(proto.Message): return all existing stats. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) - - read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask.FieldMask,) - - latest_stats_count = proto.Field(proto.INT32, number=7) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) + read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask_pb2.FieldMask,) + latest_stats_count = proto.Field(proto.INT32, number=7,) class ListFeaturesResponse(proto.Message): @@ -976,8 +930,7 @@ def raw_page(self): features = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_feature.Feature, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class SearchFeaturesRequest(proto.Message): @@ -1075,13 +1028,10 @@ class SearchFeaturesRequest(proto.Message): page token. """ - location = proto.Field(proto.STRING, number=1) - - query = proto.Field(proto.STRING, number=3) - - page_size = proto.Field(proto.INT32, number=4) - - page_token = proto.Field(proto.STRING, number=5) + location = proto.Field(proto.STRING, number=1,) + query = proto.Field(proto.STRING, number=3,) + page_size = proto.Field(proto.INT32, number=4,) + page_token = proto.Field(proto.STRING, number=5,) class SearchFeaturesResponse(proto.Message): @@ -1113,8 +1063,7 @@ def raw_page(self): features = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_feature.Feature, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateFeatureRequest(proto.Message): @@ -1144,8 +1093,9 @@ class UpdateFeatureRequest(proto.Message): """ feature = proto.Field(proto.MESSAGE, number=1, message=gca_feature.Feature,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteFeatureRequest(proto.Message): @@ -1158,12 +1108,11 @@ class DeleteFeatureRequest(proto.Message): ``projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}/features/{feature}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateFeaturestoreOperationMetadata(proto.Message): r"""Details of operations that perform create Featurestore. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Featurestore. @@ -1176,7 +1125,6 @@ class CreateFeaturestoreOperationMetadata(proto.Message): class UpdateFeaturestoreOperationMetadata(proto.Message): r"""Details of operations that perform update Featurestore. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Featurestore. @@ -1189,7 +1137,6 @@ class UpdateFeaturestoreOperationMetadata(proto.Message): class ImportFeatureValuesOperationMetadata(proto.Message): r"""Details of operations that perform import feature values. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Featurestore import @@ -1200,20 +1147,26 @@ class ImportFeatureValuesOperationMetadata(proto.Message): imported_feature_value_count (int): Number of feature values that have been imported by the operation. + invalid_row_count (int): + The number of rows in input source that weren't imported due + to either + + - Not having any featureValues. + - Having a null entityId. + - Having a null timestamp. + - Not being parsable (applicable for CSV sources). """ generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - - imported_entity_count = proto.Field(proto.INT64, number=2) - - imported_feature_value_count = proto.Field(proto.INT64, number=3) + imported_entity_count = proto.Field(proto.INT64, number=2,) + imported_feature_value_count = proto.Field(proto.INT64, number=3,) + invalid_row_count = proto.Field(proto.INT64, number=6,) class ExportFeatureValuesOperationMetadata(proto.Message): r"""Details of operations that exports Features values. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Featurestore export @@ -1227,7 +1180,6 @@ class ExportFeatureValuesOperationMetadata(proto.Message): class BatchReadFeatureValuesOperationMetadata(proto.Message): r"""Details of operations that batch reads Feature values. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Featurestore batch @@ -1241,7 +1193,6 @@ class BatchReadFeatureValuesOperationMetadata(proto.Message): class CreateEntityTypeOperationMetadata(proto.Message): r"""Details of operations that perform create EntityType. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for EntityType. @@ -1254,7 +1205,6 @@ class CreateEntityTypeOperationMetadata(proto.Message): class CreateFeatureOperationMetadata(proto.Message): r"""Details of operations that perform create Feature. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Feature. @@ -1267,7 +1217,6 @@ class CreateFeatureOperationMetadata(proto.Message): class BatchCreateFeaturesOperationMetadata(proto.Message): r"""Details of operations that perform batch create Features. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Feature. diff --git a/google/cloud/aiplatform_v1beta1/types/hyperparameter_tuning_job.py b/google/cloud/aiplatform_v1beta1/types/hyperparameter_tuning_job.py index 55978a409e..1344489d7d 100644 --- a/google/cloud/aiplatform_v1beta1/types/hyperparameter_tuning_job.py +++ b/google/cloud/aiplatform_v1beta1/types/hyperparameter_tuning_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import custom_job from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import job_state from google.cloud.aiplatform_v1beta1.types import study -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -102,38 +99,27 @@ class HyperparameterTuningJob(proto.Message): the provided encryption key. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) study_spec = proto.Field(proto.MESSAGE, number=4, message=study.StudySpec,) - - max_trial_count = proto.Field(proto.INT32, number=5) - - parallel_trial_count = proto.Field(proto.INT32, number=6) - - max_failed_trial_count = proto.Field(proto.INT32, number=7) - + max_trial_count = proto.Field(proto.INT32, number=5,) + parallel_trial_count = proto.Field(proto.INT32, number=6,) + max_failed_trial_count = proto.Field(proto.INT32, number=7,) trial_job_spec = proto.Field( proto.MESSAGE, number=8, message=custom_job.CustomJobSpec, ) - trials = proto.RepeatedField(proto.MESSAGE, number=9, message=study.Trial,) - state = proto.Field(proto.ENUM, number=10, enum=job_state.JobState,) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=14, message=timestamp.Timestamp,) - - error = proto.Field(proto.MESSAGE, number=15, message=status.Status,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=16) - + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, + ) + error = proto.Field(proto.MESSAGE, number=15, message=status_pb2.Status,) + labels = proto.MapField(proto.STRING, proto.STRING, number=16,) encryption_spec = proto.Field( proto.MESSAGE, number=17, message=gca_encryption_spec.EncryptionSpec, ) diff --git a/google/cloud/aiplatform_v1beta1/types/index.py b/google/cloud/aiplatform_v1beta1/types/index.py index fcb8371935..47341bbe06 100644 --- a/google/cloud/aiplatform_v1beta1/types/index.py +++ b/google/cloud/aiplatform_v1beta1/types/index.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import deployed_index_ref -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -92,27 +89,22 @@ class Index(proto.Message): Index is reflected in it. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - - metadata_schema_uri = proto.Field(proto.STRING, number=4) - - metadata = proto.Field(proto.MESSAGE, number=6, message=struct.Value,) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) + metadata_schema_uri = proto.Field(proto.STRING, number=4,) + metadata = proto.Field(proto.MESSAGE, number=6, message=struct_pb2.Value,) deployed_indexes = proto.RepeatedField( proto.MESSAGE, number=7, message=deployed_index_ref.DeployedIndexRef, ) - - etag = proto.Field(proto.STRING, number=8) - - labels = proto.MapField(proto.STRING, proto.STRING, number=9) - - create_time = proto.Field(proto.MESSAGE, number=10, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) + etag = proto.Field(proto.STRING, number=8,) + labels = proto.MapField(proto.STRING, proto.STRING, number=9,) + create_time = proto.Field( + proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/index_endpoint.py b/google/cloud/aiplatform_v1beta1/types/index_endpoint.py index 445d7a71bd..ae7d3cfb6b 100644 --- a/google/cloud/aiplatform_v1beta1/types/index_endpoint.py +++ b/google/cloud/aiplatform_v1beta1/types/index_endpoint.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import machine_resources -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -91,25 +88,17 @@ class IndexEndpoint(proto.Message): is network name. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) deployed_indexes = proto.RepeatedField( proto.MESSAGE, number=4, message="DeployedIndex", ) - - etag = proto.Field(proto.STRING, number=5) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) - - create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - network = proto.Field(proto.STRING, number=9) + etag = proto.Field(proto.STRING, number=5,) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) + create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + network = proto.Field(proto.STRING, number=9,) class DeployedIndex(proto.Message): @@ -184,26 +173,20 @@ class DeployedIndex(proto.Message): enabled for the private endpoint. """ - id = proto.Field(proto.STRING, number=1) - - index = proto.Field(proto.STRING, number=2) - - display_name = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - + id = proto.Field(proto.STRING, number=1,) + index = proto.Field(proto.STRING, number=2,) + display_name = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) private_endpoints = proto.Field( proto.MESSAGE, number=5, message="IndexPrivateEndpoints", ) - - index_sync_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - + index_sync_time = proto.Field( + proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp, + ) automatic_resources = proto.Field( proto.MESSAGE, number=7, message=machine_resources.AutomaticResources, ) - - enable_access_logging = proto.Field(proto.BOOL, number=8) - + enable_access_logging = proto.Field(proto.BOOL, number=8,) deployed_index_auth_config = proto.Field( proto.MESSAGE, number=9, message="DeployedIndexAuthConfig", ) @@ -237,9 +220,8 @@ class AuthProvider(proto.Message): ``service-account-name@project-id.iam.gserviceaccount.com`` """ - audiences = proto.RepeatedField(proto.STRING, number=1) - - allowed_issuers = proto.RepeatedField(proto.STRING, number=2) + audiences = proto.RepeatedField(proto.STRING, number=1,) + allowed_issuers = proto.RepeatedField(proto.STRING, number=2,) auth_provider = proto.Field(proto.MESSAGE, number=1, message=AuthProvider,) @@ -254,7 +236,7 @@ class IndexPrivateEndpoints(proto.Message): match gRPC requests. """ - match_grpc_address = proto.Field(proto.STRING, number=1) + match_grpc_address = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/index_endpoint_service.py b/google/cloud/aiplatform_v1beta1/types/index_endpoint_service.py index 7ab0cf5174..7703e02883 100644 --- a/google/cloud/aiplatform_v1beta1/types/index_endpoint_service.py +++ b/google/cloud/aiplatform_v1beta1/types/index_endpoint_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import index_endpoint as gca_index_endpoint from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -56,8 +53,7 @@ class CreateIndexEndpointRequest(proto.Message): Required. The IndexEndpoint to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) index_endpoint = proto.Field( proto.MESSAGE, number=2, message=gca_index_endpoint.IndexEndpoint, ) @@ -87,7 +83,7 @@ class GetIndexEndpointRequest(proto.Message): ``projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListIndexEndpointsRequest(proto.Message): @@ -137,15 +133,11 @@ class ListIndexEndpointsRequest(proto.Message): read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListIndexEndpointsResponse(proto.Message): @@ -168,8 +160,7 @@ def raw_page(self): index_endpoints = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_index_endpoint.IndexEndpoint, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateIndexEndpointRequest(proto.Message): @@ -188,8 +179,9 @@ class UpdateIndexEndpointRequest(proto.Message): index_endpoint = proto.Field( proto.MESSAGE, number=1, message=gca_index_endpoint.IndexEndpoint, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteIndexEndpointRequest(proto.Message): @@ -203,7 +195,7 @@ class DeleteIndexEndpointRequest(proto.Message): ``projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeployIndexRequest(proto.Message): @@ -220,8 +212,7 @@ class DeployIndexRequest(proto.Message): within the IndexEndpoint. """ - index_endpoint = proto.Field(proto.STRING, number=1) - + index_endpoint = proto.Field(proto.STRING, number=1,) deployed_index = proto.Field( proto.MESSAGE, number=2, message=gca_index_endpoint.DeployedIndex, ) @@ -270,15 +261,14 @@ class UndeployIndexRequest(proto.Message): undeployed from the IndexEndpoint. """ - index_endpoint = proto.Field(proto.STRING, number=1) - - deployed_index_id = proto.Field(proto.STRING, number=2) + index_endpoint = proto.Field(proto.STRING, number=1,) + deployed_index_id = proto.Field(proto.STRING, number=2,) class UndeployIndexResponse(proto.Message): r"""Response message for [IndexEndpointService.UndeployIndex][google.cloud.aiplatform.v1beta1.IndexEndpointService.UndeployIndex]. - """ + """ class UndeployIndexOperationMetadata(proto.Message): diff --git a/google/cloud/aiplatform_v1beta1/types/index_service.py b/google/cloud/aiplatform_v1beta1/types/index_service.py index 123858d8ad..73335e18e2 100644 --- a/google/cloud/aiplatform_v1beta1/types/index_service.py +++ b/google/cloud/aiplatform_v1beta1/types/index_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import index as gca_index from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -52,8 +49,7 @@ class CreateIndexRequest(proto.Message): Required. The Index to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) index = proto.Field(proto.MESSAGE, number=2, message=gca_index.Index,) @@ -72,7 +68,6 @@ class CreateIndexOperationMetadata(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - nearest_neighbor_search_operation_metadata = proto.Field( proto.MESSAGE, number=2, message="NearestNeighborSearchOperationMetadata", ) @@ -88,7 +83,7 @@ class GetIndexRequest(proto.Message): ``projects/{project}/locations/{location}/indexes/{index}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListIndexesRequest(proto.Message): @@ -114,15 +109,11 @@ class ListIndexesRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListIndexesResponse(proto.Message): @@ -143,8 +134,7 @@ def raw_page(self): return self indexes = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_index.Index,) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateIndexRequest(proto.Message): @@ -162,8 +152,9 @@ class UpdateIndexRequest(proto.Message): """ index = proto.Field(proto.MESSAGE, number=1, message=gca_index.Index,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class UpdateIndexOperationMetadata(proto.Message): @@ -181,7 +172,6 @@ class UpdateIndexOperationMetadata(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - nearest_neighbor_search_operation_metadata = proto.Field( proto.MESSAGE, number=2, message="NearestNeighborSearchOperationMetadata", ) @@ -198,7 +188,7 @@ class DeleteIndexRequest(proto.Message): ``projects/{project}/locations/{location}/indexes/{index}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class NearestNeighborSearchOperationMetadata(proto.Message): @@ -218,7 +208,6 @@ class NearestNeighborSearchOperationMetadata(proto.Message): class RecordError(proto.Message): r""" - Attributes: error_type (google.cloud.aiplatform_v1beta1.types.NearestNeighborSearchOperationMetadata.RecordError.RecordErrorType): The error type of this record. @@ -228,8 +217,8 @@ class RecordError(proto.Message): time to time, your code should check against error_type as the source of truth. source_gcs_uri (str): - GCS uri pointing to the original file in - user's bucket. + Cloud Storage URI pointing to the original + file in user's bucket. embedding_id (str): Empty if the embedding id is failed to parse. raw_record (str): @@ -252,22 +241,17 @@ class RecordErrorType(proto.Enum): number=1, enum="NearestNeighborSearchOperationMetadata.RecordError.RecordErrorType", ) - - error_message = proto.Field(proto.STRING, number=2) - - source_gcs_uri = proto.Field(proto.STRING, number=3) - - embedding_id = proto.Field(proto.STRING, number=4) - - raw_record = proto.Field(proto.STRING, number=5) + error_message = proto.Field(proto.STRING, number=2,) + source_gcs_uri = proto.Field(proto.STRING, number=3,) + embedding_id = proto.Field(proto.STRING, number=4,) + raw_record = proto.Field(proto.STRING, number=5,) class ContentValidationStats(proto.Message): r""" - Attributes: source_gcs_uri (str): - GCS uri pointing to the original file in - user's bucket. + Cloud Storage URI pointing to the original + file in user's bucket. valid_record_count (int): Number of records in this file that were successfully processed. @@ -281,12 +265,9 @@ class ContentValidationStats(proto.Message): will be reported. """ - source_gcs_uri = proto.Field(proto.STRING, number=1) - - valid_record_count = proto.Field(proto.INT64, number=2) - - invalid_record_count = proto.Field(proto.INT64, number=3) - + source_gcs_uri = proto.Field(proto.STRING, number=1,) + valid_record_count = proto.Field(proto.INT64, number=2,) + invalid_record_count = proto.Field(proto.INT64, number=3,) partial_errors = proto.RepeatedField( proto.MESSAGE, number=4, diff --git a/google/cloud/aiplatform_v1beta1/types/io.py b/google/cloud/aiplatform_v1beta1/types/io.py index e18a20b132..6d456e7b6b 100644 --- a/google/cloud/aiplatform_v1beta1/types/io.py +++ b/google/cloud/aiplatform_v1beta1/types/io.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -36,7 +34,6 @@ class AvroSource(proto.Message): r"""The storage details for Avro input content. - Attributes: gcs_source (google.cloud.aiplatform_v1beta1.types.GcsSource): Required. Google Cloud Storage location. @@ -47,7 +44,6 @@ class AvroSource(proto.Message): class CsvSource(proto.Message): r"""The storage details for CSV input content. - Attributes: gcs_source (google.cloud.aiplatform_v1beta1.types.GcsSource): Required. Google Cloud Storage location. @@ -58,7 +54,6 @@ class CsvSource(proto.Message): class GcsSource(proto.Message): r"""The Google Cloud Storage location for the input content. - Attributes: uris (Sequence[str]): Required. Google Cloud Storage URI(-s) to the @@ -67,7 +62,7 @@ class GcsSource(proto.Message): https://cloud.google.com/storage/docs/gsutil/addlhelp/WildcardNames. """ - uris = proto.RepeatedField(proto.STRING, number=1) + uris = proto.RepeatedField(proto.STRING, number=1,) class GcsDestination(proto.Message): @@ -82,12 +77,11 @@ class GcsDestination(proto.Message): directory is created if it doesn't exist. """ - output_uri_prefix = proto.Field(proto.STRING, number=1) + output_uri_prefix = proto.Field(proto.STRING, number=1,) 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 @@ -97,12 +91,11 @@ class BigQuerySource(proto.Message): ``bq://projectId.bqDatasetId.bqTableId``. """ - input_uri = proto.Field(proto.STRING, number=1) + input_uri = proto.Field(proto.STRING, number=1,) class BigQueryDestination(proto.Message): r"""The BigQuery location for the output content. - Attributes: output_uri (str): Required. BigQuery URI to a project or table, up to 2000 @@ -118,12 +111,11 @@ class BigQueryDestination(proto.Message): ``bq://projectId.bqDatasetId.bqTableId``. """ - output_uri = proto.Field(proto.STRING, number=1) + output_uri = proto.Field(proto.STRING, number=1,) class CsvDestination(proto.Message): r"""The storage details for CSV output content. - Attributes: gcs_destination (google.cloud.aiplatform_v1beta1.types.GcsDestination): Required. Google Cloud Storage location. @@ -134,7 +126,6 @@ class CsvDestination(proto.Message): class TFRecordDestination(proto.Message): r"""The storage details for TFRecord output content. - Attributes: gcs_destination (google.cloud.aiplatform_v1beta1.types.GcsDestination): Required. Google Cloud Storage location. @@ -145,7 +136,6 @@ class TFRecordDestination(proto.Message): class ContainerRegistryDestination(proto.Message): r"""The Container Registry location for the container image. - Attributes: output_uri (str): Required. Container Registry URI of a container image. Only @@ -162,7 +152,7 @@ class ContainerRegistryDestination(proto.Message): default tag. """ - output_uri = proto.Field(proto.STRING, number=1) + output_uri = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/job_service.py b/google/cloud/aiplatform_v1beta1/types/job_service.py index 778f323040..52fe9b14b8 100644 --- a/google/cloud/aiplatform_v1beta1/types/job_service.py +++ b/google/cloud/aiplatform_v1beta1/types/job_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import ( batch_prediction_job as gca_batch_prediction_job, ) @@ -32,8 +29,8 @@ model_deployment_monitoring_job as gca_model_deployment_monitoring_job, ) from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -91,8 +88,7 @@ class CreateCustomJobRequest(proto.Message): Required. The CustomJob to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) custom_job = proto.Field(proto.MESSAGE, number=2, message=gca_custom_job.CustomJob,) @@ -106,7 +102,7 @@ class GetCustomJobRequest(proto.Message): ``projects/{project}/locations/{location}/customJobs/{custom_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListCustomJobsRequest(proto.Message): @@ -148,15 +144,11 @@ class ListCustomJobsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListCustomJobsResponse(proto.Message): @@ -179,8 +171,7 @@ def raw_page(self): custom_jobs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_custom_job.CustomJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteCustomJobRequest(proto.Message): @@ -194,7 +185,7 @@ class DeleteCustomJobRequest(proto.Message): ``projects/{project}/locations/{location}/customJobs/{custom_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelCustomJobRequest(proto.Message): @@ -207,7 +198,7 @@ class CancelCustomJobRequest(proto.Message): ``projects/{project}/locations/{location}/customJobs/{custom_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateDataLabelingJobRequest(proto.Message): @@ -222,8 +213,7 @@ class CreateDataLabelingJobRequest(proto.Message): Required. The DataLabelingJob to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) data_labeling_job = proto.Field( proto.MESSAGE, number=2, message=gca_data_labeling_job.DataLabelingJob, ) @@ -239,7 +229,7 @@ class GetDataLabelingJobRequest(proto.Message): ``projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListDataLabelingJobsRequest(proto.Message): @@ -284,17 +274,12 @@ class ListDataLabelingJobsRequest(proto.Message): for descending. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) - - order_by = proto.Field(proto.STRING, number=6) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + order_by = proto.Field(proto.STRING, number=6,) class ListDataLabelingJobsResponse(proto.Message): @@ -316,8 +301,7 @@ def raw_page(self): data_labeling_jobs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_data_labeling_job.DataLabelingJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteDataLabelingJobRequest(proto.Message): @@ -331,7 +315,7 @@ class DeleteDataLabelingJobRequest(proto.Message): ``projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelDataLabelingJobRequest(proto.Message): @@ -344,7 +328,7 @@ class CancelDataLabelingJobRequest(proto.Message): ``projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateHyperparameterTuningJobRequest(proto.Message): @@ -361,8 +345,7 @@ class CreateHyperparameterTuningJobRequest(proto.Message): create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) hyperparameter_tuning_job = proto.Field( proto.MESSAGE, number=2, @@ -381,7 +364,7 @@ class GetHyperparameterTuningJobRequest(proto.Message): ``projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListHyperparameterTuningJobsRequest(proto.Message): @@ -423,15 +406,11 @@ class ListHyperparameterTuningJobsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListHyperparameterTuningJobsResponse(proto.Message): @@ -458,8 +437,7 @@ def raw_page(self): number=1, message=gca_hyperparameter_tuning_job.HyperparameterTuningJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteHyperparameterTuningJobRequest(proto.Message): @@ -473,7 +451,7 @@ class DeleteHyperparameterTuningJobRequest(proto.Message): ``projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelHyperparameterTuningJobRequest(proto.Message): @@ -487,7 +465,7 @@ class CancelHyperparameterTuningJobRequest(proto.Message): ``projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateBatchPredictionJobRequest(proto.Message): @@ -503,8 +481,7 @@ class CreateBatchPredictionJobRequest(proto.Message): Required. The BatchPredictionJob to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) batch_prediction_job = proto.Field( proto.MESSAGE, number=2, message=gca_batch_prediction_job.BatchPredictionJob, ) @@ -521,7 +498,7 @@ class GetBatchPredictionJobRequest(proto.Message): ``projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListBatchPredictionJobsRequest(proto.Message): @@ -565,15 +542,11 @@ class ListBatchPredictionJobsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListBatchPredictionJobsResponse(proto.Message): @@ -597,8 +570,7 @@ def raw_page(self): batch_prediction_jobs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_batch_prediction_job.BatchPredictionJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteBatchPredictionJobRequest(proto.Message): @@ -612,7 +584,7 @@ class DeleteBatchPredictionJobRequest(proto.Message): ``projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelBatchPredictionJobRequest(proto.Message): @@ -626,7 +598,7 @@ class CancelBatchPredictionJobRequest(proto.Message): ``projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateModelDeploymentMonitoringJobRequest(proto.Message): @@ -642,8 +614,7 @@ class CreateModelDeploymentMonitoringJobRequest(proto.Message): create """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) model_deployment_monitoring_job = proto.Field( proto.MESSAGE, number=2, @@ -689,7 +660,6 @@ class SearchModelDeploymentMonitoringStatsAnomaliesRequest(proto.Message): class StatsAnomaliesObjective(proto.Message): r"""Stats requested for specific objective. - Attributes: type_ (google.cloud.aiplatform_v1beta1.types.ModelDeploymentMonitoringObjectiveType): @@ -709,26 +679,18 @@ class StatsAnomaliesObjective(proto.Message): number=1, enum=gca_model_deployment_monitoring_job.ModelDeploymentMonitoringObjectiveType, ) + top_feature_count = proto.Field(proto.INT32, number=4,) - top_feature_count = proto.Field(proto.INT32, number=4) - - model_deployment_monitoring_job = proto.Field(proto.STRING, number=1) - - deployed_model_id = proto.Field(proto.STRING, number=2) - - feature_display_name = proto.Field(proto.STRING, number=3) - + model_deployment_monitoring_job = proto.Field(proto.STRING, number=1,) + deployed_model_id = proto.Field(proto.STRING, number=2,) + feature_display_name = proto.Field(proto.STRING, number=3,) objectives = proto.RepeatedField( proto.MESSAGE, number=4, message=StatsAnomaliesObjective, ) - - page_size = proto.Field(proto.INT32, number=5) - - page_token = proto.Field(proto.STRING, number=6) - - start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) + page_size = proto.Field(proto.INT32, number=5,) + page_token = proto.Field(proto.STRING, number=6,) + start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) class SearchModelDeploymentMonitoringStatsAnomaliesResponse(proto.Message): @@ -756,8 +718,7 @@ def raw_page(self): number=1, message=gca_model_deployment_monitoring_job.ModelMonitoringStatsAnomalies, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetModelDeploymentMonitoringJobRequest(proto.Message): @@ -771,7 +732,7 @@ class GetModelDeploymentMonitoringJobRequest(proto.Message): ``projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListModelDeploymentMonitoringJobsRequest(proto.Message): @@ -792,15 +753,11 @@ class ListModelDeploymentMonitoringJobsRequest(proto.Message): Mask specifying which fields to read """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListModelDeploymentMonitoringJobsResponse(proto.Message): @@ -824,8 +781,7 @@ def raw_page(self): number=1, message=gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateModelDeploymentMonitoringJobRequest(proto.Message): @@ -846,8 +802,9 @@ class UpdateModelDeploymentMonitoringJobRequest(proto.Message): number=1, message=gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteModelDeploymentMonitoringJobRequest(proto.Message): @@ -861,7 +818,7 @@ class DeleteModelDeploymentMonitoringJobRequest(proto.Message): ``projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class PauseModelDeploymentMonitoringJobRequest(proto.Message): @@ -875,7 +832,7 @@ class PauseModelDeploymentMonitoringJobRequest(proto.Message): ``projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ResumeModelDeploymentMonitoringJobRequest(proto.Message): @@ -889,7 +846,7 @@ class ResumeModelDeploymentMonitoringJobRequest(proto.Message): ``projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateModelDeploymentMonitoringJobOperationMetadata(proto.Message): diff --git a/google/cloud/aiplatform_v1beta1/types/job_state.py b/google/cloud/aiplatform_v1beta1/types/job_state.py index b77947cc9a..dd05f8e0c5 100644 --- a/google/cloud/aiplatform_v1beta1/types/job_state.py +++ b/google/cloud/aiplatform_v1beta1/types/job_state.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore diff --git a/google/cloud/aiplatform_v1beta1/types/lineage_subgraph.py b/google/cloud/aiplatform_v1beta1/types/lineage_subgraph.py index f4ff6b2d97..23df024ffd 100644 --- a/google/cloud/aiplatform_v1beta1/types/lineage_subgraph.py +++ b/google/cloud/aiplatform_v1beta1/types/lineage_subgraph.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import artifact from google.cloud.aiplatform_v1beta1.types import event from google.cloud.aiplatform_v1beta1.types import execution @@ -43,11 +40,9 @@ class LineageSubgraph(proto.Message): """ artifacts = proto.RepeatedField(proto.MESSAGE, number=1, message=artifact.Artifact,) - executions = proto.RepeatedField( proto.MESSAGE, number=2, message=execution.Execution, ) - events = proto.RepeatedField(proto.MESSAGE, number=3, message=event.Event,) diff --git a/google/cloud/aiplatform_v1beta1/types/machine_resources.py b/google/cloud/aiplatform_v1beta1/types/machine_resources.py index d06e10f16e..abd28b68c4 100644 --- a/google/cloud/aiplatform_v1beta1/types/machine_resources.py +++ b/google/cloud/aiplatform_v1beta1/types/machine_resources.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import ( accelerator_type as gca_accelerator_type, ) @@ -39,7 +36,6 @@ class MachineSpec(proto.Message): r"""Specification of a single machine. - Attributes: machine_type (str): Immutable. The type of the machine. For the machine types @@ -65,13 +61,11 @@ class MachineSpec(proto.Message): machine. """ - machine_type = proto.Field(proto.STRING, number=1) - + machine_type = proto.Field(proto.STRING, number=1,) accelerator_type = proto.Field( proto.ENUM, number=2, enum=gca_accelerator_type.AcceleratorType, ) - - accelerator_count = proto.Field(proto.INT32, number=3) + accelerator_count = proto.Field(proto.INT32, number=3,) class DedicatedResources(proto.Message): @@ -136,11 +130,8 @@ class DedicatedResources(proto.Message): """ machine_spec = proto.Field(proto.MESSAGE, number=1, message="MachineSpec",) - - min_replica_count = proto.Field(proto.INT32, number=2) - - max_replica_count = proto.Field(proto.INT32, number=3) - + min_replica_count = proto.Field(proto.INT32, number=2,) + max_replica_count = proto.Field(proto.INT32, number=3,) autoscaling_metric_specs = proto.RepeatedField( proto.MESSAGE, number=4, message="AutoscalingMetricSpec", ) @@ -178,9 +169,8 @@ class AutomaticResources(proto.Message): number. """ - min_replica_count = proto.Field(proto.INT32, number=1) - - max_replica_count = proto.Field(proto.INT32, number=2) + min_replica_count = proto.Field(proto.INT32, number=1,) + max_replica_count = proto.Field(proto.INT32, number=2,) class BatchDedicatedResources(proto.Message): @@ -204,15 +194,12 @@ class BatchDedicatedResources(proto.Message): """ machine_spec = proto.Field(proto.MESSAGE, number=1, message="MachineSpec",) - - starting_replica_count = proto.Field(proto.INT32, number=2) - - max_replica_count = proto.Field(proto.INT32, number=3) + starting_replica_count = proto.Field(proto.INT32, number=2,) + max_replica_count = proto.Field(proto.INT32, number=3,) class ResourcesConsumed(proto.Message): r"""Statistics information about resource consumption. - Attributes: replica_hours (float): Output only. The number of replica hours @@ -222,12 +209,11 @@ class ResourcesConsumed(proto.Message): not strictly related to wall time. """ - replica_hours = proto.Field(proto.DOUBLE, number=1) + replica_hours = proto.Field(proto.DOUBLE, number=1,) class DiskSpec(proto.Message): r"""Represents the spec of disk options. - Attributes: boot_disk_type (str): Type of the boot disk (default is "pd-ssd"). @@ -239,9 +225,8 @@ class DiskSpec(proto.Message): 100GB). """ - boot_disk_type = proto.Field(proto.STRING, number=1) - - boot_disk_size_gb = proto.Field(proto.INT32, number=2) + boot_disk_type = proto.Field(proto.STRING, number=1,) + boot_disk_size_gb = proto.Field(proto.INT32, number=2,) class AutoscalingMetricSpec(proto.Message): @@ -265,9 +250,8 @@ class AutoscalingMetricSpec(proto.Message): provided. """ - metric_name = proto.Field(proto.STRING, number=1) - - target = proto.Field(proto.INT32, number=2) + metric_name = proto.Field(proto.STRING, number=1,) + target = proto.Field(proto.INT32, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py b/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py index 7a467d5069..a26ab13237 100644 --- a/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py +++ b/google/cloud/aiplatform_v1beta1/types/manual_batch_tuning_parameters.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,7 +24,6 @@ class ManualBatchTuningParameters(proto.Message): r"""Manual batch tuning parameters. - Attributes: batch_size (int): Immutable. The number of the records (e.g. @@ -41,7 +38,7 @@ class ManualBatchTuningParameters(proto.Message): The default value is 4. """ - batch_size = proto.Field(proto.INT32, number=1) + batch_size = proto.Field(proto.INT32, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/metadata_schema.py b/google/cloud/aiplatform_v1beta1/types/metadata_schema.py index d2c6f97fa8..41ad5806df 100644 --- a/google/cloud/aiplatform_v1beta1/types/metadata_schema.py +++ b/google/cloud/aiplatform_v1beta1/types/metadata_schema.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -28,7 +25,6 @@ class MetadataSchema(proto.Message): r"""Instance of a general MetadataSchema. - Attributes: name (str): Output only. The resource name of the @@ -65,17 +61,12 @@ class MetadataSchemaType(proto.Enum): EXECUTION_TYPE = 2 CONTEXT_TYPE = 3 - name = proto.Field(proto.STRING, number=1) - - schema_version = proto.Field(proto.STRING, number=2) - - schema = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + schema_version = proto.Field(proto.STRING, number=2,) + schema = proto.Field(proto.STRING, number=3,) schema_type = proto.Field(proto.ENUM, number=4, enum=MetadataSchemaType,) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - description = proto.Field(proto.STRING, number=6) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + description = proto.Field(proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/metadata_service.py b/google/cloud/aiplatform_v1beta1/types/metadata_service.py index 3d755b3415..84b46c1bfd 100644 --- a/google/cloud/aiplatform_v1beta1/types/metadata_service.py +++ b/google/cloud/aiplatform_v1beta1/types/metadata_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import artifact as gca_artifact from google.cloud.aiplatform_v1beta1.types import context as gca_context from google.cloud.aiplatform_v1beta1.types import event @@ -25,7 +22,7 @@ from google.cloud.aiplatform_v1beta1.types import metadata_schema as gca_metadata_schema from google.cloud.aiplatform_v1beta1.types import metadata_store as gca_metadata_store from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -95,13 +92,11 @@ class CreateMetadataStoreRequest(proto.Message): MetadataStore.) """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) metadata_store = proto.Field( proto.MESSAGE, number=2, message=gca_metadata_store.MetadataStore, ) - - metadata_store_id = proto.Field(proto.STRING, number=3) + metadata_store_id = proto.Field(proto.STRING, number=3,) class CreateMetadataStoreOperationMetadata(proto.Message): @@ -130,7 +125,7 @@ class GetMetadataStoreRequest(proto.Message): projects/{project}/locations/{location}/metadataStores/{metadatastore} """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListMetadataStoresRequest(proto.Message): @@ -157,11 +152,9 @@ class ListMetadataStoresRequest(proto.Message): request will fail with INVALID_ARGUMENT error.) """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListMetadataStoresResponse(proto.Message): @@ -185,8 +178,7 @@ def raw_page(self): metadata_stores = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_metadata_store.MetadataStore, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteMetadataStoreRequest(proto.Message): @@ -205,9 +197,8 @@ class DeleteMetadataStoreRequest(proto.Message): resources.) """ - name = proto.Field(proto.STRING, number=1) - - force = proto.Field(proto.BOOL, number=2) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) class DeleteMetadataStoreOperationMetadata(proto.Message): @@ -248,11 +239,9 @@ class CreateArtifactRequest(proto.Message): if the caller can't view the preexisting Artifact.) """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) artifact = proto.Field(proto.MESSAGE, number=2, message=gca_artifact.Artifact,) - - artifact_id = proto.Field(proto.STRING, number=3) + artifact_id = proto.Field(proto.STRING, number=3,) class GetArtifactRequest(proto.Message): @@ -266,7 +255,7 @@ class GetArtifactRequest(proto.Message): projects/{project}/locations/{location}/metadataStores/{metadatastore}/artifacts/{artifact} """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListArtifactsRequest(proto.Message): @@ -318,13 +307,10 @@ class ListArtifactsRequest(proto.Message): display_name = "test" AND metadata.field1.bool_value = true. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListArtifactsResponse(proto.Message): @@ -349,8 +335,7 @@ def raw_page(self): artifacts = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_artifact.Artifact, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateArtifactRequest(proto.Message): @@ -376,10 +361,10 @@ class UpdateArtifactRequest(proto.Message): """ artifact = proto.Field(proto.MESSAGE, number=1, message=gca_artifact.Artifact,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - allow_missing = proto.Field(proto.BOOL, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + allow_missing = proto.Field(proto.BOOL, number=3,) class CreateContextRequest(proto.Message): @@ -405,11 +390,9 @@ class CreateContextRequest(proto.Message): caller can't view the preexisting Context.) """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) context = proto.Field(proto.MESSAGE, number=2, message=gca_context.Context,) - - context_id = proto.Field(proto.STRING, number=3) + context_id = proto.Field(proto.STRING, number=3,) class GetContextRequest(proto.Message): @@ -423,7 +406,7 @@ class GetContextRequest(proto.Message): projects/{project}/locations/{location}/metadataStores/{metadatastore}/contexts/{context} """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListContextsRequest(proto.Message): @@ -451,13 +434,10 @@ class ListContextsRequest(proto.Message): """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListContextsResponse(proto.Message): @@ -482,8 +462,7 @@ def raw_page(self): contexts = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_context.Context, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateContextRequest(proto.Message): @@ -508,10 +487,10 @@ class UpdateContextRequest(proto.Message): """ context = proto.Field(proto.MESSAGE, number=1, message=gca_context.Context,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - allow_missing = proto.Field(proto.BOOL, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + allow_missing = proto.Field(proto.BOOL, number=3,) class DeleteContextRequest(proto.Message): @@ -530,9 +509,8 @@ class DeleteContextRequest(proto.Message): resources, such as another Context, Artifact, or Execution). """ - name = proto.Field(proto.STRING, number=1) - - force = proto.Field(proto.BOOL, number=2) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) class AddContextArtifactsAndExecutionsRequest(proto.Message): @@ -553,17 +531,15 @@ class AddContextArtifactsAndExecutionsRequest(proto.Message): associate with the Context. """ - context = proto.Field(proto.STRING, number=1) - - artifacts = proto.RepeatedField(proto.STRING, number=2) - - executions = proto.RepeatedField(proto.STRING, number=3) + context = proto.Field(proto.STRING, number=1,) + artifacts = proto.RepeatedField(proto.STRING, number=2,) + executions = proto.RepeatedField(proto.STRING, number=3,) class AddContextArtifactsAndExecutionsResponse(proto.Message): r"""Response message for [MetadataService.AddContextArtifactsAndExecutions][google.cloud.aiplatform.v1beta1.MetadataService.AddContextArtifactsAndExecutions]. - """ + """ class AddContextChildrenRequest(proto.Message): @@ -579,15 +555,14 @@ class AddContextChildrenRequest(proto.Message): The resource names of the child Contexts. """ - context = proto.Field(proto.STRING, number=1) - - child_contexts = proto.RepeatedField(proto.STRING, number=2) + context = proto.Field(proto.STRING, number=1,) + child_contexts = proto.RepeatedField(proto.STRING, number=2,) class AddContextChildrenResponse(proto.Message): r"""Response message for [MetadataService.AddContextChildren][google.cloud.aiplatform.v1beta1.MetadataService.AddContextChildren]. - """ + """ class QueryContextLineageSubgraphRequest(proto.Message): @@ -606,7 +581,7 @@ class QueryContextLineageSubgraphRequest(proto.Message): Events that would be returned for the Context exceeds 1000. """ - context = proto.Field(proto.STRING, number=1) + context = proto.Field(proto.STRING, number=1,) class CreateExecutionRequest(proto.Message): @@ -633,11 +608,9 @@ class CreateExecutionRequest(proto.Message): if the caller can't view the preexisting Execution.) """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) execution = proto.Field(proto.MESSAGE, number=2, message=gca_execution.Execution,) - - execution_id = proto.Field(proto.STRING, number=3) + execution_id = proto.Field(proto.STRING, number=3,) class GetExecutionRequest(proto.Message): @@ -651,7 +624,7 @@ class GetExecutionRequest(proto.Message): projects/{project}/locations/{location}/metadataStores/{metadatastore}/executions/{execution} """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListExecutionsRequest(proto.Message): @@ -704,13 +677,10 @@ class ListExecutionsRequest(proto.Message): "test" AND metadata.field1.bool_value = true. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListExecutionsResponse(proto.Message): @@ -735,8 +705,7 @@ def raw_page(self): executions = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_execution.Execution, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateExecutionRequest(proto.Message): @@ -762,10 +731,10 @@ class UpdateExecutionRequest(proto.Message): """ execution = proto.Field(proto.MESSAGE, number=1, message=gca_execution.Execution,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) - - allow_missing = proto.Field(proto.BOOL, number=3) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) + allow_missing = proto.Field(proto.BOOL, number=3,) class AddExecutionEventsRequest(proto.Message): @@ -782,15 +751,14 @@ class AddExecutionEventsRequest(proto.Message): The Events to create and add. """ - execution = proto.Field(proto.STRING, number=1) - + execution = proto.Field(proto.STRING, number=1,) events = proto.RepeatedField(proto.MESSAGE, number=2, message=event.Event,) class AddExecutionEventsResponse(proto.Message): r"""Response message for [MetadataService.AddExecutionEvents][google.cloud.aiplatform.v1beta1.MetadataService.AddExecutionEvents]. - """ + """ class QueryExecutionInputsAndOutputsRequest(proto.Message): @@ -805,7 +773,7 @@ class QueryExecutionInputsAndOutputsRequest(proto.Message): projects/{project}/locations/{location}/metadataStores/{metadatastore}/executions/{execution} """ - execution = proto.Field(proto.STRING, number=1) + execution = proto.Field(proto.STRING, number=1,) class CreateMetadataSchemaRequest(proto.Message): @@ -833,13 +801,11 @@ class CreateMetadataSchemaRequest(proto.Message): MetadataSchema.) """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) metadata_schema = proto.Field( proto.MESSAGE, number=2, message=gca_metadata_schema.MetadataSchema, ) - - metadata_schema_id = proto.Field(proto.STRING, number=3) + metadata_schema_id = proto.Field(proto.STRING, number=3,) class GetMetadataSchemaRequest(proto.Message): @@ -853,7 +819,7 @@ class GetMetadataSchemaRequest(proto.Message): projects/{project}/locations/{location}/metadataStores/{metadatastore}/metadataSchemas/{metadataschema} """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListMetadataSchemasRequest(proto.Message): @@ -883,13 +849,10 @@ class ListMetadataSchemasRequest(proto.Message): for matching results. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListMetadataSchemasResponse(proto.Message): @@ -914,8 +877,7 @@ def raw_page(self): metadata_schemas = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_metadata_schema.MetadataSchema, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class QueryArtifactLineageSubgraphRequest(proto.Message): @@ -961,11 +923,9 @@ class QueryArtifactLineageSubgraphRequest(proto.Message): display_name = "test" AND metadata.field1.bool_value = true. """ - artifact = proto.Field(proto.STRING, number=1) - - max_hops = proto.Field(proto.INT32, number=2) - - filter = proto.Field(proto.STRING, number=3) + artifact = proto.Field(proto.STRING, number=1,) + max_hops = proto.Field(proto.INT32, number=2,) + filter = proto.Field(proto.STRING, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/metadata_store.py b/google/cloud/aiplatform_v1beta1/types/metadata_store.py index b57c00573a..ac39fde5f0 100644 --- a/google/cloud/aiplatform_v1beta1/types/metadata_store.py +++ b/google/cloud/aiplatform_v1beta1/types/metadata_store.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -55,27 +52,21 @@ class MetadataStore(proto.Message): class MetadataStoreState(proto.Message): r"""Represent state information for a MetadataStore. - Attributes: disk_utilization_bytes (int): The disk utilization of the MetadataStore in bytes. """ - disk_utilization_bytes = proto.Field(proto.INT64, number=1) - - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + disk_utilization_bytes = proto.Field(proto.INT64, number=1,) + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) encryption_spec = proto.Field( proto.MESSAGE, number=5, message=gca_encryption_spec.EncryptionSpec, ) - - description = proto.Field(proto.STRING, number=6) - + description = proto.Field(proto.STRING, number=6,) state = proto.Field(proto.MESSAGE, number=7, message=MetadataStoreState,) diff --git a/google/cloud/aiplatform_v1beta1/types/migratable_resource.py b/google/cloud/aiplatform_v1beta1/types/migratable_resource.py index 9a695ea349..4a35c5f8d0 100644 --- a/google/cloud/aiplatform_v1beta1/types/migratable_resource.py +++ b/google/cloud/aiplatform_v1beta1/types/migratable_resource.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -55,7 +52,6 @@ class MigratableResource(proto.Message): class MlEngineModelVersion(proto.Message): r"""Represents one model Version in ml.googleapis.com. - Attributes: endpoint (str): The ml.googleapis.com endpoint that this model Version @@ -70,13 +66,11 @@ class MlEngineModelVersion(proto.Message): ``projects/{project}/models/{model}/versions/{version}``. """ - endpoint = proto.Field(proto.STRING, number=1) - - version = proto.Field(proto.STRING, number=2) + endpoint = proto.Field(proto.STRING, number=1,) + version = proto.Field(proto.STRING, number=2,) class AutomlModel(proto.Message): r"""Represents one Model in automl.googleapis.com. - Attributes: model (str): Full resource name of automl Model. Format: @@ -86,13 +80,11 @@ class AutomlModel(proto.Message): automl.googleapis.com. """ - model = proto.Field(proto.STRING, number=1) - - model_display_name = proto.Field(proto.STRING, number=3) + model = proto.Field(proto.STRING, number=1,) + model_display_name = proto.Field(proto.STRING, number=3,) class AutomlDataset(proto.Message): r"""Represents one Dataset in automl.googleapis.com. - Attributes: dataset (str): Full resource name of automl Dataset. Format: @@ -102,13 +94,11 @@ class AutomlDataset(proto.Message): automl.googleapis.com. """ - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=4) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=4,) class DataLabelingDataset(proto.Message): r"""Represents one Dataset in datalabeling.googleapis.com. - Attributes: dataset (str): Full resource name of data labeling Dataset. Format: @@ -136,14 +126,11 @@ class DataLabelingAnnotatedDataset(proto.Message): datalabeling.googleapis.com. """ - annotated_dataset = proto.Field(proto.STRING, number=1) - - annotated_dataset_display_name = proto.Field(proto.STRING, number=3) - - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=4) + annotated_dataset = proto.Field(proto.STRING, number=1,) + annotated_dataset_display_name = proto.Field(proto.STRING, number=3,) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=4,) data_labeling_annotated_datasets = proto.RepeatedField( proto.MESSAGE, number=3, @@ -153,25 +140,20 @@ class DataLabelingAnnotatedDataset(proto.Message): ml_engine_model_version = proto.Field( proto.MESSAGE, number=1, oneof="resource", message=MlEngineModelVersion, ) - automl_model = proto.Field( proto.MESSAGE, number=2, oneof="resource", message=AutomlModel, ) - automl_dataset = proto.Field( proto.MESSAGE, number=3, oneof="resource", message=AutomlDataset, ) - data_labeling_dataset = proto.Field( proto.MESSAGE, number=4, oneof="resource", message=DataLabelingDataset, ) - last_migrate_time = proto.Field( - proto.MESSAGE, number=5, message=timestamp.Timestamp, + proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp, ) - last_update_time = proto.Field( - proto.MESSAGE, number=6, message=timestamp.Timestamp, + proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp, ) diff --git a/google/cloud/aiplatform_v1beta1/types/migration_service.py b/google/cloud/aiplatform_v1beta1/types/migration_service.py index f189abc783..1bc2d2432a 100644 --- a/google/cloud/aiplatform_v1beta1/types/migration_service.py +++ b/google/cloud/aiplatform_v1beta1/types/migration_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import ( migratable_resource as gca_migratable_resource, ) from google.cloud.aiplatform_v1beta1.types import operation -from google.rpc import status_pb2 as status # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -78,13 +75,10 @@ class SearchMigratableResourcesRequest(proto.Message): migrated resources. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) class SearchMigratableResourcesResponse(proto.Message): @@ -108,8 +102,7 @@ def raw_page(self): migratable_resources = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_migratable_resource.MigratableResource, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class BatchMigrateResourcesRequest(proto.Message): @@ -127,8 +120,7 @@ class BatchMigrateResourcesRequest(proto.Message): can be migrated in one batch. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) migrate_resource_requests = proto.RepeatedField( proto.MESSAGE, number=2, message="MigrateResourceRequest", ) @@ -181,11 +173,9 @@ class MigrateMlEngineModelVersionConfig(proto.Message): unspecified. """ - endpoint = proto.Field(proto.STRING, number=1) - - model_version = proto.Field(proto.STRING, number=2) - - model_display_name = proto.Field(proto.STRING, number=3) + endpoint = proto.Field(proto.STRING, number=1,) + model_version = proto.Field(proto.STRING, number=2,) + model_display_name = proto.Field(proto.STRING, number=3,) class MigrateAutomlModelConfig(proto.Message): r"""Config for migrating Model in automl.googleapis.com to AI @@ -201,9 +191,8 @@ class MigrateAutomlModelConfig(proto.Message): unspecified. """ - model = proto.Field(proto.STRING, number=1) - - model_display_name = proto.Field(proto.STRING, number=2) + model = proto.Field(proto.STRING, number=1,) + model_display_name = proto.Field(proto.STRING, number=2,) class MigrateAutomlDatasetConfig(proto.Message): r"""Config for migrating Dataset in automl.googleapis.com to AI @@ -219,9 +208,8 @@ class MigrateAutomlDatasetConfig(proto.Message): unspecified. """ - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=2) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=2,) class MigrateDataLabelingDatasetConfig(proto.Message): r"""Config for migrating Dataset in datalabeling.googleapis.com @@ -254,12 +242,10 @@ class MigrateDataLabelingAnnotatedDatasetConfig(proto.Message): ``projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}``. """ - annotated_dataset = proto.Field(proto.STRING, number=1) - - dataset = proto.Field(proto.STRING, number=1) - - dataset_display_name = proto.Field(proto.STRING, number=2) + annotated_dataset = proto.Field(proto.STRING, number=1,) + dataset = proto.Field(proto.STRING, number=1,) + dataset_display_name = proto.Field(proto.STRING, number=2,) migrate_data_labeling_annotated_dataset_configs = proto.RepeatedField( proto.MESSAGE, number=3, @@ -272,15 +258,12 @@ class MigrateDataLabelingAnnotatedDatasetConfig(proto.Message): oneof="request", message=MigrateMlEngineModelVersionConfig, ) - migrate_automl_model_config = proto.Field( proto.MESSAGE, number=2, oneof="request", message=MigrateAutomlModelConfig, ) - migrate_automl_dataset_config = proto.Field( proto.MESSAGE, number=3, oneof="request", message=MigrateAutomlDatasetConfig, ) - migrate_data_labeling_dataset_config = proto.Field( proto.MESSAGE, number=4, @@ -305,7 +288,6 @@ class BatchMigrateResourcesResponse(proto.Message): class MigrateResourceResponse(proto.Message): r"""Describes a successfully migrated resource. - Attributes: dataset (str): Migrated Dataset's resource name. @@ -317,10 +299,8 @@ class MigrateResourceResponse(proto.Message): datalabeling.googleapis.com. """ - dataset = proto.Field(proto.STRING, number=1, oneof="migrated_resource") - - model = proto.Field(proto.STRING, number=2, oneof="migrated_resource") - + dataset = proto.Field(proto.STRING, number=1, oneof="migrated_resource",) + model = proto.Field(proto.STRING, number=2, oneof="migrated_resource",) migratable_resource = proto.Field( proto.MESSAGE, number=3, message=gca_migratable_resource.MigratableResource, ) @@ -356,13 +336,10 @@ class PartialResult(proto.Message): """ error = proto.Field( - proto.MESSAGE, number=2, oneof="result", message=status.Status, + proto.MESSAGE, number=2, oneof="result", message=status_pb2.Status, ) - - model = proto.Field(proto.STRING, number=3, oneof="result") - - dataset = proto.Field(proto.STRING, number=4, oneof="result") - + model = proto.Field(proto.STRING, number=3, oneof="result",) + dataset = proto.Field(proto.STRING, number=4, oneof="result",) request = proto.Field( proto.MESSAGE, number=1, message="MigrateResourceRequest", ) @@ -370,7 +347,6 @@ class PartialResult(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - partial_results = proto.RepeatedField( proto.MESSAGE, number=2, message=PartialResult, ) diff --git a/google/cloud/aiplatform_v1beta1/types/model.py b/google/cloud/aiplatform_v1beta1/types/model.py index 8608621480..2363d22fe3 100644 --- a/google/cloud/aiplatform_v1beta1/types/model.py +++ b/google/cloud/aiplatform_v1beta1/types/model.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import deployed_model_ref from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import env_var from google.cloud.aiplatform_v1beta1.types import explanation -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -34,7 +31,6 @@ class Model(proto.Message): r"""A trained machine learning Model. - Attributes: name (str): The resource name of the Model. @@ -293,58 +289,42 @@ class ExportableContent(proto.Enum): ARTIFACT = 1 IMAGE = 2 - id = proto.Field(proto.STRING, number=1) - + id = proto.Field(proto.STRING, number=1,) exportable_contents = proto.RepeatedField( proto.ENUM, number=2, enum="Model.ExportFormat.ExportableContent", ) - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) predict_schemata = proto.Field(proto.MESSAGE, number=4, message="PredictSchemata",) - - metadata_schema_uri = proto.Field(proto.STRING, number=5) - - metadata = proto.Field(proto.MESSAGE, number=6, message=struct.Value,) - + metadata_schema_uri = proto.Field(proto.STRING, number=5,) + metadata = proto.Field(proto.MESSAGE, number=6, message=struct_pb2.Value,) supported_export_formats = proto.RepeatedField( proto.MESSAGE, number=20, message=ExportFormat, ) - - training_pipeline = proto.Field(proto.STRING, number=7) - + training_pipeline = proto.Field(proto.STRING, number=7,) container_spec = proto.Field(proto.MESSAGE, number=9, message="ModelContainerSpec",) - - artifact_uri = proto.Field(proto.STRING, number=26) - + artifact_uri = proto.Field(proto.STRING, number=26,) supported_deployment_resources_types = proto.RepeatedField( proto.ENUM, number=10, enum=DeploymentResourcesType, ) - - supported_input_storage_formats = proto.RepeatedField(proto.STRING, number=11) - - supported_output_storage_formats = proto.RepeatedField(proto.STRING, number=12) - - create_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=14, message=timestamp.Timestamp,) - + supported_input_storage_formats = proto.RepeatedField(proto.STRING, number=11,) + supported_output_storage_formats = proto.RepeatedField(proto.STRING, number=12,) + create_time = proto.Field( + proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, + ) deployed_models = proto.RepeatedField( proto.MESSAGE, number=15, message=deployed_model_ref.DeployedModelRef, ) - explanation_spec = proto.Field( proto.MESSAGE, number=23, message=explanation.ExplanationSpec, ) - - etag = proto.Field(proto.STRING, number=16) - - labels = proto.MapField(proto.STRING, proto.STRING, number=17) - + etag = proto.Field(proto.STRING, number=16,) + labels = proto.MapField(proto.STRING, proto.STRING, number=17,) encryption_spec = proto.Field( proto.MESSAGE, number=24, message=gca_encryption_spec.EncryptionSpec, ) @@ -407,11 +387,9 @@ class PredictSchemata(proto.Message): where the user only has a read access. """ - instance_schema_uri = proto.Field(proto.STRING, number=1) - - parameters_schema_uri = proto.Field(proto.STRING, number=2) - - prediction_schema_uri = proto.Field(proto.STRING, number=3) + instance_schema_uri = proto.Field(proto.STRING, number=1,) + parameters_schema_uri = proto.Field(proto.STRING, number=2,) + prediction_schema_uri = proto.Field(proto.STRING, number=3,) class ModelContainerSpec(proto.Message): @@ -649,24 +627,17 @@ class ModelContainerSpec(proto.Message): environment variable.) """ - image_uri = proto.Field(proto.STRING, number=1) - - command = proto.RepeatedField(proto.STRING, number=2) - - args = proto.RepeatedField(proto.STRING, number=3) - + image_uri = proto.Field(proto.STRING, number=1,) + command = proto.RepeatedField(proto.STRING, number=2,) + args = proto.RepeatedField(proto.STRING, number=3,) env = proto.RepeatedField(proto.MESSAGE, number=4, message=env_var.EnvVar,) - ports = proto.RepeatedField(proto.MESSAGE, number=5, message="Port",) - - predict_route = proto.Field(proto.STRING, number=6) - - health_route = proto.Field(proto.STRING, number=7) + predict_route = proto.Field(proto.STRING, number=6,) + health_route = proto.Field(proto.STRING, number=7,) class Port(proto.Message): r"""Represents a network port in a container. - Attributes: container_port (int): The number of the port to expose on the pod's @@ -674,7 +645,7 @@ class Port(proto.Message): 1 and 65535 inclusive. """ - container_port = proto.Field(proto.INT32, number=3) + container_port = proto.Field(proto.INT32, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/model_deployment_monitoring_job.py b/google/cloud/aiplatform_v1beta1/types/model_deployment_monitoring_job.py index e5f19dd3b7..0a05808db9 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_deployment_monitoring_job.py +++ b/google/cloud/aiplatform_v1beta1/types/model_deployment_monitoring_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import feature_monitoring_stats from google.cloud.aiplatform_v1beta1.types import io from google.cloud.aiplatform_v1beta1.types import job_state from google.cloud.aiplatform_v1beta1.types import model_monitoring -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -165,56 +162,42 @@ class MonitoringScheduleState(proto.Enum): OFFLINE = 2 RUNNING = 3 - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - endpoint = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + endpoint = proto.Field(proto.STRING, number=3,) state = proto.Field(proto.ENUM, number=4, enum=job_state.JobState,) - schedule_state = proto.Field(proto.ENUM, number=5, enum=MonitoringScheduleState,) - model_deployment_monitoring_objective_configs = proto.RepeatedField( proto.MESSAGE, number=6, message="ModelDeploymentMonitoringObjectiveConfig", ) - model_deployment_monitoring_schedule_config = proto.Field( proto.MESSAGE, number=7, message="ModelDeploymentMonitoringScheduleConfig", ) - logging_sampling_strategy = proto.Field( proto.MESSAGE, number=8, message=model_monitoring.SamplingStrategy, ) - model_monitoring_alert_config = proto.Field( proto.MESSAGE, number=15, message=model_monitoring.ModelMonitoringAlertConfig, ) - - predict_instance_schema_uri = proto.Field(proto.STRING, number=9) - + predict_instance_schema_uri = proto.Field(proto.STRING, number=9,) sample_predict_instance = proto.Field( - proto.MESSAGE, number=19, message=struct.Value, + proto.MESSAGE, number=19, message=struct_pb2.Value, ) - - analysis_instance_schema_uri = proto.Field(proto.STRING, number=16) - + analysis_instance_schema_uri = proto.Field(proto.STRING, number=16,) bigquery_tables = proto.RepeatedField( proto.MESSAGE, number=10, message="ModelDeploymentMonitoringBigQueryTable", ) - - log_ttl = proto.Field(proto.MESSAGE, number=17, message=duration.Duration,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=11) - - create_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - + log_ttl = proto.Field(proto.MESSAGE, number=17, message=duration_pb2.Duration,) + labels = proto.MapField(proto.STRING, proto.STRING, number=11,) + create_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp, + ) next_schedule_time = proto.Field( - proto.MESSAGE, number=14, message=timestamp.Timestamp, + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, ) - stats_anomalies_base_directory = proto.Field( proto.MESSAGE, number=20, message=io.GcsDestination, ) @@ -249,10 +232,8 @@ class LogType(proto.Enum): EXPLAIN = 2 log_source = proto.Field(proto.ENUM, number=1, enum=LogSource,) - log_type = proto.Field(proto.ENUM, number=2, enum=LogType,) - - bigquery_table_path = proto.Field(proto.STRING, number=3) + bigquery_table_path = proto.Field(proto.STRING, number=3,) class ModelDeploymentMonitoringObjectiveConfig(proto.Message): @@ -267,8 +248,7 @@ class ModelDeploymentMonitoringObjectiveConfig(proto.Message): modelmonitoring job of this deployed model. """ - deployed_model_id = proto.Field(proto.STRING, number=1) - + deployed_model_id = proto.Field(proto.STRING, number=1,) objective_config = proto.Field( proto.MESSAGE, number=2, @@ -278,7 +258,6 @@ class ModelDeploymentMonitoringObjectiveConfig(proto.Message): class ModelDeploymentMonitoringScheduleConfig(proto.Message): r"""The config for scheduling monitoring job. - Attributes: monitor_interval (google.protobuf.duration_pb2.Duration): Required. The model monitoring job running @@ -286,12 +265,13 @@ class ModelDeploymentMonitoringScheduleConfig(proto.Message): hour. """ - monitor_interval = proto.Field(proto.MESSAGE, number=1, message=duration.Duration,) + monitor_interval = proto.Field( + proto.MESSAGE, number=1, message=duration_pb2.Duration, + ) class ModelMonitoringStatsAnomalies(proto.Message): r"""Statistics and anomalies generated by Model Monitoring. - Attributes: objective (google.cloud.aiplatform_v1beta1.types.ModelDeploymentMonitoringObjectiveType): Model Monitoring Objective those stats and @@ -307,7 +287,6 @@ class ModelMonitoringStatsAnomalies(proto.Message): class FeatureHistoricStatsAnomalies(proto.Message): r"""Historical Stats (and Anomalies) for a specific Feature. - Attributes: feature_display_name (str): Display Name of the Feature. @@ -320,18 +299,15 @@ class FeatureHistoricStatsAnomalies(proto.Message): different time window's Prediction Dataset. """ - feature_display_name = proto.Field(proto.STRING, number=1) - + feature_display_name = proto.Field(proto.STRING, number=1,) threshold = proto.Field( proto.MESSAGE, number=3, message=model_monitoring.ThresholdConfig, ) - training_stats = proto.Field( proto.MESSAGE, number=4, message=feature_monitoring_stats.FeatureStatsAnomaly, ) - prediction_stats = proto.RepeatedField( proto.MESSAGE, number=5, @@ -341,11 +317,8 @@ class FeatureHistoricStatsAnomalies(proto.Message): objective = proto.Field( proto.ENUM, number=1, enum="ModelDeploymentMonitoringObjectiveType", ) - - deployed_model_id = proto.Field(proto.STRING, number=2) - - anomaly_count = proto.Field(proto.INT32, number=3) - + deployed_model_id = proto.Field(proto.STRING, number=2,) + anomaly_count = proto.Field(proto.INT32, number=3,) feature_stats = proto.RepeatedField( proto.MESSAGE, number=4, message=FeatureHistoricStatsAnomalies, ) diff --git a/google/cloud/aiplatform_v1beta1/types/model_evaluation.py b/google/cloud/aiplatform_v1beta1/types/model_evaluation.py index 661241eb26..d7ef59b8f9 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_evaluation.py +++ b/google/cloud/aiplatform_v1beta1/types/model_evaluation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import explanation -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -74,7 +71,6 @@ class ModelEvaluation(proto.Message): class ModelEvaluationExplanationSpec(proto.Message): r""" - Attributes: explanation_type (str): Explanation type. @@ -87,26 +83,19 @@ class ModelEvaluationExplanationSpec(proto.Message): Explanation spec details. """ - explanation_type = proto.Field(proto.STRING, number=1) - + explanation_type = proto.Field(proto.STRING, number=1,) explanation_spec = proto.Field( proto.MESSAGE, number=2, message=explanation.ExplanationSpec, ) - name = proto.Field(proto.STRING, number=1) - - metrics_schema_uri = proto.Field(proto.STRING, number=2) - - metrics = proto.Field(proto.MESSAGE, number=3, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - slice_dimensions = proto.RepeatedField(proto.STRING, number=5) - + name = proto.Field(proto.STRING, number=1,) + metrics_schema_uri = proto.Field(proto.STRING, number=2,) + metrics = proto.Field(proto.MESSAGE, number=3, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + slice_dimensions = proto.RepeatedField(proto.STRING, number=5,) model_explanation = proto.Field( proto.MESSAGE, number=8, message=explanation.ModelExplanation, ) - explanation_specs = proto.RepeatedField( proto.MESSAGE, number=9, message=ModelEvaluationExplanationSpec, ) diff --git a/google/cloud/aiplatform_v1beta1/types/model_evaluation_slice.py b/google/cloud/aiplatform_v1beta1/types/model_evaluation_slice.py index ef15398bd7..94066203c6 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_evaluation_slice.py +++ b/google/cloud/aiplatform_v1beta1/types/model_evaluation_slice.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -57,7 +54,6 @@ class ModelEvaluationSlice(proto.Message): class Slice(proto.Message): r"""Definition of a slice. - Attributes: dimension (str): Output only. The dimension of the slice. Well-known @@ -73,19 +69,14 @@ class Slice(proto.Message): this slice. """ - dimension = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.STRING, number=2) - - name = proto.Field(proto.STRING, number=1) + dimension = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.STRING, number=2,) + name = proto.Field(proto.STRING, number=1,) slice_ = proto.Field(proto.MESSAGE, number=2, message=Slice,) - - metrics_schema_uri = proto.Field(proto.STRING, number=3) - - metrics = proto.Field(proto.MESSAGE, number=4, message=struct.Value,) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) + metrics_schema_uri = proto.Field(proto.STRING, number=3,) + metrics = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Value,) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/model_monitoring.py b/google/cloud/aiplatform_v1beta1/types/model_monitoring.py index fd605d8265..30d8375934 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_monitoring.py +++ b/google/cloud/aiplatform_v1beta1/types/model_monitoring.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import io @@ -34,7 +31,6 @@ class ModelMonitoringObjectiveConfig(proto.Message): r"""Next ID: 6 - Attributes: training_dataset (google.cloud.aiplatform_v1beta1.types.ModelMonitoringObjectiveConfig.TrainingDataset): Training dataset for models. This field has @@ -50,7 +46,6 @@ class ModelMonitoringObjectiveConfig(proto.Message): class TrainingDataset(proto.Message): r"""Training Dataset information. - Attributes: dataset (str): The resource name of the Dataset used to @@ -81,20 +76,15 @@ class TrainingDataset(proto.Message): dataset. """ - dataset = proto.Field(proto.STRING, number=3, oneof="data_source") - + dataset = proto.Field(proto.STRING, number=3, oneof="data_source",) gcs_source = proto.Field( proto.MESSAGE, number=4, oneof="data_source", message=io.GcsSource, ) - bigquery_source = proto.Field( proto.MESSAGE, number=5, oneof="data_source", message=io.BigQuerySource, ) - - data_format = proto.Field(proto.STRING, number=2) - - target_field = proto.Field(proto.STRING, number=6) - + data_format = proto.Field(proto.STRING, number=2,) + target_field = proto.Field(proto.STRING, number=6,) logging_sampling_strategy = proto.Field( proto.MESSAGE, number=7, message="SamplingStrategy", ) @@ -120,7 +110,6 @@ class TrainingPredictionSkewDetectionConfig(proto.Message): class PredictionDriftDetectionConfig(proto.Message): r"""The config for Prediction data drift detection. - Attributes: drift_thresholds (Sequence[google.cloud.aiplatform_v1beta1.types.ModelMonitoringObjectiveConfig.PredictionDriftDetectionConfig.DriftThresholdsEntry]): Key is the feature name and value is the @@ -136,11 +125,9 @@ class PredictionDriftDetectionConfig(proto.Message): ) training_dataset = proto.Field(proto.MESSAGE, number=1, message=TrainingDataset,) - training_prediction_skew_detection_config = proto.Field( proto.MESSAGE, number=2, message=TrainingPredictionSkewDetectionConfig, ) - prediction_drift_detection_config = proto.Field( proto.MESSAGE, number=3, message=PredictionDriftDetectionConfig, ) @@ -148,7 +135,6 @@ class PredictionDriftDetectionConfig(proto.Message): class ModelMonitoringAlertConfig(proto.Message): r"""Next ID: 2 - Attributes: email_alert_config (google.cloud.aiplatform_v1beta1.types.ModelMonitoringAlertConfig.EmailAlertConfig): Email alert config. @@ -156,13 +142,12 @@ class ModelMonitoringAlertConfig(proto.Message): class EmailAlertConfig(proto.Message): r"""The config for email alert. - Attributes: user_emails (Sequence[str]): The email addresses to send the alert. """ - user_emails = proto.RepeatedField(proto.STRING, number=1) + user_emails = proto.RepeatedField(proto.STRING, number=1,) email_alert_config = proto.Field( proto.MESSAGE, number=1, oneof="alert", message=EmailAlertConfig, @@ -188,7 +173,7 @@ class ThresholdConfig(proto.Message): will be triggered for that feature. """ - value = proto.Field(proto.DOUBLE, number=1, oneof="threshold") + value = proto.Field(proto.DOUBLE, number=1, oneof="threshold",) class SamplingStrategy(proto.Message): @@ -204,13 +189,12 @@ class SamplingStrategy(proto.Message): class RandomSampleConfig(proto.Message): r"""Requests are randomly selected. - Attributes: sample_rate (float): Sample rate (0, 1] """ - sample_rate = proto.Field(proto.DOUBLE, number=1) + sample_rate = proto.Field(proto.DOUBLE, number=1,) random_sample_config = proto.Field( proto.MESSAGE, number=1, message=RandomSampleConfig, diff --git a/google/cloud/aiplatform_v1beta1/types/model_service.py b/google/cloud/aiplatform_v1beta1/types/model_service.py index be2f1aae6e..9f94a8fed9 100644 --- a/google/cloud/aiplatform_v1beta1/types/model_service.py +++ b/google/cloud/aiplatform_v1beta1/types/model_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,16 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import io from google.cloud.aiplatform_v1beta1.types import model as gca_model from google.cloud.aiplatform_v1beta1.types import model_evaluation from google.cloud.aiplatform_v1beta1.types import model_evaluation_slice from google.cloud.aiplatform_v1beta1.types import operation -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -63,8 +60,7 @@ class UploadModelRequest(proto.Message): Required. The Model to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) model = proto.Field(proto.MESSAGE, number=2, message=gca_model.Model,) @@ -94,7 +90,7 @@ class UploadModelResponse(proto.Message): ``projects/{project}/locations/{location}/models/{model}`` """ - model = proto.Field(proto.STRING, number=1) + model = proto.Field(proto.STRING, number=1,) class GetModelRequest(proto.Message): @@ -107,7 +103,7 @@ class GetModelRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListModelsRequest(proto.Message): @@ -151,15 +147,11 @@ class ListModelsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListModelsResponse(proto.Message): @@ -180,8 +172,7 @@ def raw_page(self): return self models = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_model.Model,) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateModelRequest(proto.Message): @@ -199,8 +190,9 @@ class UpdateModelRequest(proto.Message): """ model = proto.Field(proto.MESSAGE, number=1, message=gca_model.Model,) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class DeleteModelRequest(proto.Message): @@ -214,7 +206,7 @@ class DeleteModelRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ExportModelRequest(proto.Message): @@ -232,7 +224,6 @@ class ExportModelRequest(proto.Message): class OutputConfig(proto.Message): r"""Output configuration for the Model export. - Attributes: export_format_id (str): The ID of the format in which the Model must be exported. @@ -259,18 +250,15 @@ class OutputConfig(proto.Message): ``IMAGE``. """ - export_format_id = proto.Field(proto.STRING, number=1) - + export_format_id = proto.Field(proto.STRING, number=1,) artifact_destination = proto.Field( proto.MESSAGE, number=3, message=io.GcsDestination, ) - image_destination = proto.Field( proto.MESSAGE, number=4, message=io.ContainerRegistryDestination, ) - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) output_config = proto.Field(proto.MESSAGE, number=2, message=OutputConfig,) @@ -304,14 +292,12 @@ class OutputInfo(proto.Message): image created. """ - artifact_output_uri = proto.Field(proto.STRING, number=2) - - image_output_uri = proto.Field(proto.STRING, number=3) + artifact_output_uri = proto.Field(proto.STRING, number=2,) + image_output_uri = proto.Field(proto.STRING, number=3,) generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - output_info = proto.Field(proto.MESSAGE, number=2, message=OutputInfo,) @@ -319,7 +305,7 @@ class ExportModelResponse(proto.Message): r"""Response message of [ModelService.ExportModel][google.cloud.aiplatform.v1beta1.ModelService.ExportModel] operation. - """ + """ class GetModelEvaluationRequest(proto.Message): @@ -332,7 +318,7 @@ class GetModelEvaluationRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListModelEvaluationsRequest(proto.Message): @@ -358,15 +344,11 @@ class ListModelEvaluationsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListModelEvaluationsResponse(proto.Message): @@ -390,8 +372,7 @@ def raw_page(self): model_evaluations = proto.RepeatedField( proto.MESSAGE, number=1, message=model_evaluation.ModelEvaluation, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetModelEvaluationSliceRequest(proto.Message): @@ -405,7 +386,7 @@ class GetModelEvaluationSliceRequest(proto.Message): ``projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListModelEvaluationSlicesRequest(proto.Message): @@ -433,15 +414,11 @@ class ListModelEvaluationSlicesRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListModelEvaluationSlicesResponse(proto.Message): @@ -465,8 +442,7 @@ def raw_page(self): model_evaluation_slices = proto.RepeatedField( proto.MESSAGE, number=1, message=model_evaluation_slice.ModelEvaluationSlice, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/operation.py b/google/cloud/aiplatform_v1beta1/types/operation.py index 90565867e8..637c8cd951 100644 --- a/google/cloud/aiplatform_v1beta1/types/operation.py +++ b/google/cloud/aiplatform_v1beta1/types/operation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,7 +27,6 @@ class GenericOperationMetadata(proto.Message): r"""Generic Metadata shared by all operations. - Attributes: partial_failures (Sequence[google.rpc.status_pb2.Status]): Output only. Partial failures encountered. @@ -49,17 +45,14 @@ class GenericOperationMetadata(proto.Message): """ partial_failures = proto.RepeatedField( - proto.MESSAGE, number=1, message=status.Status, + proto.MESSAGE, number=1, message=status_pb2.Status, ) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) class DeleteOperationMetadata(proto.Message): r"""Details of operations that perform deletes of any entities. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): The common part of the operation metadata. diff --git a/google/cloud/aiplatform_v1beta1/types/pipeline_job.py b/google/cloud/aiplatform_v1beta1/types/pipeline_job.py index db6eb5c5bc..120d2ce71f 100644 --- a/google/cloud/aiplatform_v1beta1/types/pipeline_job.py +++ b/google/cloud/aiplatform_v1beta1/types/pipeline_job.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,19 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import artifact from google.cloud.aiplatform_v1beta1.types import context from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import execution as gca_execution from google.cloud.aiplatform_v1beta1.types import pipeline_state from google.cloud.aiplatform_v1beta1.types import value as gca_value -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -42,7 +39,6 @@ class PipelineJob(proto.Message): r"""An instance of a machine learning PipelineJob. - Attributes: name (str): Output only. The resource name of the @@ -118,7 +114,6 @@ class PipelineJob(proto.Message): class RuntimeConfig(proto.Message): r"""The runtime config of a PipelineJob. - Attributes: parameters (Sequence[google.cloud.aiplatform_v1beta1.types.PipelineJob.RuntimeConfig.ParametersEntry]): The runtime parameters of the PipelineJob. The parameters @@ -139,45 +134,29 @@ class RuntimeConfig(proto.Message): parameters = proto.MapField( proto.STRING, proto.MESSAGE, number=1, message=gca_value.Value, ) - - gcs_output_directory = proto.Field(proto.STRING, number=2) - - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - pipeline_spec = proto.Field(proto.MESSAGE, number=7, message=struct.Struct,) - + gcs_output_directory = proto.Field(proto.STRING, number=2,) + + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + pipeline_spec = proto.Field(proto.MESSAGE, number=7, message=struct_pb2.Struct,) state = proto.Field(proto.ENUM, number=8, enum=pipeline_state.PipelineState,) - job_detail = proto.Field(proto.MESSAGE, number=9, message="PipelineJobDetail",) - - error = proto.Field(proto.MESSAGE, number=10, message=status.Status,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=11) - + error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) + labels = proto.MapField(proto.STRING, proto.STRING, number=11,) runtime_config = proto.Field(proto.MESSAGE, number=12, message=RuntimeConfig,) - encryption_spec = proto.Field( proto.MESSAGE, number=16, message=gca_encryption_spec.EncryptionSpec, ) - - service_account = proto.Field(proto.STRING, number=17) - - network = proto.Field(proto.STRING, number=18) + service_account = proto.Field(proto.STRING, number=17,) + network = proto.Field(proto.STRING, number=18,) class PipelineJobDetail(proto.Message): r"""The runtime detail of PipelineJob. - Attributes: pipeline_context (google.cloud.aiplatform_v1beta1.types.Context): Output only. The context of the pipeline. @@ -190,11 +169,9 @@ class PipelineJobDetail(proto.Message): """ pipeline_context = proto.Field(proto.MESSAGE, number=1, message=context.Context,) - pipeline_run_context = proto.Field( proto.MESSAGE, number=2, message=context.Context, ) - task_details = proto.RepeatedField( proto.MESSAGE, number=3, message="PipelineTaskDetail", ) @@ -202,7 +179,6 @@ class PipelineJobDetail(proto.Message): class PipelineTaskDetail(proto.Message): r"""The runtime detail of a task execution. - Attributes: task_id (int): Output only. The system generated ID of the @@ -254,7 +230,6 @@ class State(proto.Enum): class ArtifactList(proto.Message): r"""A list of artifact metadata. - Attributes: artifacts (Sequence[google.cloud.aiplatform_v1beta1.types.Artifact]): Output only. A list of artifact metadata. @@ -264,32 +239,21 @@ class ArtifactList(proto.Message): proto.MESSAGE, number=1, message=artifact.Artifact, ) - task_id = proto.Field(proto.INT64, number=1) - - parent_task_id = proto.Field(proto.INT64, number=12) - - task_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - + task_id = proto.Field(proto.INT64, number=1,) + parent_task_id = proto.Field(proto.INT64, number=12,) + task_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) executor_detail = proto.Field( proto.MESSAGE, number=6, message="PipelineTaskExecutorDetail", ) - state = proto.Field(proto.ENUM, number=7, enum=State,) - execution = proto.Field(proto.MESSAGE, number=8, message=gca_execution.Execution,) - - error = proto.Field(proto.MESSAGE, number=9, message=status.Status,) - + error = proto.Field(proto.MESSAGE, number=9, message=status_pb2.Status,) inputs = proto.MapField( proto.STRING, proto.MESSAGE, number=10, message=ArtifactList, ) - outputs = proto.MapField( proto.STRING, proto.MESSAGE, number=11, message=ArtifactList, ) @@ -297,7 +261,6 @@ class ArtifactList(proto.Message): class PipelineTaskExecutorDetail(proto.Message): r"""The runtime detail of a pipeline executor. - Attributes: container_detail (google.cloud.aiplatform_v1beta1.types.PipelineTaskExecutorDetail.ContainerDetail): Output only. The detailed info for a @@ -326,25 +289,22 @@ class ContainerDetail(proto.Message): events. """ - main_job = proto.Field(proto.STRING, number=1) - - pre_caching_check_job = proto.Field(proto.STRING, number=2) + main_job = proto.Field(proto.STRING, number=1,) + pre_caching_check_job = proto.Field(proto.STRING, number=2,) class CustomJobDetail(proto.Message): r"""The detailed info for a custom job executor. - Attributes: job (str): Output only. The name of the [CustomJob][google.cloud.aiplatform.v1beta1.CustomJob]. """ - job = proto.Field(proto.STRING, number=1) + job = proto.Field(proto.STRING, number=1,) container_detail = proto.Field( proto.MESSAGE, number=1, oneof="details", message=ContainerDetail, ) - custom_job_detail = proto.Field( proto.MESSAGE, number=2, oneof="details", message=CustomJobDetail, ) diff --git a/google/cloud/aiplatform_v1beta1/types/pipeline_service.py b/google/cloud/aiplatform_v1beta1/types/pipeline_service.py index ce51990e4d..f2ba495371 100644 --- a/google/cloud/aiplatform_v1beta1/types/pipeline_service.py +++ b/google/cloud/aiplatform_v1beta1/types/pipeline_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,15 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import pipeline_job as gca_pipeline_job from google.cloud.aiplatform_v1beta1.types import ( training_pipeline as gca_training_pipeline, ) -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -57,8 +54,7 @@ class CreateTrainingPipelineRequest(proto.Message): Required. The TrainingPipeline to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) training_pipeline = proto.Field( proto.MESSAGE, number=2, message=gca_training_pipeline.TrainingPipeline, ) @@ -74,7 +70,7 @@ class GetTrainingPipelineRequest(proto.Message): ``projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListTrainingPipelinesRequest(proto.Message): @@ -114,15 +110,11 @@ class ListTrainingPipelinesRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) class ListTrainingPipelinesResponse(proto.Message): @@ -146,8 +138,7 @@ def raw_page(self): training_pipelines = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_training_pipeline.TrainingPipeline, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteTrainingPipelineRequest(proto.Message): @@ -161,7 +152,7 @@ class DeleteTrainingPipelineRequest(proto.Message): ``projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelTrainingPipelineRequest(proto.Message): @@ -175,7 +166,7 @@ class CancelTrainingPipelineRequest(proto.Message): ``projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreatePipelineJobRequest(proto.Message): @@ -198,13 +189,11 @@ class CreatePipelineJobRequest(proto.Message): characters are /[a-z][0-9]-/. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) pipeline_job = proto.Field( proto.MESSAGE, number=2, message=gca_pipeline_job.PipelineJob, ) - - pipeline_job_id = proto.Field(proto.STRING, number=3) + pipeline_job_id = proto.Field(proto.STRING, number=3,) class GetPipelineJobRequest(proto.Message): @@ -217,7 +206,7 @@ class GetPipelineJobRequest(proto.Message): ``projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListPipelineJobsRequest(proto.Message): @@ -251,13 +240,10 @@ class ListPipelineJobsRequest(proto.Message): call. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) class ListPipelineJobsResponse(proto.Message): @@ -280,8 +266,7 @@ def raw_page(self): pipeline_jobs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_pipeline_job.PipelineJob, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeletePipelineJobRequest(proto.Message): @@ -295,7 +280,7 @@ class DeletePipelineJobRequest(proto.Message): ``projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CancelPipelineJobRequest(proto.Message): @@ -308,7 +293,7 @@ class CancelPipelineJobRequest(proto.Message): ``projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/pipeline_state.py b/google/cloud/aiplatform_v1beta1/types/pipeline_state.py index cede653bd6..c8e864640e 100644 --- a/google/cloud/aiplatform_v1beta1/types/pipeline_state.py +++ b/google/cloud/aiplatform_v1beta1/types/pipeline_state.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore diff --git a/google/cloud/aiplatform_v1beta1/types/prediction_service.py b/google/cloud/aiplatform_v1beta1/types/prediction_service.py index 14eaa6b8fd..669b28a66a 100644 --- a/google/cloud/aiplatform_v1beta1/types/prediction_service.py +++ b/google/cloud/aiplatform_v1beta1/types/prediction_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import explanation -from google.protobuf import struct_pb2 as struct # type: ignore +from google.protobuf import struct_pb2 # type: ignore __protobuf__ = proto.module( @@ -63,11 +60,9 @@ class PredictRequest(proto.Message): [parameters_schema_uri][google.cloud.aiplatform.v1beta1.PredictSchemata.parameters_schema_uri]. """ - endpoint = proto.Field(proto.STRING, number=1) - - instances = proto.RepeatedField(proto.MESSAGE, number=2, message=struct.Value,) - - parameters = proto.Field(proto.MESSAGE, number=3, message=struct.Value,) + endpoint = proto.Field(proto.STRING, number=1,) + instances = proto.RepeatedField(proto.MESSAGE, number=2, message=struct_pb2.Value,) + parameters = proto.Field(proto.MESSAGE, number=3, message=struct_pb2.Value,) class PredictResponse(proto.Message): @@ -87,9 +82,10 @@ class PredictResponse(proto.Message): served this prediction. """ - predictions = proto.RepeatedField(proto.MESSAGE, number=1, message=struct.Value,) - - deployed_model_id = proto.Field(proto.STRING, number=2) + predictions = proto.RepeatedField( + proto.MESSAGE, number=1, message=struct_pb2.Value, + ) + deployed_model_id = proto.Field(proto.STRING, number=2,) class ExplainRequest(proto.Message): @@ -137,17 +133,13 @@ class ExplainRequest(proto.Message): [Endpoint.traffic_split][google.cloud.aiplatform.v1beta1.Endpoint.traffic_split]. """ - endpoint = proto.Field(proto.STRING, number=1) - - instances = proto.RepeatedField(proto.MESSAGE, number=2, message=struct.Value,) - - parameters = proto.Field(proto.MESSAGE, number=4, message=struct.Value,) - + endpoint = proto.Field(proto.STRING, number=1,) + instances = proto.RepeatedField(proto.MESSAGE, number=2, message=struct_pb2.Value,) + parameters = proto.Field(proto.MESSAGE, number=4, message=struct_pb2.Value,) explanation_spec_override = proto.Field( proto.MESSAGE, number=5, message=explanation.ExplanationSpecOverride, ) - - deployed_model_id = proto.Field(proto.STRING, number=3) + deployed_model_id = proto.Field(proto.STRING, number=3,) class ExplainResponse(proto.Message): @@ -174,10 +166,10 @@ class ExplainResponse(proto.Message): explanations = proto.RepeatedField( proto.MESSAGE, number=1, message=explanation.Explanation, ) - - deployed_model_id = proto.Field(proto.STRING, number=2) - - predictions = proto.RepeatedField(proto.MESSAGE, number=3, message=struct.Value,) + deployed_model_id = proto.Field(proto.STRING, number=2,) + predictions = proto.RepeatedField( + proto.MESSAGE, number=3, message=struct_pb2.Value, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/specialist_pool.py b/google/cloud/aiplatform_v1beta1/types/specialist_pool.py index 4ac8c6a709..0e7fe971e9 100644 --- a/google/cloud/aiplatform_v1beta1/types/specialist_pool.py +++ b/google/cloud/aiplatform_v1beta1/types/specialist_pool.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -54,15 +52,11 @@ class SpecialistPool(proto.Message): data labeling jobs. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - specialist_managers_count = proto.Field(proto.INT32, number=3) - - specialist_manager_emails = proto.RepeatedField(proto.STRING, number=4) - - pending_data_labeling_jobs = proto.RepeatedField(proto.STRING, number=5) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + specialist_managers_count = proto.Field(proto.INT32, number=3,) + specialist_manager_emails = proto.RepeatedField(proto.STRING, number=4,) + pending_data_labeling_jobs = proto.RepeatedField(proto.STRING, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/specialist_pool_service.py b/google/cloud/aiplatform_v1beta1/types/specialist_pool_service.py index 955b1e5a53..09d93d1c16 100644 --- a/google/cloud/aiplatform_v1beta1/types/specialist_pool_service.py +++ b/google/cloud/aiplatform_v1beta1/types/specialist_pool_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import operation from google.cloud.aiplatform_v1beta1.types import specialist_pool as gca_specialist_pool -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -51,8 +48,7 @@ class CreateSpecialistPoolRequest(proto.Message): Required. The SpecialistPool to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) specialist_pool = proto.Field( proto.MESSAGE, number=2, message=gca_specialist_pool.SpecialistPool, ) @@ -83,7 +79,7 @@ class GetSpecialistPoolRequest(proto.Message): ``projects/{project}/locations/{location}/specialistPools/{specialist_pool}``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListSpecialistPoolsRequest(proto.Message): @@ -107,13 +103,10 @@ class ListSpecialistPoolsRequest(proto.Message): FieldMask represents a set of """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - read_mask = proto.Field(proto.MESSAGE, number=4, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + read_mask = proto.Field(proto.MESSAGE, number=4, message=field_mask_pb2.FieldMask,) class ListSpecialistPoolsResponse(proto.Message): @@ -135,8 +128,7 @@ def raw_page(self): specialist_pools = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_specialist_pool.SpecialistPool, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteSpecialistPoolRequest(proto.Message): @@ -155,9 +147,8 @@ class DeleteSpecialistPoolRequest(proto.Message): SpecialistPool has no specialist managers.) """ - name = proto.Field(proto.STRING, number=1) - - force = proto.Field(proto.BOOL, number=2) + name = proto.Field(proto.STRING, number=1,) + force = proto.Field(proto.BOOL, number=2,) class UpdateSpecialistPoolRequest(proto.Message): @@ -176,8 +167,9 @@ class UpdateSpecialistPoolRequest(proto.Message): specialist_pool = proto.Field( proto.MESSAGE, number=1, message=gca_specialist_pool.SpecialistPool, ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class UpdateSpecialistPoolOperationMetadata(proto.Message): @@ -193,8 +185,7 @@ class UpdateSpecialistPoolOperationMetadata(proto.Message): The operation generic information. """ - specialist_pool = proto.Field(proto.STRING, number=1) - + specialist_pool = proto.Field(proto.STRING, number=1,) generic_metadata = proto.Field( proto.MESSAGE, number=2, message=operation.GenericOperationMetadata, ) diff --git a/google/cloud/aiplatform_v1beta1/types/study.py b/google/cloud/aiplatform_v1beta1/types/study.py index b89652b37d..63e58e5f42 100644 --- a/google/cloud/aiplatform_v1beta1/types/study.py +++ b/google/cloud/aiplatform_v1beta1/types/study.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -31,7 +28,6 @@ class Study(proto.Message): r"""A message representing a Study. - Attributes: name (str): Output only. The name of a study. The study's globally @@ -60,17 +56,12 @@ class State(proto.Enum): INACTIVE = 2 COMPLETED = 3 - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) study_spec = proto.Field(proto.MESSAGE, number=3, message="StudySpec",) - state = proto.Field(proto.ENUM, number=4, enum=State,) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - inactive_reason = proto.Field(proto.STRING, number=6) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + inactive_reason = proto.Field(proto.STRING, number=6,) class Trial(proto.Message): @@ -133,7 +124,6 @@ class State(proto.Enum): class Parameter(proto.Message): r"""A message representing a parameter to be tuned. - Attributes: parameter_id (str): Output only. The ID of the parameter. The parameter should @@ -147,36 +137,24 @@ class Parameter(proto.Message): 'CATEGORICAL'. """ - parameter_id = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.MESSAGE, number=2, message=struct.Value,) - - name = proto.Field(proto.STRING, number=1) - - id = proto.Field(proto.STRING, number=2) + parameter_id = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.MESSAGE, number=2, message=struct_pb2.Value,) + name = proto.Field(proto.STRING, number=1,) + id = proto.Field(proto.STRING, number=2,) state = proto.Field(proto.ENUM, number=3, enum=State,) - parameters = proto.RepeatedField(proto.MESSAGE, number=4, message=Parameter,) - final_measurement = proto.Field(proto.MESSAGE, number=5, message="Measurement",) - measurements = proto.RepeatedField(proto.MESSAGE, number=6, message="Measurement",) - - start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - client_id = proto.Field(proto.STRING, number=9) - - infeasible_reason = proto.Field(proto.STRING, number=10) - - custom_job = proto.Field(proto.STRING, number=11) + start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + client_id = proto.Field(proto.STRING, number=9,) + infeasible_reason = proto.Field(proto.STRING, number=10,) + custom_job = proto.Field(proto.STRING, number=11,) class StudySpec(proto.Message): r"""Represents specification of a Study. - Attributes: decay_curve_stopping_spec (google.cloud.aiplatform_v1beta1.types.StudySpec.DecayCurveAutomatedStoppingSpec): The automated early stopping spec using decay @@ -238,7 +216,6 @@ class MeasurementSelectionType(proto.Enum): class MetricSpec(proto.Message): r"""Represents a metric to optimize. - Attributes: metric_id (str): Required. The ID of the metric. Must not @@ -255,13 +232,11 @@ class GoalType(proto.Enum): MAXIMIZE = 1 MINIMIZE = 2 - metric_id = proto.Field(proto.STRING, number=1) - + metric_id = proto.Field(proto.STRING, number=1,) goal = proto.Field(proto.ENUM, number=2, enum="StudySpec.MetricSpec.GoalType",) class ParameterSpec(proto.Message): r"""Represents a single parameter to optimize. - Attributes: double_value_spec (google.cloud.aiplatform_v1beta1.types.StudySpec.ParameterSpec.DoubleValueSpec): The value spec for a 'DOUBLE' parameter. @@ -295,7 +270,6 @@ class ScaleType(proto.Enum): class DoubleValueSpec(proto.Message): r"""Value specification for a parameter in ``DOUBLE`` type. - Attributes: min_value (float): Required. Inclusive minimum value of the @@ -305,13 +279,11 @@ class DoubleValueSpec(proto.Message): parameter. """ - min_value = proto.Field(proto.DOUBLE, number=1) - - max_value = proto.Field(proto.DOUBLE, number=2) + min_value = proto.Field(proto.DOUBLE, number=1,) + max_value = proto.Field(proto.DOUBLE, number=2,) class IntegerValueSpec(proto.Message): r"""Value specification for a parameter in ``INTEGER`` type. - Attributes: min_value (int): Required. Inclusive minimum value of the @@ -321,23 +293,20 @@ class IntegerValueSpec(proto.Message): parameter. """ - min_value = proto.Field(proto.INT64, number=1) - - max_value = proto.Field(proto.INT64, number=2) + min_value = proto.Field(proto.INT64, number=1,) + max_value = proto.Field(proto.INT64, number=2,) class CategoricalValueSpec(proto.Message): r"""Value specification for a parameter in ``CATEGORICAL`` type. - Attributes: values (Sequence[str]): Required. The list of possible categories. """ - values = proto.RepeatedField(proto.STRING, number=1) + values = proto.RepeatedField(proto.STRING, number=1,) class DiscreteValueSpec(proto.Message): r"""Value specification for a parameter in ``DISCRETE`` type. - Attributes: values (Sequence[float]): Required. A list of possible values. @@ -348,7 +317,7 @@ class DiscreteValueSpec(proto.Message): 1,000 values. """ - values = proto.RepeatedField(proto.DOUBLE, number=1) + values = proto.RepeatedField(proto.DOUBLE, number=1,) class ConditionalParameterSpec(proto.Message): r"""Represents a parameter spec with condition from its parent @@ -382,7 +351,7 @@ class DiscreteValueCondition(proto.Message): The Epsilon of the value matching is 1e-10. """ - values = proto.RepeatedField(proto.DOUBLE, number=1) + values = proto.RepeatedField(proto.DOUBLE, number=1,) class IntValueCondition(proto.Message): r"""Represents the spec to match integer values from parent @@ -395,7 +364,7 @@ class IntValueCondition(proto.Message): ``integer_value_spec`` of parent parameter. """ - values = proto.RepeatedField(proto.INT64, number=1) + values = proto.RepeatedField(proto.INT64, number=1,) class CategoricalValueCondition(proto.Message): r"""Represents the spec to match categorical values from parent @@ -408,7 +377,7 @@ class CategoricalValueCondition(proto.Message): ``categorical_value_spec`` of parent parameter. """ - values = proto.RepeatedField(proto.STRING, number=1) + values = proto.RepeatedField(proto.STRING, number=1,) parent_discrete_values = proto.Field( proto.MESSAGE, @@ -416,21 +385,18 @@ class CategoricalValueCondition(proto.Message): oneof="parent_value_condition", message="StudySpec.ParameterSpec.ConditionalParameterSpec.DiscreteValueCondition", ) - parent_int_values = proto.Field( proto.MESSAGE, number=3, oneof="parent_value_condition", message="StudySpec.ParameterSpec.ConditionalParameterSpec.IntValueCondition", ) - parent_categorical_values = proto.Field( proto.MESSAGE, number=4, oneof="parent_value_condition", message="StudySpec.ParameterSpec.ConditionalParameterSpec.CategoricalValueCondition", ) - parameter_spec = proto.Field( proto.MESSAGE, number=1, message="StudySpec.ParameterSpec", ) @@ -441,34 +407,28 @@ class CategoricalValueCondition(proto.Message): oneof="parameter_value_spec", message="StudySpec.ParameterSpec.DoubleValueSpec", ) - integer_value_spec = proto.Field( proto.MESSAGE, number=3, oneof="parameter_value_spec", message="StudySpec.ParameterSpec.IntegerValueSpec", ) - categorical_value_spec = proto.Field( proto.MESSAGE, number=4, oneof="parameter_value_spec", message="StudySpec.ParameterSpec.CategoricalValueSpec", ) - discrete_value_spec = proto.Field( proto.MESSAGE, number=5, oneof="parameter_value_spec", message="StudySpec.ParameterSpec.DiscreteValueSpec", ) - - parameter_id = proto.Field(proto.STRING, number=1) - + parameter_id = proto.Field(proto.STRING, number=1,) scale_type = proto.Field( proto.ENUM, number=6, enum="StudySpec.ParameterSpec.ScaleType", ) - conditional_parameter_specs = proto.RepeatedField( proto.MESSAGE, number=10, @@ -492,7 +452,7 @@ class DecayCurveAutomatedStoppingSpec(proto.Message): will be used as the x-axis. """ - use_elapsed_duration = proto.Field(proto.BOOL, number=1) + use_elapsed_duration = proto.Field(proto.BOOL, number=1,) class MedianAutomatedStoppingSpec(proto.Message): r"""The median automated stopping rule stops a pending Trial if the @@ -511,11 +471,10 @@ class MedianAutomatedStoppingSpec(proto.Message): for each completed Trials. """ - use_elapsed_duration = proto.Field(proto.BOOL, number=1) + use_elapsed_duration = proto.Field(proto.BOOL, number=1,) class ConvexStopConfig(proto.Message): r"""Configuration for ConvexStopPolicy. - Attributes: max_num_steps (int): Steps used in predicting the final objective for early @@ -551,15 +510,11 @@ class ConvexStopConfig(proto.Message): and min_elapsed_seconds. """ - max_num_steps = proto.Field(proto.INT64, number=1) - - min_num_steps = proto.Field(proto.INT64, number=2) - - autoregressive_order = proto.Field(proto.INT64, number=3) - - learning_rate_parameter_name = proto.Field(proto.STRING, number=4) - - use_seconds = proto.Field(proto.BOOL, number=5) + max_num_steps = proto.Field(proto.INT64, number=1,) + min_num_steps = proto.Field(proto.INT64, number=2,) + autoregressive_order = proto.Field(proto.INT64, number=3,) + learning_rate_parameter_name = proto.Field(proto.STRING, number=4,) + use_seconds = proto.Field(proto.BOOL, number=5,) decay_curve_stopping_spec = proto.Field( proto.MESSAGE, @@ -567,29 +522,22 @@ class ConvexStopConfig(proto.Message): oneof="automated_stopping_spec", message=DecayCurveAutomatedStoppingSpec, ) - median_automated_stopping_spec = proto.Field( proto.MESSAGE, number=5, oneof="automated_stopping_spec", message=MedianAutomatedStoppingSpec, ) - convex_stop_config = proto.Field( proto.MESSAGE, number=8, oneof="automated_stopping_spec", message=ConvexStopConfig, ) - metrics = proto.RepeatedField(proto.MESSAGE, number=1, message=MetricSpec,) - parameters = proto.RepeatedField(proto.MESSAGE, number=2, message=ParameterSpec,) - algorithm = proto.Field(proto.ENUM, number=3, enum=Algorithm,) - observation_noise = proto.Field(proto.ENUM, number=6, enum=ObservationNoise,) - measurement_selection_type = proto.Field( proto.ENUM, number=7, enum=MeasurementSelectionType, ) @@ -616,7 +564,6 @@ class Measurement(proto.Message): class Metric(proto.Message): r"""A message representing a metric in the measurement. - Attributes: metric_id (str): Output only. The ID of the Metric. The Metric should be @@ -626,14 +573,13 @@ class Metric(proto.Message): Output only. The value for this metric. """ - metric_id = proto.Field(proto.STRING, number=1) - - value = proto.Field(proto.DOUBLE, number=2) - - elapsed_duration = proto.Field(proto.MESSAGE, number=1, message=duration.Duration,) - - step_count = proto.Field(proto.INT64, number=2) + metric_id = proto.Field(proto.STRING, number=1,) + value = proto.Field(proto.DOUBLE, number=2,) + elapsed_duration = proto.Field( + proto.MESSAGE, number=1, message=duration_pb2.Duration, + ) + step_count = proto.Field(proto.INT64, number=2,) metrics = proto.RepeatedField(proto.MESSAGE, number=3, message=Metric,) diff --git a/google/cloud/aiplatform_v1beta1/types/tensorboard.py b/google/cloud/aiplatform_v1beta1/types/tensorboard.py index 45db95e7fb..aa04ae2551 100644 --- a/google/cloud/aiplatform_v1beta1/types/tensorboard.py +++ b/google/cloud/aiplatform_v1beta1/types/tensorboard.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -28,7 +25,7 @@ class Tensorboard(proto.Message): - r"""Tensorboard is a physical database that stores users’ + r"""Tensorboard is a physical database that stores users' training metrics. A default Tensorboard is provided in each region of a GCP project. If needed users can also create extra Tensorboards in their projects. @@ -82,27 +79,18 @@ class Tensorboard(proto.Message): update happens. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) encryption_spec = proto.Field( proto.MESSAGE, number=11, message=gca_encryption_spec.EncryptionSpec, ) - - blob_storage_path_prefix = proto.Field(proto.STRING, number=10) - - run_count = proto.Field(proto.INT32, number=5) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=8) - - etag = proto.Field(proto.STRING, number=9) + blob_storage_path_prefix = proto.Field(proto.STRING, number=10,) + run_count = proto.Field(proto.INT32, number=5,) + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=8,) + etag = proto.Field(proto.STRING, number=9,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/tensorboard_data.py b/google/cloud/aiplatform_v1beta1/types/tensorboard_data.py index cd217297fc..30e9e4a749 100644 --- a/google/cloud/aiplatform_v1beta1/types/tensorboard_data.py +++ b/google/cloud/aiplatform_v1beta1/types/tensorboard_data.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import tensorboard_time_series -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -37,7 +34,6 @@ class TimeSeriesData(proto.Message): r"""All the data stored in a TensorboardTimeSeries. - Attributes: tensorboard_time_series_id (str): Required. The ID of the @@ -52,14 +48,12 @@ class TimeSeriesData(proto.Message): Required. Data points in this time series. """ - tensorboard_time_series_id = proto.Field(proto.STRING, number=1) - + tensorboard_time_series_id = proto.Field(proto.STRING, number=1,) value_type = proto.Field( proto.ENUM, number=2, enum=tensorboard_time_series.TensorboardTimeSeries.ValueType, ) - values = proto.RepeatedField( proto.MESSAGE, number=3, message="TimeSeriesDataPoint", ) @@ -67,7 +61,6 @@ class TimeSeriesData(proto.Message): class TimeSeriesDataPoint(proto.Message): r"""A TensorboardTimeSeries data point. - Attributes: scalar (google.cloud.aiplatform_v1beta1.types.Scalar): A scalar value. @@ -83,34 +76,28 @@ class TimeSeriesDataPoint(proto.Message): """ scalar = proto.Field(proto.MESSAGE, number=3, oneof="value", message="Scalar",) - tensor = proto.Field( proto.MESSAGE, number=4, oneof="value", message="TensorboardTensor", ) - blobs = proto.Field( proto.MESSAGE, number=5, oneof="value", message="TensorboardBlobSequence", ) - - wall_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) - - step = proto.Field(proto.INT64, number=2) + wall_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + step = proto.Field(proto.INT64, number=2,) class Scalar(proto.Message): r"""One point viewable on a scalar metric plot. - Attributes: value (float): Value of the point at this step / timestamp. """ - value = proto.Field(proto.DOUBLE, number=1) + value = proto.Field(proto.DOUBLE, number=1,) class TensorboardTensor(proto.Message): r"""One point viewable on a tensor metric plot. - Attributes: value (bytes): Required. Serialized form of @@ -120,9 +107,8 @@ class TensorboardTensor(proto.Message): [value][google.cloud.aiplatform.v1beta1.TensorboardTensor.value]. """ - value = proto.Field(proto.BYTES, number=1) - - version_number = proto.Field(proto.INT32, number=2) + value = proto.Field(proto.BYTES, number=1,) + version_number = proto.Field(proto.INT32, number=2,) class TensorboardBlobSequence(proto.Message): @@ -140,7 +126,6 @@ class TensorboardBlobSequence(proto.Message): class TensorboardBlob(proto.Message): r"""One blob (e.g, image, graph) viewable on a blob metric plot. - Attributes: id (str): Output only. A URI safe key uniquely @@ -153,9 +138,8 @@ class TensorboardBlob(proto.Message): ReadTensorboardBlobData endpoint. """ - id = proto.Field(proto.STRING, number=1) - - data = proto.Field(proto.BYTES, number=2) + id = proto.Field(proto.STRING, number=1,) + data = proto.Field(proto.BYTES, number=2,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/tensorboard_experiment.py b/google/cloud/aiplatform_v1beta1/types/tensorboard_experiment.py index 6c073aa5e8..0703252eca 100644 --- a/google/cloud/aiplatform_v1beta1/types/tensorboard_experiment.py +++ b/google/cloud/aiplatform_v1beta1/types/tensorboard_experiment.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -75,21 +72,14 @@ class TensorboardExperiment(proto.Message): training job. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=6) - - etag = proto.Field(proto.STRING, number=7) - - source = proto.Field(proto.STRING, number=8) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=6,) + etag = proto.Field(proto.STRING, number=7,) + source = proto.Field(proto.STRING, number=8,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/tensorboard_run.py b/google/cloud/aiplatform_v1beta1/types/tensorboard_run.py index f9cff272c4..030d8de1cf 100644 --- a/google/cloud/aiplatform_v1beta1/types/tensorboard_run.py +++ b/google/cloud/aiplatform_v1beta1/types/tensorboard_run.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -56,19 +53,13 @@ class TensorboardRun(proto.Message): update happens. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=8) - - etag = proto.Field(proto.STRING, number=9) + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=8,) + etag = proto.Field(proto.STRING, number=9,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/tensorboard_service.py b/google/cloud/aiplatform_v1beta1/types/tensorboard_service.py index 32b7aa3dbe..0691fd97d3 100644 --- a/google/cloud/aiplatform_v1beta1/types/tensorboard_service.py +++ b/google/cloud/aiplatform_v1beta1/types/tensorboard_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import operation from google.cloud.aiplatform_v1beta1.types import tensorboard as gca_tensorboard from google.cloud.aiplatform_v1beta1.types import tensorboard_data @@ -28,7 +25,7 @@ from google.cloud.aiplatform_v1beta1.types import ( tensorboard_time_series as gca_tensorboard_time_series, ) -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore __protobuf__ = proto.module( @@ -85,8 +82,7 @@ class CreateTensorboardRequest(proto.Message): Required. The Tensorboard to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) tensorboard = proto.Field( proto.MESSAGE, number=2, message=gca_tensorboard.Tensorboard, ) @@ -102,7 +98,7 @@ class GetTensorboardRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListTensorboardsRequest(proto.Message): @@ -137,17 +133,12 @@ class ListTensorboardsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) - - read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) + read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask_pb2.FieldMask,) class ListTensorboardsResponse(proto.Message): @@ -171,8 +162,7 @@ def raw_page(self): tensorboards = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_tensorboard.Tensorboard, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateTensorboardRequest(proto.Message): @@ -194,8 +184,9 @@ class UpdateTensorboardRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}`` """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) tensorboard = proto.Field( proto.MESSAGE, number=2, message=gca_tensorboard.Tensorboard, ) @@ -211,7 +202,7 @@ class DeleteTensorboardRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateTensorboardExperimentRequest(proto.Message): @@ -234,15 +225,13 @@ class CreateTensorboardExperimentRequest(proto.Message): are /[a-z][0-9]-/. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) tensorboard_experiment = proto.Field( proto.MESSAGE, number=2, message=gca_tensorboard_experiment.TensorboardExperiment, ) - - tensorboard_experiment_id = proto.Field(proto.STRING, number=3) + tensorboard_experiment_id = proto.Field(proto.STRING, number=3,) class GetTensorboardExperimentRequest(proto.Message): @@ -256,7 +245,7 @@ class GetTensorboardExperimentRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListTensorboardExperimentsRequest(proto.Message): @@ -293,17 +282,12 @@ class ListTensorboardExperimentsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) - - read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) + read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask_pb2.FieldMask,) class ListTensorboardExperimentsResponse(proto.Message): @@ -330,8 +314,7 @@ def raw_page(self): number=1, message=gca_tensorboard_experiment.TensorboardExperiment, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateTensorboardExperimentRequest(proto.Message): @@ -353,8 +336,9 @@ class UpdateTensorboardExperimentRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}`` """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) tensorboard_experiment = proto.Field( proto.MESSAGE, number=2, @@ -373,7 +357,7 @@ class DeleteTensorboardExperimentRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateTensorboardRunRequest(proto.Message): @@ -396,13 +380,11 @@ class CreateTensorboardRunRequest(proto.Message): are /[a-z][0-9]-/. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) tensorboard_run = proto.Field( proto.MESSAGE, number=2, message=gca_tensorboard_run.TensorboardRun, ) - - tensorboard_run_id = proto.Field(proto.STRING, number=3) + tensorboard_run_id = proto.Field(proto.STRING, number=3,) class GetTensorboardRunRequest(proto.Message): @@ -415,7 +397,7 @@ class GetTensorboardRunRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ReadTensorboardBlobDataRequest(proto.Message): @@ -431,9 +413,8 @@ class ReadTensorboardBlobDataRequest(proto.Message): IDs of the blobs to read. """ - time_series = proto.Field(proto.STRING, number=1) - - blob_ids = proto.RepeatedField(proto.STRING, number=2) + time_series = proto.Field(proto.STRING, number=1,) + blob_ids = proto.RepeatedField(proto.STRING, number=2,) class ReadTensorboardBlobDataResponse(proto.Message): @@ -483,17 +464,12 @@ class ListTensorboardRunsRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) - - read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) + read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask_pb2.FieldMask,) class ListTensorboardRunsResponse(proto.Message): @@ -517,8 +493,7 @@ def raw_page(self): tensorboard_runs = proto.RepeatedField( proto.MESSAGE, number=1, message=gca_tensorboard_run.TensorboardRun, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateTensorboardRunRequest(proto.Message): @@ -540,8 +515,9 @@ class UpdateTensorboardRunRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}`` """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) tensorboard_run = proto.Field( proto.MESSAGE, number=2, message=gca_tensorboard_run.TensorboardRun, ) @@ -558,7 +534,7 @@ class DeleteTensorboardRunRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateTensorboardTimeSeriesRequest(proto.Message): @@ -582,10 +558,8 @@ class CreateTensorboardTimeSeriesRequest(proto.Message): create. """ - parent = proto.Field(proto.STRING, number=1) - - tensorboard_time_series_id = proto.Field(proto.STRING, number=3) - + parent = proto.Field(proto.STRING, number=1,) + tensorboard_time_series_id = proto.Field(proto.STRING, number=3,) tensorboard_time_series = proto.Field( proto.MESSAGE, number=2, @@ -604,7 +578,7 @@ class GetTensorboardTimeSeriesRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}/timeSeries/{time_series}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListTensorboardTimeSeriesRequest(proto.Message): @@ -641,17 +615,12 @@ class ListTensorboardTimeSeriesRequest(proto.Message): Mask specifying which fields to read. """ - parent = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) - - read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask.FieldMask,) + parent = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) + read_mask = proto.Field(proto.MESSAGE, number=6, message=field_mask_pb2.FieldMask,) class ListTensorboardTimeSeriesResponse(proto.Message): @@ -678,8 +647,7 @@ def raw_page(self): number=1, message=gca_tensorboard_time_series.TensorboardTimeSeries, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class UpdateTensorboardTimeSeriesRequest(proto.Message): @@ -701,8 +669,9 @@ class UpdateTensorboardTimeSeriesRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}/timeSeries/{time_series}`` """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) tensorboard_time_series = proto.Field( proto.MESSAGE, number=2, @@ -721,7 +690,7 @@ class DeleteTensorboardTimeSeriesRequest(proto.Message): ``projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}/timeSeries/{time_series}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ReadTensorboardTimeSeriesDataRequest(proto.Message): @@ -743,11 +712,9 @@ class ReadTensorboardTimeSeriesDataRequest(proto.Message): match the filter expression. """ - tensorboard_time_series = proto.Field(proto.STRING, number=1) - - max_data_points = proto.Field(proto.INT32, number=2) - - filter = proto.Field(proto.STRING, number=3) + tensorboard_time_series = proto.Field(proto.STRING, number=1,) + max_data_points = proto.Field(proto.INT32, number=2,) + filter = proto.Field(proto.STRING, number=3,) class ReadTensorboardTimeSeriesDataResponse(proto.Message): @@ -783,8 +750,7 @@ class WriteTensorboardRunDataRequest(proto.Message): is 5000. """ - tensorboard_run = proto.Field(proto.STRING, number=1) - + tensorboard_run = proto.Field(proto.STRING, number=1,) time_series_data = proto.RepeatedField( proto.MESSAGE, number=2, message=tensorboard_data.TimeSeriesData, ) @@ -793,7 +759,7 @@ class WriteTensorboardRunDataRequest(proto.Message): class WriteTensorboardRunDataResponse(proto.Message): r"""Response message for [TensorboardService.WriteTensorboardRunData][google.cloud.aiplatform.v1beta1.TensorboardService.WriteTensorboardRunData]. - """ + """ class ExportTensorboardTimeSeriesDataRequest(proto.Message): @@ -827,15 +793,11 @@ class ExportTensorboardTimeSeriesDataRequest(proto.Message): a pseudo random order. """ - tensorboard_time_series = proto.Field(proto.STRING, number=1) - - filter = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + tensorboard_time_series = proto.Field(proto.STRING, number=1,) + filter = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ExportTensorboardTimeSeriesDataResponse(proto.Message): @@ -859,13 +821,11 @@ def raw_page(self): time_series_data_points = proto.RepeatedField( proto.MESSAGE, number=1, message=tensorboard_data.TimeSeriesDataPoint, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class CreateTensorboardOperationMetadata(proto.Message): r"""Details of operations that perform create Tensorboard. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Tensorboard. @@ -878,7 +838,6 @@ class CreateTensorboardOperationMetadata(proto.Message): class UpdateTensorboardOperationMetadata(proto.Message): r"""Details of operations that perform update Tensorboard. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for Tensorboard. diff --git a/google/cloud/aiplatform_v1beta1/types/tensorboard_time_series.py b/google/cloud/aiplatform_v1beta1/types/tensorboard_time_series.py index 47a66d38f6..1eb895ae36 100644 --- a/google/cloud/aiplatform_v1beta1/types/tensorboard_time_series.py +++ b/google/cloud/aiplatform_v1beta1/types/tensorboard_time_series.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -77,7 +74,6 @@ class ValueType(proto.Enum): class Metadata(proto.Message): r"""Describes metadata for a TensorboardTimeSeries. - Attributes: max_step (int): Output only. Max step index of all data @@ -91,32 +87,21 @@ class Metadata(proto.Message): ValueType is BLOB_SEQUENCE. """ - max_step = proto.Field(proto.INT64, number=1) - + max_step = proto.Field(proto.INT64, number=1,) max_wall_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp.Timestamp, + proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, ) + max_blob_sequence_length = proto.Field(proto.INT64, number=3,) - max_blob_sequence_length = proto.Field(proto.INT64, number=3) - - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - - description = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) + description = proto.Field(proto.STRING, number=3,) value_type = proto.Field(proto.ENUM, number=4, enum=ValueType,) - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - etag = proto.Field(proto.STRING, number=7) - - plugin_name = proto.Field(proto.STRING, number=8) - - plugin_data = proto.Field(proto.BYTES, number=9) - + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + etag = proto.Field(proto.STRING, number=7,) + plugin_name = proto.Field(proto.STRING, number=8,) + plugin_data = proto.Field(proto.BYTES, number=9,) metadata = proto.Field(proto.MESSAGE, number=10, message=Metadata,) diff --git a/google/cloud/aiplatform_v1beta1/types/training_pipeline.py b/google/cloud/aiplatform_v1beta1/types/training_pipeline.py index 52c716bfed..4313865bac 100644 --- a/google/cloud/aiplatform_v1beta1/types/training_pipeline.py +++ b/google/cloud/aiplatform_v1beta1/types/training_pipeline.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,17 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec from google.cloud.aiplatform_v1beta1.types import io from google.cloud.aiplatform_v1beta1.types import model from google.cloud.aiplatform_v1beta1.types import pipeline_state -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -151,34 +148,28 @@ class TrainingPipeline(proto.Message): is not set separately. """ - name = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) input_data_config = proto.Field(proto.MESSAGE, number=3, message="InputDataConfig",) - - training_task_definition = proto.Field(proto.STRING, number=4) - - training_task_inputs = proto.Field(proto.MESSAGE, number=5, message=struct.Value,) - - training_task_metadata = proto.Field(proto.MESSAGE, number=6, message=struct.Value,) - + training_task_definition = proto.Field(proto.STRING, number=4,) + training_task_inputs = proto.Field( + proto.MESSAGE, number=5, message=struct_pb2.Value, + ) + training_task_metadata = proto.Field( + proto.MESSAGE, number=6, message=struct_pb2.Value, + ) model_to_upload = proto.Field(proto.MESSAGE, number=7, message=model.Model,) - state = proto.Field(proto.ENUM, number=9, enum=pipeline_state.PipelineState,) - - error = proto.Field(proto.MESSAGE, number=10, message=status.Status,) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=14, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=15) - + error = proto.Field(proto.MESSAGE, number=10, message=status_pb2.Status,) + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + start_time = proto.Field(proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=13, message=timestamp_pb2.Timestamp,) + update_time = proto.Field( + proto.MESSAGE, number=14, message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField(proto.STRING, proto.STRING, number=15,) encryption_spec = proto.Field( proto.MESSAGE, number=18, message=gca_encryption_spec.EncryptionSpec, ) @@ -304,32 +295,24 @@ class InputDataConfig(proto.Message): fraction_split = proto.Field( proto.MESSAGE, number=2, oneof="split", message="FractionSplit", ) - filter_split = proto.Field( proto.MESSAGE, number=3, oneof="split", message="FilterSplit", ) - predefined_split = proto.Field( proto.MESSAGE, number=4, oneof="split", message="PredefinedSplit", ) - timestamp_split = proto.Field( proto.MESSAGE, number=5, oneof="split", message="TimestampSplit", ) - gcs_destination = proto.Field( proto.MESSAGE, number=8, oneof="destination", message=io.GcsDestination, ) - bigquery_destination = proto.Field( proto.MESSAGE, number=10, oneof="destination", message=io.BigQueryDestination, ) - - dataset_id = proto.Field(proto.STRING, number=1) - - annotations_filter = proto.Field(proto.STRING, number=6) - - annotation_schema_uri = proto.Field(proto.STRING, number=9) + dataset_id = proto.Field(proto.STRING, number=1,) + annotations_filter = proto.Field(proto.STRING, number=6,) + annotation_schema_uri = proto.Field(proto.STRING, number=9,) class FractionSplit(proto.Message): @@ -353,11 +336,9 @@ class FractionSplit(proto.Message): used to evaluate the Model. """ - training_fraction = proto.Field(proto.DOUBLE, number=1) - - validation_fraction = proto.Field(proto.DOUBLE, number=2) - - test_fraction = proto.Field(proto.DOUBLE, number=3) + training_fraction = proto.Field(proto.DOUBLE, number=1,) + validation_fraction = proto.Field(proto.DOUBLE, number=2,) + test_fraction = proto.Field(proto.DOUBLE, number=3,) class FilterSplit(proto.Message): @@ -400,11 +381,9 @@ class FilterSplit(proto.Message): test order. """ - training_filter = proto.Field(proto.STRING, number=1) - - validation_filter = proto.Field(proto.STRING, number=2) - - test_filter = proto.Field(proto.STRING, number=3) + training_filter = proto.Field(proto.STRING, number=1,) + validation_filter = proto.Field(proto.STRING, number=2,) + test_filter = proto.Field(proto.STRING, number=3,) class PredefinedSplit(proto.Message): @@ -424,7 +403,7 @@ class PredefinedSplit(proto.Message): ignored by the pipeline. """ - key = proto.Field(proto.STRING, number=1) + key = proto.Field(proto.STRING, number=1,) class TimestampSplit(proto.Message): @@ -453,13 +432,10 @@ class TimestampSplit(proto.Message): value, that piece is ignored by the pipeline. """ - training_fraction = proto.Field(proto.DOUBLE, number=1) - - validation_fraction = proto.Field(proto.DOUBLE, number=2) - - test_fraction = proto.Field(proto.DOUBLE, number=3) - - key = proto.Field(proto.STRING, number=4) + training_fraction = proto.Field(proto.DOUBLE, number=1,) + validation_fraction = proto.Field(proto.DOUBLE, number=2,) + test_fraction = proto.Field(proto.DOUBLE, number=3,) + key = proto.Field(proto.STRING, number=4,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/types.py b/google/cloud/aiplatform_v1beta1/types/types.py index 53581d3bdb..dc46a25c25 100644 --- a/google/cloud/aiplatform_v1beta1/types/types.py +++ b/google/cloud/aiplatform_v1beta1/types/types.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -26,46 +24,42 @@ class BoolArray(proto.Message): r"""A list of boolean values. - Attributes: values (Sequence[bool]): A list of bool values. """ - values = proto.RepeatedField(proto.BOOL, number=1) + values = proto.RepeatedField(proto.BOOL, number=1,) class DoubleArray(proto.Message): r"""A list of double values. - Attributes: values (Sequence[float]): A list of bool values. """ - values = proto.RepeatedField(proto.DOUBLE, number=1) + values = proto.RepeatedField(proto.DOUBLE, number=1,) class Int64Array(proto.Message): r"""A list of int64 values. - Attributes: values (Sequence[int]): A list of int64 values. """ - values = proto.RepeatedField(proto.INT64, number=1) + values = proto.RepeatedField(proto.INT64, number=1,) class StringArray(proto.Message): r"""A list of string values. - Attributes: values (Sequence[str]): A list of string values. """ - values = proto.RepeatedField(proto.STRING, number=1) + values = proto.RepeatedField(proto.STRING, number=1,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/user_action_reference.py b/google/cloud/aiplatform_v1beta1/types/user_action_reference.py index 7c51035fbf..a67f6bb2a0 100644 --- a/google/cloud/aiplatform_v1beta1/types/user_action_reference.py +++ b/google/cloud/aiplatform_v1beta1/types/user_action_reference.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -44,11 +42,9 @@ class UserActionReference(proto.Message): "/google.cloud.aiplatform.{apiVersion}.DatasetService.CreateDataset". """ - operation = proto.Field(proto.STRING, number=1, oneof="reference") - - data_labeling_job = proto.Field(proto.STRING, number=2, oneof="reference") - - method = proto.Field(proto.STRING, number=3) + operation = proto.Field(proto.STRING, number=1, oneof="reference",) + data_labeling_job = proto.Field(proto.STRING, number=2, oneof="reference",) + method = proto.Field(proto.STRING, number=3,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/value.py b/google/cloud/aiplatform_v1beta1/types/value.py index fe79c9e2e8..0ebcb60c30 100644 --- a/google/cloud/aiplatform_v1beta1/types/value.py +++ b/google/cloud/aiplatform_v1beta1/types/value.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore @@ -25,7 +23,6 @@ class Value(proto.Message): r"""Value is the value of the field. - Attributes: int_value (int): An integer value. @@ -35,11 +32,9 @@ class Value(proto.Message): A string value. """ - int_value = proto.Field(proto.INT64, number=1, oneof="value") - - double_value = proto.Field(proto.DOUBLE, number=2, oneof="value") - - string_value = proto.Field(proto.STRING, number=3, oneof="value") + int_value = proto.Field(proto.INT64, number=1, oneof="value",) + double_value = proto.Field(proto.DOUBLE, number=2, oneof="value",) + string_value = proto.Field(proto.STRING, number=3, oneof="value",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/aiplatform_v1beta1/types/vizier_service.py b/google/cloud/aiplatform_v1beta1/types/vizier_service.py index 1808933a7f..2952d92c7e 100644 --- a/google/cloud/aiplatform_v1beta1/types/vizier_service.py +++ b/google/cloud/aiplatform_v1beta1/types/vizier_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.aiplatform_v1beta1.types import operation from google.cloud.aiplatform_v1beta1.types import study as gca_study -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -62,7 +59,7 @@ class GetStudyRequest(proto.Message): ``projects/{project}/locations/{location}/studies/{study}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateStudyRequest(proto.Message): @@ -79,8 +76,7 @@ class CreateStudyRequest(proto.Message): create the Study. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) study = proto.Field(proto.MESSAGE, number=2, message=gca_study.Study,) @@ -103,11 +99,9 @@ class ListStudiesRequest(proto.Message): service will pick an appropriate default. """ - parent = proto.Field(proto.STRING, number=1) - - page_token = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_token = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) class ListStudiesResponse(proto.Message): @@ -128,8 +122,7 @@ def raw_page(self): return self studies = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_study.Study,) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteStudyRequest(proto.Message): @@ -143,7 +136,7 @@ class DeleteStudyRequest(proto.Message): ``projects/{project}/locations/{location}/studies/{study}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class LookupStudyRequest(proto.Message): @@ -159,9 +152,8 @@ class LookupStudyRequest(proto.Message): the Study """ - parent = proto.Field(proto.STRING, number=1) - - display_name = proto.Field(proto.STRING, number=2) + parent = proto.Field(proto.STRING, number=1,) + display_name = proto.Field(proto.STRING, number=2,) class SuggestTrialsRequest(proto.Message): @@ -186,11 +178,9 @@ class SuggestTrialsRequest(proto.Message): Trial if the last suggested Trial was completed. """ - parent = proto.Field(proto.STRING, number=1) - - suggestion_count = proto.Field(proto.INT32, number=2) - - client_id = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + suggestion_count = proto.Field(proto.INT32, number=2,) + client_id = proto.Field(proto.STRING, number=3,) class SuggestTrialsResponse(proto.Message): @@ -210,17 +200,13 @@ class SuggestTrialsResponse(proto.Message): """ trials = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_study.Trial,) - study_state = proto.Field(proto.ENUM, number=2, enum=gca_study.Study.State,) - - start_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + start_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) class SuggestTrialsMetadata(proto.Message): r"""Details of operations that perform Trials suggestion. - Attributes: generic_metadata (google.cloud.aiplatform_v1beta1.types.GenericOperationMetadata): Operation metadata for suggesting Trials. @@ -237,8 +223,7 @@ class SuggestTrialsMetadata(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - - client_id = proto.Field(proto.STRING, number=2) + client_id = proto.Field(proto.STRING, number=2,) class CreateTrialRequest(proto.Message): @@ -254,8 +239,7 @@ class CreateTrialRequest(proto.Message): Required. The Trial to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) trial = proto.Field(proto.MESSAGE, number=2, message=gca_study.Trial,) @@ -269,7 +253,7 @@ class GetTrialRequest(proto.Message): ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListTrialsRequest(proto.Message): @@ -291,11 +275,9 @@ class ListTrialsRequest(proto.Message): service will pick an appropriate default. """ - parent = proto.Field(proto.STRING, number=1) - - page_token = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_token = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) class ListTrialsResponse(proto.Message): @@ -316,8 +298,7 @@ def raw_page(self): return self trials = proto.RepeatedField(proto.MESSAGE, number=1, message=gca_study.Trial,) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class AddTrialMeasurementRequest(proto.Message): @@ -333,8 +314,7 @@ class AddTrialMeasurementRequest(proto.Message): Trial. """ - trial_name = proto.Field(proto.STRING, number=1) - + trial_name = proto.Field(proto.STRING, number=1,) measurement = proto.Field(proto.MESSAGE, number=3, message=gca_study.Measurement,) @@ -360,15 +340,12 @@ class CompleteTrialRequest(proto.Message): ``trial_infeasible`` is true. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) final_measurement = proto.Field( proto.MESSAGE, number=2, message=gca_study.Measurement, ) - - trial_infeasible = proto.Field(proto.BOOL, number=3) - - infeasible_reason = proto.Field(proto.STRING, number=4) + trial_infeasible = proto.Field(proto.BOOL, number=3,) + infeasible_reason = proto.Field(proto.STRING, number=4,) class DeleteTrialRequest(proto.Message): @@ -381,7 +358,7 @@ class DeleteTrialRequest(proto.Message): ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CheckTrialEarlyStoppingStateRequest(proto.Message): @@ -394,7 +371,7 @@ class CheckTrialEarlyStoppingStateRequest(proto.Message): ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` """ - trial_name = proto.Field(proto.STRING, number=1) + trial_name = proto.Field(proto.STRING, number=1,) class CheckTrialEarlyStoppingStateResponse(proto.Message): @@ -406,7 +383,7 @@ class CheckTrialEarlyStoppingStateResponse(proto.Message): True if the Trial should stop. """ - should_stop = proto.Field(proto.BOOL, number=1) + should_stop = proto.Field(proto.BOOL, number=1,) class CheckTrialEarlyStoppingStateMetatdata(proto.Message): @@ -427,10 +404,8 @@ class CheckTrialEarlyStoppingStateMetatdata(proto.Message): generic_metadata = proto.Field( proto.MESSAGE, number=1, message=operation.GenericOperationMetadata, ) - - study = proto.Field(proto.STRING, number=2) - - trial = proto.Field(proto.STRING, number=3) + study = proto.Field(proto.STRING, number=2,) + trial = proto.Field(proto.STRING, number=3,) class StopTrialRequest(proto.Message): @@ -443,7 +418,7 @@ class StopTrialRequest(proto.Message): ``projects/{project}/locations/{location}/studies/{study}/trials/{trial}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListOptimalTrialsRequest(proto.Message): @@ -456,7 +431,7 @@ class ListOptimalTrialsRequest(proto.Message): optimal Trial belongs to. """ - parent = proto.Field(proto.STRING, number=1) + parent = proto.Field(proto.STRING, number=1,) class ListOptimalTrialsResponse(proto.Message): diff --git a/noxfile.py b/noxfile.py index 38bf2db67d..4ea506a2a2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -101,7 +101,7 @@ def default(session): "--cov-config=.coveragerc", "--cov-report=", "--cov-fail-under=0", - os.path.join("tests", "unit"), + os.path.join("tests", "unit", "gapic"), *session.posargs, ) diff --git a/synth.py b/synth.py index d0ff3de448..c60f1b9319 100644 --- a/synth.py +++ b/synth.py @@ -56,7 +56,6 @@ f"scripts/fixup_prediction_{version}_keywords.py", "google/cloud/aiplatform/__init__.py", f"google/cloud/aiplatform/{version}/schema/**/services/", - f"tests/unit/gapic/aiplatform_{version}/test_prediction_service.py", f"tests/unit/gapic/definition_{version}/", f"tests/unit/gapic/instance_{version}/", f"tests/unit/gapic/params_{version}/", @@ -86,6 +85,24 @@ # Patch the library # ---------------------------------------------------------------------------- +# Fix assert with endpoint missing port +# https://github.com/googleapis/gapic-generator-python/issues/872 +s.replace( + "tests/unit/gapic/**/*.py", + '''create_channel\.assert_called_with\( +(\s+)"aiplatform\.googleapis\.com",''', + '''create_channel.assert_called_with( +\g<1>"aiplatform.googleapis.com:443",''' +) + +# Patch broken assert +# https://github.com/googleapis/gapic-generator-python/issues/414 +s.replace( + "tests/unit/gapic/**/test_prediction_service.py", + """assert args\[0\]\.parameters == struct_pb2\.Value\(null_value=struct_pb2\.NullValue\.NULL_VALUE\)""", + """# https://github.com/googleapis/gapic-generator-python/issues/414 + # assert args[0].parameters == struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)""" +) # Generator adds a bad import statement to enhanced type; # need to fix in post-processing steps. diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index c169373dcf..a247634611 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -9,4 +9,5 @@ google-api-core==1.22.2 libcst==0.2.5 proto-plus==1.10.1 mock==4.0.2 -google-cloud-storage==1.32.0 \ No newline at end of file +google-cloud-storage==1.32.0 +google-auth==1.25.0 # TODO: Remove when google-api-core >= 1.26.0 is required diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000000..4de65971c2 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000000..4de65971c2 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py new file mode 100644 index 0000000000..4de65971c2 --- /dev/null +++ b/tests/unit/gapic/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/aiplatform_v1/__init__.py b/tests/unit/gapic/aiplatform_v1/__init__.py index 42ffdf2bc4..4de65971c2 100644 --- a/tests/unit/gapic/aiplatform_v1/__init__.py +++ b/tests/unit/gapic/aiplatform_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/aiplatform_v1/test_dataset_service.py b/tests/unit/gapic/aiplatform_v1/test_dataset_service.py index c59b335074..6ebf22cd26 100644 --- a/tests/unit/gapic/aiplatform_v1/test_dataset_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_dataset_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1.services.dataset_service import ( DatasetServiceAsyncClient, @@ -41,6 +40,12 @@ from google.cloud.aiplatform_v1.services.dataset_service import DatasetServiceClient from google.cloud.aiplatform_v1.services.dataset_service import pagers from google.cloud.aiplatform_v1.services.dataset_service import transports +from google.cloud.aiplatform_v1.services.dataset_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.dataset_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1.types import annotation from google.cloud.aiplatform_v1.types import annotation_spec from google.cloud.aiplatform_v1.types import data_item @@ -52,9 +57,33 @@ from google.cloud.aiplatform_v1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -105,7 +134,7 @@ def test__get_default_mtls_endpoint(): "client_class", [DatasetServiceClient, DatasetServiceAsyncClient,] ) def test_dataset_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -122,7 +151,7 @@ def test_dataset_service_client_from_service_account_info(client_class): "client_class", [DatasetServiceClient, DatasetServiceAsyncClient,] ) def test_dataset_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -175,7 +204,7 @@ def test_dataset_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(DatasetServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -463,7 +492,7 @@ def test_create_dataset( transport: str = "grpc", request_type=dataset_service.CreateDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -474,13 +503,11 @@ def test_create_dataset( with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.CreateDatasetRequest() # Establish that the response is the type that we expect. @@ -495,7 +522,7 @@ def test_create_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -503,7 +530,6 @@ def test_create_dataset_empty_call(): client.create_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.CreateDatasetRequest() @@ -512,7 +538,7 @@ async def test_create_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.CreateDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -525,13 +551,11 @@ async def test_create_dataset_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.CreateDatasetRequest() # Establish that the response is the type that we expect. @@ -544,17 +568,17 @@ async def test_create_dataset_async_from_dict(): def test_create_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.CreateDatasetRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -569,11 +593,14 @@ def test_create_dataset_field_headers(): @pytest.mark.asyncio async def test_create_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.CreateDatasetRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -581,7 +608,6 @@ async def test_create_dataset_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -595,13 +621,12 @@ async def test_create_dataset_field_headers_async(): def test_create_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_dataset( @@ -612,14 +637,12 @@ def test_create_dataset_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].dataset == gca_dataset.Dataset(name="name_value") def test_create_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -633,7 +656,9 @@ def test_create_dataset_flattened_error(): @pytest.mark.asyncio async def test_create_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: @@ -653,15 +678,15 @@ async def test_create_dataset_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].dataset == gca_dataset.Dataset(name="name_value") @pytest.mark.asyncio async def test_create_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -677,7 +702,7 @@ def test_get_dataset( transport: str = "grpc", request_type=dataset_service.GetDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -693,25 +718,18 @@ def test_get_dataset( metadata_schema_uri="metadata_schema_uri_value", etag="etag_value", ) - response = client.get_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetDatasetRequest() # Establish that the response is the type that we expect. - assert isinstance(response, dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -723,7 +741,7 @@ def test_get_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -731,7 +749,6 @@ def test_get_dataset_empty_call(): client.get_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetDatasetRequest() @@ -740,7 +757,7 @@ async def test_get_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.GetDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -758,24 +775,18 @@ async def test_get_dataset_async( etag="etag_value", ) ) - response = await client.get_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetDatasetRequest() # Establish that the response is the type that we expect. assert isinstance(response, dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -785,17 +796,17 @@ async def test_get_dataset_async_from_dict(): def test_get_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: call.return_value = dataset.Dataset() - client.get_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -810,17 +821,19 @@ def test_get_dataset_field_headers(): @pytest.mark.asyncio async def test_get_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(dataset.Dataset()) - await client.get_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -834,13 +847,12 @@ async def test_get_dataset_field_headers_async(): def test_get_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset.Dataset() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_dataset(name="name_value",) @@ -849,12 +861,11 @@ def test_get_dataset_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -866,7 +877,9 @@ def test_get_dataset_flattened_error(): @pytest.mark.asyncio async def test_get_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: @@ -882,13 +895,14 @@ async def test_get_dataset_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -902,7 +916,7 @@ def test_update_dataset( transport: str = "grpc", request_type=dataset_service.UpdateDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -918,25 +932,18 @@ def test_update_dataset( metadata_schema_uri="metadata_schema_uri_value", etag="etag_value", ) - response = client.update_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.UpdateDatasetRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -948,7 +955,7 @@ def test_update_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -956,7 +963,6 @@ def test_update_dataset_empty_call(): client.update_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.UpdateDatasetRequest() @@ -965,7 +971,7 @@ async def test_update_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.UpdateDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -983,24 +989,18 @@ async def test_update_dataset_async( etag="etag_value", ) ) - response = await client.update_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.UpdateDatasetRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -1010,17 +1010,17 @@ async def test_update_dataset_async_from_dict(): def test_update_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.UpdateDatasetRequest() + request.dataset.name = "dataset.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: call.return_value = gca_dataset.Dataset() - client.update_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1037,17 +1037,19 @@ def test_update_dataset_field_headers(): @pytest.mark.asyncio async def test_update_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.UpdateDatasetRequest() + request.dataset.name = "dataset.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_dataset.Dataset()) - await client.update_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1063,32 +1065,29 @@ async def test_update_dataset_field_headers_async(): def test_update_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_dataset.Dataset() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_dataset( dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].dataset == gca_dataset.Dataset(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1096,13 +1095,15 @@ def test_update_dataset_flattened_error(): client.update_dataset( dataset_service.UpdateDatasetRequest(), dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: @@ -1114,22 +1115,22 @@ async def test_update_dataset_flattened_async(): # using the keyword arguments to the method. response = await client.update_dataset( dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].dataset == gca_dataset.Dataset(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1137,7 +1138,7 @@ async def test_update_dataset_flattened_error_async(): await client.update_dataset( dataset_service.UpdateDatasetRequest(), dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1145,7 +1146,7 @@ def test_list_datasets( transport: str = "grpc", request_type=dataset_service.ListDatasetsRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1158,19 +1159,15 @@ def test_list_datasets( call.return_value = dataset_service.ListDatasetsResponse( next_page_token="next_page_token_value", ) - response = client.list_datasets(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDatasetsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDatasetsPager) - assert response.next_page_token == "next_page_token_value" @@ -1182,7 +1179,7 @@ def test_list_datasets_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1190,7 +1187,6 @@ def test_list_datasets_empty_call(): client.list_datasets() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDatasetsRequest() @@ -1199,7 +1195,7 @@ async def test_list_datasets_async( transport: str = "grpc_asyncio", request_type=dataset_service.ListDatasetsRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1214,18 +1210,15 @@ async def test_list_datasets_async( next_page_token="next_page_token_value", ) ) - response = await client.list_datasets(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDatasetsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListDatasetsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1235,17 +1228,17 @@ async def test_list_datasets_async_from_dict(): def test_list_datasets_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDatasetsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: call.return_value = dataset_service.ListDatasetsResponse() - client.list_datasets(request) # Establish that the underlying gRPC stub method was called. @@ -1260,11 +1253,14 @@ def test_list_datasets_field_headers(): @pytest.mark.asyncio async def test_list_datasets_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDatasetsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1272,7 +1268,6 @@ async def test_list_datasets_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( dataset_service.ListDatasetsResponse() ) - await client.list_datasets(request) # Establish that the underlying gRPC stub method was called. @@ -1286,13 +1281,12 @@ async def test_list_datasets_field_headers_async(): def test_list_datasets_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset_service.ListDatasetsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_datasets(parent="parent_value",) @@ -1301,12 +1295,11 @@ def test_list_datasets_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_datasets_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1318,7 +1311,9 @@ def test_list_datasets_flattened_error(): @pytest.mark.asyncio async def test_list_datasets_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: @@ -1336,13 +1331,14 @@ async def test_list_datasets_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_datasets_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1353,7 +1349,7 @@ async def test_list_datasets_flattened_error_async(): def test_list_datasets_pager(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: @@ -1387,7 +1383,7 @@ def test_list_datasets_pager(): def test_list_datasets_pages(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: @@ -1413,7 +1409,7 @@ def test_list_datasets_pages(): @pytest.mark.asyncio async def test_list_datasets_async_pager(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1446,7 +1442,7 @@ async def test_list_datasets_async_pager(): @pytest.mark.asyncio async def test_list_datasets_async_pages(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1478,7 +1474,7 @@ def test_delete_dataset( transport: str = "grpc", request_type=dataset_service.DeleteDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1489,13 +1485,11 @@ def test_delete_dataset( with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.DeleteDatasetRequest() # Establish that the response is the type that we expect. @@ -1510,7 +1504,7 @@ def test_delete_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1518,7 +1512,6 @@ def test_delete_dataset_empty_call(): client.delete_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.DeleteDatasetRequest() @@ -1527,7 +1520,7 @@ async def test_delete_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.DeleteDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1540,13 +1533,11 @@ async def test_delete_dataset_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.DeleteDatasetRequest() # Establish that the response is the type that we expect. @@ -1559,17 +1550,17 @@ async def test_delete_dataset_async_from_dict(): def test_delete_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.DeleteDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1584,11 +1575,14 @@ def test_delete_dataset_field_headers(): @pytest.mark.asyncio async def test_delete_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.DeleteDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1596,7 +1590,6 @@ async def test_delete_dataset_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1610,13 +1603,12 @@ async def test_delete_dataset_field_headers_async(): def test_delete_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_dataset(name="name_value",) @@ -1625,12 +1617,11 @@ def test_delete_dataset_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1642,7 +1633,9 @@ def test_delete_dataset_flattened_error(): @pytest.mark.asyncio async def test_delete_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: @@ -1660,13 +1653,14 @@ async def test_delete_dataset_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1680,7 +1674,7 @@ def test_import_data( transport: str = "grpc", request_type=dataset_service.ImportDataRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1691,13 +1685,11 @@ def test_import_data( with mock.patch.object(type(client.transport.import_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.import_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ImportDataRequest() # Establish that the response is the type that we expect. @@ -1712,7 +1704,7 @@ def test_import_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1720,7 +1712,6 @@ def test_import_data_empty_call(): client.import_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ImportDataRequest() @@ -1729,7 +1720,7 @@ async def test_import_data_async( transport: str = "grpc_asyncio", request_type=dataset_service.ImportDataRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1742,13 +1733,11 @@ async def test_import_data_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.import_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ImportDataRequest() # Establish that the response is the type that we expect. @@ -1761,17 +1750,17 @@ async def test_import_data_async_from_dict(): def test_import_data_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ImportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_data), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.import_data(request) # Establish that the underlying gRPC stub method was called. @@ -1786,11 +1775,14 @@ def test_import_data_field_headers(): @pytest.mark.asyncio async def test_import_data_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ImportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1798,7 +1790,6 @@ async def test_import_data_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.import_data(request) # Establish that the underlying gRPC stub method was called. @@ -1812,13 +1803,12 @@ async def test_import_data_field_headers_async(): def test_import_data_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.import_data( @@ -1832,16 +1822,14 @@ def test_import_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].import_configs == [ dataset.ImportDataConfig(gcs_source=io.GcsSource(uris=["uris_value"])) ] def test_import_data_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1857,7 +1845,9 @@ def test_import_data_flattened_error(): @pytest.mark.asyncio async def test_import_data_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_data), "__call__") as call: @@ -1880,9 +1870,7 @@ async def test_import_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].import_configs == [ dataset.ImportDataConfig(gcs_source=io.GcsSource(uris=["uris_value"])) ] @@ -1890,7 +1878,9 @@ async def test_import_data_flattened_async(): @pytest.mark.asyncio async def test_import_data_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1908,7 +1898,7 @@ def test_export_data( transport: str = "grpc", request_type=dataset_service.ExportDataRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1919,13 +1909,11 @@ def test_export_data( with mock.patch.object(type(client.transport.export_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.export_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ExportDataRequest() # Establish that the response is the type that we expect. @@ -1940,7 +1928,7 @@ def test_export_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1948,7 +1936,6 @@ def test_export_data_empty_call(): client.export_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ExportDataRequest() @@ -1957,7 +1944,7 @@ async def test_export_data_async( transport: str = "grpc_asyncio", request_type=dataset_service.ExportDataRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1970,13 +1957,11 @@ async def test_export_data_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.export_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ExportDataRequest() # Establish that the response is the type that we expect. @@ -1989,17 +1974,17 @@ async def test_export_data_async_from_dict(): def test_export_data_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ExportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_data), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.export_data(request) # Establish that the underlying gRPC stub method was called. @@ -2014,11 +1999,14 @@ def test_export_data_field_headers(): @pytest.mark.asyncio async def test_export_data_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ExportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2026,7 +2014,6 @@ async def test_export_data_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.export_data(request) # Establish that the underlying gRPC stub method was called. @@ -2040,13 +2027,12 @@ async def test_export_data_field_headers_async(): def test_export_data_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.export_data( @@ -2062,9 +2048,7 @@ def test_export_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].export_config == dataset.ExportDataConfig( gcs_destination=io.GcsDestination( output_uri_prefix="output_uri_prefix_value" @@ -2073,7 +2057,7 @@ def test_export_data_flattened(): def test_export_data_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2091,7 +2075,9 @@ def test_export_data_flattened_error(): @pytest.mark.asyncio async def test_export_data_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_data), "__call__") as call: @@ -2116,9 +2102,7 @@ async def test_export_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].export_config == dataset.ExportDataConfig( gcs_destination=io.GcsDestination( output_uri_prefix="output_uri_prefix_value" @@ -2128,7 +2112,9 @@ async def test_export_data_flattened_async(): @pytest.mark.asyncio async def test_export_data_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2148,7 +2134,7 @@ def test_list_data_items( transport: str = "grpc", request_type=dataset_service.ListDataItemsRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2161,19 +2147,15 @@ def test_list_data_items( call.return_value = dataset_service.ListDataItemsResponse( next_page_token="next_page_token_value", ) - response = client.list_data_items(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDataItemsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDataItemsPager) - assert response.next_page_token == "next_page_token_value" @@ -2185,7 +2167,7 @@ def test_list_data_items_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2193,7 +2175,6 @@ def test_list_data_items_empty_call(): client.list_data_items() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDataItemsRequest() @@ -2202,7 +2183,7 @@ async def test_list_data_items_async( transport: str = "grpc_asyncio", request_type=dataset_service.ListDataItemsRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2217,18 +2198,15 @@ async def test_list_data_items_async( next_page_token="next_page_token_value", ) ) - response = await client.list_data_items(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDataItemsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListDataItemsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2238,17 +2216,17 @@ async def test_list_data_items_async_from_dict(): def test_list_data_items_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDataItemsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: call.return_value = dataset_service.ListDataItemsResponse() - client.list_data_items(request) # Establish that the underlying gRPC stub method was called. @@ -2263,11 +2241,14 @@ def test_list_data_items_field_headers(): @pytest.mark.asyncio async def test_list_data_items_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDataItemsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2275,7 +2256,6 @@ async def test_list_data_items_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( dataset_service.ListDataItemsResponse() ) - await client.list_data_items(request) # Establish that the underlying gRPC stub method was called. @@ -2289,13 +2269,12 @@ async def test_list_data_items_field_headers_async(): def test_list_data_items_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset_service.ListDataItemsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_data_items(parent="parent_value",) @@ -2304,12 +2283,11 @@ def test_list_data_items_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_data_items_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2321,7 +2299,9 @@ def test_list_data_items_flattened_error(): @pytest.mark.asyncio async def test_list_data_items_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: @@ -2339,13 +2319,14 @@ async def test_list_data_items_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_data_items_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2356,7 +2337,7 @@ async def test_list_data_items_flattened_error_async(): def test_list_data_items_pager(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: @@ -2396,7 +2377,7 @@ def test_list_data_items_pager(): def test_list_data_items_pages(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: @@ -2428,7 +2409,7 @@ def test_list_data_items_pages(): @pytest.mark.asyncio async def test_list_data_items_async_pager(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2467,7 +2448,7 @@ async def test_list_data_items_async_pager(): @pytest.mark.asyncio async def test_list_data_items_async_pages(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2505,7 +2486,7 @@ def test_get_annotation_spec( transport: str = "grpc", request_type=dataset_service.GetAnnotationSpecRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2520,23 +2501,17 @@ def test_get_annotation_spec( call.return_value = annotation_spec.AnnotationSpec( name="name_value", display_name="display_name_value", etag="etag_value", ) - response = client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetAnnotationSpecRequest() # Establish that the response is the type that we expect. - assert isinstance(response, annotation_spec.AnnotationSpec) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" @@ -2548,7 +2523,7 @@ def test_get_annotation_spec_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2558,7 +2533,6 @@ def test_get_annotation_spec_empty_call(): client.get_annotation_spec() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetAnnotationSpecRequest() @@ -2568,7 +2542,7 @@ async def test_get_annotation_spec_async( request_type=dataset_service.GetAnnotationSpecRequest, ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2585,22 +2559,17 @@ async def test_get_annotation_spec_async( name="name_value", display_name="display_name_value", etag="etag_value", ) ) - response = await client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetAnnotationSpecRequest() # Establish that the response is the type that we expect. assert isinstance(response, annotation_spec.AnnotationSpec) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" @@ -2610,11 +2579,12 @@ async def test_get_annotation_spec_async_from_dict(): def test_get_annotation_spec_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetAnnotationSpecRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2622,7 +2592,6 @@ def test_get_annotation_spec_field_headers(): type(client.transport.get_annotation_spec), "__call__" ) as call: call.return_value = annotation_spec.AnnotationSpec() - client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. @@ -2637,11 +2606,14 @@ def test_get_annotation_spec_field_headers(): @pytest.mark.asyncio async def test_get_annotation_spec_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetAnnotationSpecRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2651,7 +2623,6 @@ async def test_get_annotation_spec_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( annotation_spec.AnnotationSpec() ) - await client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. @@ -2665,7 +2636,7 @@ async def test_get_annotation_spec_field_headers_async(): def test_get_annotation_spec_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2673,7 +2644,6 @@ def test_get_annotation_spec_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = annotation_spec.AnnotationSpec() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_annotation_spec(name="name_value",) @@ -2682,12 +2652,11 @@ def test_get_annotation_spec_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_annotation_spec_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2699,7 +2668,9 @@ def test_get_annotation_spec_flattened_error(): @pytest.mark.asyncio async def test_get_annotation_spec_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2719,13 +2690,14 @@ async def test_get_annotation_spec_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_annotation_spec_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2739,7 +2711,7 @@ def test_list_annotations( transport: str = "grpc", request_type=dataset_service.ListAnnotationsRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2752,19 +2724,15 @@ def test_list_annotations( call.return_value = dataset_service.ListAnnotationsResponse( next_page_token="next_page_token_value", ) - response = client.list_annotations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListAnnotationsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAnnotationsPager) - assert response.next_page_token == "next_page_token_value" @@ -2776,7 +2744,7 @@ def test_list_annotations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2784,7 +2752,6 @@ def test_list_annotations_empty_call(): client.list_annotations() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListAnnotationsRequest() @@ -2793,7 +2760,7 @@ async def test_list_annotations_async( transport: str = "grpc_asyncio", request_type=dataset_service.ListAnnotationsRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2808,18 +2775,15 @@ async def test_list_annotations_async( next_page_token="next_page_token_value", ) ) - response = await client.list_annotations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListAnnotationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAnnotationsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2829,17 +2793,17 @@ async def test_list_annotations_async_from_dict(): def test_list_annotations_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListAnnotationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: call.return_value = dataset_service.ListAnnotationsResponse() - client.list_annotations(request) # Establish that the underlying gRPC stub method was called. @@ -2854,11 +2818,14 @@ def test_list_annotations_field_headers(): @pytest.mark.asyncio async def test_list_annotations_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListAnnotationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2866,7 +2833,6 @@ async def test_list_annotations_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( dataset_service.ListAnnotationsResponse() ) - await client.list_annotations(request) # Establish that the underlying gRPC stub method was called. @@ -2880,13 +2846,12 @@ async def test_list_annotations_field_headers_async(): def test_list_annotations_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset_service.ListAnnotationsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_annotations(parent="parent_value",) @@ -2895,12 +2860,11 @@ def test_list_annotations_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_annotations_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2912,7 +2876,9 @@ def test_list_annotations_flattened_error(): @pytest.mark.asyncio async def test_list_annotations_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: @@ -2930,13 +2896,14 @@ async def test_list_annotations_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_annotations_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2947,7 +2914,7 @@ async def test_list_annotations_flattened_error_async(): def test_list_annotations_pager(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: @@ -2987,7 +2954,7 @@ def test_list_annotations_pager(): def test_list_annotations_pages(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: @@ -3019,7 +2986,7 @@ def test_list_annotations_pages(): @pytest.mark.asyncio async def test_list_annotations_async_pager(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3058,7 +3025,7 @@ async def test_list_annotations_async_pager(): @pytest.mark.asyncio async def test_list_annotations_async_pages(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3095,16 +3062,16 @@ async def test_list_annotations_async_pages(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DatasetServiceClient( @@ -3114,7 +3081,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DatasetServiceClient( @@ -3125,7 +3092,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = DatasetServiceClient(transport=transport) assert client.transport is transport @@ -3134,13 +3101,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.DatasetServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3155,23 +3122,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.DatasetServiceGrpcTransport,) def test_dataset_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.DatasetServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3183,7 +3150,7 @@ def test_dataset_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.DatasetServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3210,15 +3177,37 @@ def test_dataset_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_dataset_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.dataset_service.transports.DatasetServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.DatasetServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_dataset_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1.services.dataset_service.transports.DatasetServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DatasetServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3231,19 +3220,33 @@ def test_dataset_service_base_transport_with_credentials_file(): def test_dataset_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1.services.dataset_service.transports.DatasetServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DatasetServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_dataset_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + DatasetServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_dataset_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) DatasetServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3251,20 +3254,156 @@ def test_dataset_service_auth_adc(): ) -def test_dataset_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.DatasetServiceGrpcTransport, + transports.DatasetServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_dataset_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.DatasetServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.DatasetServiceGrpcTransport, + transports.DatasetServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_dataset_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DatasetServiceGrpcTransport, grpc_helpers), + (transports.DatasetServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_dataset_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DatasetServiceGrpcTransport, grpc_helpers), + (transports.DatasetServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_dataset_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DatasetServiceGrpcTransport, grpc_helpers), + (transports.DatasetServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_dataset_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -3273,7 +3412,7 @@ def test_dataset_service_transport_auth_adc(): ], ) def test_dataset_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3312,7 +3451,7 @@ def test_dataset_service_grpc_transport_client_cert_source_for_mtls(transport_cl def test_dataset_service_host_no_port(): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -3322,7 +3461,7 @@ def test_dataset_service_host_no_port(): def test_dataset_service_host_with_port(): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -3378,9 +3517,9 @@ def test_dataset_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3456,7 +3595,7 @@ def test_dataset_service_transport_channel_mtls_with_adc(transport_class): def test_dataset_service_grpc_lro_client(): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3469,7 +3608,7 @@ def test_dataset_service_grpc_lro_client(): def test_dataset_service_grpc_lro_async_client(): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3486,7 +3625,6 @@ def test_annotation_path(): dataset = "whelk" data_item = "octopus" annotation = "oyster" - expected = "projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item}/annotations/{annotation}".format( project=project, location=location, @@ -3520,7 +3658,6 @@ def test_annotation_spec_path(): location = "abalone" dataset = "squid" annotation_spec = "clam" - expected = "projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}".format( project=project, location=location, @@ -3552,7 +3689,6 @@ def test_data_item_path(): location = "mussel" dataset = "winkle" data_item = "nautilus" - expected = "projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item}".format( project=project, location=location, dataset=dataset, data_item=data_item, ) @@ -3578,7 +3714,6 @@ def test_dataset_path(): project = "whelk" location = "octopus" dataset = "oyster" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( project=project, location=location, dataset=dataset, ) @@ -3601,7 +3736,6 @@ def test_parse_dataset_path(): def test_common_billing_account_path(): billing_account = "winkle" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3622,7 +3756,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) actual = DatasetServiceClient.common_folder_path(folder) assert expected == actual @@ -3641,7 +3774,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) actual = DatasetServiceClient.common_organization_path(organization) assert expected == actual @@ -3660,7 +3792,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) actual = DatasetServiceClient.common_project_path(project) assert expected == actual @@ -3680,7 +3811,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "oyster" location = "nudibranch" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3707,7 +3837,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.DatasetServiceTransport, "_prep_wrapped_messages" ) as prep: client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3716,6 +3846,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = DatasetServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py b/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py index 90d41c04c0..707ddf6fc0 100644 --- a/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_endpoint_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1.services.endpoint_service import ( EndpointServiceAsyncClient, @@ -41,6 +40,12 @@ from google.cloud.aiplatform_v1.services.endpoint_service import EndpointServiceClient from google.cloud.aiplatform_v1.services.endpoint_service import pagers from google.cloud.aiplatform_v1.services.endpoint_service import transports +from google.cloud.aiplatform_v1.services.endpoint_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.endpoint_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1.types import accelerator_type from google.cloud.aiplatform_v1.types import encryption_spec from google.cloud.aiplatform_v1.types import endpoint @@ -50,8 +55,32 @@ from google.cloud.aiplatform_v1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -102,7 +131,7 @@ def test__get_default_mtls_endpoint(): "client_class", [EndpointServiceClient, EndpointServiceAsyncClient,] ) def test_endpoint_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -119,7 +148,7 @@ def test_endpoint_service_client_from_service_account_info(client_class): "client_class", [EndpointServiceClient, EndpointServiceAsyncClient,] ) def test_endpoint_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -172,7 +201,7 @@ def test_endpoint_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(EndpointServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -470,7 +499,7 @@ def test_create_endpoint( transport: str = "grpc", request_type=endpoint_service.CreateEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -481,13 +510,11 @@ def test_create_endpoint( with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.CreateEndpointRequest() # Establish that the response is the type that we expect. @@ -502,7 +529,7 @@ def test_create_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -510,7 +537,6 @@ def test_create_endpoint_empty_call(): client.create_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.CreateEndpointRequest() @@ -519,7 +545,7 @@ async def test_create_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.CreateEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -532,13 +558,11 @@ async def test_create_endpoint_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.CreateEndpointRequest() # Establish that the response is the type that we expect. @@ -551,17 +575,17 @@ async def test_create_endpoint_async_from_dict(): def test_create_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.CreateEndpointRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -576,11 +600,14 @@ def test_create_endpoint_field_headers(): @pytest.mark.asyncio async def test_create_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.CreateEndpointRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -588,7 +615,6 @@ async def test_create_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -602,13 +628,12 @@ async def test_create_endpoint_field_headers_async(): def test_create_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_endpoint( @@ -619,14 +644,12 @@ def test_create_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") def test_create_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -640,7 +663,9 @@ def test_create_endpoint_flattened_error(): @pytest.mark.asyncio async def test_create_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: @@ -660,15 +685,15 @@ async def test_create_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") @pytest.mark.asyncio async def test_create_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -684,7 +709,7 @@ def test_get_endpoint( transport: str = "grpc", request_type=endpoint_service.GetEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -700,25 +725,18 @@ def test_get_endpoint( description="description_value", etag="etag_value", ) - response = client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.GetEndpointRequest() # Establish that the response is the type that we expect. - assert isinstance(response, endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -730,7 +748,7 @@ def test_get_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -738,7 +756,6 @@ def test_get_endpoint_empty_call(): client.get_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.GetEndpointRequest() @@ -747,7 +764,7 @@ async def test_get_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.GetEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -765,24 +782,18 @@ async def test_get_endpoint_async( etag="etag_value", ) ) - response = await client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.GetEndpointRequest() # Establish that the response is the type that we expect. assert isinstance(response, endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -792,17 +803,17 @@ async def test_get_endpoint_async_from_dict(): def test_get_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.GetEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: call.return_value = endpoint.Endpoint() - client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -817,17 +828,19 @@ def test_get_endpoint_field_headers(): @pytest.mark.asyncio async def test_get_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.GetEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(endpoint.Endpoint()) - await client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -841,13 +854,12 @@ async def test_get_endpoint_field_headers_async(): def test_get_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = endpoint.Endpoint() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_endpoint(name="name_value",) @@ -856,12 +868,11 @@ def test_get_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -873,7 +884,9 @@ def test_get_endpoint_flattened_error(): @pytest.mark.asyncio async def test_get_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: @@ -889,13 +902,14 @@ async def test_get_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -909,7 +923,7 @@ def test_list_endpoints( transport: str = "grpc", request_type=endpoint_service.ListEndpointsRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -922,19 +936,15 @@ def test_list_endpoints( call.return_value = endpoint_service.ListEndpointsResponse( next_page_token="next_page_token_value", ) - response = client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.ListEndpointsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEndpointsPager) - assert response.next_page_token == "next_page_token_value" @@ -946,7 +956,7 @@ def test_list_endpoints_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -954,7 +964,6 @@ def test_list_endpoints_empty_call(): client.list_endpoints() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.ListEndpointsRequest() @@ -963,7 +972,7 @@ async def test_list_endpoints_async( transport: str = "grpc_asyncio", request_type=endpoint_service.ListEndpointsRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -978,18 +987,15 @@ async def test_list_endpoints_async( next_page_token="next_page_token_value", ) ) - response = await client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.ListEndpointsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListEndpointsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -999,17 +1005,17 @@ async def test_list_endpoints_async_from_dict(): def test_list_endpoints_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.ListEndpointsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: call.return_value = endpoint_service.ListEndpointsResponse() - client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. @@ -1024,11 +1030,14 @@ def test_list_endpoints_field_headers(): @pytest.mark.asyncio async def test_list_endpoints_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.ListEndpointsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1036,7 +1045,6 @@ async def test_list_endpoints_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( endpoint_service.ListEndpointsResponse() ) - await client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. @@ -1050,13 +1058,12 @@ async def test_list_endpoints_field_headers_async(): def test_list_endpoints_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = endpoint_service.ListEndpointsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_endpoints(parent="parent_value",) @@ -1065,12 +1072,11 @@ def test_list_endpoints_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_endpoints_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1082,7 +1088,9 @@ def test_list_endpoints_flattened_error(): @pytest.mark.asyncio async def test_list_endpoints_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -1100,13 +1108,14 @@ async def test_list_endpoints_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_endpoints_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1117,7 +1126,7 @@ async def test_list_endpoints_flattened_error_async(): def test_list_endpoints_pager(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -1157,7 +1166,7 @@ def test_list_endpoints_pager(): def test_list_endpoints_pages(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -1189,7 +1198,9 @@ def test_list_endpoints_pages(): @pytest.mark.asyncio async def test_list_endpoints_async_pager(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1228,7 +1239,9 @@ async def test_list_endpoints_async_pager(): @pytest.mark.asyncio async def test_list_endpoints_async_pages(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1266,7 +1279,7 @@ def test_update_endpoint( transport: str = "grpc", request_type=endpoint_service.UpdateEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1282,25 +1295,18 @@ def test_update_endpoint( description="description_value", etag="etag_value", ) - response = client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UpdateEndpointRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -1312,7 +1318,7 @@ def test_update_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1320,7 +1326,6 @@ def test_update_endpoint_empty_call(): client.update_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UpdateEndpointRequest() @@ -1329,7 +1334,7 @@ async def test_update_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.UpdateEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1347,24 +1352,18 @@ async def test_update_endpoint_async( etag="etag_value", ) ) - response = await client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UpdateEndpointRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -1374,17 +1373,17 @@ async def test_update_endpoint_async_from_dict(): def test_update_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UpdateEndpointRequest() + request.endpoint.name = "endpoint.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_endpoint), "__call__") as call: call.return_value = gca_endpoint.Endpoint() - client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1401,11 +1400,14 @@ def test_update_endpoint_field_headers(): @pytest.mark.asyncio async def test_update_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UpdateEndpointRequest() + request.endpoint.name = "endpoint.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1413,7 +1415,6 @@ async def test_update_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_endpoint.Endpoint() ) - await client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1429,32 +1430,29 @@ async def test_update_endpoint_field_headers_async(): def test_update_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_endpoint.Endpoint() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_endpoint( endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1462,13 +1460,15 @@ def test_update_endpoint_flattened_error(): client.update_endpoint( endpoint_service.UpdateEndpointRequest(), endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_endpoint), "__call__") as call: @@ -1482,22 +1482,22 @@ async def test_update_endpoint_flattened_async(): # using the keyword arguments to the method. response = await client.update_endpoint( endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1505,7 +1505,7 @@ async def test_update_endpoint_flattened_error_async(): await client.update_endpoint( endpoint_service.UpdateEndpointRequest(), endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1513,7 +1513,7 @@ def test_delete_endpoint( transport: str = "grpc", request_type=endpoint_service.DeleteEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1524,13 +1524,11 @@ def test_delete_endpoint( with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeleteEndpointRequest() # Establish that the response is the type that we expect. @@ -1545,7 +1543,7 @@ def test_delete_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1553,7 +1551,6 @@ def test_delete_endpoint_empty_call(): client.delete_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeleteEndpointRequest() @@ -1562,7 +1559,7 @@ async def test_delete_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.DeleteEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1575,13 +1572,11 @@ async def test_delete_endpoint_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeleteEndpointRequest() # Establish that the response is the type that we expect. @@ -1594,17 +1589,17 @@ async def test_delete_endpoint_async_from_dict(): def test_delete_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeleteEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1619,11 +1614,14 @@ def test_delete_endpoint_field_headers(): @pytest.mark.asyncio async def test_delete_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeleteEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1631,7 +1629,6 @@ async def test_delete_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1645,13 +1642,12 @@ async def test_delete_endpoint_field_headers_async(): def test_delete_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_endpoint(name="name_value",) @@ -1660,12 +1656,11 @@ def test_delete_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1677,7 +1672,9 @@ def test_delete_endpoint_flattened_error(): @pytest.mark.asyncio async def test_delete_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: @@ -1695,13 +1692,14 @@ async def test_delete_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1715,7 +1713,7 @@ def test_deploy_model( transport: str = "grpc", request_type=endpoint_service.DeployModelRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1726,13 +1724,11 @@ def test_deploy_model( with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.deploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeployModelRequest() # Establish that the response is the type that we expect. @@ -1747,7 +1743,7 @@ def test_deploy_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1755,7 +1751,6 @@ def test_deploy_model_empty_call(): client.deploy_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeployModelRequest() @@ -1764,7 +1759,7 @@ async def test_deploy_model_async( transport: str = "grpc_asyncio", request_type=endpoint_service.DeployModelRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1777,13 +1772,11 @@ async def test_deploy_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.deploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeployModelRequest() # Establish that the response is the type that we expect. @@ -1796,17 +1789,17 @@ async def test_deploy_model_async_from_dict(): def test_deploy_model_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.deploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -1821,11 +1814,14 @@ def test_deploy_model_field_headers(): @pytest.mark.asyncio async def test_deploy_model_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1833,7 +1829,6 @@ async def test_deploy_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.deploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -1847,13 +1842,12 @@ async def test_deploy_model_field_headers_async(): def test_deploy_model_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.deploy_model( @@ -1872,9 +1866,7 @@ def test_deploy_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model == gca_endpoint.DeployedModel( dedicated_resources=machine_resources.DedicatedResources( machine_spec=machine_resources.MachineSpec( @@ -1882,12 +1874,11 @@ def test_deploy_model_flattened(): ) ) ) - assert args[0].traffic_split == {"key_value": 541} def test_deploy_model_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1908,7 +1899,9 @@ def test_deploy_model_flattened_error(): @pytest.mark.asyncio async def test_deploy_model_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: @@ -1936,9 +1929,7 @@ async def test_deploy_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model == gca_endpoint.DeployedModel( dedicated_resources=machine_resources.DedicatedResources( machine_spec=machine_resources.MachineSpec( @@ -1946,13 +1937,14 @@ async def test_deploy_model_flattened_async(): ) ) ) - assert args[0].traffic_split == {"key_value": 541} @pytest.mark.asyncio async def test_deploy_model_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1975,7 +1967,7 @@ def test_undeploy_model( transport: str = "grpc", request_type=endpoint_service.UndeployModelRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1986,13 +1978,11 @@ def test_undeploy_model( with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UndeployModelRequest() # Establish that the response is the type that we expect. @@ -2007,7 +1997,7 @@ def test_undeploy_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2015,7 +2005,6 @@ def test_undeploy_model_empty_call(): client.undeploy_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UndeployModelRequest() @@ -2024,7 +2013,7 @@ async def test_undeploy_model_async( transport: str = "grpc_asyncio", request_type=endpoint_service.UndeployModelRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2037,13 +2026,11 @@ async def test_undeploy_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UndeployModelRequest() # Establish that the response is the type that we expect. @@ -2056,17 +2043,17 @@ async def test_undeploy_model_async_from_dict(): def test_undeploy_model_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UndeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -2081,11 +2068,14 @@ def test_undeploy_model_field_headers(): @pytest.mark.asyncio async def test_undeploy_model_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UndeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2093,7 +2083,6 @@ async def test_undeploy_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -2107,13 +2096,12 @@ async def test_undeploy_model_field_headers_async(): def test_undeploy_model_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.undeploy_model( @@ -2126,16 +2114,13 @@ def test_undeploy_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model_id == "deployed_model_id_value" - assert args[0].traffic_split == {"key_value": 541} def test_undeploy_model_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2150,7 +2135,9 @@ def test_undeploy_model_flattened_error(): @pytest.mark.asyncio async def test_undeploy_model_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: @@ -2172,17 +2159,16 @@ async def test_undeploy_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model_id == "deployed_model_id_value" - assert args[0].traffic_split == {"key_value": 541} @pytest.mark.asyncio async def test_undeploy_model_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2198,16 +2184,16 @@ async def test_undeploy_model_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = EndpointServiceClient( @@ -2217,7 +2203,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = EndpointServiceClient( @@ -2228,7 +2214,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = EndpointServiceClient(transport=transport) assert client.transport is transport @@ -2237,13 +2223,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.EndpointServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -2258,23 +2244,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.EndpointServiceGrpcTransport,) def test_endpoint_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.EndpointServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -2286,7 +2272,7 @@ def test_endpoint_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.EndpointServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -2310,15 +2296,37 @@ def test_endpoint_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_endpoint_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1.services.endpoint_service.transports.EndpointServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.EndpointServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_endpoint_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.endpoint_service.transports.EndpointServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.EndpointServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -2331,19 +2339,33 @@ def test_endpoint_service_base_transport_with_credentials_file(): def test_endpoint_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1.services.endpoint_service.transports.EndpointServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.EndpointServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_endpoint_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + EndpointServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_endpoint_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) EndpointServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -2351,20 +2373,156 @@ def test_endpoint_service_auth_adc(): ) -def test_endpoint_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.EndpointServiceGrpcTransport, + transports.EndpointServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_endpoint_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.EndpointServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.EndpointServiceGrpcTransport, + transports.EndpointServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_endpoint_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.EndpointServiceGrpcTransport, grpc_helpers), + (transports.EndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_endpoint_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.EndpointServiceGrpcTransport, grpc_helpers), + (transports.EndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_endpoint_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.EndpointServiceGrpcTransport, grpc_helpers), + (transports.EndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_endpoint_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -2373,7 +2531,7 @@ def test_endpoint_service_transport_auth_adc(): ], ) def test_endpoint_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -2412,7 +2570,7 @@ def test_endpoint_service_grpc_transport_client_cert_source_for_mtls(transport_c def test_endpoint_service_host_no_port(): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -2422,7 +2580,7 @@ def test_endpoint_service_host_no_port(): def test_endpoint_service_host_with_port(): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -2478,9 +2636,9 @@ def test_endpoint_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2556,7 +2714,7 @@ def test_endpoint_service_transport_channel_mtls_with_adc(transport_class): def test_endpoint_service_grpc_lro_client(): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -2569,7 +2727,7 @@ def test_endpoint_service_grpc_lro_client(): def test_endpoint_service_grpc_lro_async_client(): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -2584,7 +2742,6 @@ def test_endpoint_path(): project = "squid" location = "clam" endpoint = "whelk" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -2609,7 +2766,6 @@ def test_model_path(): project = "cuttlefish" location = "mussel" model = "winkle" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -2632,7 +2788,6 @@ def test_parse_model_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2653,7 +2808,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = EndpointServiceClient.common_folder_path(folder) assert expected == actual @@ -2672,7 +2826,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = EndpointServiceClient.common_organization_path(organization) assert expected == actual @@ -2691,7 +2844,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = EndpointServiceClient.common_project_path(project) assert expected == actual @@ -2711,7 +2863,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2738,7 +2889,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.EndpointServiceTransport, "_prep_wrapped_messages" ) as prep: client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2747,6 +2898,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = EndpointServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1/test_job_service.py b/tests/unit/gapic/aiplatform_v1/test_job_service.py index ea8d1d502b..3c490870e9 100644 --- a/tests/unit/gapic/aiplatform_v1/test_job_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_job_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,21 +23,27 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1.services.job_service import JobServiceAsyncClient from google.cloud.aiplatform_v1.services.job_service import JobServiceClient from google.cloud.aiplatform_v1.services.job_service import pagers from google.cloud.aiplatform_v1.services.job_service import transports +from google.cloud.aiplatform_v1.services.job_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.job_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1.types import accelerator_type from google.cloud.aiplatform_v1.types import batch_prediction_job from google.cloud.aiplatform_v1.types import ( @@ -64,13 +69,37 @@ from google.cloud.aiplatform_v1.types import study from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -116,7 +145,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [JobServiceClient, JobServiceAsyncClient,]) def test_job_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -131,7 +160,7 @@ def test_job_service_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [JobServiceClient, JobServiceAsyncClient,]) def test_job_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -182,7 +211,7 @@ def test_job_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(JobServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -466,7 +495,7 @@ def test_create_custom_job( transport: str = "grpc", request_type=job_service.CreateCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -483,23 +512,17 @@ def test_create_custom_job( display_name="display_name_value", state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateCustomJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -511,7 +534,7 @@ def test_create_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -521,7 +544,6 @@ def test_create_custom_job_empty_call(): client.create_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateCustomJobRequest() @@ -530,7 +552,7 @@ async def test_create_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.CreateCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -549,22 +571,17 @@ async def test_create_custom_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateCustomJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -574,11 +591,12 @@ async def test_create_custom_job_async_from_dict(): def test_create_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateCustomJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -586,7 +604,6 @@ def test_create_custom_job_field_headers(): type(client.transport.create_custom_job), "__call__" ) as call: call.return_value = gca_custom_job.CustomJob() - client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -601,11 +618,12 @@ def test_create_custom_job_field_headers(): @pytest.mark.asyncio async def test_create_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateCustomJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -615,7 +633,6 @@ async def test_create_custom_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_custom_job.CustomJob() ) - await client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -629,7 +646,7 @@ async def test_create_custom_job_field_headers_async(): def test_create_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -637,7 +654,6 @@ def test_create_custom_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_custom_job.CustomJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_custom_job( @@ -649,14 +665,12 @@ def test_create_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].custom_job == gca_custom_job.CustomJob(name="name_value") def test_create_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -670,7 +684,7 @@ def test_create_custom_job_flattened_error(): @pytest.mark.asyncio async def test_create_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -693,15 +707,13 @@ async def test_create_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].custom_job == gca_custom_job.CustomJob(name="name_value") @pytest.mark.asyncio async def test_create_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -717,7 +729,7 @@ def test_get_custom_job( transport: str = "grpc", request_type=job_service.GetCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -732,23 +744,17 @@ def test_get_custom_job( display_name="display_name_value", state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetCustomJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -760,7 +766,7 @@ def test_get_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -768,7 +774,6 @@ def test_get_custom_job_empty_call(): client.get_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetCustomJobRequest() @@ -777,7 +782,7 @@ async def test_get_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.GetCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -794,22 +799,17 @@ async def test_get_custom_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetCustomJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -819,17 +819,17 @@ async def test_get_custom_job_async_from_dict(): def test_get_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_custom_job), "__call__") as call: call.return_value = custom_job.CustomJob() - client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -844,11 +844,12 @@ def test_get_custom_job_field_headers(): @pytest.mark.asyncio async def test_get_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -856,7 +857,6 @@ async def test_get_custom_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( custom_job.CustomJob() ) - await client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -870,13 +870,12 @@ async def test_get_custom_job_field_headers_async(): def test_get_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_custom_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = custom_job.CustomJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_custom_job(name="name_value",) @@ -885,12 +884,11 @@ def test_get_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -902,7 +900,7 @@ def test_get_custom_job_flattened_error(): @pytest.mark.asyncio async def test_get_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_custom_job), "__call__") as call: @@ -920,13 +918,12 @@ async def test_get_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -940,7 +937,7 @@ def test_list_custom_jobs( transport: str = "grpc", request_type=job_service.ListCustomJobsRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -953,19 +950,15 @@ def test_list_custom_jobs( call.return_value = job_service.ListCustomJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListCustomJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -977,7 +970,7 @@ def test_list_custom_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -985,7 +978,6 @@ def test_list_custom_jobs_empty_call(): client.list_custom_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListCustomJobsRequest() @@ -994,7 +986,7 @@ async def test_list_custom_jobs_async( transport: str = "grpc_asyncio", request_type=job_service.ListCustomJobsRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1007,18 +999,15 @@ async def test_list_custom_jobs_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListCustomJobsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListCustomJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCustomJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1028,17 +1017,17 @@ async def test_list_custom_jobs_async_from_dict(): def test_list_custom_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListCustomJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: call.return_value = job_service.ListCustomJobsResponse() - client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -1053,11 +1042,12 @@ def test_list_custom_jobs_field_headers(): @pytest.mark.asyncio async def test_list_custom_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListCustomJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1065,7 +1055,6 @@ async def test_list_custom_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListCustomJobsResponse() ) - await client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -1079,13 +1068,12 @@ async def test_list_custom_jobs_field_headers_async(): def test_list_custom_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListCustomJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_custom_jobs(parent="parent_value",) @@ -1094,12 +1082,11 @@ def test_list_custom_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_custom_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1111,7 +1098,7 @@ def test_list_custom_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_custom_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: @@ -1129,13 +1116,12 @@ async def test_list_custom_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_custom_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1146,7 +1132,7 @@ async def test_list_custom_jobs_flattened_error_async(): def test_list_custom_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: @@ -1184,7 +1170,7 @@ def test_list_custom_jobs_pager(): def test_list_custom_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: @@ -1214,7 +1200,7 @@ def test_list_custom_jobs_pages(): @pytest.mark.asyncio async def test_list_custom_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1251,7 +1237,7 @@ async def test_list_custom_jobs_async_pager(): @pytest.mark.asyncio async def test_list_custom_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1287,7 +1273,7 @@ def test_delete_custom_job( transport: str = "grpc", request_type=job_service.DeleteCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1300,13 +1286,11 @@ def test_delete_custom_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteCustomJobRequest() # Establish that the response is the type that we expect. @@ -1321,7 +1305,7 @@ def test_delete_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1331,7 +1315,6 @@ def test_delete_custom_job_empty_call(): client.delete_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteCustomJobRequest() @@ -1340,7 +1323,7 @@ async def test_delete_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.DeleteCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1355,13 +1338,11 @@ async def test_delete_custom_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteCustomJobRequest() # Establish that the response is the type that we expect. @@ -1374,11 +1355,12 @@ async def test_delete_custom_job_async_from_dict(): def test_delete_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1386,7 +1368,6 @@ def test_delete_custom_job_field_headers(): type(client.transport.delete_custom_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1401,11 +1382,12 @@ def test_delete_custom_job_field_headers(): @pytest.mark.asyncio async def test_delete_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1415,7 +1397,6 @@ async def test_delete_custom_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1429,7 +1410,7 @@ async def test_delete_custom_job_field_headers_async(): def test_delete_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1437,7 +1418,6 @@ def test_delete_custom_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_custom_job(name="name_value",) @@ -1446,12 +1426,11 @@ def test_delete_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1463,7 +1442,7 @@ def test_delete_custom_job_flattened_error(): @pytest.mark.asyncio async def test_delete_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1483,13 +1462,12 @@ async def test_delete_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1503,7 +1481,7 @@ def test_cancel_custom_job( transport: str = "grpc", request_type=job_service.CancelCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1516,13 +1494,11 @@ def test_cancel_custom_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelCustomJobRequest() # Establish that the response is the type that we expect. @@ -1537,7 +1513,7 @@ def test_cancel_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1547,7 +1523,6 @@ def test_cancel_custom_job_empty_call(): client.cancel_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelCustomJobRequest() @@ -1556,7 +1531,7 @@ async def test_cancel_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.CancelCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1569,13 +1544,11 @@ async def test_cancel_custom_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelCustomJobRequest() # Establish that the response is the type that we expect. @@ -1588,11 +1561,12 @@ async def test_cancel_custom_job_async_from_dict(): def test_cancel_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1600,7 +1574,6 @@ def test_cancel_custom_job_field_headers(): type(client.transport.cancel_custom_job), "__call__" ) as call: call.return_value = None - client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1615,11 +1588,12 @@ def test_cancel_custom_job_field_headers(): @pytest.mark.asyncio async def test_cancel_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1627,7 +1601,6 @@ async def test_cancel_custom_job_field_headers_async(): type(client.transport.cancel_custom_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1641,7 +1614,7 @@ async def test_cancel_custom_job_field_headers_async(): def test_cancel_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1649,7 +1622,6 @@ def test_cancel_custom_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_custom_job(name="name_value",) @@ -1658,12 +1630,11 @@ def test_cancel_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1675,7 +1646,7 @@ def test_cancel_custom_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1693,13 +1664,12 @@ async def test_cancel_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1713,7 +1683,7 @@ def test_create_data_labeling_job( transport: str = "grpc", request_type=job_service.CreateDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1736,35 +1706,23 @@ def test_create_data_labeling_job( labeling_progress=1810, specialist_pools=["specialist_pools_value"], ) - response = client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateDataLabelingJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -1776,7 +1734,7 @@ def test_create_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1786,7 +1744,6 @@ def test_create_data_labeling_job_empty_call(): client.create_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateDataLabelingJobRequest() @@ -1796,7 +1753,7 @@ async def test_create_data_labeling_job_async( request_type=job_service.CreateDataLabelingJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1821,34 +1778,23 @@ async def test_create_data_labeling_job_async( specialist_pools=["specialist_pools_value"], ) ) - response = await client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateDataLabelingJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -1858,11 +1804,12 @@ async def test_create_data_labeling_job_async_from_dict(): def test_create_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateDataLabelingJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1870,7 +1817,6 @@ def test_create_data_labeling_job_field_headers(): type(client.transport.create_data_labeling_job), "__call__" ) as call: call.return_value = gca_data_labeling_job.DataLabelingJob() - client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -1885,11 +1831,12 @@ def test_create_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_create_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateDataLabelingJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1899,7 +1846,6 @@ async def test_create_data_labeling_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_data_labeling_job.DataLabelingJob() ) - await client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -1913,7 +1859,7 @@ async def test_create_data_labeling_job_field_headers_async(): def test_create_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1921,7 +1867,6 @@ def test_create_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_data_labeling_job.DataLabelingJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_data_labeling_job( @@ -1933,16 +1878,14 @@ def test_create_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].data_labeling_job == gca_data_labeling_job.DataLabelingJob( name="name_value" ) def test_create_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1956,7 +1899,7 @@ def test_create_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_create_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1979,9 +1922,7 @@ async def test_create_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].data_labeling_job == gca_data_labeling_job.DataLabelingJob( name="name_value" ) @@ -1989,7 +1930,7 @@ async def test_create_data_labeling_job_flattened_async(): @pytest.mark.asyncio async def test_create_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2005,7 +1946,7 @@ def test_get_data_labeling_job( transport: str = "grpc", request_type=job_service.GetDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2028,35 +1969,23 @@ def test_get_data_labeling_job( labeling_progress=1810, specialist_pools=["specialist_pools_value"], ) - response = client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetDataLabelingJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -2068,7 +1997,7 @@ def test_get_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2078,7 +2007,6 @@ def test_get_data_labeling_job_empty_call(): client.get_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetDataLabelingJobRequest() @@ -2087,7 +2015,7 @@ async def test_get_data_labeling_job_async( transport: str = "grpc_asyncio", request_type=job_service.GetDataLabelingJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2112,34 +2040,23 @@ async def test_get_data_labeling_job_async( specialist_pools=["specialist_pools_value"], ) ) - response = await client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetDataLabelingJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -2149,11 +2066,12 @@ async def test_get_data_labeling_job_async_from_dict(): def test_get_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2161,7 +2079,6 @@ def test_get_data_labeling_job_field_headers(): type(client.transport.get_data_labeling_job), "__call__" ) as call: call.return_value = data_labeling_job.DataLabelingJob() - client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2176,11 +2093,12 @@ def test_get_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_get_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2190,7 +2108,6 @@ async def test_get_data_labeling_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( data_labeling_job.DataLabelingJob() ) - await client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2204,7 +2121,7 @@ async def test_get_data_labeling_job_field_headers_async(): def test_get_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2212,7 +2129,6 @@ def test_get_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = data_labeling_job.DataLabelingJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_data_labeling_job(name="name_value",) @@ -2221,12 +2137,11 @@ def test_get_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2238,7 +2153,7 @@ def test_get_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_get_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2258,13 +2173,12 @@ async def test_get_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2278,7 +2192,7 @@ def test_list_data_labeling_jobs( transport: str = "grpc", request_type=job_service.ListDataLabelingJobsRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2293,19 +2207,15 @@ def test_list_data_labeling_jobs( call.return_value = job_service.ListDataLabelingJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListDataLabelingJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDataLabelingJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -2317,7 +2227,7 @@ def test_list_data_labeling_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2327,7 +2237,6 @@ def test_list_data_labeling_jobs_empty_call(): client.list_data_labeling_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListDataLabelingJobsRequest() @@ -2337,7 +2246,7 @@ async def test_list_data_labeling_jobs_async( request_type=job_service.ListDataLabelingJobsRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2354,18 +2263,15 @@ async def test_list_data_labeling_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListDataLabelingJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListDataLabelingJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2375,11 +2281,12 @@ async def test_list_data_labeling_jobs_async_from_dict(): def test_list_data_labeling_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListDataLabelingJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2387,7 +2294,6 @@ def test_list_data_labeling_jobs_field_headers(): type(client.transport.list_data_labeling_jobs), "__call__" ) as call: call.return_value = job_service.ListDataLabelingJobsResponse() - client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -2402,11 +2308,12 @@ def test_list_data_labeling_jobs_field_headers(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListDataLabelingJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2416,7 +2323,6 @@ async def test_list_data_labeling_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListDataLabelingJobsResponse() ) - await client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -2430,7 +2336,7 @@ async def test_list_data_labeling_jobs_field_headers_async(): def test_list_data_labeling_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2438,7 +2344,6 @@ def test_list_data_labeling_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListDataLabelingJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_data_labeling_jobs(parent="parent_value",) @@ -2447,12 +2352,11 @@ def test_list_data_labeling_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_data_labeling_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2464,7 +2368,7 @@ def test_list_data_labeling_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2484,13 +2388,12 @@ async def test_list_data_labeling_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_data_labeling_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2501,7 +2404,7 @@ async def test_list_data_labeling_jobs_flattened_error_async(): def test_list_data_labeling_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2547,7 +2450,7 @@ def test_list_data_labeling_jobs_pager(): def test_list_data_labeling_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2585,7 +2488,7 @@ def test_list_data_labeling_jobs_pages(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2630,7 +2533,7 @@ async def test_list_data_labeling_jobs_async_pager(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2674,7 +2577,7 @@ def test_delete_data_labeling_job( transport: str = "grpc", request_type=job_service.DeleteDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2687,13 +2590,11 @@ def test_delete_data_labeling_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2708,7 +2609,7 @@ def test_delete_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2718,7 +2619,6 @@ def test_delete_data_labeling_job_empty_call(): client.delete_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteDataLabelingJobRequest() @@ -2728,7 +2628,7 @@ async def test_delete_data_labeling_job_async( request_type=job_service.DeleteDataLabelingJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2743,13 +2643,11 @@ async def test_delete_data_labeling_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2762,11 +2660,12 @@ async def test_delete_data_labeling_job_async_from_dict(): def test_delete_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2774,7 +2673,6 @@ def test_delete_data_labeling_job_field_headers(): type(client.transport.delete_data_labeling_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2789,11 +2687,12 @@ def test_delete_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_delete_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2803,7 +2702,6 @@ async def test_delete_data_labeling_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2817,7 +2715,7 @@ async def test_delete_data_labeling_job_field_headers_async(): def test_delete_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2825,7 +2723,6 @@ def test_delete_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_data_labeling_job(name="name_value",) @@ -2834,12 +2731,11 @@ def test_delete_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2851,7 +2747,7 @@ def test_delete_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_delete_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2871,13 +2767,12 @@ async def test_delete_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2891,7 +2786,7 @@ def test_cancel_data_labeling_job( transport: str = "grpc", request_type=job_service.CancelDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2904,13 +2799,11 @@ def test_cancel_data_labeling_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2925,7 +2818,7 @@ def test_cancel_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2935,7 +2828,6 @@ def test_cancel_data_labeling_job_empty_call(): client.cancel_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelDataLabelingJobRequest() @@ -2945,7 +2837,7 @@ async def test_cancel_data_labeling_job_async( request_type=job_service.CancelDataLabelingJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2958,13 +2850,11 @@ async def test_cancel_data_labeling_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2977,11 +2867,12 @@ async def test_cancel_data_labeling_job_async_from_dict(): def test_cancel_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2989,7 +2880,6 @@ def test_cancel_data_labeling_job_field_headers(): type(client.transport.cancel_data_labeling_job), "__call__" ) as call: call.return_value = None - client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -3004,11 +2894,12 @@ def test_cancel_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_cancel_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3016,7 +2907,6 @@ async def test_cancel_data_labeling_job_field_headers_async(): type(client.transport.cancel_data_labeling_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -3030,7 +2920,7 @@ async def test_cancel_data_labeling_job_field_headers_async(): def test_cancel_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3038,7 +2928,6 @@ def test_cancel_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_data_labeling_job(name="name_value",) @@ -3047,12 +2936,11 @@ def test_cancel_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3064,7 +2952,7 @@ def test_cancel_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3082,13 +2970,12 @@ async def test_cancel_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3103,7 +2990,7 @@ def test_create_hyperparameter_tuning_job( request_type=job_service.CreateHyperparameterTuningJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3123,29 +3010,20 @@ def test_create_hyperparameter_tuning_job( max_failed_trial_count=2317, state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3157,7 +3035,7 @@ def test_create_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3167,7 +3045,6 @@ def test_create_hyperparameter_tuning_job_empty_call(): client.create_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateHyperparameterTuningJobRequest() @@ -3177,7 +3054,7 @@ async def test_create_hyperparameter_tuning_job_async( request_type=job_service.CreateHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3199,28 +3076,20 @@ async def test_create_hyperparameter_tuning_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3230,11 +3099,12 @@ async def test_create_hyperparameter_tuning_job_async_from_dict(): def test_create_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateHyperparameterTuningJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3242,7 +3112,6 @@ def test_create_hyperparameter_tuning_job_field_headers(): type(client.transport.create_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = gca_hyperparameter_tuning_job.HyperparameterTuningJob() - client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3257,11 +3126,12 @@ def test_create_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_create_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateHyperparameterTuningJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3271,7 +3141,6 @@ async def test_create_hyperparameter_tuning_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_hyperparameter_tuning_job.HyperparameterTuningJob() ) - await client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3285,7 +3154,7 @@ async def test_create_hyperparameter_tuning_job_field_headers_async(): def test_create_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3293,7 +3162,6 @@ def test_create_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_hyperparameter_tuning_job.HyperparameterTuningJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_hyperparameter_tuning_job( @@ -3307,9 +3175,7 @@ def test_create_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].hyperparameter_tuning_job == gca_hyperparameter_tuning_job.HyperparameterTuningJob( @@ -3318,7 +3184,7 @@ def test_create_hyperparameter_tuning_job_flattened(): def test_create_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3334,7 +3200,7 @@ def test_create_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_create_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3359,9 +3225,7 @@ async def test_create_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].hyperparameter_tuning_job == gca_hyperparameter_tuning_job.HyperparameterTuningJob( @@ -3371,7 +3235,7 @@ async def test_create_hyperparameter_tuning_job_flattened_async(): @pytest.mark.asyncio async def test_create_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3389,7 +3253,7 @@ def test_get_hyperparameter_tuning_job( transport: str = "grpc", request_type=job_service.GetHyperparameterTuningJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3409,29 +3273,20 @@ def test_get_hyperparameter_tuning_job( max_failed_trial_count=2317, state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3443,7 +3298,7 @@ def test_get_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3453,7 +3308,6 @@ def test_get_hyperparameter_tuning_job_empty_call(): client.get_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetHyperparameterTuningJobRequest() @@ -3463,7 +3317,7 @@ async def test_get_hyperparameter_tuning_job_async( request_type=job_service.GetHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3485,28 +3339,20 @@ async def test_get_hyperparameter_tuning_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3516,11 +3362,12 @@ async def test_get_hyperparameter_tuning_job_async_from_dict(): def test_get_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3528,7 +3375,6 @@ def test_get_hyperparameter_tuning_job_field_headers(): type(client.transport.get_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = hyperparameter_tuning_job.HyperparameterTuningJob() - client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3543,11 +3389,12 @@ def test_get_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_get_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3557,7 +3404,6 @@ async def test_get_hyperparameter_tuning_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( hyperparameter_tuning_job.HyperparameterTuningJob() ) - await client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3571,7 +3417,7 @@ async def test_get_hyperparameter_tuning_job_field_headers_async(): def test_get_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3579,7 +3425,6 @@ def test_get_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = hyperparameter_tuning_job.HyperparameterTuningJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_hyperparameter_tuning_job(name="name_value",) @@ -3588,12 +3433,11 @@ def test_get_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3605,7 +3449,7 @@ def test_get_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_get_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3625,13 +3469,12 @@ async def test_get_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3646,7 +3489,7 @@ def test_list_hyperparameter_tuning_jobs( request_type=job_service.ListHyperparameterTuningJobsRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3661,19 +3504,15 @@ def test_list_hyperparameter_tuning_jobs( call.return_value = job_service.ListHyperparameterTuningJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListHyperparameterTuningJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListHyperparameterTuningJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -3685,7 +3524,7 @@ def test_list_hyperparameter_tuning_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3695,7 +3534,6 @@ def test_list_hyperparameter_tuning_jobs_empty_call(): client.list_hyperparameter_tuning_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListHyperparameterTuningJobsRequest() @@ -3705,7 +3543,7 @@ async def test_list_hyperparameter_tuning_jobs_async( request_type=job_service.ListHyperparameterTuningJobsRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3722,18 +3560,15 @@ async def test_list_hyperparameter_tuning_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListHyperparameterTuningJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListHyperparameterTuningJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3743,11 +3578,12 @@ async def test_list_hyperparameter_tuning_jobs_async_from_dict(): def test_list_hyperparameter_tuning_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListHyperparameterTuningJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3755,7 +3591,6 @@ def test_list_hyperparameter_tuning_jobs_field_headers(): type(client.transport.list_hyperparameter_tuning_jobs), "__call__" ) as call: call.return_value = job_service.ListHyperparameterTuningJobsResponse() - client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -3770,11 +3605,12 @@ def test_list_hyperparameter_tuning_jobs_field_headers(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListHyperparameterTuningJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3784,7 +3620,6 @@ async def test_list_hyperparameter_tuning_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListHyperparameterTuningJobsResponse() ) - await client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -3798,7 +3633,7 @@ async def test_list_hyperparameter_tuning_jobs_field_headers_async(): def test_list_hyperparameter_tuning_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3806,7 +3641,6 @@ def test_list_hyperparameter_tuning_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListHyperparameterTuningJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_hyperparameter_tuning_jobs(parent="parent_value",) @@ -3815,12 +3649,11 @@ def test_list_hyperparameter_tuning_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_hyperparameter_tuning_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3832,7 +3665,7 @@ def test_list_hyperparameter_tuning_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3852,13 +3685,12 @@ async def test_list_hyperparameter_tuning_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3869,7 +3701,7 @@ async def test_list_hyperparameter_tuning_jobs_flattened_error_async(): def test_list_hyperparameter_tuning_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3920,7 +3752,7 @@ def test_list_hyperparameter_tuning_jobs_pager(): def test_list_hyperparameter_tuning_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3960,7 +3792,7 @@ def test_list_hyperparameter_tuning_jobs_pages(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4010,7 +3842,7 @@ async def test_list_hyperparameter_tuning_jobs_async_pager(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4059,7 +3891,7 @@ def test_delete_hyperparameter_tuning_job( request_type=job_service.DeleteHyperparameterTuningJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4072,13 +3904,11 @@ def test_delete_hyperparameter_tuning_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4093,7 +3923,7 @@ def test_delete_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4103,7 +3933,6 @@ def test_delete_hyperparameter_tuning_job_empty_call(): client.delete_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteHyperparameterTuningJobRequest() @@ -4113,7 +3942,7 @@ async def test_delete_hyperparameter_tuning_job_async( request_type=job_service.DeleteHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4128,13 +3957,11 @@ async def test_delete_hyperparameter_tuning_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4147,11 +3974,12 @@ async def test_delete_hyperparameter_tuning_job_async_from_dict(): def test_delete_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4159,7 +3987,6 @@ def test_delete_hyperparameter_tuning_job_field_headers(): type(client.transport.delete_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4174,11 +4001,12 @@ def test_delete_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_delete_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4188,7 +4016,6 @@ async def test_delete_hyperparameter_tuning_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4202,7 +4029,7 @@ async def test_delete_hyperparameter_tuning_job_field_headers_async(): def test_delete_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4210,7 +4037,6 @@ def test_delete_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_hyperparameter_tuning_job(name="name_value",) @@ -4219,12 +4045,11 @@ def test_delete_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4236,7 +4061,7 @@ def test_delete_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_delete_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4256,13 +4081,12 @@ async def test_delete_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4277,7 +4101,7 @@ def test_cancel_hyperparameter_tuning_job( request_type=job_service.CancelHyperparameterTuningJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4290,13 +4114,11 @@ def test_cancel_hyperparameter_tuning_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4311,7 +4133,7 @@ def test_cancel_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4321,7 +4143,6 @@ def test_cancel_hyperparameter_tuning_job_empty_call(): client.cancel_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelHyperparameterTuningJobRequest() @@ -4331,7 +4152,7 @@ async def test_cancel_hyperparameter_tuning_job_async( request_type=job_service.CancelHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4344,13 +4165,11 @@ async def test_cancel_hyperparameter_tuning_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4363,11 +4182,12 @@ async def test_cancel_hyperparameter_tuning_job_async_from_dict(): def test_cancel_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4375,7 +4195,6 @@ def test_cancel_hyperparameter_tuning_job_field_headers(): type(client.transport.cancel_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = None - client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4390,11 +4209,12 @@ def test_cancel_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_cancel_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4402,7 +4222,6 @@ async def test_cancel_hyperparameter_tuning_job_field_headers_async(): type(client.transport.cancel_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4416,7 +4235,7 @@ async def test_cancel_hyperparameter_tuning_job_field_headers_async(): def test_cancel_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4424,7 +4243,6 @@ def test_cancel_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_hyperparameter_tuning_job(name="name_value",) @@ -4433,12 +4251,11 @@ def test_cancel_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4450,7 +4267,7 @@ def test_cancel_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4468,13 +4285,12 @@ async def test_cancel_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4488,7 +4304,7 @@ def test_create_batch_prediction_job( transport: str = "grpc", request_type=job_service.CreateBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4506,25 +4322,18 @@ def test_create_batch_prediction_job( model="model_value", state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateBatchPredictionJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4536,7 +4345,7 @@ def test_create_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4546,7 +4355,6 @@ def test_create_batch_prediction_job_empty_call(): client.create_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateBatchPredictionJobRequest() @@ -4556,7 +4364,7 @@ async def test_create_batch_prediction_job_async( request_type=job_service.CreateBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4576,24 +4384,18 @@ async def test_create_batch_prediction_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateBatchPredictionJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4603,11 +4405,12 @@ async def test_create_batch_prediction_job_async_from_dict(): def test_create_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateBatchPredictionJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4615,7 +4418,6 @@ def test_create_batch_prediction_job_field_headers(): type(client.transport.create_batch_prediction_job), "__call__" ) as call: call.return_value = gca_batch_prediction_job.BatchPredictionJob() - client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4630,11 +4432,12 @@ def test_create_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_create_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateBatchPredictionJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4644,7 +4447,6 @@ async def test_create_batch_prediction_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_batch_prediction_job.BatchPredictionJob() ) - await client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4658,7 +4460,7 @@ async def test_create_batch_prediction_job_field_headers_async(): def test_create_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4666,7 +4468,6 @@ def test_create_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_batch_prediction_job.BatchPredictionJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_batch_prediction_job( @@ -4680,9 +4481,7 @@ def test_create_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].batch_prediction_job == gca_batch_prediction_job.BatchPredictionJob( @@ -4691,7 +4490,7 @@ def test_create_batch_prediction_job_flattened(): def test_create_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4707,7 +4506,7 @@ def test_create_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_create_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4732,9 +4531,7 @@ async def test_create_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].batch_prediction_job == gca_batch_prediction_job.BatchPredictionJob( @@ -4744,7 +4541,7 @@ async def test_create_batch_prediction_job_flattened_async(): @pytest.mark.asyncio async def test_create_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4762,7 +4559,7 @@ def test_get_batch_prediction_job( transport: str = "grpc", request_type=job_service.GetBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4780,25 +4577,18 @@ def test_get_batch_prediction_job( model="model_value", state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetBatchPredictionJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4810,7 +4600,7 @@ def test_get_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4820,7 +4610,6 @@ def test_get_batch_prediction_job_empty_call(): client.get_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetBatchPredictionJobRequest() @@ -4830,7 +4619,7 @@ async def test_get_batch_prediction_job_async( request_type=job_service.GetBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4850,24 +4639,18 @@ async def test_get_batch_prediction_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetBatchPredictionJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4877,11 +4660,12 @@ async def test_get_batch_prediction_job_async_from_dict(): def test_get_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4889,7 +4673,6 @@ def test_get_batch_prediction_job_field_headers(): type(client.transport.get_batch_prediction_job), "__call__" ) as call: call.return_value = batch_prediction_job.BatchPredictionJob() - client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4904,11 +4687,12 @@ def test_get_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_get_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4918,7 +4702,6 @@ async def test_get_batch_prediction_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( batch_prediction_job.BatchPredictionJob() ) - await client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4932,7 +4715,7 @@ async def test_get_batch_prediction_job_field_headers_async(): def test_get_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4940,7 +4723,6 @@ def test_get_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = batch_prediction_job.BatchPredictionJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_batch_prediction_job(name="name_value",) @@ -4949,12 +4731,11 @@ def test_get_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4966,7 +4747,7 @@ def test_get_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_get_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4986,13 +4767,12 @@ async def test_get_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5006,7 +4786,7 @@ def test_list_batch_prediction_jobs( transport: str = "grpc", request_type=job_service.ListBatchPredictionJobsRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5021,19 +4801,15 @@ def test_list_batch_prediction_jobs( call.return_value = job_service.ListBatchPredictionJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListBatchPredictionJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBatchPredictionJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -5045,7 +4821,7 @@ def test_list_batch_prediction_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5055,7 +4831,6 @@ def test_list_batch_prediction_jobs_empty_call(): client.list_batch_prediction_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListBatchPredictionJobsRequest() @@ -5065,7 +4840,7 @@ async def test_list_batch_prediction_jobs_async( request_type=job_service.ListBatchPredictionJobsRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5082,18 +4857,15 @@ async def test_list_batch_prediction_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListBatchPredictionJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListBatchPredictionJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -5103,11 +4875,12 @@ async def test_list_batch_prediction_jobs_async_from_dict(): def test_list_batch_prediction_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListBatchPredictionJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5115,7 +4888,6 @@ def test_list_batch_prediction_jobs_field_headers(): type(client.transport.list_batch_prediction_jobs), "__call__" ) as call: call.return_value = job_service.ListBatchPredictionJobsResponse() - client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -5130,11 +4902,12 @@ def test_list_batch_prediction_jobs_field_headers(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListBatchPredictionJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5144,7 +4917,6 @@ async def test_list_batch_prediction_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListBatchPredictionJobsResponse() ) - await client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -5158,7 +4930,7 @@ async def test_list_batch_prediction_jobs_field_headers_async(): def test_list_batch_prediction_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5166,7 +4938,6 @@ def test_list_batch_prediction_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListBatchPredictionJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_batch_prediction_jobs(parent="parent_value",) @@ -5175,12 +4946,11 @@ def test_list_batch_prediction_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_batch_prediction_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5192,7 +4962,7 @@ def test_list_batch_prediction_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5212,13 +4982,12 @@ async def test_list_batch_prediction_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_batch_prediction_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5229,7 +4998,7 @@ async def test_list_batch_prediction_jobs_flattened_error_async(): def test_list_batch_prediction_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5277,7 +5046,7 @@ def test_list_batch_prediction_jobs_pager(): def test_list_batch_prediction_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5315,7 +5084,7 @@ def test_list_batch_prediction_jobs_pages(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5362,7 +5131,7 @@ async def test_list_batch_prediction_jobs_async_pager(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5406,7 +5175,7 @@ def test_delete_batch_prediction_job( transport: str = "grpc", request_type=job_service.DeleteBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5419,13 +5188,11 @@ def test_delete_batch_prediction_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5440,7 +5207,7 @@ def test_delete_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5450,7 +5217,6 @@ def test_delete_batch_prediction_job_empty_call(): client.delete_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteBatchPredictionJobRequest() @@ -5460,7 +5226,7 @@ async def test_delete_batch_prediction_job_async( request_type=job_service.DeleteBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5475,13 +5241,11 @@ async def test_delete_batch_prediction_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5494,11 +5258,12 @@ async def test_delete_batch_prediction_job_async_from_dict(): def test_delete_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5506,7 +5271,6 @@ def test_delete_batch_prediction_job_field_headers(): type(client.transport.delete_batch_prediction_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5521,11 +5285,12 @@ def test_delete_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_delete_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5535,7 +5300,6 @@ async def test_delete_batch_prediction_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5549,7 +5313,7 @@ async def test_delete_batch_prediction_job_field_headers_async(): def test_delete_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5557,7 +5321,6 @@ def test_delete_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_batch_prediction_job(name="name_value",) @@ -5566,12 +5329,11 @@ def test_delete_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5583,7 +5345,7 @@ def test_delete_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_delete_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5603,13 +5365,12 @@ async def test_delete_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5623,7 +5384,7 @@ def test_cancel_batch_prediction_job( transport: str = "grpc", request_type=job_service.CancelBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5636,13 +5397,11 @@ def test_cancel_batch_prediction_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5657,7 +5416,7 @@ def test_cancel_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5667,7 +5426,6 @@ def test_cancel_batch_prediction_job_empty_call(): client.cancel_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelBatchPredictionJobRequest() @@ -5677,7 +5435,7 @@ async def test_cancel_batch_prediction_job_async( request_type=job_service.CancelBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5690,13 +5448,11 @@ async def test_cancel_batch_prediction_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5709,11 +5465,12 @@ async def test_cancel_batch_prediction_job_async_from_dict(): def test_cancel_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5721,7 +5478,6 @@ def test_cancel_batch_prediction_job_field_headers(): type(client.transport.cancel_batch_prediction_job), "__call__" ) as call: call.return_value = None - client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5736,11 +5492,12 @@ def test_cancel_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_cancel_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5748,7 +5505,6 @@ async def test_cancel_batch_prediction_job_field_headers_async(): type(client.transport.cancel_batch_prediction_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5762,7 +5518,7 @@ async def test_cancel_batch_prediction_job_field_headers_async(): def test_cancel_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5770,7 +5526,6 @@ def test_cancel_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_batch_prediction_job(name="name_value",) @@ -5779,12 +5534,11 @@ def test_cancel_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5796,7 +5550,7 @@ def test_cancel_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5814,13 +5568,12 @@ async def test_cancel_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5833,16 +5586,16 @@ async def test_cancel_batch_prediction_job_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = JobServiceClient( @@ -5852,7 +5605,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = JobServiceClient( @@ -5863,7 +5616,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = JobServiceClient(transport=transport) assert client.transport is transport @@ -5872,13 +5625,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.JobServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -5890,23 +5643,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.JobServiceGrpcTransport,) def test_job_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.JobServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -5918,7 +5671,7 @@ def test_job_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.JobServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -5955,15 +5708,37 @@ def test_job_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_job_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.job_service.transports.JobServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.JobServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_job_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1.services.job_service.transports.JobServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.JobServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -5976,19 +5751,33 @@ def test_job_service_base_transport_with_credentials_file(): def test_job_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1.services.job_service.transports.JobServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.JobServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_job_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + JobServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_job_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) JobServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -5996,26 +5785,156 @@ def test_job_service_auth_adc(): ) -def test_job_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [transports.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport,], +) +@requires_google_auth_gte_1_25_0 +def test_job_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.JobServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [transports.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport,], +) +@requires_google_auth_lt_1_25_0 +def test_job_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_job_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_job_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_job_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [transports.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport], ) def test_job_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -6054,7 +5973,7 @@ def test_job_service_grpc_transport_client_cert_source_for_mtls(transport_class) def test_job_service_host_no_port(): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -6064,7 +5983,7 @@ def test_job_service_host_no_port(): def test_job_service_host_with_port(): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -6115,9 +6034,9 @@ def test_job_service_transport_channel_mtls_with_client_cert_source(transport_cl mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -6190,7 +6109,7 @@ def test_job_service_transport_channel_mtls_with_adc(transport_class): def test_job_service_grpc_lro_client(): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -6203,7 +6122,7 @@ def test_job_service_grpc_lro_client(): def test_job_service_grpc_lro_async_client(): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -6218,7 +6137,6 @@ def test_batch_prediction_job_path(): project = "squid" location = "clam" batch_prediction_job = "whelk" - expected = "projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}".format( project=project, location=location, batch_prediction_job=batch_prediction_job, ) @@ -6245,7 +6163,6 @@ def test_custom_job_path(): project = "cuttlefish" location = "mussel" custom_job = "winkle" - expected = "projects/{project}/locations/{location}/customJobs/{custom_job}".format( project=project, location=location, custom_job=custom_job, ) @@ -6270,7 +6187,6 @@ def test_data_labeling_job_path(): project = "squid" location = "clam" data_labeling_job = "whelk" - expected = "projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}".format( project=project, location=location, data_labeling_job=data_labeling_job, ) @@ -6297,7 +6213,6 @@ def test_dataset_path(): project = "cuttlefish" location = "mussel" dataset = "winkle" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( project=project, location=location, dataset=dataset, ) @@ -6322,7 +6237,6 @@ def test_hyperparameter_tuning_job_path(): project = "squid" location = "clam" hyperparameter_tuning_job = "whelk" - expected = "projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}".format( project=project, location=location, @@ -6351,7 +6265,6 @@ def test_model_path(): project = "cuttlefish" location = "mussel" model = "winkle" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -6377,7 +6290,6 @@ def test_trial_path(): location = "clam" study = "whelk" trial = "octopus" - expected = "projects/{project}/locations/{location}/studies/{study}/trials/{trial}".format( project=project, location=location, study=study, trial=trial, ) @@ -6401,7 +6313,6 @@ def test_parse_trial_path(): def test_common_billing_account_path(): billing_account = "winkle" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -6422,7 +6333,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) actual = JobServiceClient.common_folder_path(folder) assert expected == actual @@ -6441,7 +6351,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) actual = JobServiceClient.common_organization_path(organization) assert expected == actual @@ -6460,7 +6369,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) actual = JobServiceClient.common_project_path(project) assert expected == actual @@ -6480,7 +6388,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "oyster" location = "nudibranch" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -6507,7 +6414,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.JobServiceTransport, "_prep_wrapped_messages" ) as prep: client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -6516,6 +6423,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = JobServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1/test_migration_service.py b/tests/unit/gapic/aiplatform_v1/test_migration_service.py index d1b0b51231..d4d1abdd46 100644 --- a/tests/unit/gapic/aiplatform_v1/test_migration_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_migration_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1.services.migration_service import ( MigrationServiceAsyncClient, @@ -41,10 +40,40 @@ from google.cloud.aiplatform_v1.services.migration_service import MigrationServiceClient from google.cloud.aiplatform_v1.services.migration_service import pagers from google.cloud.aiplatform_v1.services.migration_service import transports +from google.cloud.aiplatform_v1.services.migration_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.migration_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1.types import migratable_resource from google.cloud.aiplatform_v1.types import migration_service from google.longrunning import operations_pb2 from google.oauth2 import service_account +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -96,7 +125,7 @@ def test__get_default_mtls_endpoint(): "client_class", [MigrationServiceClient, MigrationServiceAsyncClient,] ) def test_migration_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -113,7 +142,7 @@ def test_migration_service_client_from_service_account_info(client_class): "client_class", [MigrationServiceClient, MigrationServiceAsyncClient,] ) def test_migration_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -166,7 +195,7 @@ def test_migration_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(MigrationServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -465,7 +494,7 @@ def test_search_migratable_resources( request_type=migration_service.SearchMigratableResourcesRequest, ): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -480,19 +509,15 @@ def test_search_migratable_resources( call.return_value = migration_service.SearchMigratableResourcesResponse( next_page_token="next_page_token_value", ) - response = client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.SearchMigratableResourcesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchMigratableResourcesPager) - assert response.next_page_token == "next_page_token_value" @@ -504,7 +529,7 @@ def test_search_migratable_resources_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -514,7 +539,6 @@ def test_search_migratable_resources_empty_call(): client.search_migratable_resources() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.SearchMigratableResourcesRequest() @@ -524,7 +548,7 @@ async def test_search_migratable_resources_async( request_type=migration_service.SearchMigratableResourcesRequest, ): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -541,18 +565,15 @@ async def test_search_migratable_resources_async( next_page_token="next_page_token_value", ) ) - response = await client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.SearchMigratableResourcesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchMigratableResourcesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -562,11 +583,12 @@ async def test_search_migratable_resources_async_from_dict(): def test_search_migratable_resources_field_headers(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.SearchMigratableResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -574,7 +596,6 @@ def test_search_migratable_resources_field_headers(): type(client.transport.search_migratable_resources), "__call__" ) as call: call.return_value = migration_service.SearchMigratableResourcesResponse() - client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. @@ -590,12 +611,13 @@ def test_search_migratable_resources_field_headers(): @pytest.mark.asyncio async def test_search_migratable_resources_field_headers_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.SearchMigratableResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -605,7 +627,6 @@ async def test_search_migratable_resources_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( migration_service.SearchMigratableResourcesResponse() ) - await client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. @@ -619,7 +640,7 @@ async def test_search_migratable_resources_field_headers_async(): def test_search_migratable_resources_flattened(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -627,7 +648,6 @@ def test_search_migratable_resources_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = migration_service.SearchMigratableResourcesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_migratable_resources(parent="parent_value",) @@ -636,12 +656,11 @@ def test_search_migratable_resources_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_search_migratable_resources_flattened_error(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -654,7 +673,7 @@ def test_search_migratable_resources_flattened_error(): @pytest.mark.asyncio async def test_search_migratable_resources_flattened_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -675,14 +694,13 @@ async def test_search_migratable_resources_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_search_migratable_resources_flattened_error_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -694,7 +712,7 @@ async def test_search_migratable_resources_flattened_error_async(): def test_search_migratable_resources_pager(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -742,7 +760,7 @@ def test_search_migratable_resources_pager(): def test_search_migratable_resources_pages(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -780,7 +798,9 @@ def test_search_migratable_resources_pages(): @pytest.mark.asyncio async def test_search_migratable_resources_async_pager(): - client = MigrationServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -827,7 +847,9 @@ async def test_search_migratable_resources_async_pager(): @pytest.mark.asyncio async def test_search_migratable_resources_async_pages(): - client = MigrationServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -871,7 +893,7 @@ def test_batch_migrate_resources( transport: str = "grpc", request_type=migration_service.BatchMigrateResourcesRequest ): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -884,13 +906,11 @@ def test_batch_migrate_resources( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.BatchMigrateResourcesRequest() # Establish that the response is the type that we expect. @@ -905,7 +925,7 @@ def test_batch_migrate_resources_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -915,7 +935,6 @@ def test_batch_migrate_resources_empty_call(): client.batch_migrate_resources() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.BatchMigrateResourcesRequest() @@ -925,7 +944,7 @@ async def test_batch_migrate_resources_async( request_type=migration_service.BatchMigrateResourcesRequest, ): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -940,13 +959,11 @@ async def test_batch_migrate_resources_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.BatchMigrateResourcesRequest() # Establish that the response is the type that we expect. @@ -959,11 +976,12 @@ async def test_batch_migrate_resources_async_from_dict(): def test_batch_migrate_resources_field_headers(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.BatchMigrateResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -971,7 +989,6 @@ def test_batch_migrate_resources_field_headers(): type(client.transport.batch_migrate_resources), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. @@ -987,12 +1004,13 @@ def test_batch_migrate_resources_field_headers(): @pytest.mark.asyncio async def test_batch_migrate_resources_field_headers_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.BatchMigrateResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1002,7 +1020,6 @@ async def test_batch_migrate_resources_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. @@ -1016,7 +1033,7 @@ async def test_batch_migrate_resources_field_headers_async(): def test_batch_migrate_resources_flattened(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1024,7 +1041,6 @@ def test_batch_migrate_resources_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.batch_migrate_resources( @@ -1042,9 +1058,7 @@ def test_batch_migrate_resources_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].migrate_resource_requests == [ migration_service.MigrateResourceRequest( migrate_ml_engine_model_version_config=migration_service.MigrateResourceRequest.MigrateMlEngineModelVersionConfig( @@ -1055,7 +1069,7 @@ def test_batch_migrate_resources_flattened(): def test_batch_migrate_resources_flattened_error(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1076,7 +1090,7 @@ def test_batch_migrate_resources_flattened_error(): @pytest.mark.asyncio async def test_batch_migrate_resources_flattened_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1106,9 +1120,7 @@ async def test_batch_migrate_resources_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].migrate_resource_requests == [ migration_service.MigrateResourceRequest( migrate_ml_engine_model_version_config=migration_service.MigrateResourceRequest.MigrateMlEngineModelVersionConfig( @@ -1121,7 +1133,7 @@ async def test_batch_migrate_resources_flattened_async(): @pytest.mark.asyncio async def test_batch_migrate_resources_flattened_error_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1143,16 +1155,16 @@ async def test_batch_migrate_resources_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MigrationServiceClient( @@ -1162,7 +1174,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MigrationServiceClient( @@ -1173,7 +1185,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = MigrationServiceClient(transport=transport) assert client.transport is transport @@ -1182,13 +1194,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.MigrationServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -1203,23 +1215,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.MigrationServiceGrpcTransport,) def test_migration_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.MigrationServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1231,7 +1243,7 @@ def test_migration_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.MigrationServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -1250,15 +1262,37 @@ def test_migration_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_migration_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.MigrationServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_migration_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.MigrationServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -1271,19 +1305,33 @@ def test_migration_service_base_transport_with_credentials_file(): def test_migration_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.MigrationServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_migration_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + MigrationServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_migration_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) MigrationServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -1291,20 +1339,156 @@ def test_migration_service_auth_adc(): ) -def test_migration_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.MigrationServiceGrpcTransport, + transports.MigrationServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_migration_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.MigrationServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.MigrationServiceGrpcTransport, + transports.MigrationServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_migration_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MigrationServiceGrpcTransport, grpc_helpers), + (transports.MigrationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_migration_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MigrationServiceGrpcTransport, grpc_helpers), + (transports.MigrationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_migration_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MigrationServiceGrpcTransport, grpc_helpers), + (transports.MigrationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_migration_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -1313,7 +1497,7 @@ def test_migration_service_transport_auth_adc(): ], ) def test_migration_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -1352,7 +1536,7 @@ def test_migration_service_grpc_transport_client_cert_source_for_mtls(transport_ def test_migration_service_host_no_port(): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -1362,7 +1546,7 @@ def test_migration_service_host_no_port(): def test_migration_service_host_with_port(): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -1418,9 +1602,9 @@ def test_migration_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -1496,7 +1680,7 @@ def test_migration_service_transport_channel_mtls_with_adc(transport_class): def test_migration_service_grpc_lro_client(): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -1509,7 +1693,7 @@ def test_migration_service_grpc_lro_client(): def test_migration_service_grpc_lro_async_client(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -1524,7 +1708,6 @@ def test_annotated_dataset_path(): project = "squid" dataset = "clam" annotated_dataset = "whelk" - expected = "projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}".format( project=project, dataset=dataset, annotated_dataset=annotated_dataset, ) @@ -1549,21 +1732,18 @@ def test_parse_annotated_dataset_path(): def test_dataset_path(): project = "cuttlefish" - location = "mussel" - dataset = "winkle" - - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( - project=project, location=location, dataset=dataset, + dataset = "mussel" + expected = "projects/{project}/datasets/{dataset}".format( + project=project, dataset=dataset, ) - actual = MigrationServiceClient.dataset_path(project, location, dataset) + actual = MigrationServiceClient.dataset_path(project, dataset) assert expected == actual def test_parse_dataset_path(): expected = { - "project": "nautilus", - "location": "scallop", - "dataset": "abalone", + "project": "winkle", + "dataset": "nautilus", } path = MigrationServiceClient.dataset_path(**expected) @@ -1573,19 +1753,20 @@ def test_parse_dataset_path(): def test_dataset_path(): - project = "squid" - dataset = "clam" - - expected = "projects/{project}/datasets/{dataset}".format( - project=project, dataset=dataset, + project = "scallop" + location = "abalone" + dataset = "squid" + expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( + project=project, location=location, dataset=dataset, ) - actual = MigrationServiceClient.dataset_path(project, dataset) + actual = MigrationServiceClient.dataset_path(project, location, dataset) assert expected == actual def test_parse_dataset_path(): expected = { - "project": "whelk", + "project": "clam", + "location": "whelk", "dataset": "octopus", } path = MigrationServiceClient.dataset_path(**expected) @@ -1599,7 +1780,6 @@ def test_dataset_path(): project = "oyster" location = "nudibranch" dataset = "cuttlefish" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( project=project, location=location, dataset=dataset, ) @@ -1624,7 +1804,6 @@ def test_model_path(): project = "scallop" location = "abalone" model = "squid" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -1649,7 +1828,6 @@ def test_model_path(): project = "oyster" location = "nudibranch" model = "cuttlefish" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -1674,7 +1852,6 @@ def test_version_path(): project = "scallop" model = "abalone" version = "squid" - expected = "projects/{project}/models/{model}/versions/{version}".format( project=project, model=model, version=version, ) @@ -1697,7 +1874,6 @@ def test_parse_version_path(): def test_common_billing_account_path(): billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -1718,7 +1894,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) actual = MigrationServiceClient.common_folder_path(folder) assert expected == actual @@ -1737,7 +1912,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) actual = MigrationServiceClient.common_organization_path(organization) assert expected == actual @@ -1756,7 +1930,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) actual = MigrationServiceClient.common_project_path(project) assert expected == actual @@ -1776,7 +1949,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "squid" location = "clam" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -1803,7 +1975,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.MigrationServiceTransport, "_prep_wrapped_messages" ) as prep: client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1812,6 +1984,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = MigrationServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1/test_model_service.py b/tests/unit/gapic/aiplatform_v1/test_model_service.py index f74aea2dea..bfc0d94a16 100644 --- a/tests/unit/gapic/aiplatform_v1/test_model_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_model_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,21 +23,27 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1.services.model_service import ModelServiceAsyncClient from google.cloud.aiplatform_v1.services.model_service import ModelServiceClient from google.cloud.aiplatform_v1.services.model_service import pagers from google.cloud.aiplatform_v1.services.model_service import transports +from google.cloud.aiplatform_v1.services.model_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.model_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1.types import deployed_model_ref from google.cloud.aiplatform_v1.types import encryption_spec from google.cloud.aiplatform_v1.types import env_var @@ -51,9 +56,33 @@ from google.cloud.aiplatform_v1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -99,7 +128,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [ModelServiceClient, ModelServiceAsyncClient,]) def test_model_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -114,7 +143,7 @@ def test_model_service_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [ModelServiceClient, ModelServiceAsyncClient,]) def test_model_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -165,7 +194,7 @@ def test_model_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(ModelServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -449,7 +478,7 @@ def test_upload_model( transport: str = "grpc", request_type=model_service.UploadModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -460,13 +489,11 @@ def test_upload_model( with mock.patch.object(type(client.transport.upload_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.upload_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UploadModelRequest() # Establish that the response is the type that we expect. @@ -481,7 +508,7 @@ def test_upload_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -489,7 +516,6 @@ def test_upload_model_empty_call(): client.upload_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UploadModelRequest() @@ -498,7 +524,7 @@ async def test_upload_model_async( transport: str = "grpc_asyncio", request_type=model_service.UploadModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -511,13 +537,11 @@ async def test_upload_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.upload_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UploadModelRequest() # Establish that the response is the type that we expect. @@ -530,17 +554,17 @@ async def test_upload_model_async_from_dict(): def test_upload_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UploadModelRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.upload_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.upload_model(request) # Establish that the underlying gRPC stub method was called. @@ -555,11 +579,12 @@ def test_upload_model_field_headers(): @pytest.mark.asyncio async def test_upload_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UploadModelRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -567,7 +592,6 @@ async def test_upload_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.upload_model(request) # Establish that the underlying gRPC stub method was called. @@ -581,13 +605,12 @@ async def test_upload_model_field_headers_async(): def test_upload_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.upload_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.upload_model( @@ -598,14 +621,12 @@ def test_upload_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == gca_model.Model(name="name_value") def test_upload_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -619,7 +640,7 @@ def test_upload_model_flattened_error(): @pytest.mark.asyncio async def test_upload_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.upload_model), "__call__") as call: @@ -639,15 +660,13 @@ async def test_upload_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == gca_model.Model(name="name_value") @pytest.mark.asyncio async def test_upload_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -661,7 +680,7 @@ async def test_upload_model_flattened_error_async(): def test_get_model(transport: str = "grpc", request_type=model_service.GetModelRequest): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -685,43 +704,30 @@ def test_get_model(transport: str = "grpc", request_type=model_service.GetModelR supported_output_storage_formats=["supported_output_storage_formats_value"], etag="etag_value", ) - response = client.get_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -733,7 +739,7 @@ def test_get_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -741,7 +747,6 @@ def test_get_model_empty_call(): client.get_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelRequest() @@ -750,7 +755,7 @@ async def test_get_model_async( transport: str = "grpc_asyncio", request_type=model_service.GetModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -780,42 +785,30 @@ async def test_get_model_async( etag="etag_value", ) ) - response = await client.get_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelRequest() # Establish that the response is the type that we expect. assert isinstance(response, model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -825,17 +818,17 @@ async def test_get_model_async_from_dict(): def test_get_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: call.return_value = model.Model() - client.get_model(request) # Establish that the underlying gRPC stub method was called. @@ -850,17 +843,17 @@ def test_get_model_field_headers(): @pytest.mark.asyncio async def test_get_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(model.Model()) - await client.get_model(request) # Establish that the underlying gRPC stub method was called. @@ -874,13 +867,12 @@ async def test_get_model_field_headers_async(): def test_get_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = model.Model() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_model(name="name_value",) @@ -889,12 +881,11 @@ def test_get_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -906,7 +897,7 @@ def test_get_model_flattened_error(): @pytest.mark.asyncio async def test_get_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: @@ -922,13 +913,12 @@ async def test_get_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -942,7 +932,7 @@ def test_list_models( transport: str = "grpc", request_type=model_service.ListModelsRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -955,19 +945,15 @@ def test_list_models( call.return_value = model_service.ListModelsResponse( next_page_token="next_page_token_value", ) - response = client.list_models(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListModelsPager) - assert response.next_page_token == "next_page_token_value" @@ -979,7 +965,7 @@ def test_list_models_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -987,7 +973,6 @@ def test_list_models_empty_call(): client.list_models() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelsRequest() @@ -996,7 +981,7 @@ async def test_list_models_async( transport: str = "grpc_asyncio", request_type=model_service.ListModelsRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1009,18 +994,15 @@ async def test_list_models_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_models(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListModelsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1030,17 +1012,17 @@ async def test_list_models_async_from_dict(): def test_list_models_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: call.return_value = model_service.ListModelsResponse() - client.list_models(request) # Establish that the underlying gRPC stub method was called. @@ -1055,11 +1037,12 @@ def test_list_models_field_headers(): @pytest.mark.asyncio async def test_list_models_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1067,7 +1050,6 @@ async def test_list_models_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelsResponse() ) - await client.list_models(request) # Establish that the underlying gRPC stub method was called. @@ -1081,13 +1063,12 @@ async def test_list_models_field_headers_async(): def test_list_models_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = model_service.ListModelsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_models(parent="parent_value",) @@ -1096,12 +1077,11 @@ def test_list_models_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_models_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1113,7 +1093,7 @@ def test_list_models_flattened_error(): @pytest.mark.asyncio async def test_list_models_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: @@ -1131,13 +1111,12 @@ async def test_list_models_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_models_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1148,7 +1127,7 @@ async def test_list_models_flattened_error_async(): def test_list_models_pager(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: @@ -1180,7 +1159,7 @@ def test_list_models_pager(): def test_list_models_pages(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: @@ -1204,7 +1183,7 @@ def test_list_models_pages(): @pytest.mark.asyncio async def test_list_models_async_pager(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1235,7 +1214,7 @@ async def test_list_models_async_pager(): @pytest.mark.asyncio async def test_list_models_async_pages(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1265,7 +1244,7 @@ def test_update_model( transport: str = "grpc", request_type=model_service.UpdateModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1289,43 +1268,30 @@ def test_update_model( supported_output_storage_formats=["supported_output_storage_formats_value"], etag="etag_value", ) - response = client.update_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UpdateModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ gca_model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -1337,7 +1303,7 @@ def test_update_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1345,7 +1311,6 @@ def test_update_model_empty_call(): client.update_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UpdateModelRequest() @@ -1354,7 +1319,7 @@ async def test_update_model_async( transport: str = "grpc_asyncio", request_type=model_service.UpdateModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1384,42 +1349,30 @@ async def test_update_model_async( etag="etag_value", ) ) - response = await client.update_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UpdateModelRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ gca_model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -1429,17 +1382,17 @@ async def test_update_model_async_from_dict(): def test_update_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UpdateModelRequest() + request.model.name = "model.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: call.return_value = gca_model.Model() - client.update_model(request) # Establish that the underlying gRPC stub method was called. @@ -1454,17 +1407,17 @@ def test_update_model_field_headers(): @pytest.mark.asyncio async def test_update_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UpdateModelRequest() + request.model.name = "model.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_model.Model()) - await client.update_model(request) # Establish that the underlying gRPC stub method was called. @@ -1478,32 +1431,29 @@ async def test_update_model_field_headers_async(): def test_update_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_model.Model() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_model( model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].model == gca_model.Model(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1511,13 +1461,13 @@ def test_update_model_flattened_error(): client.update_model( model_service.UpdateModelRequest(), model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: @@ -1529,22 +1479,20 @@ async def test_update_model_flattened_async(): # using the keyword arguments to the method. response = await client.update_model( model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].model == gca_model.Model(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1552,7 +1500,7 @@ async def test_update_model_flattened_error_async(): await client.update_model( model_service.UpdateModelRequest(), model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1560,7 +1508,7 @@ def test_delete_model( transport: str = "grpc", request_type=model_service.DeleteModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1571,13 +1519,11 @@ def test_delete_model( with mock.patch.object(type(client.transport.delete_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.DeleteModelRequest() # Establish that the response is the type that we expect. @@ -1592,7 +1538,7 @@ def test_delete_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1600,7 +1546,6 @@ def test_delete_model_empty_call(): client.delete_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.DeleteModelRequest() @@ -1609,7 +1554,7 @@ async def test_delete_model_async( transport: str = "grpc_asyncio", request_type=model_service.DeleteModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1622,13 +1567,11 @@ async def test_delete_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.DeleteModelRequest() # Establish that the response is the type that we expect. @@ -1641,17 +1584,17 @@ async def test_delete_model_async_from_dict(): def test_delete_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.DeleteModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_model(request) # Establish that the underlying gRPC stub method was called. @@ -1666,11 +1609,12 @@ def test_delete_model_field_headers(): @pytest.mark.asyncio async def test_delete_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.DeleteModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1678,7 +1622,6 @@ async def test_delete_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_model(request) # Establish that the underlying gRPC stub method was called. @@ -1692,13 +1635,12 @@ async def test_delete_model_field_headers_async(): def test_delete_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_model(name="name_value",) @@ -1707,12 +1649,11 @@ def test_delete_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1724,7 +1665,7 @@ def test_delete_model_flattened_error(): @pytest.mark.asyncio async def test_delete_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_model), "__call__") as call: @@ -1742,13 +1683,12 @@ async def test_delete_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1762,7 +1702,7 @@ def test_export_model( transport: str = "grpc", request_type=model_service.ExportModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1773,13 +1713,11 @@ def test_export_model( with mock.patch.object(type(client.transport.export_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.export_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ExportModelRequest() # Establish that the response is the type that we expect. @@ -1794,7 +1732,7 @@ def test_export_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1802,7 +1740,6 @@ def test_export_model_empty_call(): client.export_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ExportModelRequest() @@ -1811,7 +1748,7 @@ async def test_export_model_async( transport: str = "grpc_asyncio", request_type=model_service.ExportModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1824,13 +1761,11 @@ async def test_export_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.export_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ExportModelRequest() # Establish that the response is the type that we expect. @@ -1843,17 +1778,17 @@ async def test_export_model_async_from_dict(): def test_export_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ExportModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.export_model(request) # Establish that the underlying gRPC stub method was called. @@ -1868,11 +1803,12 @@ def test_export_model_field_headers(): @pytest.mark.asyncio async def test_export_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ExportModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1880,7 +1816,6 @@ async def test_export_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.export_model(request) # Establish that the underlying gRPC stub method was called. @@ -1894,13 +1829,12 @@ async def test_export_model_field_headers_async(): def test_export_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.export_model( @@ -1914,16 +1848,14 @@ def test_export_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == model_service.ExportModelRequest.OutputConfig( export_format_id="export_format_id_value" ) def test_export_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1939,7 +1871,7 @@ def test_export_model_flattened_error(): @pytest.mark.asyncio async def test_export_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_model), "__call__") as call: @@ -1962,9 +1894,7 @@ async def test_export_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == model_service.ExportModelRequest.OutputConfig( export_format_id="export_format_id_value" ) @@ -1972,7 +1902,7 @@ async def test_export_model_flattened_async(): @pytest.mark.asyncio async def test_export_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1990,7 +1920,7 @@ def test_get_model_evaluation( transport: str = "grpc", request_type=model_service.GetModelEvaluationRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2007,23 +1937,17 @@ def test_get_model_evaluation( metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], ) - response = client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, model_evaluation.ModelEvaluation) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" - assert response.slice_dimensions == ["slice_dimensions_value"] @@ -2035,7 +1959,7 @@ def test_get_model_evaluation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2045,7 +1969,6 @@ def test_get_model_evaluation_empty_call(): client.get_model_evaluation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationRequest() @@ -2055,7 +1978,7 @@ async def test_get_model_evaluation_async( request_type=model_service.GetModelEvaluationRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2074,22 +1997,17 @@ async def test_get_model_evaluation_async( slice_dimensions=["slice_dimensions_value"], ) ) - response = await client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationRequest() # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation.ModelEvaluation) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" - assert response.slice_dimensions == ["slice_dimensions_value"] @@ -2099,11 +2017,12 @@ async def test_get_model_evaluation_async_from_dict(): def test_get_model_evaluation_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2111,7 +2030,6 @@ def test_get_model_evaluation_field_headers(): type(client.transport.get_model_evaluation), "__call__" ) as call: call.return_value = model_evaluation.ModelEvaluation() - client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. @@ -2126,11 +2044,12 @@ def test_get_model_evaluation_field_headers(): @pytest.mark.asyncio async def test_get_model_evaluation_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2140,7 +2059,6 @@ async def test_get_model_evaluation_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_evaluation.ModelEvaluation() ) - await client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. @@ -2154,7 +2072,7 @@ async def test_get_model_evaluation_field_headers_async(): def test_get_model_evaluation_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2162,7 +2080,6 @@ def test_get_model_evaluation_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_evaluation.ModelEvaluation() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_model_evaluation(name="name_value",) @@ -2171,12 +2088,11 @@ def test_get_model_evaluation_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_model_evaluation_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2188,7 +2104,7 @@ def test_get_model_evaluation_flattened_error(): @pytest.mark.asyncio async def test_get_model_evaluation_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2208,13 +2124,12 @@ async def test_get_model_evaluation_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_model_evaluation_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2228,7 +2143,7 @@ def test_list_model_evaluations( transport: str = "grpc", request_type=model_service.ListModelEvaluationsRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2243,19 +2158,15 @@ def test_list_model_evaluations( call.return_value = model_service.ListModelEvaluationsResponse( next_page_token="next_page_token_value", ) - response = client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListModelEvaluationsPager) - assert response.next_page_token == "next_page_token_value" @@ -2267,7 +2178,7 @@ def test_list_model_evaluations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2277,7 +2188,6 @@ def test_list_model_evaluations_empty_call(): client.list_model_evaluations() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationsRequest() @@ -2287,7 +2197,7 @@ async def test_list_model_evaluations_async( request_type=model_service.ListModelEvaluationsRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2304,18 +2214,15 @@ async def test_list_model_evaluations_async( next_page_token="next_page_token_value", ) ) - response = await client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListModelEvaluationsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2325,11 +2232,12 @@ async def test_list_model_evaluations_async_from_dict(): def test_list_model_evaluations_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2337,7 +2245,6 @@ def test_list_model_evaluations_field_headers(): type(client.transport.list_model_evaluations), "__call__" ) as call: call.return_value = model_service.ListModelEvaluationsResponse() - client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. @@ -2352,11 +2259,12 @@ def test_list_model_evaluations_field_headers(): @pytest.mark.asyncio async def test_list_model_evaluations_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2366,7 +2274,6 @@ async def test_list_model_evaluations_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelEvaluationsResponse() ) - await client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. @@ -2380,7 +2287,7 @@ async def test_list_model_evaluations_field_headers_async(): def test_list_model_evaluations_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2388,7 +2295,6 @@ def test_list_model_evaluations_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_service.ListModelEvaluationsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_model_evaluations(parent="parent_value",) @@ -2397,12 +2303,11 @@ def test_list_model_evaluations_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_model_evaluations_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2414,7 +2319,7 @@ def test_list_model_evaluations_flattened_error(): @pytest.mark.asyncio async def test_list_model_evaluations_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2434,13 +2339,12 @@ async def test_list_model_evaluations_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_model_evaluations_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2451,7 +2355,7 @@ async def test_list_model_evaluations_flattened_error_async(): def test_list_model_evaluations_pager(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2497,7 +2401,7 @@ def test_list_model_evaluations_pager(): def test_list_model_evaluations_pages(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2535,7 +2439,7 @@ def test_list_model_evaluations_pages(): @pytest.mark.asyncio async def test_list_model_evaluations_async_pager(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2580,7 +2484,7 @@ async def test_list_model_evaluations_async_pager(): @pytest.mark.asyncio async def test_list_model_evaluations_async_pages(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2624,7 +2528,7 @@ def test_get_model_evaluation_slice( transport: str = "grpc", request_type=model_service.GetModelEvaluationSliceRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2639,21 +2543,16 @@ def test_get_model_evaluation_slice( call.return_value = model_evaluation_slice.ModelEvaluationSlice( name="name_value", metrics_schema_uri="metrics_schema_uri_value", ) - response = client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationSliceRequest() # Establish that the response is the type that we expect. - assert isinstance(response, model_evaluation_slice.ModelEvaluationSlice) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" @@ -2665,7 +2564,7 @@ def test_get_model_evaluation_slice_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2675,7 +2574,6 @@ def test_get_model_evaluation_slice_empty_call(): client.get_model_evaluation_slice() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationSliceRequest() @@ -2685,7 +2583,7 @@ async def test_get_model_evaluation_slice_async( request_type=model_service.GetModelEvaluationSliceRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2702,20 +2600,16 @@ async def test_get_model_evaluation_slice_async( name="name_value", metrics_schema_uri="metrics_schema_uri_value", ) ) - response = await client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationSliceRequest() # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation_slice.ModelEvaluationSlice) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" @@ -2725,11 +2619,12 @@ async def test_get_model_evaluation_slice_async_from_dict(): def test_get_model_evaluation_slice_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationSliceRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2737,7 +2632,6 @@ def test_get_model_evaluation_slice_field_headers(): type(client.transport.get_model_evaluation_slice), "__call__" ) as call: call.return_value = model_evaluation_slice.ModelEvaluationSlice() - client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. @@ -2752,11 +2646,12 @@ def test_get_model_evaluation_slice_field_headers(): @pytest.mark.asyncio async def test_get_model_evaluation_slice_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationSliceRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2766,7 +2661,6 @@ async def test_get_model_evaluation_slice_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_evaluation_slice.ModelEvaluationSlice() ) - await client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. @@ -2780,7 +2674,7 @@ async def test_get_model_evaluation_slice_field_headers_async(): def test_get_model_evaluation_slice_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2788,7 +2682,6 @@ def test_get_model_evaluation_slice_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_evaluation_slice.ModelEvaluationSlice() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_model_evaluation_slice(name="name_value",) @@ -2797,12 +2690,11 @@ def test_get_model_evaluation_slice_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_model_evaluation_slice_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2814,7 +2706,7 @@ def test_get_model_evaluation_slice_flattened_error(): @pytest.mark.asyncio async def test_get_model_evaluation_slice_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2834,13 +2726,12 @@ async def test_get_model_evaluation_slice_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_model_evaluation_slice_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2854,7 +2745,7 @@ def test_list_model_evaluation_slices( transport: str = "grpc", request_type=model_service.ListModelEvaluationSlicesRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2869,19 +2760,15 @@ def test_list_model_evaluation_slices( call.return_value = model_service.ListModelEvaluationSlicesResponse( next_page_token="next_page_token_value", ) - response = client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationSlicesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListModelEvaluationSlicesPager) - assert response.next_page_token == "next_page_token_value" @@ -2893,7 +2780,7 @@ def test_list_model_evaluation_slices_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2903,7 +2790,6 @@ def test_list_model_evaluation_slices_empty_call(): client.list_model_evaluation_slices() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationSlicesRequest() @@ -2913,7 +2799,7 @@ async def test_list_model_evaluation_slices_async( request_type=model_service.ListModelEvaluationSlicesRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2930,18 +2816,15 @@ async def test_list_model_evaluation_slices_async( next_page_token="next_page_token_value", ) ) - response = await client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationSlicesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListModelEvaluationSlicesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2951,11 +2834,12 @@ async def test_list_model_evaluation_slices_async_from_dict(): def test_list_model_evaluation_slices_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationSlicesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2963,7 +2847,6 @@ def test_list_model_evaluation_slices_field_headers(): type(client.transport.list_model_evaluation_slices), "__call__" ) as call: call.return_value = model_service.ListModelEvaluationSlicesResponse() - client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. @@ -2978,11 +2861,12 @@ def test_list_model_evaluation_slices_field_headers(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationSlicesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2992,7 +2876,6 @@ async def test_list_model_evaluation_slices_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelEvaluationSlicesResponse() ) - await client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. @@ -3006,7 +2889,7 @@ async def test_list_model_evaluation_slices_field_headers_async(): def test_list_model_evaluation_slices_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3014,7 +2897,6 @@ def test_list_model_evaluation_slices_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_service.ListModelEvaluationSlicesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_model_evaluation_slices(parent="parent_value",) @@ -3023,12 +2905,11 @@ def test_list_model_evaluation_slices_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_model_evaluation_slices_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3040,7 +2921,7 @@ def test_list_model_evaluation_slices_flattened_error(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3060,13 +2941,12 @@ async def test_list_model_evaluation_slices_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_model_evaluation_slices_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3077,7 +2957,7 @@ async def test_list_model_evaluation_slices_flattened_error_async(): def test_list_model_evaluation_slices_pager(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3127,7 +3007,7 @@ def test_list_model_evaluation_slices_pager(): def test_list_model_evaluation_slices_pages(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3167,7 +3047,7 @@ def test_list_model_evaluation_slices_pages(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_async_pager(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3217,7 +3097,7 @@ async def test_list_model_evaluation_slices_async_pager(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_async_pages(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3264,16 +3144,16 @@ async def test_list_model_evaluation_slices_async_pages(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ModelServiceClient( @@ -3283,7 +3163,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ModelServiceClient( @@ -3294,7 +3174,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = ModelServiceClient(transport=transport) assert client.transport is transport @@ -3303,13 +3183,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.ModelServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3324,23 +3204,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.ModelServiceGrpcTransport,) def test_model_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.ModelServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3352,7 +3232,7 @@ def test_model_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.ModelServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3379,15 +3259,37 @@ def test_model_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_model_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.model_service.transports.ModelServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ModelServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_model_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1.services.model_service.transports.ModelServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ModelServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3400,19 +3302,33 @@ def test_model_service_base_transport_with_credentials_file(): def test_model_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1.services.model_service.transports.ModelServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ModelServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_model_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + ModelServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_model_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) ModelServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3420,26 +3336,162 @@ def test_model_service_auth_adc(): ) -def test_model_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.ModelServiceGrpcTransport, + transports.ModelServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_model_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.ModelServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ModelServiceGrpcTransport, + transports.ModelServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_model_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ModelServiceGrpcTransport, grpc_helpers), + (transports.ModelServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_model_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ModelServiceGrpcTransport, grpc_helpers), + (transports.ModelServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_model_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ModelServiceGrpcTransport, grpc_helpers), + (transports.ModelServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_model_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [transports.ModelServiceGrpcTransport, transports.ModelServiceGrpcAsyncIOTransport], ) def test_model_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3478,7 +3530,7 @@ def test_model_service_grpc_transport_client_cert_source_for_mtls(transport_clas def test_model_service_host_no_port(): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -3488,7 +3540,7 @@ def test_model_service_host_no_port(): def test_model_service_host_with_port(): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -3539,9 +3591,9 @@ def test_model_service_transport_channel_mtls_with_client_cert_source(transport_ mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3614,7 +3666,7 @@ def test_model_service_transport_channel_mtls_with_adc(transport_class): def test_model_service_grpc_lro_client(): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3627,7 +3679,7 @@ def test_model_service_grpc_lro_client(): def test_model_service_grpc_lro_async_client(): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3642,7 +3694,6 @@ def test_endpoint_path(): project = "squid" location = "clam" endpoint = "whelk" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -3667,7 +3718,6 @@ def test_model_path(): project = "cuttlefish" location = "mussel" model = "winkle" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -3693,7 +3743,6 @@ def test_model_evaluation_path(): location = "clam" model = "whelk" evaluation = "octopus" - expected = "projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}".format( project=project, location=location, model=model, evaluation=evaluation, ) @@ -3723,7 +3772,6 @@ def test_model_evaluation_slice_path(): model = "scallop" evaluation = "abalone" slice = "squid" - expected = "projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice}".format( project=project, location=location, @@ -3756,7 +3804,6 @@ def test_training_pipeline_path(): project = "cuttlefish" location = "mussel" training_pipeline = "winkle" - expected = "projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}".format( project=project, location=location, training_pipeline=training_pipeline, ) @@ -3781,7 +3828,6 @@ def test_parse_training_pipeline_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3802,7 +3848,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = ModelServiceClient.common_folder_path(folder) assert expected == actual @@ -3821,7 +3866,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = ModelServiceClient.common_organization_path(organization) assert expected == actual @@ -3840,7 +3884,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = ModelServiceClient.common_project_path(project) assert expected == actual @@ -3860,7 +3903,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3887,7 +3929,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ModelServiceTransport, "_prep_wrapped_messages" ) as prep: client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3896,6 +3938,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ModelServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py b/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py index d0079aae4d..e1cac311f2 100644 --- a/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_pipeline_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1.services.pipeline_service import ( PipelineServiceAsyncClient, @@ -41,6 +40,12 @@ from google.cloud.aiplatform_v1.services.pipeline_service import PipelineServiceClient from google.cloud.aiplatform_v1.services.pipeline_service import pagers from google.cloud.aiplatform_v1.services.pipeline_service import transports +from google.cloud.aiplatform_v1.services.pipeline_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.pipeline_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1.types import deployed_model_ref from google.cloud.aiplatform_v1.types import encryption_spec from google.cloud.aiplatform_v1.types import env_var @@ -53,11 +58,35 @@ from google.cloud.aiplatform_v1.types import training_pipeline as gca_training_pipeline from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -108,7 +137,7 @@ def test__get_default_mtls_endpoint(): "client_class", [PipelineServiceClient, PipelineServiceAsyncClient,] ) def test_pipeline_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -125,7 +154,7 @@ def test_pipeline_service_client_from_service_account_info(client_class): "client_class", [PipelineServiceClient, PipelineServiceAsyncClient,] ) def test_pipeline_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -178,7 +207,7 @@ def test_pipeline_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(PipelineServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -476,7 +505,7 @@ def test_create_training_pipeline( transport: str = "grpc", request_type=pipeline_service.CreateTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -494,25 +523,18 @@ def test_create_training_pipeline( training_task_definition="training_task_definition_value", state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) - response = client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreateTrainingPipelineRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -524,7 +546,7 @@ def test_create_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -534,7 +556,6 @@ def test_create_training_pipeline_empty_call(): client.create_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreateTrainingPipelineRequest() @@ -544,7 +565,7 @@ async def test_create_training_pipeline_async( request_type=pipeline_service.CreateTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -564,24 +585,18 @@ async def test_create_training_pipeline_async( state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) ) - response = await client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreateTrainingPipelineRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -591,11 +606,12 @@ async def test_create_training_pipeline_async_from_dict(): def test_create_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CreateTrainingPipelineRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -603,7 +619,6 @@ def test_create_training_pipeline_field_headers(): type(client.transport.create_training_pipeline), "__call__" ) as call: call.return_value = gca_training_pipeline.TrainingPipeline() - client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -618,11 +633,14 @@ def test_create_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_create_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CreateTrainingPipelineRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -632,7 +650,6 @@ async def test_create_training_pipeline_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_training_pipeline.TrainingPipeline() ) - await client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -646,7 +663,7 @@ async def test_create_training_pipeline_field_headers_async(): def test_create_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -654,7 +671,6 @@ def test_create_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_training_pipeline.TrainingPipeline() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_training_pipeline( @@ -666,16 +682,14 @@ def test_create_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].training_pipeline == gca_training_pipeline.TrainingPipeline( name="name_value" ) def test_create_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -689,7 +703,9 @@ def test_create_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_create_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -712,9 +728,7 @@ async def test_create_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].training_pipeline == gca_training_pipeline.TrainingPipeline( name="name_value" ) @@ -722,7 +736,9 @@ async def test_create_training_pipeline_flattened_async(): @pytest.mark.asyncio async def test_create_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -738,7 +754,7 @@ def test_get_training_pipeline( transport: str = "grpc", request_type=pipeline_service.GetTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -756,25 +772,18 @@ def test_get_training_pipeline( training_task_definition="training_task_definition_value", state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) - response = client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetTrainingPipelineRequest() # Establish that the response is the type that we expect. - assert isinstance(response, training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -786,7 +795,7 @@ def test_get_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -796,7 +805,6 @@ def test_get_training_pipeline_empty_call(): client.get_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetTrainingPipelineRequest() @@ -806,7 +814,7 @@ async def test_get_training_pipeline_async( request_type=pipeline_service.GetTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -826,24 +834,18 @@ async def test_get_training_pipeline_async( state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) ) - response = await client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetTrainingPipelineRequest() # Establish that the response is the type that we expect. assert isinstance(response, training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -853,11 +855,12 @@ async def test_get_training_pipeline_async_from_dict(): def test_get_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.GetTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -865,7 +868,6 @@ def test_get_training_pipeline_field_headers(): type(client.transport.get_training_pipeline), "__call__" ) as call: call.return_value = training_pipeline.TrainingPipeline() - client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -880,11 +882,14 @@ def test_get_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_get_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.GetTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -894,7 +899,6 @@ async def test_get_training_pipeline_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( training_pipeline.TrainingPipeline() ) - await client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -908,7 +912,7 @@ async def test_get_training_pipeline_field_headers_async(): def test_get_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -916,7 +920,6 @@ def test_get_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = training_pipeline.TrainingPipeline() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_training_pipeline(name="name_value",) @@ -925,12 +928,11 @@ def test_get_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -942,7 +944,9 @@ def test_get_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_get_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -962,13 +966,14 @@ async def test_get_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -982,7 +987,7 @@ def test_list_training_pipelines( transport: str = "grpc", request_type=pipeline_service.ListTrainingPipelinesRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -997,19 +1002,15 @@ def test_list_training_pipelines( call.return_value = pipeline_service.ListTrainingPipelinesResponse( next_page_token="next_page_token_value", ) - response = client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListTrainingPipelinesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTrainingPipelinesPager) - assert response.next_page_token == "next_page_token_value" @@ -1021,7 +1022,7 @@ def test_list_training_pipelines_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1031,7 +1032,6 @@ def test_list_training_pipelines_empty_call(): client.list_training_pipelines() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListTrainingPipelinesRequest() @@ -1041,7 +1041,7 @@ async def test_list_training_pipelines_async( request_type=pipeline_service.ListTrainingPipelinesRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1058,18 +1058,15 @@ async def test_list_training_pipelines_async( next_page_token="next_page_token_value", ) ) - response = await client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListTrainingPipelinesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTrainingPipelinesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1079,11 +1076,12 @@ async def test_list_training_pipelines_async_from_dict(): def test_list_training_pipelines_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.ListTrainingPipelinesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1091,7 +1089,6 @@ def test_list_training_pipelines_field_headers(): type(client.transport.list_training_pipelines), "__call__" ) as call: call.return_value = pipeline_service.ListTrainingPipelinesResponse() - client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. @@ -1106,11 +1103,14 @@ def test_list_training_pipelines_field_headers(): @pytest.mark.asyncio async def test_list_training_pipelines_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.ListTrainingPipelinesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1120,7 +1120,6 @@ async def test_list_training_pipelines_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( pipeline_service.ListTrainingPipelinesResponse() ) - await client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. @@ -1134,7 +1133,7 @@ async def test_list_training_pipelines_field_headers_async(): def test_list_training_pipelines_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1142,7 +1141,6 @@ def test_list_training_pipelines_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = pipeline_service.ListTrainingPipelinesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_training_pipelines(parent="parent_value",) @@ -1151,12 +1149,11 @@ def test_list_training_pipelines_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_training_pipelines_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1168,7 +1165,9 @@ def test_list_training_pipelines_flattened_error(): @pytest.mark.asyncio async def test_list_training_pipelines_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1188,13 +1187,14 @@ async def test_list_training_pipelines_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_training_pipelines_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1205,7 +1205,7 @@ async def test_list_training_pipelines_flattened_error_async(): def test_list_training_pipelines_pager(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1251,7 +1251,7 @@ def test_list_training_pipelines_pager(): def test_list_training_pipelines_pages(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1289,7 +1289,9 @@ def test_list_training_pipelines_pages(): @pytest.mark.asyncio async def test_list_training_pipelines_async_pager(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1334,7 +1336,9 @@ async def test_list_training_pipelines_async_pager(): @pytest.mark.asyncio async def test_list_training_pipelines_async_pages(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1378,7 +1382,7 @@ def test_delete_training_pipeline( transport: str = "grpc", request_type=pipeline_service.DeleteTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1391,13 +1395,11 @@ def test_delete_training_pipeline( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeleteTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1412,7 +1414,7 @@ def test_delete_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1422,7 +1424,6 @@ def test_delete_training_pipeline_empty_call(): client.delete_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeleteTrainingPipelineRequest() @@ -1432,7 +1433,7 @@ async def test_delete_training_pipeline_async( request_type=pipeline_service.DeleteTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1447,13 +1448,11 @@ async def test_delete_training_pipeline_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeleteTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1466,11 +1465,12 @@ async def test_delete_training_pipeline_async_from_dict(): def test_delete_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.DeleteTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1478,7 +1478,6 @@ def test_delete_training_pipeline_field_headers(): type(client.transport.delete_training_pipeline), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1493,11 +1492,14 @@ def test_delete_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_delete_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.DeleteTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1507,7 +1509,6 @@ async def test_delete_training_pipeline_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1521,7 +1522,7 @@ async def test_delete_training_pipeline_field_headers_async(): def test_delete_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1529,7 +1530,6 @@ def test_delete_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_training_pipeline(name="name_value",) @@ -1538,12 +1538,11 @@ def test_delete_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1555,7 +1554,9 @@ def test_delete_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_delete_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1575,13 +1576,14 @@ async def test_delete_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1595,7 +1597,7 @@ def test_cancel_training_pipeline( transport: str = "grpc", request_type=pipeline_service.CancelTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1608,13 +1610,11 @@ def test_cancel_training_pipeline( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1629,7 +1629,7 @@ def test_cancel_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1639,7 +1639,6 @@ def test_cancel_training_pipeline_empty_call(): client.cancel_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelTrainingPipelineRequest() @@ -1649,7 +1648,7 @@ async def test_cancel_training_pipeline_async( request_type=pipeline_service.CancelTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1662,13 +1661,11 @@ async def test_cancel_training_pipeline_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1681,11 +1678,12 @@ async def test_cancel_training_pipeline_async_from_dict(): def test_cancel_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CancelTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1693,7 +1691,6 @@ def test_cancel_training_pipeline_field_headers(): type(client.transport.cancel_training_pipeline), "__call__" ) as call: call.return_value = None - client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1708,11 +1705,14 @@ def test_cancel_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_cancel_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CancelTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1720,7 +1720,6 @@ async def test_cancel_training_pipeline_field_headers_async(): type(client.transport.cancel_training_pipeline), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1734,7 +1733,7 @@ async def test_cancel_training_pipeline_field_headers_async(): def test_cancel_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1742,7 +1741,6 @@ def test_cancel_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_training_pipeline(name="name_value",) @@ -1751,12 +1749,11 @@ def test_cancel_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1768,7 +1765,9 @@ def test_cancel_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_cancel_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1786,13 +1785,14 @@ async def test_cancel_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1805,16 +1805,16 @@ async def test_cancel_training_pipeline_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PipelineServiceClient( @@ -1824,7 +1824,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PipelineServiceClient( @@ -1835,7 +1835,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = PipelineServiceClient(transport=transport) assert client.transport is transport @@ -1844,13 +1844,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.PipelineServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -1865,23 +1865,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.PipelineServiceGrpcTransport,) def test_pipeline_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.PipelineServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1893,7 +1893,7 @@ def test_pipeline_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.PipelineServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -1915,15 +1915,37 @@ def test_pipeline_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_pipeline_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.pipeline_service.transports.PipelineServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.PipelineServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_pipeline_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1.services.pipeline_service.transports.PipelineServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PipelineServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -1936,19 +1958,33 @@ def test_pipeline_service_base_transport_with_credentials_file(): def test_pipeline_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1.services.pipeline_service.transports.PipelineServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PipelineServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_pipeline_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + PipelineServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_pipeline_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) PipelineServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -1956,20 +1992,156 @@ def test_pipeline_service_auth_adc(): ) -def test_pipeline_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.PipelineServiceGrpcTransport, + transports.PipelineServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_pipeline_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.PipelineServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.PipelineServiceGrpcTransport, + transports.PipelineServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_pipeline_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PipelineServiceGrpcTransport, grpc_helpers), + (transports.PipelineServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_pipeline_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PipelineServiceGrpcTransport, grpc_helpers), + (transports.PipelineServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_pipeline_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PipelineServiceGrpcTransport, grpc_helpers), + (transports.PipelineServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_pipeline_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -1978,7 +2150,7 @@ def test_pipeline_service_transport_auth_adc(): ], ) def test_pipeline_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -2017,7 +2189,7 @@ def test_pipeline_service_grpc_transport_client_cert_source_for_mtls(transport_c def test_pipeline_service_host_no_port(): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -2027,7 +2199,7 @@ def test_pipeline_service_host_no_port(): def test_pipeline_service_host_with_port(): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -2083,9 +2255,9 @@ def test_pipeline_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2161,7 +2333,7 @@ def test_pipeline_service_transport_channel_mtls_with_adc(transport_class): def test_pipeline_service_grpc_lro_client(): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -2174,7 +2346,7 @@ def test_pipeline_service_grpc_lro_client(): def test_pipeline_service_grpc_lro_async_client(): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -2189,7 +2361,6 @@ def test_endpoint_path(): project = "squid" location = "clam" endpoint = "whelk" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -2214,7 +2385,6 @@ def test_model_path(): project = "cuttlefish" location = "mussel" model = "winkle" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -2239,7 +2409,6 @@ def test_training_pipeline_path(): project = "squid" location = "clam" training_pipeline = "whelk" - expected = "projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}".format( project=project, location=location, training_pipeline=training_pipeline, ) @@ -2264,7 +2433,6 @@ def test_parse_training_pipeline_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2285,7 +2453,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = PipelineServiceClient.common_folder_path(folder) assert expected == actual @@ -2304,7 +2471,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = PipelineServiceClient.common_organization_path(organization) assert expected == actual @@ -2323,7 +2489,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = PipelineServiceClient.common_project_path(project) assert expected == actual @@ -2343,7 +2508,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2370,7 +2534,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.PipelineServiceTransport, "_prep_wrapped_messages" ) as prep: client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2379,6 +2543,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = PipelineServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1/test_prediction_service.py b/tests/unit/gapic/aiplatform_v1/test_prediction_service.py new file mode 100644 index 0000000000..a65e69f1b6 --- /dev/null +++ b/tests/unit/gapic/aiplatform_v1/test_prediction_service.py @@ -0,0 +1,1375 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +import os +import mock +import packaging.version + +import grpc +from grpc.experimental import aio +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule + + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.aiplatform_v1.services.prediction_service import ( + PredictionServiceAsyncClient, +) +from google.cloud.aiplatform_v1.services.prediction_service import ( + PredictionServiceClient, +) +from google.cloud.aiplatform_v1.services.prediction_service import transports +from google.cloud.aiplatform_v1.services.prediction_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.prediction_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) +from google.cloud.aiplatform_v1.types import prediction_service +from google.oauth2 import service_account +from google.protobuf import struct_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return ( + "foo.googleapis.com" + if ("localhost" in client.DEFAULT_ENDPOINT) + else client.DEFAULT_ENDPOINT + ) + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert PredictionServiceClient._get_default_mtls_endpoint(None) is None + assert ( + PredictionServiceClient._get_default_mtls_endpoint(api_endpoint) + == api_mtls_endpoint + ) + assert ( + PredictionServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) + == api_mtls_endpoint + ) + assert ( + PredictionServiceClient._get_default_mtls_endpoint(sandbox_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + PredictionServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) + == sandbox_mtls_endpoint + ) + assert ( + PredictionServiceClient._get_default_mtls_endpoint(non_googleapi) + == non_googleapi + ) + + +@pytest.mark.parametrize( + "client_class", [PredictionServiceClient, PredictionServiceAsyncClient,] +) +def test_prediction_service_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == "aiplatform.googleapis.com:443" + + +@pytest.mark.parametrize( + "client_class", [PredictionServiceClient, PredictionServiceAsyncClient,] +) +def test_prediction_service_client_from_service_account_file(client_class): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_file" + ) as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json") + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == "aiplatform.googleapis.com:443" + + +def test_prediction_service_client_get_transport_class(): + transport = PredictionServiceClient.get_transport_class() + available_transports = [ + transports.PredictionServiceGrpcTransport, + ] + assert transport in available_transports + + transport = PredictionServiceClient.get_transport_class("grpc") + assert transport == transports.PredictionServiceGrpcTransport + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (PredictionServiceClient, transports.PredictionServiceGrpcTransport, "grpc"), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +@mock.patch.object( + PredictionServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceClient), +) +@mock.patch.object( + PredictionServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceAsyncClient), +) +def test_prediction_service_client_client_options( + client_class, transport_class, transport_name +): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(PredictionServiceClient, "get_transport_class") as gtc: + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(PredictionServiceClient, "get_transport_class") as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class() + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} + ): + with pytest.raises(ValueError): + client = client_class() + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,use_client_cert_env", + [ + ( + PredictionServiceClient, + transports.PredictionServiceGrpcTransport, + "grpc", + "true", + ), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + "grpc_asyncio", + "true", + ), + ( + PredictionServiceClient, + transports.PredictionServiceGrpcTransport, + "grpc", + "false", + ), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + "grpc_asyncio", + "false", + ), + ], +) +@mock.patch.object( + PredictionServiceClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceClient), +) +@mock.patch.object( + PredictionServiceAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(PredictionServiceAsyncClient), +) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_prediction_service_client_mtls_env_auto( + client_class, transport_class, transport_name, use_client_cert_env +): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + options = client_options.ClientOptions( + client_cert_source=client_cert_source_callback + ) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (PredictionServiceClient, transports.PredictionServiceGrpcTransport, "grpc"), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_prediction_service_client_client_options_scopes( + client_class, transport_class, transport_name +): + # Check the case scopes are provided. + options = client_options.ClientOptions(scopes=["1", "2"],) + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +@pytest.mark.parametrize( + "client_class,transport_class,transport_name", + [ + (PredictionServiceClient, transports.PredictionServiceGrpcTransport, "grpc"), + ( + PredictionServiceAsyncClient, + transports.PredictionServiceGrpcAsyncIOTransport, + "grpc_asyncio", + ), + ], +) +def test_prediction_service_client_client_options_credentials_file( + client_class, transport_class, transport_name +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_prediction_service_client_client_options_from_dict(): + with mock.patch( + "google.cloud.aiplatform_v1.services.prediction_service.transports.PredictionServiceGrpcTransport.__init__" + ) as grpc_transport: + grpc_transport.return_value = None + client = PredictionServiceClient( + client_options={"api_endpoint": "squid.clam.whelk"} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + + +def test_predict( + transport: str = "grpc", request_type=prediction_service.PredictRequest +): + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = prediction_service.PredictResponse( + deployed_model_id="deployed_model_id_value", + ) + response = client.predict(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == prediction_service.PredictRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, prediction_service.PredictResponse) + assert response.deployed_model_id == "deployed_model_id_value" + + +def test_predict_from_dict(): + test_predict(request_type=dict) + + +def test_predict_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + client.predict() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == prediction_service.PredictRequest() + + +@pytest.mark.asyncio +async def test_predict_async( + transport: str = "grpc_asyncio", request_type=prediction_service.PredictRequest +): + client = PredictionServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + prediction_service.PredictResponse( + deployed_model_id="deployed_model_id_value", + ) + ) + response = await client.predict(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == prediction_service.PredictRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, prediction_service.PredictResponse) + assert response.deployed_model_id == "deployed_model_id_value" + + +@pytest.mark.asyncio +async def test_predict_async_from_dict(): + await test_predict_async(request_type=dict) + + +def test_predict_field_headers(): + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = prediction_service.PredictRequest() + + request.endpoint = "endpoint/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + call.return_value = prediction_service.PredictResponse() + client.predict(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "endpoint=endpoint/value",) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_predict_field_headers_async(): + client = PredictionServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = prediction_service.PredictRequest() + + request.endpoint = "endpoint/value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + prediction_service.PredictResponse() + ) + await client.predict(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ("x-goog-request-params", "endpoint=endpoint/value",) in kw["metadata"] + + +def test_predict_flattened(): + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = prediction_service.PredictResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.predict( + endpoint="endpoint_value", + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0].endpoint == "endpoint_value" + assert args[0].instances == [ + struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) + ] + # https://github.com/googleapis/gapic-generator-python/issues/414 + # assert args[0].parameters == struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) + + +def test_predict_flattened_error(): + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.predict( + prediction_service.PredictRequest(), + endpoint="endpoint_value", + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), + ) + + +@pytest.mark.asyncio +async def test_predict_flattened_async(): + client = PredictionServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = prediction_service.PredictResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + prediction_service.PredictResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.predict( + endpoint="endpoint_value", + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0].endpoint == "endpoint_value" + assert args[0].instances == [ + struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) + ] + # https://github.com/googleapis/gapic-generator-python/issues/414 + # assert args[0].parameters == struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) + + +@pytest.mark.asyncio +async def test_predict_flattened_error_async(): + client = PredictionServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.predict( + prediction_service.PredictRequest(), + endpoint="endpoint_value", + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.PredictionServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.PredictionServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = PredictionServiceClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.PredictionServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = PredictionServiceClient( + client_options={"scopes": ["1", "2"]}, transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.PredictionServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = PredictionServiceClient(transport=transport) + assert client.transport is transport + + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.PredictionServiceGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.PredictionServiceGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + assert isinstance(client.transport, transports.PredictionServiceGrpcTransport,) + + +def test_prediction_service_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.PredictionServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json", + ) + + +def test_prediction_service_base_transport(): + # Instantiate the base transport. + with mock.patch( + "google.cloud.aiplatform_v1.services.prediction_service.transports.PredictionServiceTransport.__init__" + ) as Transport: + Transport.return_value = None + transport = transports.PredictionServiceTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ("predict",) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + +@requires_google_auth_gte_1_25_0 +def test_prediction_service_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.prediction_service.transports.PredictionServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.PredictionServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_prediction_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.prediction_service.transports.PredictionServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.PredictionServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +def test_prediction_service_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( + "google.cloud.aiplatform_v1.services.prediction_service.transports.PredictionServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.PredictionServiceTransport() + adc.assert_called_once() + + +@requires_google_auth_gte_1_25_0 +def test_prediction_service_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + PredictionServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_prediction_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + PredictionServiceClient() + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_prediction_service_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_prediction_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") + adc.assert_called_once_with( + scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PredictionServiceGrpcTransport, grpc_helpers), + (transports.PredictionServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_prediction_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PredictionServiceGrpcTransport, grpc_helpers), + (transports.PredictionServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_prediction_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PredictionServiceGrpcTransport, grpc_helpers), + (transports.PredictionServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_prediction_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +def test_prediction_service_grpc_transport_client_cert_source_for_mtls(transport_class): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds, + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback, + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, private_key=expected_key + ) + + +def test_prediction_service_host_no_port(): + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="aiplatform.googleapis.com" + ), + ) + assert client.transport._host == "aiplatform.googleapis.com:443" + + +def test_prediction_service_host_with_port(): + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions( + api_endpoint="aiplatform.googleapis.com:8000" + ), + ) + assert client.transport._host == "aiplatform.googleapis.com:8000" + + +def test_prediction_service_grpc_transport_channel(): + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.PredictionServiceGrpcTransport( + host="squid.clam.whelk", channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_prediction_service_grpc_asyncio_transport_channel(): + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.PredictionServiceGrpcAsyncIOTransport( + host="squid.clam.whelk", channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +def test_prediction_service_transport_channel_mtls_with_client_cert_source( + transport_class, +): + with mock.patch( + "grpc.ssl_channel_credentials", autospec=True + ) as grpc_ssl_channel_cred: + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +def test_prediction_service_transport_channel_mtls_with_adc(transport_class): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object( + transport_class, "create_channel" + ) as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_endpoint_path(): + project = "squid" + location = "clam" + endpoint = "whelk" + expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( + project=project, location=location, endpoint=endpoint, + ) + actual = PredictionServiceClient.endpoint_path(project, location, endpoint) + assert expected == actual + + +def test_parse_endpoint_path(): + expected = { + "project": "octopus", + "location": "oyster", + "endpoint": "nudibranch", + } + path = PredictionServiceClient.endpoint_path(**expected) + + # Check that the path construction is reversible. + actual = PredictionServiceClient.parse_endpoint_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = PredictionServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = PredictionServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = PredictionServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder,) + actual = PredictionServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = PredictionServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = PredictionServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization,) + actual = PredictionServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = PredictionServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = PredictionServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project,) + actual = PredictionServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = PredictionServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = PredictionServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = PredictionServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = PredictionServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = PredictionServiceClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_withDEFAULT_CLIENT_INFO(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object( + transports.PredictionServiceTransport, "_prep_wrapped_messages" + ) as prep: + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object( + transports.PredictionServiceTransport, "_prep_wrapped_messages" + ) as prep: + transport_class = PredictionServiceClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + ) + prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py b/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py index 339187f22a..2f54d4b68c 100644 --- a/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py +++ b/tests/unit/gapic/aiplatform_v1/test_specialist_pool_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1.services.specialist_pool_service import ( SpecialistPoolServiceAsyncClient, @@ -43,13 +42,43 @@ ) from google.cloud.aiplatform_v1.services.specialist_pool_service import pagers from google.cloud.aiplatform_v1.services.specialist_pool_service import transports +from google.cloud.aiplatform_v1.services.specialist_pool_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1.services.specialist_pool_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1.types import operation as gca_operation from google.cloud.aiplatform_v1.types import specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool as gca_specialist_pool from google.cloud.aiplatform_v1.types import specialist_pool_service from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -101,7 +130,7 @@ def test__get_default_mtls_endpoint(): "client_class", [SpecialistPoolServiceClient, SpecialistPoolServiceAsyncClient,] ) def test_specialist_pool_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -118,7 +147,7 @@ def test_specialist_pool_service_client_from_service_account_info(client_class): "client_class", [SpecialistPoolServiceClient, SpecialistPoolServiceAsyncClient,] ) def test_specialist_pool_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -175,7 +204,7 @@ def test_specialist_pool_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(SpecialistPoolServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -482,7 +511,7 @@ def test_create_specialist_pool( request_type=specialist_pool_service.CreateSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -495,13 +524,11 @@ def test_create_specialist_pool( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.CreateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -516,7 +543,7 @@ def test_create_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -526,7 +553,6 @@ def test_create_specialist_pool_empty_call(): client.create_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.CreateSpecialistPoolRequest() @@ -536,7 +562,7 @@ async def test_create_specialist_pool_async( request_type=specialist_pool_service.CreateSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -551,13 +577,11 @@ async def test_create_specialist_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.CreateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -571,12 +595,13 @@ async def test_create_specialist_pool_async_from_dict(): def test_create_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.CreateSpecialistPoolRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -584,7 +609,6 @@ def test_create_specialist_pool_field_headers(): type(client.transport.create_specialist_pool), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -600,12 +624,13 @@ def test_create_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_create_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.CreateSpecialistPoolRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -615,7 +640,6 @@ async def test_create_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -630,7 +654,7 @@ async def test_create_specialist_pool_field_headers_async(): def test_create_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -639,7 +663,6 @@ def test_create_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_specialist_pool( @@ -651,9 +674,7 @@ def test_create_specialist_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) @@ -661,7 +682,7 @@ def test_create_specialist_pool_flattened(): def test_create_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -677,7 +698,7 @@ def test_create_specialist_pool_flattened_error(): @pytest.mark.asyncio async def test_create_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -701,9 +722,7 @@ async def test_create_specialist_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) @@ -712,7 +731,7 @@ async def test_create_specialist_pool_flattened_async(): @pytest.mark.asyncio async def test_create_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -730,7 +749,7 @@ def test_get_specialist_pool( request_type=specialist_pool_service.GetSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -749,27 +768,19 @@ def test_get_specialist_pool( specialist_manager_emails=["specialist_manager_emails_value"], pending_data_labeling_jobs=["pending_data_labeling_jobs_value"], ) - response = client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.GetSpecialistPoolRequest() # Establish that the response is the type that we expect. - assert isinstance(response, specialist_pool.SpecialistPool) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.specialist_managers_count == 2662 - assert response.specialist_manager_emails == ["specialist_manager_emails_value"] - assert response.pending_data_labeling_jobs == ["pending_data_labeling_jobs_value"] @@ -781,7 +792,7 @@ def test_get_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -791,7 +802,6 @@ def test_get_specialist_pool_empty_call(): client.get_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.GetSpecialistPoolRequest() @@ -801,7 +811,7 @@ async def test_get_specialist_pool_async( request_type=specialist_pool_service.GetSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -822,26 +832,19 @@ async def test_get_specialist_pool_async( pending_data_labeling_jobs=["pending_data_labeling_jobs_value"], ) ) - response = await client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.GetSpecialistPoolRequest() # Establish that the response is the type that we expect. assert isinstance(response, specialist_pool.SpecialistPool) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.specialist_managers_count == 2662 - assert response.specialist_manager_emails == ["specialist_manager_emails_value"] - assert response.pending_data_labeling_jobs == ["pending_data_labeling_jobs_value"] @@ -852,12 +855,13 @@ async def test_get_specialist_pool_async_from_dict(): def test_get_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.GetSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -865,7 +869,6 @@ def test_get_specialist_pool_field_headers(): type(client.transport.get_specialist_pool), "__call__" ) as call: call.return_value = specialist_pool.SpecialistPool() - client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -881,12 +884,13 @@ def test_get_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_get_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.GetSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -896,7 +900,6 @@ async def test_get_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( specialist_pool.SpecialistPool() ) - await client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -911,7 +914,7 @@ async def test_get_specialist_pool_field_headers_async(): def test_get_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -920,7 +923,6 @@ def test_get_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = specialist_pool.SpecialistPool() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_specialist_pool(name="name_value",) @@ -929,13 +931,12 @@ def test_get_specialist_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -949,7 +950,7 @@ def test_get_specialist_pool_flattened_error(): @pytest.mark.asyncio async def test_get_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -970,14 +971,13 @@ async def test_get_specialist_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -993,7 +993,7 @@ def test_list_specialist_pools( request_type=specialist_pool_service.ListSpecialistPoolsRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1008,19 +1008,15 @@ def test_list_specialist_pools( call.return_value = specialist_pool_service.ListSpecialistPoolsResponse( next_page_token="next_page_token_value", ) - response = client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.ListSpecialistPoolsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSpecialistPoolsPager) - assert response.next_page_token == "next_page_token_value" @@ -1032,7 +1028,7 @@ def test_list_specialist_pools_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1042,7 +1038,6 @@ def test_list_specialist_pools_empty_call(): client.list_specialist_pools() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.ListSpecialistPoolsRequest() @@ -1052,7 +1047,7 @@ async def test_list_specialist_pools_async( request_type=specialist_pool_service.ListSpecialistPoolsRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1069,18 +1064,15 @@ async def test_list_specialist_pools_async( next_page_token="next_page_token_value", ) ) - response = await client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.ListSpecialistPoolsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSpecialistPoolsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1091,12 +1083,13 @@ async def test_list_specialist_pools_async_from_dict(): def test_list_specialist_pools_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.ListSpecialistPoolsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1104,7 +1097,6 @@ def test_list_specialist_pools_field_headers(): type(client.transport.list_specialist_pools), "__call__" ) as call: call.return_value = specialist_pool_service.ListSpecialistPoolsResponse() - client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. @@ -1120,12 +1112,13 @@ def test_list_specialist_pools_field_headers(): @pytest.mark.asyncio async def test_list_specialist_pools_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.ListSpecialistPoolsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1135,7 +1128,6 @@ async def test_list_specialist_pools_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( specialist_pool_service.ListSpecialistPoolsResponse() ) - await client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. @@ -1150,7 +1142,7 @@ async def test_list_specialist_pools_field_headers_async(): def test_list_specialist_pools_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1159,7 +1151,6 @@ def test_list_specialist_pools_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = specialist_pool_service.ListSpecialistPoolsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_specialist_pools(parent="parent_value",) @@ -1168,13 +1159,12 @@ def test_list_specialist_pools_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_specialist_pools_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1188,7 +1178,7 @@ def test_list_specialist_pools_flattened_error(): @pytest.mark.asyncio async def test_list_specialist_pools_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1209,14 +1199,13 @@ async def test_list_specialist_pools_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_specialist_pools_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1228,7 +1217,9 @@ async def test_list_specialist_pools_flattened_error_async(): def test_list_specialist_pools_pager(): - client = SpecialistPoolServiceClient(credentials=credentials.AnonymousCredentials,) + client = SpecialistPoolServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1274,7 +1265,9 @@ def test_list_specialist_pools_pager(): def test_list_specialist_pools_pages(): - client = SpecialistPoolServiceClient(credentials=credentials.AnonymousCredentials,) + client = SpecialistPoolServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1313,7 +1306,7 @@ def test_list_specialist_pools_pages(): @pytest.mark.asyncio async def test_list_specialist_pools_async_pager(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1360,7 +1353,7 @@ async def test_list_specialist_pools_async_pager(): @pytest.mark.asyncio async def test_list_specialist_pools_async_pages(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1406,7 +1399,7 @@ def test_delete_specialist_pool( request_type=specialist_pool_service.DeleteSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1419,13 +1412,11 @@ def test_delete_specialist_pool( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.DeleteSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1440,7 +1431,7 @@ def test_delete_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1450,7 +1441,6 @@ def test_delete_specialist_pool_empty_call(): client.delete_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.DeleteSpecialistPoolRequest() @@ -1460,7 +1450,7 @@ async def test_delete_specialist_pool_async( request_type=specialist_pool_service.DeleteSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1475,13 +1465,11 @@ async def test_delete_specialist_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.DeleteSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1495,12 +1483,13 @@ async def test_delete_specialist_pool_async_from_dict(): def test_delete_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.DeleteSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1508,7 +1497,6 @@ def test_delete_specialist_pool_field_headers(): type(client.transport.delete_specialist_pool), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1524,12 +1512,13 @@ def test_delete_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_delete_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.DeleteSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1539,7 +1528,6 @@ async def test_delete_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1554,7 +1542,7 @@ async def test_delete_specialist_pool_field_headers_async(): def test_delete_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1563,7 +1551,6 @@ def test_delete_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_specialist_pool(name="name_value",) @@ -1572,13 +1559,12 @@ def test_delete_specialist_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1592,7 +1578,7 @@ def test_delete_specialist_pool_flattened_error(): @pytest.mark.asyncio async def test_delete_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1613,14 +1599,13 @@ async def test_delete_specialist_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1636,7 +1621,7 @@ def test_update_specialist_pool( request_type=specialist_pool_service.UpdateSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1649,13 +1634,11 @@ def test_update_specialist_pool( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.UpdateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1670,7 +1653,7 @@ def test_update_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1680,7 +1663,6 @@ def test_update_specialist_pool_empty_call(): client.update_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.UpdateSpecialistPoolRequest() @@ -1690,7 +1672,7 @@ async def test_update_specialist_pool_async( request_type=specialist_pool_service.UpdateSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1705,13 +1687,11 @@ async def test_update_specialist_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.UpdateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1725,12 +1705,13 @@ async def test_update_specialist_pool_async_from_dict(): def test_update_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.UpdateSpecialistPoolRequest() + request.specialist_pool.name = "specialist_pool.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1738,7 +1719,6 @@ def test_update_specialist_pool_field_headers(): type(client.transport.update_specialist_pool), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1757,12 +1737,13 @@ def test_update_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_update_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.UpdateSpecialistPoolRequest() + request.specialist_pool.name = "specialist_pool.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1772,7 +1753,6 @@ async def test_update_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1790,7 +1770,7 @@ async def test_update_specialist_pool_field_headers_async(): def test_update_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1799,29 +1779,26 @@ def test_update_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_specialist_pool( specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1830,14 +1807,14 @@ def test_update_specialist_pool_flattened_error(): client.update_specialist_pool( specialist_pool_service.UpdateSpecialistPoolRequest(), specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1854,25 +1831,23 @@ async def test_update_specialist_pool_flattened_async(): # using the keyword arguments to the method. response = await client.update_specialist_pool( specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1881,23 +1856,23 @@ async def test_update_specialist_pool_flattened_error_async(): await client.update_specialist_pool( specialist_pool_service.UpdateSpecialistPoolRequest(), specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SpecialistPoolServiceClient( @@ -1907,7 +1882,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SpecialistPoolServiceClient( @@ -1918,7 +1893,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = SpecialistPoolServiceClient(transport=transport) assert client.transport is transport @@ -1927,13 +1902,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.SpecialistPoolServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -1948,8 +1923,8 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() @@ -1957,16 +1932,16 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance(client.transport, transports.SpecialistPoolServiceGrpcTransport,) def test_specialist_pool_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.SpecialistPoolServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1978,7 +1953,7 @@ def test_specialist_pool_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.SpecialistPoolServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -2000,15 +1975,37 @@ def test_specialist_pool_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_specialist_pool_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1.services.specialist_pool_service.transports.SpecialistPoolServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.SpecialistPoolServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_specialist_pool_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1.services.specialist_pool_service.transports.SpecialistPoolServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SpecialistPoolServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -2021,19 +2018,33 @@ def test_specialist_pool_service_base_transport_with_credentials_file(): def test_specialist_pool_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1.services.specialist_pool_service.transports.SpecialistPoolServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SpecialistPoolServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_specialist_pool_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + SpecialistPoolServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_specialist_pool_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) SpecialistPoolServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -2041,20 +2052,158 @@ def test_specialist_pool_service_auth_adc(): ) -def test_specialist_pool_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.SpecialistPoolServiceGrpcTransport, + transports.SpecialistPoolServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_specialist_pool_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.SpecialistPoolServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.SpecialistPoolServiceGrpcTransport, + transports.SpecialistPoolServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_specialist_pool_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SpecialistPoolServiceGrpcTransport, grpc_helpers), + (transports.SpecialistPoolServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_specialist_pool_service_transport_create_channel( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SpecialistPoolServiceGrpcTransport, grpc_helpers), + (transports.SpecialistPoolServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_specialist_pool_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SpecialistPoolServiceGrpcTransport, grpc_helpers), + (transports.SpecialistPoolServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_specialist_pool_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -2065,7 +2214,7 @@ def test_specialist_pool_service_transport_auth_adc(): def test_specialist_pool_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -2104,7 +2253,7 @@ def test_specialist_pool_service_grpc_transport_client_cert_source_for_mtls( def test_specialist_pool_service_host_no_port(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -2114,7 +2263,7 @@ def test_specialist_pool_service_host_no_port(): def test_specialist_pool_service_host_with_port(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -2170,9 +2319,9 @@ def test_specialist_pool_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2248,7 +2397,7 @@ def test_specialist_pool_service_transport_channel_mtls_with_adc(transport_class def test_specialist_pool_service_grpc_lro_client(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -2261,7 +2410,7 @@ def test_specialist_pool_service_grpc_lro_client(): def test_specialist_pool_service_grpc_lro_async_client(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -2276,7 +2425,6 @@ def test_specialist_pool_path(): project = "squid" location = "clam" specialist_pool = "whelk" - expected = "projects/{project}/locations/{location}/specialistPools/{specialist_pool}".format( project=project, location=location, specialist_pool=specialist_pool, ) @@ -2301,7 +2449,6 @@ def test_parse_specialist_pool_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2322,7 +2469,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = SpecialistPoolServiceClient.common_folder_path(folder) assert expected == actual @@ -2341,7 +2487,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = SpecialistPoolServiceClient.common_organization_path(organization) assert expected == actual @@ -2360,7 +2505,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = SpecialistPoolServiceClient.common_project_path(project) assert expected == actual @@ -2380,7 +2524,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2407,7 +2550,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.SpecialistPoolServiceTransport, "_prep_wrapped_messages" ) as prep: client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2416,6 +2559,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = SpecialistPoolServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/__init__.py b/tests/unit/gapic/aiplatform_v1beta1/__init__.py index 42ffdf2bc4..4de65971c2 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/__init__.py +++ b/tests/unit/gapic/aiplatform_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py index 5a3818dc9d..03b3c97547 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_dataset_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.dataset_service import ( DatasetServiceAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.aiplatform_v1beta1.services.dataset_service import pagers from google.cloud.aiplatform_v1beta1.services.dataset_service import transports +from google.cloud.aiplatform_v1beta1.services.dataset_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.dataset_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import annotation from google.cloud.aiplatform_v1beta1.types import annotation_spec from google.cloud.aiplatform_v1beta1.types import data_item @@ -54,9 +59,33 @@ from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -107,7 +136,7 @@ def test__get_default_mtls_endpoint(): "client_class", [DatasetServiceClient, DatasetServiceAsyncClient,] ) def test_dataset_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -124,7 +153,7 @@ def test_dataset_service_client_from_service_account_info(client_class): "client_class", [DatasetServiceClient, DatasetServiceAsyncClient,] ) def test_dataset_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -177,7 +206,7 @@ def test_dataset_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(DatasetServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -465,7 +494,7 @@ def test_create_dataset( transport: str = "grpc", request_type=dataset_service.CreateDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -476,13 +505,11 @@ def test_create_dataset( with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.CreateDatasetRequest() # Establish that the response is the type that we expect. @@ -497,7 +524,7 @@ def test_create_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -505,7 +532,6 @@ def test_create_dataset_empty_call(): client.create_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.CreateDatasetRequest() @@ -514,7 +540,7 @@ async def test_create_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.CreateDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -527,13 +553,11 @@ async def test_create_dataset_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.CreateDatasetRequest() # Establish that the response is the type that we expect. @@ -546,17 +570,17 @@ async def test_create_dataset_async_from_dict(): def test_create_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.CreateDatasetRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -571,11 +595,14 @@ def test_create_dataset_field_headers(): @pytest.mark.asyncio async def test_create_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.CreateDatasetRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -583,7 +610,6 @@ async def test_create_dataset_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -597,13 +623,12 @@ async def test_create_dataset_field_headers_async(): def test_create_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_dataset( @@ -614,14 +639,12 @@ def test_create_dataset_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].dataset == gca_dataset.Dataset(name="name_value") def test_create_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -635,7 +658,9 @@ def test_create_dataset_flattened_error(): @pytest.mark.asyncio async def test_create_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_dataset), "__call__") as call: @@ -655,15 +680,15 @@ async def test_create_dataset_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].dataset == gca_dataset.Dataset(name="name_value") @pytest.mark.asyncio async def test_create_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -679,7 +704,7 @@ def test_get_dataset( transport: str = "grpc", request_type=dataset_service.GetDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -695,25 +720,18 @@ def test_get_dataset( metadata_schema_uri="metadata_schema_uri_value", etag="etag_value", ) - response = client.get_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetDatasetRequest() # Establish that the response is the type that we expect. - assert isinstance(response, dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -725,7 +743,7 @@ def test_get_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -733,7 +751,6 @@ def test_get_dataset_empty_call(): client.get_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetDatasetRequest() @@ -742,7 +759,7 @@ async def test_get_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.GetDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -760,24 +777,18 @@ async def test_get_dataset_async( etag="etag_value", ) ) - response = await client.get_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetDatasetRequest() # Establish that the response is the type that we expect. assert isinstance(response, dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -787,17 +798,17 @@ async def test_get_dataset_async_from_dict(): def test_get_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: call.return_value = dataset.Dataset() - client.get_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -812,17 +823,19 @@ def test_get_dataset_field_headers(): @pytest.mark.asyncio async def test_get_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(dataset.Dataset()) - await client.get_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -836,13 +849,12 @@ async def test_get_dataset_field_headers_async(): def test_get_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset.Dataset() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_dataset(name="name_value",) @@ -851,12 +863,11 @@ def test_get_dataset_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -868,7 +879,9 @@ def test_get_dataset_flattened_error(): @pytest.mark.asyncio async def test_get_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_dataset), "__call__") as call: @@ -884,13 +897,14 @@ async def test_get_dataset_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -904,7 +918,7 @@ def test_update_dataset( transport: str = "grpc", request_type=dataset_service.UpdateDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -920,25 +934,18 @@ def test_update_dataset( metadata_schema_uri="metadata_schema_uri_value", etag="etag_value", ) - response = client.update_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.UpdateDatasetRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -950,7 +957,7 @@ def test_update_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -958,7 +965,6 @@ def test_update_dataset_empty_call(): client.update_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.UpdateDatasetRequest() @@ -967,7 +973,7 @@ async def test_update_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.UpdateDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -985,24 +991,18 @@ async def test_update_dataset_async( etag="etag_value", ) ) - response = await client.update_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.UpdateDatasetRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_dataset.Dataset) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -1012,17 +1012,17 @@ async def test_update_dataset_async_from_dict(): def test_update_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.UpdateDatasetRequest() + request.dataset.name = "dataset.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: call.return_value = gca_dataset.Dataset() - client.update_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1039,17 +1039,19 @@ def test_update_dataset_field_headers(): @pytest.mark.asyncio async def test_update_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.UpdateDatasetRequest() + request.dataset.name = "dataset.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_dataset.Dataset()) - await client.update_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1065,32 +1067,29 @@ async def test_update_dataset_field_headers_async(): def test_update_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_dataset.Dataset() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_dataset( dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].dataset == gca_dataset.Dataset(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1098,13 +1097,15 @@ def test_update_dataset_flattened_error(): client.update_dataset( dataset_service.UpdateDatasetRequest(), dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_dataset), "__call__") as call: @@ -1116,22 +1117,22 @@ async def test_update_dataset_flattened_async(): # using the keyword arguments to the method. response = await client.update_dataset( dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].dataset == gca_dataset.Dataset(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1139,7 +1140,7 @@ async def test_update_dataset_flattened_error_async(): await client.update_dataset( dataset_service.UpdateDatasetRequest(), dataset=gca_dataset.Dataset(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1147,7 +1148,7 @@ def test_list_datasets( transport: str = "grpc", request_type=dataset_service.ListDatasetsRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1160,19 +1161,15 @@ def test_list_datasets( call.return_value = dataset_service.ListDatasetsResponse( next_page_token="next_page_token_value", ) - response = client.list_datasets(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDatasetsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDatasetsPager) - assert response.next_page_token == "next_page_token_value" @@ -1184,7 +1181,7 @@ def test_list_datasets_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1192,7 +1189,6 @@ def test_list_datasets_empty_call(): client.list_datasets() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDatasetsRequest() @@ -1201,7 +1197,7 @@ async def test_list_datasets_async( transport: str = "grpc_asyncio", request_type=dataset_service.ListDatasetsRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1216,18 +1212,15 @@ async def test_list_datasets_async( next_page_token="next_page_token_value", ) ) - response = await client.list_datasets(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDatasetsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListDatasetsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1237,17 +1230,17 @@ async def test_list_datasets_async_from_dict(): def test_list_datasets_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDatasetsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: call.return_value = dataset_service.ListDatasetsResponse() - client.list_datasets(request) # Establish that the underlying gRPC stub method was called. @@ -1262,11 +1255,14 @@ def test_list_datasets_field_headers(): @pytest.mark.asyncio async def test_list_datasets_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDatasetsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1274,7 +1270,6 @@ async def test_list_datasets_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( dataset_service.ListDatasetsResponse() ) - await client.list_datasets(request) # Establish that the underlying gRPC stub method was called. @@ -1288,13 +1283,12 @@ async def test_list_datasets_field_headers_async(): def test_list_datasets_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset_service.ListDatasetsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_datasets(parent="parent_value",) @@ -1303,12 +1297,11 @@ def test_list_datasets_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_datasets_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1320,7 +1313,9 @@ def test_list_datasets_flattened_error(): @pytest.mark.asyncio async def test_list_datasets_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: @@ -1338,13 +1333,14 @@ async def test_list_datasets_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_datasets_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1355,7 +1351,7 @@ async def test_list_datasets_flattened_error_async(): def test_list_datasets_pager(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: @@ -1389,7 +1385,7 @@ def test_list_datasets_pager(): def test_list_datasets_pages(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_datasets), "__call__") as call: @@ -1415,7 +1411,7 @@ def test_list_datasets_pages(): @pytest.mark.asyncio async def test_list_datasets_async_pager(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1448,7 +1444,7 @@ async def test_list_datasets_async_pager(): @pytest.mark.asyncio async def test_list_datasets_async_pages(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1480,7 +1476,7 @@ def test_delete_dataset( transport: str = "grpc", request_type=dataset_service.DeleteDatasetRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1491,13 +1487,11 @@ def test_delete_dataset( with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.DeleteDatasetRequest() # Establish that the response is the type that we expect. @@ -1512,7 +1506,7 @@ def test_delete_dataset_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1520,7 +1514,6 @@ def test_delete_dataset_empty_call(): client.delete_dataset() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.DeleteDatasetRequest() @@ -1529,7 +1522,7 @@ async def test_delete_dataset_async( transport: str = "grpc_asyncio", request_type=dataset_service.DeleteDatasetRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1542,13 +1535,11 @@ async def test_delete_dataset_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.DeleteDatasetRequest() # Establish that the response is the type that we expect. @@ -1561,17 +1552,17 @@ async def test_delete_dataset_async_from_dict(): def test_delete_dataset_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.DeleteDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1586,11 +1577,14 @@ def test_delete_dataset_field_headers(): @pytest.mark.asyncio async def test_delete_dataset_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.DeleteDatasetRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1598,7 +1592,6 @@ async def test_delete_dataset_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_dataset(request) # Establish that the underlying gRPC stub method was called. @@ -1612,13 +1605,12 @@ async def test_delete_dataset_field_headers_async(): def test_delete_dataset_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_dataset(name="name_value",) @@ -1627,12 +1619,11 @@ def test_delete_dataset_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_dataset_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1644,7 +1635,9 @@ def test_delete_dataset_flattened_error(): @pytest.mark.asyncio async def test_delete_dataset_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_dataset), "__call__") as call: @@ -1662,13 +1655,14 @@ async def test_delete_dataset_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_dataset_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1682,7 +1676,7 @@ def test_import_data( transport: str = "grpc", request_type=dataset_service.ImportDataRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1693,13 +1687,11 @@ def test_import_data( with mock.patch.object(type(client.transport.import_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.import_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ImportDataRequest() # Establish that the response is the type that we expect. @@ -1714,7 +1706,7 @@ def test_import_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1722,7 +1714,6 @@ def test_import_data_empty_call(): client.import_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ImportDataRequest() @@ -1731,7 +1722,7 @@ async def test_import_data_async( transport: str = "grpc_asyncio", request_type=dataset_service.ImportDataRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1744,13 +1735,11 @@ async def test_import_data_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.import_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ImportDataRequest() # Establish that the response is the type that we expect. @@ -1763,17 +1752,17 @@ async def test_import_data_async_from_dict(): def test_import_data_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ImportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_data), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.import_data(request) # Establish that the underlying gRPC stub method was called. @@ -1788,11 +1777,14 @@ def test_import_data_field_headers(): @pytest.mark.asyncio async def test_import_data_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ImportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1800,7 +1792,6 @@ async def test_import_data_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.import_data(request) # Establish that the underlying gRPC stub method was called. @@ -1814,13 +1805,12 @@ async def test_import_data_field_headers_async(): def test_import_data_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.import_data( @@ -1834,16 +1824,14 @@ def test_import_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].import_configs == [ dataset.ImportDataConfig(gcs_source=io.GcsSource(uris=["uris_value"])) ] def test_import_data_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1859,7 +1847,9 @@ def test_import_data_flattened_error(): @pytest.mark.asyncio async def test_import_data_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.import_data), "__call__") as call: @@ -1882,9 +1872,7 @@ async def test_import_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].import_configs == [ dataset.ImportDataConfig(gcs_source=io.GcsSource(uris=["uris_value"])) ] @@ -1892,7 +1880,9 @@ async def test_import_data_flattened_async(): @pytest.mark.asyncio async def test_import_data_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1910,7 +1900,7 @@ def test_export_data( transport: str = "grpc", request_type=dataset_service.ExportDataRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1921,13 +1911,11 @@ def test_export_data( with mock.patch.object(type(client.transport.export_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.export_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ExportDataRequest() # Establish that the response is the type that we expect. @@ -1942,7 +1930,7 @@ def test_export_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1950,7 +1938,6 @@ def test_export_data_empty_call(): client.export_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ExportDataRequest() @@ -1959,7 +1946,7 @@ async def test_export_data_async( transport: str = "grpc_asyncio", request_type=dataset_service.ExportDataRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1972,13 +1959,11 @@ async def test_export_data_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.export_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ExportDataRequest() # Establish that the response is the type that we expect. @@ -1991,17 +1976,17 @@ async def test_export_data_async_from_dict(): def test_export_data_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ExportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_data), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.export_data(request) # Establish that the underlying gRPC stub method was called. @@ -2016,11 +2001,14 @@ def test_export_data_field_headers(): @pytest.mark.asyncio async def test_export_data_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ExportDataRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2028,7 +2016,6 @@ async def test_export_data_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.export_data(request) # Establish that the underlying gRPC stub method was called. @@ -2042,13 +2029,12 @@ async def test_export_data_field_headers_async(): def test_export_data_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_data), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.export_data( @@ -2064,9 +2050,7 @@ def test_export_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].export_config == dataset.ExportDataConfig( gcs_destination=io.GcsDestination( output_uri_prefix="output_uri_prefix_value" @@ -2075,7 +2059,7 @@ def test_export_data_flattened(): def test_export_data_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2093,7 +2077,9 @@ def test_export_data_flattened_error(): @pytest.mark.asyncio async def test_export_data_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_data), "__call__") as call: @@ -2118,9 +2104,7 @@ async def test_export_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].export_config == dataset.ExportDataConfig( gcs_destination=io.GcsDestination( output_uri_prefix="output_uri_prefix_value" @@ -2130,7 +2114,9 @@ async def test_export_data_flattened_async(): @pytest.mark.asyncio async def test_export_data_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2150,7 +2136,7 @@ def test_list_data_items( transport: str = "grpc", request_type=dataset_service.ListDataItemsRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2163,19 +2149,15 @@ def test_list_data_items( call.return_value = dataset_service.ListDataItemsResponse( next_page_token="next_page_token_value", ) - response = client.list_data_items(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDataItemsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDataItemsPager) - assert response.next_page_token == "next_page_token_value" @@ -2187,7 +2169,7 @@ def test_list_data_items_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2195,7 +2177,6 @@ def test_list_data_items_empty_call(): client.list_data_items() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDataItemsRequest() @@ -2204,7 +2185,7 @@ async def test_list_data_items_async( transport: str = "grpc_asyncio", request_type=dataset_service.ListDataItemsRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2219,18 +2200,15 @@ async def test_list_data_items_async( next_page_token="next_page_token_value", ) ) - response = await client.list_data_items(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListDataItemsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListDataItemsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2240,17 +2218,17 @@ async def test_list_data_items_async_from_dict(): def test_list_data_items_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDataItemsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: call.return_value = dataset_service.ListDataItemsResponse() - client.list_data_items(request) # Establish that the underlying gRPC stub method was called. @@ -2265,11 +2243,14 @@ def test_list_data_items_field_headers(): @pytest.mark.asyncio async def test_list_data_items_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListDataItemsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2277,7 +2258,6 @@ async def test_list_data_items_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( dataset_service.ListDataItemsResponse() ) - await client.list_data_items(request) # Establish that the underlying gRPC stub method was called. @@ -2291,13 +2271,12 @@ async def test_list_data_items_field_headers_async(): def test_list_data_items_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset_service.ListDataItemsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_data_items(parent="parent_value",) @@ -2306,12 +2285,11 @@ def test_list_data_items_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_data_items_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2323,7 +2301,9 @@ def test_list_data_items_flattened_error(): @pytest.mark.asyncio async def test_list_data_items_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: @@ -2341,13 +2321,14 @@ async def test_list_data_items_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_data_items_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2358,7 +2339,7 @@ async def test_list_data_items_flattened_error_async(): def test_list_data_items_pager(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: @@ -2398,7 +2379,7 @@ def test_list_data_items_pager(): def test_list_data_items_pages(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_data_items), "__call__") as call: @@ -2430,7 +2411,7 @@ def test_list_data_items_pages(): @pytest.mark.asyncio async def test_list_data_items_async_pager(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2469,7 +2450,7 @@ async def test_list_data_items_async_pager(): @pytest.mark.asyncio async def test_list_data_items_async_pages(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2507,7 +2488,7 @@ def test_get_annotation_spec( transport: str = "grpc", request_type=dataset_service.GetAnnotationSpecRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2522,23 +2503,17 @@ def test_get_annotation_spec( call.return_value = annotation_spec.AnnotationSpec( name="name_value", display_name="display_name_value", etag="etag_value", ) - response = client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetAnnotationSpecRequest() # Establish that the response is the type that we expect. - assert isinstance(response, annotation_spec.AnnotationSpec) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" @@ -2550,7 +2525,7 @@ def test_get_annotation_spec_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2560,7 +2535,6 @@ def test_get_annotation_spec_empty_call(): client.get_annotation_spec() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetAnnotationSpecRequest() @@ -2570,7 +2544,7 @@ async def test_get_annotation_spec_async( request_type=dataset_service.GetAnnotationSpecRequest, ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2587,22 +2561,17 @@ async def test_get_annotation_spec_async( name="name_value", display_name="display_name_value", etag="etag_value", ) ) - response = await client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.GetAnnotationSpecRequest() # Establish that the response is the type that we expect. assert isinstance(response, annotation_spec.AnnotationSpec) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" @@ -2612,11 +2581,12 @@ async def test_get_annotation_spec_async_from_dict(): def test_get_annotation_spec_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetAnnotationSpecRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2624,7 +2594,6 @@ def test_get_annotation_spec_field_headers(): type(client.transport.get_annotation_spec), "__call__" ) as call: call.return_value = annotation_spec.AnnotationSpec() - client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. @@ -2639,11 +2608,14 @@ def test_get_annotation_spec_field_headers(): @pytest.mark.asyncio async def test_get_annotation_spec_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.GetAnnotationSpecRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2653,7 +2625,6 @@ async def test_get_annotation_spec_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( annotation_spec.AnnotationSpec() ) - await client.get_annotation_spec(request) # Establish that the underlying gRPC stub method was called. @@ -2667,7 +2638,7 @@ async def test_get_annotation_spec_field_headers_async(): def test_get_annotation_spec_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2675,7 +2646,6 @@ def test_get_annotation_spec_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = annotation_spec.AnnotationSpec() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_annotation_spec(name="name_value",) @@ -2684,12 +2654,11 @@ def test_get_annotation_spec_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_annotation_spec_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2701,7 +2670,9 @@ def test_get_annotation_spec_flattened_error(): @pytest.mark.asyncio async def test_get_annotation_spec_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2721,13 +2692,14 @@ async def test_get_annotation_spec_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_annotation_spec_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2741,7 +2713,7 @@ def test_list_annotations( transport: str = "grpc", request_type=dataset_service.ListAnnotationsRequest ): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2754,19 +2726,15 @@ def test_list_annotations( call.return_value = dataset_service.ListAnnotationsResponse( next_page_token="next_page_token_value", ) - response = client.list_annotations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListAnnotationsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAnnotationsPager) - assert response.next_page_token == "next_page_token_value" @@ -2778,7 +2746,7 @@ def test_list_annotations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2786,7 +2754,6 @@ def test_list_annotations_empty_call(): client.list_annotations() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListAnnotationsRequest() @@ -2795,7 +2762,7 @@ async def test_list_annotations_async( transport: str = "grpc_asyncio", request_type=dataset_service.ListAnnotationsRequest ): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2810,18 +2777,15 @@ async def test_list_annotations_async( next_page_token="next_page_token_value", ) ) - response = await client.list_annotations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == dataset_service.ListAnnotationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAnnotationsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2831,17 +2795,17 @@ async def test_list_annotations_async_from_dict(): def test_list_annotations_field_headers(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListAnnotationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: call.return_value = dataset_service.ListAnnotationsResponse() - client.list_annotations(request) # Establish that the underlying gRPC stub method was called. @@ -2856,11 +2820,14 @@ def test_list_annotations_field_headers(): @pytest.mark.asyncio async def test_list_annotations_field_headers_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = dataset_service.ListAnnotationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2868,7 +2835,6 @@ async def test_list_annotations_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( dataset_service.ListAnnotationsResponse() ) - await client.list_annotations(request) # Establish that the underlying gRPC stub method was called. @@ -2882,13 +2848,12 @@ async def test_list_annotations_field_headers_async(): def test_list_annotations_flattened(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = dataset_service.ListAnnotationsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_annotations(parent="parent_value",) @@ -2897,12 +2862,11 @@ def test_list_annotations_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_annotations_flattened_error(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2914,7 +2878,9 @@ def test_list_annotations_flattened_error(): @pytest.mark.asyncio async def test_list_annotations_flattened_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: @@ -2932,13 +2898,14 @@ async def test_list_annotations_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_annotations_flattened_error_async(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2949,7 +2916,7 @@ async def test_list_annotations_flattened_error_async(): def test_list_annotations_pager(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: @@ -2989,7 +2956,7 @@ def test_list_annotations_pager(): def test_list_annotations_pages(): - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_annotations), "__call__") as call: @@ -3021,7 +2988,7 @@ def test_list_annotations_pages(): @pytest.mark.asyncio async def test_list_annotations_async_pager(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3060,7 +3027,7 @@ async def test_list_annotations_async_pager(): @pytest.mark.asyncio async def test_list_annotations_async_pages(): - client = DatasetServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DatasetServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3097,16 +3064,16 @@ async def test_list_annotations_async_pages(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DatasetServiceClient( @@ -3116,7 +3083,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DatasetServiceClient( @@ -3127,7 +3094,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = DatasetServiceClient(transport=transport) assert client.transport is transport @@ -3136,13 +3103,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.DatasetServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.DatasetServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3157,23 +3124,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = DatasetServiceClient(credentials=credentials.AnonymousCredentials(),) + client = DatasetServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.DatasetServiceGrpcTransport,) def test_dataset_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.DatasetServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3185,7 +3152,7 @@ def test_dataset_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.DatasetServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3212,15 +3179,37 @@ def test_dataset_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_dataset_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.dataset_service.transports.DatasetServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.DatasetServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_dataset_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.dataset_service.transports.DatasetServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DatasetServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3233,19 +3222,33 @@ def test_dataset_service_base_transport_with_credentials_file(): def test_dataset_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.dataset_service.transports.DatasetServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DatasetServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_dataset_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + DatasetServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_dataset_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) DatasetServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3253,20 +3256,156 @@ def test_dataset_service_auth_adc(): ) -def test_dataset_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.DatasetServiceGrpcTransport, + transports.DatasetServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_dataset_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.DatasetServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.DatasetServiceGrpcTransport, + transports.DatasetServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_dataset_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DatasetServiceGrpcTransport, grpc_helpers), + (transports.DatasetServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_dataset_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DatasetServiceGrpcTransport, grpc_helpers), + (transports.DatasetServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_dataset_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.DatasetServiceGrpcTransport, grpc_helpers), + (transports.DatasetServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_dataset_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -3275,7 +3414,7 @@ def test_dataset_service_transport_auth_adc(): ], ) def test_dataset_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3314,7 +3453,7 @@ def test_dataset_service_grpc_transport_client_cert_source_for_mtls(transport_cl def test_dataset_service_host_no_port(): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -3324,7 +3463,7 @@ def test_dataset_service_host_no_port(): def test_dataset_service_host_with_port(): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -3380,9 +3519,9 @@ def test_dataset_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3458,7 +3597,7 @@ def test_dataset_service_transport_channel_mtls_with_adc(transport_class): def test_dataset_service_grpc_lro_client(): client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3471,7 +3610,7 @@ def test_dataset_service_grpc_lro_client(): def test_dataset_service_grpc_lro_async_client(): client = DatasetServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3488,7 +3627,6 @@ def test_annotation_path(): dataset = "whelk" data_item = "octopus" annotation = "oyster" - expected = "projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item}/annotations/{annotation}".format( project=project, location=location, @@ -3522,7 +3660,6 @@ def test_annotation_spec_path(): location = "abalone" dataset = "squid" annotation_spec = "clam" - expected = "projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}".format( project=project, location=location, @@ -3554,7 +3691,6 @@ def test_data_item_path(): location = "mussel" dataset = "winkle" data_item = "nautilus" - expected = "projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item}".format( project=project, location=location, dataset=dataset, data_item=data_item, ) @@ -3580,7 +3716,6 @@ def test_dataset_path(): project = "whelk" location = "octopus" dataset = "oyster" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( project=project, location=location, dataset=dataset, ) @@ -3603,7 +3738,6 @@ def test_parse_dataset_path(): def test_common_billing_account_path(): billing_account = "winkle" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3624,7 +3758,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) actual = DatasetServiceClient.common_folder_path(folder) assert expected == actual @@ -3643,7 +3776,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) actual = DatasetServiceClient.common_organization_path(organization) assert expected == actual @@ -3662,7 +3794,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) actual = DatasetServiceClient.common_project_path(project) assert expected == actual @@ -3682,7 +3813,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "oyster" location = "nudibranch" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3709,7 +3839,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.DatasetServiceTransport, "_prep_wrapped_messages" ) as prep: client = DatasetServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3718,6 +3848,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = DatasetServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py index a8ee297c20..de53fedc34 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_endpoint_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.endpoint_service import ( EndpointServiceAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.aiplatform_v1beta1.services.endpoint_service import pagers from google.cloud.aiplatform_v1beta1.services.endpoint_service import transports +from google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import accelerator_type from google.cloud.aiplatform_v1beta1.types import encryption_spec from google.cloud.aiplatform_v1beta1.types import endpoint @@ -54,9 +59,33 @@ from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -107,7 +136,7 @@ def test__get_default_mtls_endpoint(): "client_class", [EndpointServiceClient, EndpointServiceAsyncClient,] ) def test_endpoint_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -124,7 +153,7 @@ def test_endpoint_service_client_from_service_account_info(client_class): "client_class", [EndpointServiceClient, EndpointServiceAsyncClient,] ) def test_endpoint_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -177,7 +206,7 @@ def test_endpoint_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(EndpointServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -475,7 +504,7 @@ def test_create_endpoint( transport: str = "grpc", request_type=endpoint_service.CreateEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -486,13 +515,11 @@ def test_create_endpoint( with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.CreateEndpointRequest() # Establish that the response is the type that we expect. @@ -507,7 +534,7 @@ def test_create_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -515,7 +542,6 @@ def test_create_endpoint_empty_call(): client.create_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.CreateEndpointRequest() @@ -524,7 +550,7 @@ async def test_create_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.CreateEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -537,13 +563,11 @@ async def test_create_endpoint_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.CreateEndpointRequest() # Establish that the response is the type that we expect. @@ -556,17 +580,17 @@ async def test_create_endpoint_async_from_dict(): def test_create_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.CreateEndpointRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -581,11 +605,14 @@ def test_create_endpoint_field_headers(): @pytest.mark.asyncio async def test_create_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.CreateEndpointRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -593,7 +620,6 @@ async def test_create_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -607,13 +633,12 @@ async def test_create_endpoint_field_headers_async(): def test_create_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_endpoint( @@ -624,14 +649,12 @@ def test_create_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") def test_create_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -645,7 +668,9 @@ def test_create_endpoint_flattened_error(): @pytest.mark.asyncio async def test_create_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: @@ -665,15 +690,15 @@ async def test_create_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") @pytest.mark.asyncio async def test_create_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -689,7 +714,7 @@ def test_get_endpoint( transport: str = "grpc", request_type=endpoint_service.GetEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -705,25 +730,18 @@ def test_get_endpoint( description="description_value", etag="etag_value", ) - response = client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.GetEndpointRequest() # Establish that the response is the type that we expect. - assert isinstance(response, endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -735,7 +753,7 @@ def test_get_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -743,7 +761,6 @@ def test_get_endpoint_empty_call(): client.get_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.GetEndpointRequest() @@ -752,7 +769,7 @@ async def test_get_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.GetEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -770,24 +787,18 @@ async def test_get_endpoint_async( etag="etag_value", ) ) - response = await client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.GetEndpointRequest() # Establish that the response is the type that we expect. assert isinstance(response, endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -797,17 +808,17 @@ async def test_get_endpoint_async_from_dict(): def test_get_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.GetEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: call.return_value = endpoint.Endpoint() - client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -822,17 +833,19 @@ def test_get_endpoint_field_headers(): @pytest.mark.asyncio async def test_get_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.GetEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(endpoint.Endpoint()) - await client.get_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -846,13 +859,12 @@ async def test_get_endpoint_field_headers_async(): def test_get_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = endpoint.Endpoint() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_endpoint(name="name_value",) @@ -861,12 +873,11 @@ def test_get_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -878,7 +889,9 @@ def test_get_endpoint_flattened_error(): @pytest.mark.asyncio async def test_get_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: @@ -894,13 +907,14 @@ async def test_get_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -914,7 +928,7 @@ def test_list_endpoints( transport: str = "grpc", request_type=endpoint_service.ListEndpointsRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -927,19 +941,15 @@ def test_list_endpoints( call.return_value = endpoint_service.ListEndpointsResponse( next_page_token="next_page_token_value", ) - response = client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.ListEndpointsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEndpointsPager) - assert response.next_page_token == "next_page_token_value" @@ -951,7 +961,7 @@ def test_list_endpoints_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -959,7 +969,6 @@ def test_list_endpoints_empty_call(): client.list_endpoints() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.ListEndpointsRequest() @@ -968,7 +977,7 @@ async def test_list_endpoints_async( transport: str = "grpc_asyncio", request_type=endpoint_service.ListEndpointsRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -983,18 +992,15 @@ async def test_list_endpoints_async( next_page_token="next_page_token_value", ) ) - response = await client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.ListEndpointsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListEndpointsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1004,17 +1010,17 @@ async def test_list_endpoints_async_from_dict(): def test_list_endpoints_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.ListEndpointsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: call.return_value = endpoint_service.ListEndpointsResponse() - client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. @@ -1029,11 +1035,14 @@ def test_list_endpoints_field_headers(): @pytest.mark.asyncio async def test_list_endpoints_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.ListEndpointsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1041,7 +1050,6 @@ async def test_list_endpoints_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( endpoint_service.ListEndpointsResponse() ) - await client.list_endpoints(request) # Establish that the underlying gRPC stub method was called. @@ -1055,13 +1063,12 @@ async def test_list_endpoints_field_headers_async(): def test_list_endpoints_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = endpoint_service.ListEndpointsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_endpoints(parent="parent_value",) @@ -1070,12 +1077,11 @@ def test_list_endpoints_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_endpoints_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1087,7 +1093,9 @@ def test_list_endpoints_flattened_error(): @pytest.mark.asyncio async def test_list_endpoints_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -1105,13 +1113,14 @@ async def test_list_endpoints_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_endpoints_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1122,7 +1131,7 @@ async def test_list_endpoints_flattened_error_async(): def test_list_endpoints_pager(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -1162,7 +1171,7 @@ def test_list_endpoints_pager(): def test_list_endpoints_pages(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -1194,7 +1203,9 @@ def test_list_endpoints_pages(): @pytest.mark.asyncio async def test_list_endpoints_async_pager(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1233,7 +1244,9 @@ async def test_list_endpoints_async_pager(): @pytest.mark.asyncio async def test_list_endpoints_async_pages(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1271,7 +1284,7 @@ def test_update_endpoint( transport: str = "grpc", request_type=endpoint_service.UpdateEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1287,25 +1300,18 @@ def test_update_endpoint( description="description_value", etag="etag_value", ) - response = client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UpdateEndpointRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -1317,7 +1323,7 @@ def test_update_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1325,7 +1331,6 @@ def test_update_endpoint_empty_call(): client.update_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UpdateEndpointRequest() @@ -1334,7 +1339,7 @@ async def test_update_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.UpdateEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1352,24 +1357,18 @@ async def test_update_endpoint_async( etag="etag_value", ) ) - response = await client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UpdateEndpointRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_endpoint.Endpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -1379,17 +1378,17 @@ async def test_update_endpoint_async_from_dict(): def test_update_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UpdateEndpointRequest() + request.endpoint.name = "endpoint.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_endpoint), "__call__") as call: call.return_value = gca_endpoint.Endpoint() - client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1406,11 +1405,14 @@ def test_update_endpoint_field_headers(): @pytest.mark.asyncio async def test_update_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UpdateEndpointRequest() + request.endpoint.name = "endpoint.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1418,7 +1420,6 @@ async def test_update_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_endpoint.Endpoint() ) - await client.update_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1434,32 +1435,29 @@ async def test_update_endpoint_field_headers_async(): def test_update_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_endpoint.Endpoint() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_endpoint( endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1467,13 +1465,15 @@ def test_update_endpoint_flattened_error(): client.update_endpoint( endpoint_service.UpdateEndpointRequest(), endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_endpoint), "__call__") as call: @@ -1487,22 +1487,22 @@ async def test_update_endpoint_flattened_async(): # using the keyword arguments to the method. response = await client.update_endpoint( endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == gca_endpoint.Endpoint(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1510,7 +1510,7 @@ async def test_update_endpoint_flattened_error_async(): await client.update_endpoint( endpoint_service.UpdateEndpointRequest(), endpoint=gca_endpoint.Endpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1518,7 +1518,7 @@ def test_delete_endpoint( transport: str = "grpc", request_type=endpoint_service.DeleteEndpointRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1529,13 +1529,11 @@ def test_delete_endpoint( with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeleteEndpointRequest() # Establish that the response is the type that we expect. @@ -1550,7 +1548,7 @@ def test_delete_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1558,7 +1556,6 @@ def test_delete_endpoint_empty_call(): client.delete_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeleteEndpointRequest() @@ -1567,7 +1564,7 @@ async def test_delete_endpoint_async( transport: str = "grpc_asyncio", request_type=endpoint_service.DeleteEndpointRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1580,13 +1577,11 @@ async def test_delete_endpoint_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeleteEndpointRequest() # Establish that the response is the type that we expect. @@ -1599,17 +1594,17 @@ async def test_delete_endpoint_async_from_dict(): def test_delete_endpoint_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeleteEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1624,11 +1619,14 @@ def test_delete_endpoint_field_headers(): @pytest.mark.asyncio async def test_delete_endpoint_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeleteEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1636,7 +1634,6 @@ async def test_delete_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1650,13 +1647,12 @@ async def test_delete_endpoint_field_headers_async(): def test_delete_endpoint_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_endpoint(name="name_value",) @@ -1665,12 +1661,11 @@ def test_delete_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_endpoint_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1682,7 +1677,9 @@ def test_delete_endpoint_flattened_error(): @pytest.mark.asyncio async def test_delete_endpoint_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: @@ -1700,13 +1697,14 @@ async def test_delete_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_endpoint_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1720,7 +1718,7 @@ def test_deploy_model( transport: str = "grpc", request_type=endpoint_service.DeployModelRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1731,13 +1729,11 @@ def test_deploy_model( with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.deploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeployModelRequest() # Establish that the response is the type that we expect. @@ -1752,7 +1748,7 @@ def test_deploy_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1760,7 +1756,6 @@ def test_deploy_model_empty_call(): client.deploy_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeployModelRequest() @@ -1769,7 +1764,7 @@ async def test_deploy_model_async( transport: str = "grpc_asyncio", request_type=endpoint_service.DeployModelRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1782,13 +1777,11 @@ async def test_deploy_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.deploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.DeployModelRequest() # Establish that the response is the type that we expect. @@ -1801,17 +1794,17 @@ async def test_deploy_model_async_from_dict(): def test_deploy_model_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.deploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -1826,11 +1819,14 @@ def test_deploy_model_field_headers(): @pytest.mark.asyncio async def test_deploy_model_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.DeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1838,7 +1834,6 @@ async def test_deploy_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.deploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -1852,13 +1847,12 @@ async def test_deploy_model_field_headers_async(): def test_deploy_model_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.deploy_model( @@ -1877,9 +1871,7 @@ def test_deploy_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model == gca_endpoint.DeployedModel( dedicated_resources=machine_resources.DedicatedResources( machine_spec=machine_resources.MachineSpec( @@ -1887,12 +1879,11 @@ def test_deploy_model_flattened(): ) ) ) - assert args[0].traffic_split == {"key_value": 541} def test_deploy_model_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1913,7 +1904,9 @@ def test_deploy_model_flattened_error(): @pytest.mark.asyncio async def test_deploy_model_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_model), "__call__") as call: @@ -1941,9 +1934,7 @@ async def test_deploy_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model == gca_endpoint.DeployedModel( dedicated_resources=machine_resources.DedicatedResources( machine_spec=machine_resources.MachineSpec( @@ -1951,13 +1942,14 @@ async def test_deploy_model_flattened_async(): ) ) ) - assert args[0].traffic_split == {"key_value": 541} @pytest.mark.asyncio async def test_deploy_model_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1980,7 +1972,7 @@ def test_undeploy_model( transport: str = "grpc", request_type=endpoint_service.UndeployModelRequest ): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1991,13 +1983,11 @@ def test_undeploy_model( with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UndeployModelRequest() # Establish that the response is the type that we expect. @@ -2012,7 +2002,7 @@ def test_undeploy_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2020,7 +2010,6 @@ def test_undeploy_model_empty_call(): client.undeploy_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UndeployModelRequest() @@ -2029,7 +2018,7 @@ async def test_undeploy_model_async( transport: str = "grpc_asyncio", request_type=endpoint_service.UndeployModelRequest ): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2042,13 +2031,11 @@ async def test_undeploy_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == endpoint_service.UndeployModelRequest() # Establish that the response is the type that we expect. @@ -2061,17 +2048,17 @@ async def test_undeploy_model_async_from_dict(): def test_undeploy_model_field_headers(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UndeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -2086,11 +2073,14 @@ def test_undeploy_model_field_headers(): @pytest.mark.asyncio async def test_undeploy_model_field_headers_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = endpoint_service.UndeployModelRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2098,7 +2088,6 @@ async def test_undeploy_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.undeploy_model(request) # Establish that the underlying gRPC stub method was called. @@ -2112,13 +2101,12 @@ async def test_undeploy_model_field_headers_async(): def test_undeploy_model_flattened(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.undeploy_model( @@ -2131,16 +2119,13 @@ def test_undeploy_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model_id == "deployed_model_id_value" - assert args[0].traffic_split == {"key_value": 541} def test_undeploy_model_flattened_error(): - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2155,7 +2140,9 @@ def test_undeploy_model_flattened_error(): @pytest.mark.asyncio async def test_undeploy_model_flattened_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_model), "__call__") as call: @@ -2177,17 +2164,16 @@ async def test_undeploy_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].deployed_model_id == "deployed_model_id_value" - assert args[0].traffic_split == {"key_value": 541} @pytest.mark.asyncio async def test_undeploy_model_flattened_error_async(): - client = EndpointServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2203,16 +2189,16 @@ async def test_undeploy_model_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = EndpointServiceClient( @@ -2222,7 +2208,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = EndpointServiceClient( @@ -2233,7 +2219,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = EndpointServiceClient(transport=transport) assert client.transport is transport @@ -2242,13 +2228,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.EndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.EndpointServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -2263,23 +2249,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = EndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = EndpointServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.EndpointServiceGrpcTransport,) def test_endpoint_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.EndpointServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -2291,7 +2277,7 @@ def test_endpoint_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.EndpointServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -2315,15 +2301,37 @@ def test_endpoint_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_endpoint_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.EndpointServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.EndpointServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_endpoint_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.EndpointServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.EndpointServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -2336,19 +2344,33 @@ def test_endpoint_service_base_transport_with_credentials_file(): def test_endpoint_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.EndpointServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.EndpointServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_endpoint_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + EndpointServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_endpoint_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) EndpointServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -2356,20 +2378,156 @@ def test_endpoint_service_auth_adc(): ) -def test_endpoint_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.EndpointServiceGrpcTransport, + transports.EndpointServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_endpoint_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.EndpointServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.EndpointServiceGrpcTransport, + transports.EndpointServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_endpoint_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.EndpointServiceGrpcTransport, grpc_helpers), + (transports.EndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_endpoint_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.EndpointServiceGrpcTransport, grpc_helpers), + (transports.EndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_endpoint_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.EndpointServiceGrpcTransport, grpc_helpers), + (transports.EndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_endpoint_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -2378,7 +2536,7 @@ def test_endpoint_service_transport_auth_adc(): ], ) def test_endpoint_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -2417,7 +2575,7 @@ def test_endpoint_service_grpc_transport_client_cert_source_for_mtls(transport_c def test_endpoint_service_host_no_port(): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -2427,7 +2585,7 @@ def test_endpoint_service_host_no_port(): def test_endpoint_service_host_with_port(): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -2483,9 +2641,9 @@ def test_endpoint_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2561,7 +2719,7 @@ def test_endpoint_service_transport_channel_mtls_with_adc(transport_class): def test_endpoint_service_grpc_lro_client(): client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -2574,7 +2732,7 @@ def test_endpoint_service_grpc_lro_client(): def test_endpoint_service_grpc_lro_async_client(): client = EndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -2589,7 +2747,6 @@ def test_endpoint_path(): project = "squid" location = "clam" endpoint = "whelk" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -2614,7 +2771,6 @@ def test_model_path(): project = "cuttlefish" location = "mussel" model = "winkle" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -2637,7 +2793,6 @@ def test_parse_model_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2658,7 +2813,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = EndpointServiceClient.common_folder_path(folder) assert expected == actual @@ -2677,7 +2831,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = EndpointServiceClient.common_organization_path(organization) assert expected == actual @@ -2696,7 +2849,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = EndpointServiceClient.common_project_path(project) assert expected == actual @@ -2716,7 +2868,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2743,7 +2894,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.EndpointServiceTransport, "_prep_wrapped_messages" ) as prep: client = EndpointServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2752,6 +2903,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = EndpointServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py index db9a7d5367..6645e05944 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_online_serving_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,13 +23,13 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service import ( FeaturestoreOnlineServingServiceAsyncClient, @@ -41,9 +40,39 @@ from google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service import ( transports, ) +from google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import feature_selector from google.cloud.aiplatform_v1beta1.types import featurestore_online_service from google.oauth2 import service_account +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -109,7 +138,7 @@ def test__get_default_mtls_endpoint(): def test_featurestore_online_serving_service_client_from_service_account_info( client_class, ): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -132,7 +161,7 @@ def test_featurestore_online_serving_service_client_from_service_account_info( def test_featurestore_online_serving_service_client_from_service_account_file( client_class, ): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -191,7 +220,7 @@ def test_featurestore_online_serving_service_client_client_options( with mock.patch.object( FeaturestoreOnlineServingServiceClient, "get_transport_class" ) as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -500,7 +529,7 @@ def test_read_feature_values( request_type=featurestore_online_service.ReadFeatureValuesRequest, ): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -513,17 +542,14 @@ def test_read_feature_values( ) as call: # Designate an appropriate return value for the call. call.return_value = featurestore_online_service.ReadFeatureValuesResponse() - response = client.read_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_online_service.ReadFeatureValuesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, featurestore_online_service.ReadFeatureValuesResponse) @@ -535,7 +561,7 @@ def test_read_feature_values_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -545,7 +571,6 @@ def test_read_feature_values_empty_call(): client.read_feature_values() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_online_service.ReadFeatureValuesRequest() @@ -555,7 +580,7 @@ async def test_read_feature_values_async( request_type=featurestore_online_service.ReadFeatureValuesRequest, ): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -570,13 +595,11 @@ async def test_read_feature_values_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore_online_service.ReadFeatureValuesResponse() ) - response = await client.read_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_online_service.ReadFeatureValuesRequest() # Establish that the response is the type that we expect. @@ -590,12 +613,13 @@ async def test_read_feature_values_async_from_dict(): def test_read_feature_values_field_headers(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_online_service.ReadFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -603,7 +627,6 @@ def test_read_feature_values_field_headers(): type(client.transport.read_feature_values), "__call__" ) as call: call.return_value = featurestore_online_service.ReadFeatureValuesResponse() - client.read_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -619,12 +642,13 @@ def test_read_feature_values_field_headers(): @pytest.mark.asyncio async def test_read_feature_values_field_headers_async(): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_online_service.ReadFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -634,7 +658,6 @@ async def test_read_feature_values_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore_online_service.ReadFeatureValuesResponse() ) - await client.read_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -649,7 +672,7 @@ async def test_read_feature_values_field_headers_async(): def test_read_feature_values_flattened(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -658,7 +681,6 @@ def test_read_feature_values_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = featurestore_online_service.ReadFeatureValuesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.read_feature_values(entity_type="entity_type_value",) @@ -667,13 +689,12 @@ def test_read_feature_values_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" def test_read_feature_values_flattened_error(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -688,7 +709,7 @@ def test_read_feature_values_flattened_error(): @pytest.mark.asyncio async def test_read_feature_values_flattened_async(): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -709,14 +730,13 @@ async def test_read_feature_values_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" @pytest.mark.asyncio async def test_read_feature_values_flattened_error_async(): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -733,7 +753,7 @@ def test_streaming_read_feature_values( request_type=featurestore_online_service.StreamingReadFeatureValuesRequest, ): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -748,13 +768,11 @@ def test_streaming_read_feature_values( call.return_value = iter( [featurestore_online_service.ReadFeatureValuesResponse()] ) - response = client.streaming_read_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert ( args[0] == featurestore_online_service.StreamingReadFeatureValuesRequest() ) @@ -774,7 +792,7 @@ def test_streaming_read_feature_values_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -784,7 +802,6 @@ def test_streaming_read_feature_values_empty_call(): client.streaming_read_feature_values() call.assert_called() _, args, _ = call.mock_calls[0] - assert ( args[0] == featurestore_online_service.StreamingReadFeatureValuesRequest() ) @@ -796,7 +813,7 @@ async def test_streaming_read_feature_values_async( request_type=featurestore_online_service.StreamingReadFeatureValuesRequest, ): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -812,13 +829,11 @@ async def test_streaming_read_feature_values_async( call.return_value.read = mock.AsyncMock( side_effect=[featurestore_online_service.ReadFeatureValuesResponse()] ) - response = await client.streaming_read_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert ( args[0] == featurestore_online_service.StreamingReadFeatureValuesRequest() ) @@ -835,12 +850,13 @@ async def test_streaming_read_feature_values_async_from_dict(): def test_streaming_read_feature_values_field_headers(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_online_service.StreamingReadFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -850,7 +866,6 @@ def test_streaming_read_feature_values_field_headers(): call.return_value = iter( [featurestore_online_service.ReadFeatureValuesResponse()] ) - client.streaming_read_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -866,12 +881,13 @@ def test_streaming_read_feature_values_field_headers(): @pytest.mark.asyncio async def test_streaming_read_feature_values_field_headers_async(): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_online_service.StreamingReadFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -882,7 +898,6 @@ async def test_streaming_read_feature_values_field_headers_async(): call.return_value.read = mock.AsyncMock( side_effect=[featurestore_online_service.ReadFeatureValuesResponse()] ) - await client.streaming_read_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -897,7 +912,7 @@ async def test_streaming_read_feature_values_field_headers_async(): def test_streaming_read_feature_values_flattened(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -908,7 +923,6 @@ def test_streaming_read_feature_values_flattened(): call.return_value = iter( [featurestore_online_service.ReadFeatureValuesResponse()] ) - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.streaming_read_feature_values(entity_type="entity_type_value",) @@ -917,13 +931,12 @@ def test_streaming_read_feature_values_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" def test_streaming_read_feature_values_flattened_error(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -938,7 +951,7 @@ def test_streaming_read_feature_values_flattened_error(): @pytest.mark.asyncio async def test_streaming_read_feature_values_flattened_async(): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -961,14 +974,13 @@ async def test_streaming_read_feature_values_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" @pytest.mark.asyncio async def test_streaming_read_feature_values_flattened_error_async(): client = FeaturestoreOnlineServingServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -983,16 +995,16 @@ async def test_streaming_read_feature_values_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.FeaturestoreOnlineServingServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.FeaturestoreOnlineServingServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = FeaturestoreOnlineServingServiceClient( @@ -1002,7 +1014,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.FeaturestoreOnlineServingServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = FeaturestoreOnlineServingServiceClient( @@ -1013,7 +1025,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.FeaturestoreOnlineServingServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = FeaturestoreOnlineServingServiceClient(transport=transport) assert client.transport is transport @@ -1022,13 +1034,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.FeaturestoreOnlineServingServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.FeaturestoreOnlineServingServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -1043,8 +1055,8 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() @@ -1052,7 +1064,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( client.transport, transports.FeaturestoreOnlineServingServiceGrpcTransport, @@ -1061,9 +1073,9 @@ def test_transport_grpc_default(): def test_featurestore_online_serving_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.FeaturestoreOnlineServingServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1075,7 +1087,7 @@ def test_featurestore_online_serving_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.FeaturestoreOnlineServingServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -1089,15 +1101,37 @@ def test_featurestore_online_serving_service_base_transport(): getattr(transport, method)(request=object()) +@requires_google_auth_gte_1_25_0 def test_featurestore_online_serving_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.FeaturestoreOnlineServingServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.FeaturestoreOnlineServingServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_featurestore_online_serving_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.FeaturestoreOnlineServingServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.FeaturestoreOnlineServingServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -1110,19 +1144,33 @@ def test_featurestore_online_serving_service_base_transport_with_credentials_fil def test_featurestore_online_serving_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.FeaturestoreOnlineServingServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.FeaturestoreOnlineServingServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_featurestore_online_serving_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + FeaturestoreOnlineServingServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_featurestore_online_serving_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) FeaturestoreOnlineServingServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -1130,20 +1178,169 @@ def test_featurestore_online_serving_service_auth_adc(): ) -def test_featurestore_online_serving_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.FeaturestoreOnlineServingServiceGrpcTransport, + transports.FeaturestoreOnlineServingServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_featurestore_online_serving_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.FeaturestoreOnlineServingServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.FeaturestoreOnlineServingServiceGrpcTransport, + transports.FeaturestoreOnlineServingServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_featurestore_online_serving_service_transport_auth_adc_old_google_auth( + transport_class, +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.FeaturestoreOnlineServingServiceGrpcTransport, grpc_helpers), + ( + transports.FeaturestoreOnlineServingServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_gte_1_26_0 +def test_featurestore_online_serving_service_transport_create_channel( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.FeaturestoreOnlineServingServiceGrpcTransport, grpc_helpers), + ( + transports.FeaturestoreOnlineServingServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_lt_1_26_0 +def test_featurestore_online_serving_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.FeaturestoreOnlineServingServiceGrpcTransport, grpc_helpers), + ( + transports.FeaturestoreOnlineServingServiceGrpcAsyncIOTransport, + grpc_helpers_async, + ), + ], +) +@requires_api_core_lt_1_26_0 +def test_featurestore_online_serving_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -1154,7 +1351,7 @@ def test_featurestore_online_serving_service_transport_auth_adc(): def test_featurestore_online_serving_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -1193,7 +1390,7 @@ def test_featurestore_online_serving_service_grpc_transport_client_cert_source_f def test_featurestore_online_serving_service_host_no_port(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -1203,7 +1400,7 @@ def test_featurestore_online_serving_service_host_no_port(): def test_featurestore_online_serving_service_host_with_port(): client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -1259,9 +1456,9 @@ def test_featurestore_online_serving_service_transport_channel_mtls_with_client_ mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -1342,7 +1539,6 @@ def test_entity_type_path(): location = "clam" featurestore = "whelk" entity_type = "octopus" - expected = "projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}".format( project=project, location=location, @@ -1371,7 +1567,6 @@ def test_parse_entity_type_path(): def test_common_billing_account_path(): billing_account = "winkle" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -1398,7 +1593,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) actual = FeaturestoreOnlineServingServiceClient.common_folder_path(folder) assert expected == actual @@ -1417,7 +1611,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) actual = FeaturestoreOnlineServingServiceClient.common_organization_path( organization @@ -1438,7 +1631,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) actual = FeaturestoreOnlineServingServiceClient.common_project_path(project) assert expected == actual @@ -1458,7 +1650,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "oyster" location = "nudibranch" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -1487,7 +1678,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.FeaturestoreOnlineServingServiceTransport, "_prep_wrapped_messages" ) as prep: client = FeaturestoreOnlineServingServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1496,6 +1687,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = FeaturestoreOnlineServingServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py index cffb5d0ade..5721f569ac 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_featurestore_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.featurestore_service import ( FeaturestoreServiceAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.aiplatform_v1beta1.services.featurestore_service import pagers from google.cloud.aiplatform_v1beta1.services.featurestore_service import transports +from google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import entity_type from google.cloud.aiplatform_v1beta1.types import entity_type as gca_entity_type from google.cloud.aiplatform_v1beta1.types import feature @@ -57,9 +62,33 @@ from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -111,7 +140,7 @@ def test__get_default_mtls_endpoint(): "client_class", [FeaturestoreServiceClient, FeaturestoreServiceAsyncClient,] ) def test_featurestore_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -128,7 +157,7 @@ def test_featurestore_service_client_from_service_account_info(client_class): "client_class", [FeaturestoreServiceClient, FeaturestoreServiceAsyncClient,] ) def test_featurestore_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -185,7 +214,7 @@ def test_featurestore_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(FeaturestoreServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -491,7 +520,7 @@ def test_create_featurestore( transport: str = "grpc", request_type=featurestore_service.CreateFeaturestoreRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -504,13 +533,11 @@ def test_create_featurestore( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateFeaturestoreRequest() # Establish that the response is the type that we expect. @@ -525,7 +552,7 @@ def test_create_featurestore_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -535,7 +562,6 @@ def test_create_featurestore_empty_call(): client.create_featurestore() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateFeaturestoreRequest() @@ -545,7 +571,7 @@ async def test_create_featurestore_async( request_type=featurestore_service.CreateFeaturestoreRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -560,13 +586,11 @@ async def test_create_featurestore_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateFeaturestoreRequest() # Establish that the response is the type that we expect. @@ -579,11 +603,14 @@ async def test_create_featurestore_async_from_dict(): def test_create_featurestore_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.CreateFeaturestoreRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -591,7 +618,6 @@ def test_create_featurestore_field_headers(): type(client.transport.create_featurestore), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -607,12 +633,13 @@ def test_create_featurestore_field_headers(): @pytest.mark.asyncio async def test_create_featurestore_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.CreateFeaturestoreRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -622,7 +649,6 @@ async def test_create_featurestore_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -636,7 +662,9 @@ async def test_create_featurestore_field_headers_async(): def test_create_featurestore_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -644,7 +672,6 @@ def test_create_featurestore_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_featurestore( @@ -656,14 +683,14 @@ def test_create_featurestore_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].featurestore == gca_featurestore.Featurestore(name="name_value") def test_create_featurestore_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -678,7 +705,7 @@ def test_create_featurestore_flattened_error(): @pytest.mark.asyncio async def test_create_featurestore_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -702,16 +729,14 @@ async def test_create_featurestore_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].featurestore == gca_featurestore.Featurestore(name="name_value") @pytest.mark.asyncio async def test_create_featurestore_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -728,7 +753,7 @@ def test_get_featurestore( transport: str = "grpc", request_type=featurestore_service.GetFeaturestoreRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -740,29 +765,20 @@ def test_get_featurestore( # Designate an appropriate return value for the call. call.return_value = featurestore.Featurestore( name="name_value", - display_name="display_name_value", etag="etag_value", state=featurestore.Featurestore.State.STABLE, ) - response = client.get_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetFeaturestoreRequest() # Establish that the response is the type that we expect. - assert isinstance(response, featurestore.Featurestore) - assert response.name == "name_value" - - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.state == featurestore.Featurestore.State.STABLE @@ -774,7 +790,7 @@ def test_get_featurestore_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -782,7 +798,6 @@ def test_get_featurestore_empty_call(): client.get_featurestore() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetFeaturestoreRequest() @@ -792,7 +807,7 @@ async def test_get_featurestore_async( request_type=featurestore_service.GetFeaturestoreRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -805,29 +820,21 @@ async def test_get_featurestore_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore.Featurestore( name="name_value", - display_name="display_name_value", etag="etag_value", state=featurestore.Featurestore.State.STABLE, ) ) - response = await client.get_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetFeaturestoreRequest() # Establish that the response is the type that we expect. assert isinstance(response, featurestore.Featurestore) - assert response.name == "name_value" - - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.state == featurestore.Featurestore.State.STABLE @@ -837,17 +844,19 @@ async def test_get_featurestore_async_from_dict(): def test_get_featurestore_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.GetFeaturestoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_featurestore), "__call__") as call: call.return_value = featurestore.Featurestore() - client.get_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -863,12 +872,13 @@ def test_get_featurestore_field_headers(): @pytest.mark.asyncio async def test_get_featurestore_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.GetFeaturestoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -876,7 +886,6 @@ async def test_get_featurestore_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore.Featurestore() ) - await client.get_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -890,13 +899,14 @@ async def test_get_featurestore_field_headers_async(): def test_get_featurestore_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_featurestore), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = featurestore.Featurestore() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_featurestore(name="name_value",) @@ -905,12 +915,13 @@ def test_get_featurestore_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_featurestore_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -923,7 +934,7 @@ def test_get_featurestore_flattened_error(): @pytest.mark.asyncio async def test_get_featurestore_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -942,14 +953,13 @@ async def test_get_featurestore_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_featurestore_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -964,7 +974,7 @@ def test_list_featurestores( transport: str = "grpc", request_type=featurestore_service.ListFeaturestoresRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -979,19 +989,15 @@ def test_list_featurestores( call.return_value = featurestore_service.ListFeaturestoresResponse( next_page_token="next_page_token_value", ) - response = client.list_featurestores(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListFeaturestoresRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFeaturestoresPager) - assert response.next_page_token == "next_page_token_value" @@ -1003,7 +1009,7 @@ def test_list_featurestores_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1013,7 +1019,6 @@ def test_list_featurestores_empty_call(): client.list_featurestores() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListFeaturestoresRequest() @@ -1023,7 +1028,7 @@ async def test_list_featurestores_async( request_type=featurestore_service.ListFeaturestoresRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1040,18 +1045,15 @@ async def test_list_featurestores_async( next_page_token="next_page_token_value", ) ) - response = await client.list_featurestores(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListFeaturestoresRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturestoresAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1061,11 +1063,14 @@ async def test_list_featurestores_async_from_dict(): def test_list_featurestores_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ListFeaturestoresRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1073,7 +1078,6 @@ def test_list_featurestores_field_headers(): type(client.transport.list_featurestores), "__call__" ) as call: call.return_value = featurestore_service.ListFeaturestoresResponse() - client.list_featurestores(request) # Establish that the underlying gRPC stub method was called. @@ -1089,12 +1093,13 @@ def test_list_featurestores_field_headers(): @pytest.mark.asyncio async def test_list_featurestores_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ListFeaturestoresRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1104,7 +1109,6 @@ async def test_list_featurestores_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore_service.ListFeaturestoresResponse() ) - await client.list_featurestores(request) # Establish that the underlying gRPC stub method was called. @@ -1118,7 +1122,9 @@ async def test_list_featurestores_field_headers_async(): def test_list_featurestores_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1126,7 +1132,6 @@ def test_list_featurestores_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = featurestore_service.ListFeaturestoresResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_featurestores(parent="parent_value",) @@ -1135,12 +1140,13 @@ def test_list_featurestores_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_featurestores_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1153,7 +1159,7 @@ def test_list_featurestores_flattened_error(): @pytest.mark.asyncio async def test_list_featurestores_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1174,14 +1180,13 @@ async def test_list_featurestores_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_featurestores_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1193,7 +1198,7 @@ async def test_list_featurestores_flattened_error_async(): def test_list_featurestores_pager(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1238,7 +1243,7 @@ def test_list_featurestores_pager(): def test_list_featurestores_pages(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1276,7 +1281,7 @@ def test_list_featurestores_pages(): @pytest.mark.asyncio async def test_list_featurestores_async_pager(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1322,7 +1327,7 @@ async def test_list_featurestores_async_pager(): @pytest.mark.asyncio async def test_list_featurestores_async_pages(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1366,7 +1371,7 @@ def test_update_featurestore( transport: str = "grpc", request_type=featurestore_service.UpdateFeaturestoreRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1379,13 +1384,11 @@ def test_update_featurestore( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateFeaturestoreRequest() # Establish that the response is the type that we expect. @@ -1400,7 +1403,7 @@ def test_update_featurestore_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1410,7 +1413,6 @@ def test_update_featurestore_empty_call(): client.update_featurestore() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateFeaturestoreRequest() @@ -1420,7 +1422,7 @@ async def test_update_featurestore_async( request_type=featurestore_service.UpdateFeaturestoreRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1435,13 +1437,11 @@ async def test_update_featurestore_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateFeaturestoreRequest() # Establish that the response is the type that we expect. @@ -1454,11 +1454,14 @@ async def test_update_featurestore_async_from_dict(): def test_update_featurestore_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.UpdateFeaturestoreRequest() + request.featurestore.name = "featurestore.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1466,7 +1469,6 @@ def test_update_featurestore_field_headers(): type(client.transport.update_featurestore), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -1485,12 +1487,13 @@ def test_update_featurestore_field_headers(): @pytest.mark.asyncio async def test_update_featurestore_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.UpdateFeaturestoreRequest() + request.featurestore.name = "featurestore.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1500,7 +1503,6 @@ async def test_update_featurestore_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -1517,7 +1519,9 @@ async def test_update_featurestore_field_headers_async(): def test_update_featurestore_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1525,26 +1529,25 @@ def test_update_featurestore_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_featurestore( featurestore=gca_featurestore.Featurestore(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].featurestore == gca_featurestore.Featurestore(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_featurestore_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1552,14 +1555,14 @@ def test_update_featurestore_flattened_error(): client.update_featurestore( featurestore_service.UpdateFeaturestoreRequest(), featurestore=gca_featurestore.Featurestore(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_featurestore_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1576,23 +1579,21 @@ async def test_update_featurestore_flattened_async(): # using the keyword arguments to the method. response = await client.update_featurestore( featurestore=gca_featurestore.Featurestore(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].featurestore == gca_featurestore.Featurestore(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_featurestore_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1601,7 +1602,7 @@ async def test_update_featurestore_flattened_error_async(): await client.update_featurestore( featurestore_service.UpdateFeaturestoreRequest(), featurestore=gca_featurestore.Featurestore(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1609,7 +1610,7 @@ def test_delete_featurestore( transport: str = "grpc", request_type=featurestore_service.DeleteFeaturestoreRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1622,13 +1623,11 @@ def test_delete_featurestore( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteFeaturestoreRequest() # Establish that the response is the type that we expect. @@ -1643,7 +1642,7 @@ def test_delete_featurestore_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1653,7 +1652,6 @@ def test_delete_featurestore_empty_call(): client.delete_featurestore() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteFeaturestoreRequest() @@ -1663,7 +1661,7 @@ async def test_delete_featurestore_async( request_type=featurestore_service.DeleteFeaturestoreRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1678,13 +1676,11 @@ async def test_delete_featurestore_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_featurestore(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteFeaturestoreRequest() # Establish that the response is the type that we expect. @@ -1697,11 +1693,14 @@ async def test_delete_featurestore_async_from_dict(): def test_delete_featurestore_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.DeleteFeaturestoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1709,7 +1708,6 @@ def test_delete_featurestore_field_headers(): type(client.transport.delete_featurestore), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -1725,12 +1723,13 @@ def test_delete_featurestore_field_headers(): @pytest.mark.asyncio async def test_delete_featurestore_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.DeleteFeaturestoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1740,7 +1739,6 @@ async def test_delete_featurestore_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_featurestore(request) # Establish that the underlying gRPC stub method was called. @@ -1754,7 +1752,9 @@ async def test_delete_featurestore_field_headers_async(): def test_delete_featurestore_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1762,7 +1762,6 @@ def test_delete_featurestore_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_featurestore(name="name_value",) @@ -1771,12 +1770,13 @@ def test_delete_featurestore_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_featurestore_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1789,7 +1789,7 @@ def test_delete_featurestore_flattened_error(): @pytest.mark.asyncio async def test_delete_featurestore_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1810,14 +1810,13 @@ async def test_delete_featurestore_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_featurestore_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1832,7 +1831,7 @@ def test_create_entity_type( transport: str = "grpc", request_type=featurestore_service.CreateEntityTypeRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1845,13 +1844,11 @@ def test_create_entity_type( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateEntityTypeRequest() # Establish that the response is the type that we expect. @@ -1866,7 +1863,7 @@ def test_create_entity_type_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1876,7 +1873,6 @@ def test_create_entity_type_empty_call(): client.create_entity_type() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateEntityTypeRequest() @@ -1886,7 +1882,7 @@ async def test_create_entity_type_async( request_type=featurestore_service.CreateEntityTypeRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1901,13 +1897,11 @@ async def test_create_entity_type_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateEntityTypeRequest() # Establish that the response is the type that we expect. @@ -1920,11 +1914,14 @@ async def test_create_entity_type_async_from_dict(): def test_create_entity_type_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.CreateEntityTypeRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1932,7 +1929,6 @@ def test_create_entity_type_field_headers(): type(client.transport.create_entity_type), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -1948,12 +1944,13 @@ def test_create_entity_type_field_headers(): @pytest.mark.asyncio async def test_create_entity_type_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.CreateEntityTypeRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1963,7 +1960,6 @@ async def test_create_entity_type_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -1977,7 +1973,9 @@ async def test_create_entity_type_field_headers_async(): def test_create_entity_type_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1985,7 +1983,6 @@ def test_create_entity_type_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_entity_type( @@ -1997,14 +1994,14 @@ def test_create_entity_type_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].entity_type == gca_entity_type.EntityType(name="name_value") def test_create_entity_type_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2019,7 +2016,7 @@ def test_create_entity_type_flattened_error(): @pytest.mark.asyncio async def test_create_entity_type_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2043,16 +2040,14 @@ async def test_create_entity_type_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].entity_type == gca_entity_type.EntityType(name="name_value") @pytest.mark.asyncio async def test_create_entity_type_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2069,7 +2064,7 @@ def test_get_entity_type( transport: str = "grpc", request_type=featurestore_service.GetEntityTypeRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2082,23 +2077,17 @@ def test_get_entity_type( call.return_value = entity_type.EntityType( name="name_value", description="description_value", etag="etag_value", ) - response = client.get_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetEntityTypeRequest() # Establish that the response is the type that we expect. - assert isinstance(response, entity_type.EntityType) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -2110,7 +2099,7 @@ def test_get_entity_type_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2118,7 +2107,6 @@ def test_get_entity_type_empty_call(): client.get_entity_type() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetEntityTypeRequest() @@ -2128,7 +2116,7 @@ async def test_get_entity_type_async( request_type=featurestore_service.GetEntityTypeRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2143,22 +2131,17 @@ async def test_get_entity_type_async( name="name_value", description="description_value", etag="etag_value", ) ) - response = await client.get_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetEntityTypeRequest() # Establish that the response is the type that we expect. assert isinstance(response, entity_type.EntityType) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -2168,17 +2151,19 @@ async def test_get_entity_type_async_from_dict(): def test_get_entity_type_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.GetEntityTypeRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_entity_type), "__call__") as call: call.return_value = entity_type.EntityType() - client.get_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -2194,12 +2179,13 @@ def test_get_entity_type_field_headers(): @pytest.mark.asyncio async def test_get_entity_type_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.GetEntityTypeRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2207,7 +2193,6 @@ async def test_get_entity_type_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( entity_type.EntityType() ) - await client.get_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -2221,13 +2206,14 @@ async def test_get_entity_type_field_headers_async(): def test_get_entity_type_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_entity_type), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = entity_type.EntityType() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_entity_type(name="name_value",) @@ -2236,12 +2222,13 @@ def test_get_entity_type_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_entity_type_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2254,7 +2241,7 @@ def test_get_entity_type_flattened_error(): @pytest.mark.asyncio async def test_get_entity_type_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2273,14 +2260,13 @@ async def test_get_entity_type_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_entity_type_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2295,7 +2281,7 @@ def test_list_entity_types( transport: str = "grpc", request_type=featurestore_service.ListEntityTypesRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2310,19 +2296,15 @@ def test_list_entity_types( call.return_value = featurestore_service.ListEntityTypesResponse( next_page_token="next_page_token_value", ) - response = client.list_entity_types(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListEntityTypesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEntityTypesPager) - assert response.next_page_token == "next_page_token_value" @@ -2334,7 +2316,7 @@ def test_list_entity_types_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2344,7 +2326,6 @@ def test_list_entity_types_empty_call(): client.list_entity_types() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListEntityTypesRequest() @@ -2354,7 +2335,7 @@ async def test_list_entity_types_async( request_type=featurestore_service.ListEntityTypesRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2371,18 +2352,15 @@ async def test_list_entity_types_async( next_page_token="next_page_token_value", ) ) - response = await client.list_entity_types(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListEntityTypesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListEntityTypesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2392,11 +2370,14 @@ async def test_list_entity_types_async_from_dict(): def test_list_entity_types_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ListEntityTypesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2404,7 +2385,6 @@ def test_list_entity_types_field_headers(): type(client.transport.list_entity_types), "__call__" ) as call: call.return_value = featurestore_service.ListEntityTypesResponse() - client.list_entity_types(request) # Establish that the underlying gRPC stub method was called. @@ -2420,12 +2400,13 @@ def test_list_entity_types_field_headers(): @pytest.mark.asyncio async def test_list_entity_types_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ListEntityTypesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2435,7 +2416,6 @@ async def test_list_entity_types_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore_service.ListEntityTypesResponse() ) - await client.list_entity_types(request) # Establish that the underlying gRPC stub method was called. @@ -2449,7 +2429,9 @@ async def test_list_entity_types_field_headers_async(): def test_list_entity_types_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2457,7 +2439,6 @@ def test_list_entity_types_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = featurestore_service.ListEntityTypesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_entity_types(parent="parent_value",) @@ -2466,12 +2447,13 @@ def test_list_entity_types_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_entity_types_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2484,7 +2466,7 @@ def test_list_entity_types_flattened_error(): @pytest.mark.asyncio async def test_list_entity_types_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2505,14 +2487,13 @@ async def test_list_entity_types_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_entity_types_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2524,7 +2505,7 @@ async def test_list_entity_types_flattened_error_async(): def test_list_entity_types_pager(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2566,7 +2547,7 @@ def test_list_entity_types_pager(): def test_list_entity_types_pages(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2601,7 +2582,7 @@ def test_list_entity_types_pages(): @pytest.mark.asyncio async def test_list_entity_types_async_pager(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2644,7 +2625,7 @@ async def test_list_entity_types_async_pager(): @pytest.mark.asyncio async def test_list_entity_types_async_pages(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2685,7 +2666,7 @@ def test_update_entity_type( transport: str = "grpc", request_type=featurestore_service.UpdateEntityTypeRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2700,23 +2681,17 @@ def test_update_entity_type( call.return_value = gca_entity_type.EntityType( name="name_value", description="description_value", etag="etag_value", ) - response = client.update_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateEntityTypeRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_entity_type.EntityType) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -2728,7 +2703,7 @@ def test_update_entity_type_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2738,7 +2713,6 @@ def test_update_entity_type_empty_call(): client.update_entity_type() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateEntityTypeRequest() @@ -2748,7 +2722,7 @@ async def test_update_entity_type_async( request_type=featurestore_service.UpdateEntityTypeRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2765,22 +2739,17 @@ async def test_update_entity_type_async( name="name_value", description="description_value", etag="etag_value", ) ) - response = await client.update_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateEntityTypeRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_entity_type.EntityType) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -2790,11 +2759,14 @@ async def test_update_entity_type_async_from_dict(): def test_update_entity_type_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.UpdateEntityTypeRequest() + request.entity_type.name = "entity_type.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2802,7 +2774,6 @@ def test_update_entity_type_field_headers(): type(client.transport.update_entity_type), "__call__" ) as call: call.return_value = gca_entity_type.EntityType() - client.update_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -2820,12 +2791,13 @@ def test_update_entity_type_field_headers(): @pytest.mark.asyncio async def test_update_entity_type_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.UpdateEntityTypeRequest() + request.entity_type.name = "entity_type.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2835,7 +2807,6 @@ async def test_update_entity_type_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_entity_type.EntityType() ) - await client.update_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -2851,7 +2822,9 @@ async def test_update_entity_type_field_headers_async(): def test_update_entity_type_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2859,26 +2832,25 @@ def test_update_entity_type_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_entity_type.EntityType() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_entity_type( entity_type=gca_entity_type.EntityType(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].entity_type == gca_entity_type.EntityType(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_entity_type_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2886,14 +2858,14 @@ def test_update_entity_type_flattened_error(): client.update_entity_type( featurestore_service.UpdateEntityTypeRequest(), entity_type=gca_entity_type.EntityType(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_entity_type_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2910,23 +2882,21 @@ async def test_update_entity_type_flattened_async(): # using the keyword arguments to the method. response = await client.update_entity_type( entity_type=gca_entity_type.EntityType(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].entity_type == gca_entity_type.EntityType(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_entity_type_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2935,7 +2905,7 @@ async def test_update_entity_type_flattened_error_async(): await client.update_entity_type( featurestore_service.UpdateEntityTypeRequest(), entity_type=gca_entity_type.EntityType(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2943,7 +2913,7 @@ def test_delete_entity_type( transport: str = "grpc", request_type=featurestore_service.DeleteEntityTypeRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2956,13 +2926,11 @@ def test_delete_entity_type( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteEntityTypeRequest() # Establish that the response is the type that we expect. @@ -2977,7 +2945,7 @@ def test_delete_entity_type_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2987,7 +2955,6 @@ def test_delete_entity_type_empty_call(): client.delete_entity_type() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteEntityTypeRequest() @@ -2997,7 +2964,7 @@ async def test_delete_entity_type_async( request_type=featurestore_service.DeleteEntityTypeRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3012,13 +2979,11 @@ async def test_delete_entity_type_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_entity_type(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteEntityTypeRequest() # Establish that the response is the type that we expect. @@ -3031,11 +2996,14 @@ async def test_delete_entity_type_async_from_dict(): def test_delete_entity_type_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.DeleteEntityTypeRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3043,7 +3011,6 @@ def test_delete_entity_type_field_headers(): type(client.transport.delete_entity_type), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -3059,12 +3026,13 @@ def test_delete_entity_type_field_headers(): @pytest.mark.asyncio async def test_delete_entity_type_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.DeleteEntityTypeRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3074,7 +3042,6 @@ async def test_delete_entity_type_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_entity_type(request) # Establish that the underlying gRPC stub method was called. @@ -3088,7 +3055,9 @@ async def test_delete_entity_type_field_headers_async(): def test_delete_entity_type_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3096,7 +3065,6 @@ def test_delete_entity_type_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_entity_type(name="name_value",) @@ -3105,12 +3073,13 @@ def test_delete_entity_type_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_entity_type_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3123,7 +3092,7 @@ def test_delete_entity_type_flattened_error(): @pytest.mark.asyncio async def test_delete_entity_type_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3144,14 +3113,13 @@ async def test_delete_entity_type_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_entity_type_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3166,7 +3134,7 @@ def test_create_feature( transport: str = "grpc", request_type=featurestore_service.CreateFeatureRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3177,13 +3145,11 @@ def test_create_feature( with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateFeatureRequest() # Establish that the response is the type that we expect. @@ -3198,7 +3164,7 @@ def test_create_feature_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3206,7 +3172,6 @@ def test_create_feature_empty_call(): client.create_feature() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateFeatureRequest() @@ -3216,7 +3181,7 @@ async def test_create_feature_async( request_type=featurestore_service.CreateFeatureRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3229,13 +3194,11 @@ async def test_create_feature_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.CreateFeatureRequest() # Establish that the response is the type that we expect. @@ -3248,17 +3211,19 @@ async def test_create_feature_async_from_dict(): def test_create_feature_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.CreateFeatureRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_feature), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -3274,12 +3239,13 @@ def test_create_feature_field_headers(): @pytest.mark.asyncio async def test_create_feature_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.CreateFeatureRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3287,7 +3253,6 @@ async def test_create_feature_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_feature(request) # Establish that the underlying gRPC stub method was called. @@ -3301,13 +3266,14 @@ async def test_create_feature_field_headers_async(): def test_create_feature_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_feature( @@ -3318,14 +3284,14 @@ def test_create_feature_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].feature == gca_feature.Feature(name="name_value") def test_create_feature_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3340,7 +3306,7 @@ def test_create_feature_flattened_error(): @pytest.mark.asyncio async def test_create_feature_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3361,16 +3327,14 @@ async def test_create_feature_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].feature == gca_feature.Feature(name="name_value") @pytest.mark.asyncio async def test_create_feature_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3388,7 +3352,7 @@ def test_batch_create_features( request_type=featurestore_service.BatchCreateFeaturesRequest, ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3401,13 +3365,11 @@ def test_batch_create_features( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.batch_create_features(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.BatchCreateFeaturesRequest() # Establish that the response is the type that we expect. @@ -3422,7 +3384,7 @@ def test_batch_create_features_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3432,7 +3394,6 @@ def test_batch_create_features_empty_call(): client.batch_create_features() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.BatchCreateFeaturesRequest() @@ -3442,7 +3403,7 @@ async def test_batch_create_features_async( request_type=featurestore_service.BatchCreateFeaturesRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3457,13 +3418,11 @@ async def test_batch_create_features_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.batch_create_features(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.BatchCreateFeaturesRequest() # Establish that the response is the type that we expect. @@ -3476,11 +3435,14 @@ async def test_batch_create_features_async_from_dict(): def test_batch_create_features_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.BatchCreateFeaturesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3488,7 +3450,6 @@ def test_batch_create_features_field_headers(): type(client.transport.batch_create_features), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.batch_create_features(request) # Establish that the underlying gRPC stub method was called. @@ -3504,12 +3465,13 @@ def test_batch_create_features_field_headers(): @pytest.mark.asyncio async def test_batch_create_features_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.BatchCreateFeaturesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3519,7 +3481,6 @@ async def test_batch_create_features_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.batch_create_features(request) # Establish that the underlying gRPC stub method was called. @@ -3533,7 +3494,9 @@ async def test_batch_create_features_field_headers_async(): def test_batch_create_features_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3541,7 +3504,6 @@ def test_batch_create_features_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.batch_create_features( @@ -3553,16 +3515,16 @@ def test_batch_create_features_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].requests == [ featurestore_service.CreateFeatureRequest(parent="parent_value") ] def test_batch_create_features_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3577,7 +3539,7 @@ def test_batch_create_features_flattened_error(): @pytest.mark.asyncio async def test_batch_create_features_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3601,9 +3563,7 @@ async def test_batch_create_features_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].requests == [ featurestore_service.CreateFeatureRequest(parent="parent_value") ] @@ -3612,7 +3572,7 @@ async def test_batch_create_features_flattened_async(): @pytest.mark.asyncio async def test_batch_create_features_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3629,7 +3589,7 @@ def test_get_feature( transport: str = "grpc", request_type=featurestore_service.GetFeatureRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3645,25 +3605,18 @@ def test_get_feature( value_type=feature.Feature.ValueType.BOOL, etag="etag_value", ) - response = client.get_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetFeatureRequest() # Establish that the response is the type that we expect. - assert isinstance(response, feature.Feature) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.value_type == feature.Feature.ValueType.BOOL - assert response.etag == "etag_value" @@ -3675,7 +3628,7 @@ def test_get_feature_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3683,7 +3636,6 @@ def test_get_feature_empty_call(): client.get_feature() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetFeatureRequest() @@ -3692,7 +3644,7 @@ async def test_get_feature_async( transport: str = "grpc_asyncio", request_type=featurestore_service.GetFeatureRequest ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3710,24 +3662,18 @@ async def test_get_feature_async( etag="etag_value", ) ) - response = await client.get_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.GetFeatureRequest() # Establish that the response is the type that we expect. assert isinstance(response, feature.Feature) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.value_type == feature.Feature.ValueType.BOOL - assert response.etag == "etag_value" @@ -3737,17 +3683,19 @@ async def test_get_feature_async_from_dict(): def test_get_feature_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.GetFeatureRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = feature.Feature() - client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -3763,18 +3711,18 @@ def test_get_feature_field_headers(): @pytest.mark.asyncio async def test_get_feature_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.GetFeatureRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_feature), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(feature.Feature()) - await client.get_feature(request) # Establish that the underlying gRPC stub method was called. @@ -3788,13 +3736,14 @@ async def test_get_feature_field_headers_async(): def test_get_feature_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = feature.Feature() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_feature(name="name_value",) @@ -3803,12 +3752,13 @@ def test_get_feature_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_feature_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3821,7 +3771,7 @@ def test_get_feature_flattened_error(): @pytest.mark.asyncio async def test_get_feature_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3838,14 +3788,13 @@ async def test_get_feature_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_feature_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3860,7 +3809,7 @@ def test_list_features( transport: str = "grpc", request_type=featurestore_service.ListFeaturesRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3873,19 +3822,15 @@ def test_list_features( call.return_value = featurestore_service.ListFeaturesResponse( next_page_token="next_page_token_value", ) - response = client.list_features(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListFeaturesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListFeaturesPager) - assert response.next_page_token == "next_page_token_value" @@ -3897,7 +3842,7 @@ def test_list_features_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3905,7 +3850,6 @@ def test_list_features_empty_call(): client.list_features() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListFeaturesRequest() @@ -3915,7 +3859,7 @@ async def test_list_features_async( request_type=featurestore_service.ListFeaturesRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3930,18 +3874,15 @@ async def test_list_features_async( next_page_token="next_page_token_value", ) ) - response = await client.list_features(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ListFeaturesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListFeaturesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3951,17 +3892,19 @@ async def test_list_features_async_from_dict(): def test_list_features_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ListFeaturesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_features), "__call__") as call: call.return_value = featurestore_service.ListFeaturesResponse() - client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -3977,12 +3920,13 @@ def test_list_features_field_headers(): @pytest.mark.asyncio async def test_list_features_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ListFeaturesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3990,7 +3934,6 @@ async def test_list_features_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore_service.ListFeaturesResponse() ) - await client.list_features(request) # Establish that the underlying gRPC stub method was called. @@ -4004,13 +3947,14 @@ async def test_list_features_field_headers_async(): def test_list_features_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = featurestore_service.ListFeaturesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_features(parent="parent_value",) @@ -4019,12 +3963,13 @@ def test_list_features_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_features_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4037,7 +3982,7 @@ def test_list_features_flattened_error(): @pytest.mark.asyncio async def test_list_features_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4056,14 +4001,13 @@ async def test_list_features_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_features_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4075,7 +4019,7 @@ async def test_list_features_flattened_error_async(): def test_list_features_pager(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_features), "__call__") as call: @@ -4111,7 +4055,7 @@ def test_list_features_pager(): def test_list_features_pages(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_features), "__call__") as call: @@ -4140,7 +4084,7 @@ def test_list_features_pages(): @pytest.mark.asyncio async def test_list_features_async_pager(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4177,7 +4121,7 @@ async def test_list_features_async_pager(): @pytest.mark.asyncio async def test_list_features_async_pages(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4212,7 +4156,7 @@ def test_update_feature( transport: str = "grpc", request_type=featurestore_service.UpdateFeatureRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4228,25 +4172,18 @@ def test_update_feature( value_type=gca_feature.Feature.ValueType.BOOL, etag="etag_value", ) - response = client.update_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateFeatureRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_feature.Feature) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.value_type == gca_feature.Feature.ValueType.BOOL - assert response.etag == "etag_value" @@ -4258,7 +4195,7 @@ def test_update_feature_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4266,7 +4203,6 @@ def test_update_feature_empty_call(): client.update_feature() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateFeatureRequest() @@ -4276,7 +4212,7 @@ async def test_update_feature_async( request_type=featurestore_service.UpdateFeatureRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4294,24 +4230,18 @@ async def test_update_feature_async( etag="etag_value", ) ) - response = await client.update_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.UpdateFeatureRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_feature.Feature) - assert response.name == "name_value" - assert response.description == "description_value" - assert response.value_type == gca_feature.Feature.ValueType.BOOL - assert response.etag == "etag_value" @@ -4321,17 +4251,19 @@ async def test_update_feature_async_from_dict(): def test_update_feature_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.UpdateFeatureRequest() + request.feature.name = "feature.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feature), "__call__") as call: call.return_value = gca_feature.Feature() - client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -4349,18 +4281,18 @@ def test_update_feature_field_headers(): @pytest.mark.asyncio async def test_update_feature_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.UpdateFeatureRequest() + request.feature.name = "feature.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feature), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_feature.Feature()) - await client.update_feature(request) # Establish that the underlying gRPC stub method was called. @@ -4376,32 +4308,33 @@ async def test_update_feature_field_headers_async(): def test_update_feature_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_feature.Feature() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_feature( feature=gca_feature.Feature(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].feature == gca_feature.Feature(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_feature_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4409,14 +4342,14 @@ def test_update_feature_flattened_error(): client.update_feature( featurestore_service.UpdateFeatureRequest(), feature=gca_feature.Feature(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_feature_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4429,23 +4362,21 @@ async def test_update_feature_flattened_async(): # using the keyword arguments to the method. response = await client.update_feature( feature=gca_feature.Feature(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].feature == gca_feature.Feature(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_feature_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4454,7 +4385,7 @@ async def test_update_feature_flattened_error_async(): await client.update_feature( featurestore_service.UpdateFeatureRequest(), feature=gca_feature.Feature(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -4462,7 +4393,7 @@ def test_delete_feature( transport: str = "grpc", request_type=featurestore_service.DeleteFeatureRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4473,13 +4404,11 @@ def test_delete_feature( with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteFeatureRequest() # Establish that the response is the type that we expect. @@ -4494,7 +4423,7 @@ def test_delete_feature_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4502,7 +4431,6 @@ def test_delete_feature_empty_call(): client.delete_feature() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteFeatureRequest() @@ -4512,7 +4440,7 @@ async def test_delete_feature_async( request_type=featurestore_service.DeleteFeatureRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4525,13 +4453,11 @@ async def test_delete_feature_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_feature(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.DeleteFeatureRequest() # Establish that the response is the type that we expect. @@ -4544,17 +4470,19 @@ async def test_delete_feature_async_from_dict(): def test_delete_feature_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.DeleteFeatureRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -4570,12 +4498,13 @@ def test_delete_feature_field_headers(): @pytest.mark.asyncio async def test_delete_feature_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.DeleteFeatureRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4583,7 +4512,6 @@ async def test_delete_feature_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_feature(request) # Establish that the underlying gRPC stub method was called. @@ -4597,13 +4525,14 @@ async def test_delete_feature_field_headers_async(): def test_delete_feature_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_feature), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_feature(name="name_value",) @@ -4612,12 +4541,13 @@ def test_delete_feature_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_feature_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4630,7 +4560,7 @@ def test_delete_feature_flattened_error(): @pytest.mark.asyncio async def test_delete_feature_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4649,14 +4579,13 @@ async def test_delete_feature_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_feature_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4672,7 +4601,7 @@ def test_import_feature_values( request_type=featurestore_service.ImportFeatureValuesRequest, ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4685,13 +4614,11 @@ def test_import_feature_values( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.import_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ImportFeatureValuesRequest() # Establish that the response is the type that we expect. @@ -4706,7 +4633,7 @@ def test_import_feature_values_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4716,7 +4643,6 @@ def test_import_feature_values_empty_call(): client.import_feature_values() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ImportFeatureValuesRequest() @@ -4726,7 +4652,7 @@ async def test_import_feature_values_async( request_type=featurestore_service.ImportFeatureValuesRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4741,13 +4667,11 @@ async def test_import_feature_values_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.import_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ImportFeatureValuesRequest() # Establish that the response is the type that we expect. @@ -4760,11 +4684,14 @@ async def test_import_feature_values_async_from_dict(): def test_import_feature_values_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ImportFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4772,7 +4699,6 @@ def test_import_feature_values_field_headers(): type(client.transport.import_feature_values), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.import_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -4788,12 +4714,13 @@ def test_import_feature_values_field_headers(): @pytest.mark.asyncio async def test_import_feature_values_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ImportFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4803,7 +4730,6 @@ async def test_import_feature_values_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.import_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -4817,7 +4743,9 @@ async def test_import_feature_values_field_headers_async(): def test_import_feature_values_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4825,7 +4753,6 @@ def test_import_feature_values_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.import_feature_values(entity_type="entity_type_value",) @@ -4834,12 +4761,13 @@ def test_import_feature_values_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" def test_import_feature_values_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4853,7 +4781,7 @@ def test_import_feature_values_flattened_error(): @pytest.mark.asyncio async def test_import_feature_values_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4874,14 +4802,13 @@ async def test_import_feature_values_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" @pytest.mark.asyncio async def test_import_feature_values_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4898,7 +4825,7 @@ def test_batch_read_feature_values( request_type=featurestore_service.BatchReadFeatureValuesRequest, ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4911,13 +4838,11 @@ def test_batch_read_feature_values( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.batch_read_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.BatchReadFeatureValuesRequest() # Establish that the response is the type that we expect. @@ -4932,7 +4857,7 @@ def test_batch_read_feature_values_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4942,7 +4867,6 @@ def test_batch_read_feature_values_empty_call(): client.batch_read_feature_values() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.BatchReadFeatureValuesRequest() @@ -4952,7 +4876,7 @@ async def test_batch_read_feature_values_async( request_type=featurestore_service.BatchReadFeatureValuesRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4967,13 +4891,11 @@ async def test_batch_read_feature_values_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.batch_read_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.BatchReadFeatureValuesRequest() # Establish that the response is the type that we expect. @@ -4986,11 +4908,14 @@ async def test_batch_read_feature_values_async_from_dict(): def test_batch_read_feature_values_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.BatchReadFeatureValuesRequest() + request.featurestore = "featurestore/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4998,7 +4923,6 @@ def test_batch_read_feature_values_field_headers(): type(client.transport.batch_read_feature_values), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.batch_read_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -5016,12 +4940,13 @@ def test_batch_read_feature_values_field_headers(): @pytest.mark.asyncio async def test_batch_read_feature_values_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.BatchReadFeatureValuesRequest() + request.featurestore = "featurestore/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5031,7 +4956,6 @@ async def test_batch_read_feature_values_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.batch_read_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -5047,7 +4971,9 @@ async def test_batch_read_feature_values_field_headers_async(): def test_batch_read_feature_values_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5055,7 +4981,6 @@ def test_batch_read_feature_values_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.batch_read_feature_values(featurestore="featurestore_value",) @@ -5064,12 +4989,13 @@ def test_batch_read_feature_values_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].featurestore == "featurestore_value" def test_batch_read_feature_values_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5083,7 +5009,7 @@ def test_batch_read_feature_values_flattened_error(): @pytest.mark.asyncio async def test_batch_read_feature_values_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5106,14 +5032,13 @@ async def test_batch_read_feature_values_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].featurestore == "featurestore_value" @pytest.mark.asyncio async def test_batch_read_feature_values_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5130,7 +5055,7 @@ def test_export_feature_values( request_type=featurestore_service.ExportFeatureValuesRequest, ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5143,13 +5068,11 @@ def test_export_feature_values( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.export_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ExportFeatureValuesRequest() # Establish that the response is the type that we expect. @@ -5164,7 +5087,7 @@ def test_export_feature_values_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5174,7 +5097,6 @@ def test_export_feature_values_empty_call(): client.export_feature_values() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ExportFeatureValuesRequest() @@ -5184,7 +5106,7 @@ async def test_export_feature_values_async( request_type=featurestore_service.ExportFeatureValuesRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5199,13 +5121,11 @@ async def test_export_feature_values_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.export_feature_values(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.ExportFeatureValuesRequest() # Establish that the response is the type that we expect. @@ -5218,11 +5138,14 @@ async def test_export_feature_values_async_from_dict(): def test_export_feature_values_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ExportFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5230,7 +5153,6 @@ def test_export_feature_values_field_headers(): type(client.transport.export_feature_values), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.export_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -5246,12 +5168,13 @@ def test_export_feature_values_field_headers(): @pytest.mark.asyncio async def test_export_feature_values_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.ExportFeatureValuesRequest() + request.entity_type = "entity_type/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5261,7 +5184,6 @@ async def test_export_feature_values_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.export_feature_values(request) # Establish that the underlying gRPC stub method was called. @@ -5275,7 +5197,9 @@ async def test_export_feature_values_field_headers_async(): def test_export_feature_values_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5283,7 +5207,6 @@ def test_export_feature_values_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.export_feature_values(entity_type="entity_type_value",) @@ -5292,12 +5215,13 @@ def test_export_feature_values_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" def test_export_feature_values_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5311,7 +5235,7 @@ def test_export_feature_values_flattened_error(): @pytest.mark.asyncio async def test_export_feature_values_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5332,14 +5256,13 @@ async def test_export_feature_values_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].entity_type == "entity_type_value" @pytest.mark.asyncio async def test_export_feature_values_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5355,7 +5278,7 @@ def test_search_features( transport: str = "grpc", request_type=featurestore_service.SearchFeaturesRequest ): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5368,19 +5291,15 @@ def test_search_features( call.return_value = featurestore_service.SearchFeaturesResponse( next_page_token="next_page_token_value", ) - response = client.search_features(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.SearchFeaturesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchFeaturesPager) - assert response.next_page_token == "next_page_token_value" @@ -5392,7 +5311,7 @@ def test_search_features_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5400,7 +5319,6 @@ def test_search_features_empty_call(): client.search_features() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.SearchFeaturesRequest() @@ -5410,7 +5328,7 @@ async def test_search_features_async( request_type=featurestore_service.SearchFeaturesRequest, ): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5425,18 +5343,15 @@ async def test_search_features_async( next_page_token="next_page_token_value", ) ) - response = await client.search_features(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == featurestore_service.SearchFeaturesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchFeaturesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -5446,17 +5361,19 @@ async def test_search_features_async_from_dict(): def test_search_features_field_headers(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.SearchFeaturesRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_features), "__call__") as call: call.return_value = featurestore_service.SearchFeaturesResponse() - client.search_features(request) # Establish that the underlying gRPC stub method was called. @@ -5472,12 +5389,13 @@ def test_search_features_field_headers(): @pytest.mark.asyncio async def test_search_features_field_headers_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = featurestore_service.SearchFeaturesRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5485,7 +5403,6 @@ async def test_search_features_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( featurestore_service.SearchFeaturesResponse() ) - await client.search_features(request) # Establish that the underlying gRPC stub method was called. @@ -5499,13 +5416,14 @@ async def test_search_features_field_headers_async(): def test_search_features_flattened(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_features), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = featurestore_service.SearchFeaturesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_features(location="location_value",) @@ -5514,12 +5432,13 @@ def test_search_features_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" def test_search_features_flattened_error(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5532,7 +5451,7 @@ def test_search_features_flattened_error(): @pytest.mark.asyncio async def test_search_features_flattened_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5551,14 +5470,13 @@ async def test_search_features_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" @pytest.mark.asyncio async def test_search_features_flattened_error_async(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5570,7 +5488,7 @@ async def test_search_features_flattened_error_async(): def test_search_features_pager(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_features), "__call__") as call: @@ -5606,7 +5524,7 @@ def test_search_features_pager(): def test_search_features_pages(): - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials,) + client = FeaturestoreServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_features), "__call__") as call: @@ -5635,7 +5553,7 @@ def test_search_features_pages(): @pytest.mark.asyncio async def test_search_features_async_pager(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5672,7 +5590,7 @@ async def test_search_features_async_pager(): @pytest.mark.asyncio async def test_search_features_async_pages(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5706,16 +5624,16 @@ async def test_search_features_async_pages(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.FeaturestoreServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.FeaturestoreServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = FeaturestoreServiceClient( @@ -5725,7 +5643,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.FeaturestoreServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = FeaturestoreServiceClient( @@ -5736,7 +5654,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.FeaturestoreServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = FeaturestoreServiceClient(transport=transport) assert client.transport is transport @@ -5745,13 +5663,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.FeaturestoreServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.FeaturestoreServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -5766,23 +5684,25 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = FeaturestoreServiceClient(credentials=credentials.AnonymousCredentials(),) + client = FeaturestoreServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) assert isinstance(client.transport, transports.FeaturestoreServiceGrpcTransport,) def test_featurestore_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.FeaturestoreServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -5794,7 +5714,7 @@ def test_featurestore_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.FeaturestoreServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -5831,15 +5751,37 @@ def test_featurestore_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_featurestore_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.FeaturestoreServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.FeaturestoreServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_featurestore_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.FeaturestoreServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.FeaturestoreServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -5852,19 +5794,33 @@ def test_featurestore_service_base_transport_with_credentials_file(): def test_featurestore_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.FeaturestoreServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.FeaturestoreServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_featurestore_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + FeaturestoreServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_featurestore_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) FeaturestoreServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -5872,20 +5828,156 @@ def test_featurestore_service_auth_adc(): ) -def test_featurestore_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.FeaturestoreServiceGrpcTransport, + transports.FeaturestoreServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_featurestore_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.FeaturestoreServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.FeaturestoreServiceGrpcTransport, + transports.FeaturestoreServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_featurestore_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.FeaturestoreServiceGrpcTransport, grpc_helpers), + (transports.FeaturestoreServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_featurestore_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.FeaturestoreServiceGrpcTransport, grpc_helpers), + (transports.FeaturestoreServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_featurestore_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.FeaturestoreServiceGrpcTransport, grpc_helpers), + (transports.FeaturestoreServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_featurestore_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -5896,7 +5988,7 @@ def test_featurestore_service_transport_auth_adc(): def test_featurestore_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -5935,7 +6027,7 @@ def test_featurestore_service_grpc_transport_client_cert_source_for_mtls( def test_featurestore_service_host_no_port(): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -5945,7 +6037,7 @@ def test_featurestore_service_host_no_port(): def test_featurestore_service_host_with_port(): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -6001,9 +6093,9 @@ def test_featurestore_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -6079,7 +6171,7 @@ def test_featurestore_service_transport_channel_mtls_with_adc(transport_class): def test_featurestore_service_grpc_lro_client(): client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -6092,7 +6184,7 @@ def test_featurestore_service_grpc_lro_client(): def test_featurestore_service_grpc_lro_async_client(): client = FeaturestoreServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -6108,7 +6200,6 @@ def test_entity_type_path(): location = "clam" featurestore = "whelk" entity_type = "octopus" - expected = "projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}".format( project=project, location=location, @@ -6141,7 +6232,6 @@ def test_feature_path(): featurestore = "scallop" entity_type = "abalone" feature = "squid" - expected = "projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entity_type}/features/{feature}".format( project=project, location=location, @@ -6174,7 +6264,6 @@ def test_featurestore_path(): project = "cuttlefish" location = "mussel" featurestore = "winkle" - expected = "projects/{project}/locations/{location}/featurestores/{featurestore}".format( project=project, location=location, featurestore=featurestore, ) @@ -6199,7 +6288,6 @@ def test_parse_featurestore_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -6220,7 +6308,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = FeaturestoreServiceClient.common_folder_path(folder) assert expected == actual @@ -6239,7 +6326,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = FeaturestoreServiceClient.common_organization_path(organization) assert expected == actual @@ -6258,7 +6344,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = FeaturestoreServiceClient.common_project_path(project) assert expected == actual @@ -6278,7 +6363,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -6305,7 +6389,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.FeaturestoreServiceTransport, "_prep_wrapped_messages" ) as prep: client = FeaturestoreServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -6314,6 +6398,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = FeaturestoreServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py index 9580632c24..8387d2a3b1 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_index_endpoint_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.index_endpoint_service import ( IndexEndpointServiceAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.aiplatform_v1beta1.services.index_endpoint_service import pagers from google.cloud.aiplatform_v1beta1.services.index_endpoint_service import transports +from google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint as gca_index_endpoint from google.cloud.aiplatform_v1beta1.types import index_endpoint_service @@ -50,8 +55,32 @@ from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -103,7 +132,7 @@ def test__get_default_mtls_endpoint(): "client_class", [IndexEndpointServiceClient, IndexEndpointServiceAsyncClient,] ) def test_index_endpoint_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -120,7 +149,7 @@ def test_index_endpoint_service_client_from_service_account_info(client_class): "client_class", [IndexEndpointServiceClient, IndexEndpointServiceAsyncClient,] ) def test_index_endpoint_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -177,7 +206,7 @@ def test_index_endpoint_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(IndexEndpointServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -484,7 +513,7 @@ def test_create_index_endpoint( request_type=index_endpoint_service.CreateIndexEndpointRequest, ): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -497,13 +526,11 @@ def test_create_index_endpoint( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.CreateIndexEndpointRequest() # Establish that the response is the type that we expect. @@ -518,7 +545,7 @@ def test_create_index_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -528,7 +555,6 @@ def test_create_index_endpoint_empty_call(): client.create_index_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.CreateIndexEndpointRequest() @@ -538,7 +564,7 @@ async def test_create_index_endpoint_async( request_type=index_endpoint_service.CreateIndexEndpointRequest, ): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -553,13 +579,11 @@ async def test_create_index_endpoint_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.CreateIndexEndpointRequest() # Establish that the response is the type that we expect. @@ -572,11 +596,14 @@ async def test_create_index_endpoint_async_from_dict(): def test_create_index_endpoint_field_headers(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.CreateIndexEndpointRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -584,7 +611,6 @@ def test_create_index_endpoint_field_headers(): type(client.transport.create_index_endpoint), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -600,12 +626,13 @@ def test_create_index_endpoint_field_headers(): @pytest.mark.asyncio async def test_create_index_endpoint_field_headers_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.CreateIndexEndpointRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -615,7 +642,6 @@ async def test_create_index_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -629,7 +655,9 @@ async def test_create_index_endpoint_field_headers_async(): def test_create_index_endpoint_flattened(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -637,7 +665,6 @@ def test_create_index_endpoint_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_index_endpoint( @@ -649,16 +676,16 @@ def test_create_index_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].index_endpoint == gca_index_endpoint.IndexEndpoint( name="name_value" ) def test_create_index_endpoint_flattened_error(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -673,7 +700,7 @@ def test_create_index_endpoint_flattened_error(): @pytest.mark.asyncio async def test_create_index_endpoint_flattened_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -697,9 +724,7 @@ async def test_create_index_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].index_endpoint == gca_index_endpoint.IndexEndpoint( name="name_value" ) @@ -708,7 +733,7 @@ async def test_create_index_endpoint_flattened_async(): @pytest.mark.asyncio async def test_create_index_endpoint_flattened_error_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -725,7 +750,7 @@ def test_get_index_endpoint( transport: str = "grpc", request_type=index_endpoint_service.GetIndexEndpointRequest ): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -744,27 +769,19 @@ def test_get_index_endpoint( etag="etag_value", network="network_value", ) - response = client.get_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.GetIndexEndpointRequest() # Establish that the response is the type that we expect. - assert isinstance(response, index_endpoint.IndexEndpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.network == "network_value" @@ -776,7 +793,7 @@ def test_get_index_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -786,7 +803,6 @@ def test_get_index_endpoint_empty_call(): client.get_index_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.GetIndexEndpointRequest() @@ -796,7 +812,7 @@ async def test_get_index_endpoint_async( request_type=index_endpoint_service.GetIndexEndpointRequest, ): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -817,26 +833,19 @@ async def test_get_index_endpoint_async( network="network_value", ) ) - response = await client.get_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.GetIndexEndpointRequest() # Establish that the response is the type that we expect. assert isinstance(response, index_endpoint.IndexEndpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.network == "network_value" @@ -846,11 +855,14 @@ async def test_get_index_endpoint_async_from_dict(): def test_get_index_endpoint_field_headers(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.GetIndexEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -858,7 +870,6 @@ def test_get_index_endpoint_field_headers(): type(client.transport.get_index_endpoint), "__call__" ) as call: call.return_value = index_endpoint.IndexEndpoint() - client.get_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -874,12 +885,13 @@ def test_get_index_endpoint_field_headers(): @pytest.mark.asyncio async def test_get_index_endpoint_field_headers_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.GetIndexEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -889,7 +901,6 @@ async def test_get_index_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( index_endpoint.IndexEndpoint() ) - await client.get_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -903,7 +914,9 @@ async def test_get_index_endpoint_field_headers_async(): def test_get_index_endpoint_flattened(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -911,7 +924,6 @@ def test_get_index_endpoint_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = index_endpoint.IndexEndpoint() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_index_endpoint(name="name_value",) @@ -920,12 +932,13 @@ def test_get_index_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_index_endpoint_flattened_error(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -938,7 +951,7 @@ def test_get_index_endpoint_flattened_error(): @pytest.mark.asyncio async def test_get_index_endpoint_flattened_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -959,14 +972,13 @@ async def test_get_index_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_index_endpoint_flattened_error_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -982,7 +994,7 @@ def test_list_index_endpoints( request_type=index_endpoint_service.ListIndexEndpointsRequest, ): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -997,19 +1009,15 @@ def test_list_index_endpoints( call.return_value = index_endpoint_service.ListIndexEndpointsResponse( next_page_token="next_page_token_value", ) - response = client.list_index_endpoints(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.ListIndexEndpointsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListIndexEndpointsPager) - assert response.next_page_token == "next_page_token_value" @@ -1021,7 +1029,7 @@ def test_list_index_endpoints_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1031,7 +1039,6 @@ def test_list_index_endpoints_empty_call(): client.list_index_endpoints() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.ListIndexEndpointsRequest() @@ -1041,7 +1048,7 @@ async def test_list_index_endpoints_async( request_type=index_endpoint_service.ListIndexEndpointsRequest, ): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1058,18 +1065,15 @@ async def test_list_index_endpoints_async( next_page_token="next_page_token_value", ) ) - response = await client.list_index_endpoints(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.ListIndexEndpointsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListIndexEndpointsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1079,11 +1083,14 @@ async def test_list_index_endpoints_async_from_dict(): def test_list_index_endpoints_field_headers(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.ListIndexEndpointsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1091,7 +1098,6 @@ def test_list_index_endpoints_field_headers(): type(client.transport.list_index_endpoints), "__call__" ) as call: call.return_value = index_endpoint_service.ListIndexEndpointsResponse() - client.list_index_endpoints(request) # Establish that the underlying gRPC stub method was called. @@ -1107,12 +1113,13 @@ def test_list_index_endpoints_field_headers(): @pytest.mark.asyncio async def test_list_index_endpoints_field_headers_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.ListIndexEndpointsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1122,7 +1129,6 @@ async def test_list_index_endpoints_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( index_endpoint_service.ListIndexEndpointsResponse() ) - await client.list_index_endpoints(request) # Establish that the underlying gRPC stub method was called. @@ -1136,7 +1142,9 @@ async def test_list_index_endpoints_field_headers_async(): def test_list_index_endpoints_flattened(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1144,7 +1152,6 @@ def test_list_index_endpoints_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = index_endpoint_service.ListIndexEndpointsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_index_endpoints(parent="parent_value",) @@ -1153,12 +1160,13 @@ def test_list_index_endpoints_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_index_endpoints_flattened_error(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1171,7 +1179,7 @@ def test_list_index_endpoints_flattened_error(): @pytest.mark.asyncio async def test_list_index_endpoints_flattened_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1192,14 +1200,13 @@ async def test_list_index_endpoints_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_index_endpoints_flattened_error_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1211,7 +1218,9 @@ async def test_list_index_endpoints_flattened_error_async(): def test_list_index_endpoints_pager(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials,) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1257,7 +1266,9 @@ def test_list_index_endpoints_pager(): def test_list_index_endpoints_pages(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials,) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1296,7 +1307,7 @@ def test_list_index_endpoints_pages(): @pytest.mark.asyncio async def test_list_index_endpoints_async_pager(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1343,7 +1354,7 @@ async def test_list_index_endpoints_async_pager(): @pytest.mark.asyncio async def test_list_index_endpoints_async_pages(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1389,7 +1400,7 @@ def test_update_index_endpoint( request_type=index_endpoint_service.UpdateIndexEndpointRequest, ): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1408,27 +1419,19 @@ def test_update_index_endpoint( etag="etag_value", network="network_value", ) - response = client.update_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.UpdateIndexEndpointRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_index_endpoint.IndexEndpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.network == "network_value" @@ -1440,7 +1443,7 @@ def test_update_index_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1450,7 +1453,6 @@ def test_update_index_endpoint_empty_call(): client.update_index_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.UpdateIndexEndpointRequest() @@ -1460,7 +1462,7 @@ async def test_update_index_endpoint_async( request_type=index_endpoint_service.UpdateIndexEndpointRequest, ): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1481,26 +1483,19 @@ async def test_update_index_endpoint_async( network="network_value", ) ) - response = await client.update_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.UpdateIndexEndpointRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_index_endpoint.IndexEndpoint) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.network == "network_value" @@ -1510,11 +1505,14 @@ async def test_update_index_endpoint_async_from_dict(): def test_update_index_endpoint_field_headers(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.UpdateIndexEndpointRequest() + request.index_endpoint.name = "index_endpoint.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1522,7 +1520,6 @@ def test_update_index_endpoint_field_headers(): type(client.transport.update_index_endpoint), "__call__" ) as call: call.return_value = gca_index_endpoint.IndexEndpoint() - client.update_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1541,12 +1538,13 @@ def test_update_index_endpoint_field_headers(): @pytest.mark.asyncio async def test_update_index_endpoint_field_headers_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.UpdateIndexEndpointRequest() + request.index_endpoint.name = "index_endpoint.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1556,7 +1554,6 @@ async def test_update_index_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_index_endpoint.IndexEndpoint() ) - await client.update_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1573,7 +1570,9 @@ async def test_update_index_endpoint_field_headers_async(): def test_update_index_endpoint_flattened(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1581,28 +1580,27 @@ def test_update_index_endpoint_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_index_endpoint.IndexEndpoint() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_index_endpoint( index_endpoint=gca_index_endpoint.IndexEndpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].index_endpoint == gca_index_endpoint.IndexEndpoint( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_index_endpoint_flattened_error(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1610,14 +1608,14 @@ def test_update_index_endpoint_flattened_error(): client.update_index_endpoint( index_endpoint_service.UpdateIndexEndpointRequest(), index_endpoint=gca_index_endpoint.IndexEndpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_index_endpoint_flattened_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1634,25 +1632,23 @@ async def test_update_index_endpoint_flattened_async(): # using the keyword arguments to the method. response = await client.update_index_endpoint( index_endpoint=gca_index_endpoint.IndexEndpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].index_endpoint == gca_index_endpoint.IndexEndpoint( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_index_endpoint_flattened_error_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1661,7 +1657,7 @@ async def test_update_index_endpoint_flattened_error_async(): await client.update_index_endpoint( index_endpoint_service.UpdateIndexEndpointRequest(), index_endpoint=gca_index_endpoint.IndexEndpoint(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1670,7 +1666,7 @@ def test_delete_index_endpoint( request_type=index_endpoint_service.DeleteIndexEndpointRequest, ): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1683,13 +1679,11 @@ def test_delete_index_endpoint( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.DeleteIndexEndpointRequest() # Establish that the response is the type that we expect. @@ -1704,7 +1698,7 @@ def test_delete_index_endpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1714,7 +1708,6 @@ def test_delete_index_endpoint_empty_call(): client.delete_index_endpoint() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.DeleteIndexEndpointRequest() @@ -1724,7 +1717,7 @@ async def test_delete_index_endpoint_async( request_type=index_endpoint_service.DeleteIndexEndpointRequest, ): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1739,13 +1732,11 @@ async def test_delete_index_endpoint_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_index_endpoint(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.DeleteIndexEndpointRequest() # Establish that the response is the type that we expect. @@ -1758,11 +1749,14 @@ async def test_delete_index_endpoint_async_from_dict(): def test_delete_index_endpoint_field_headers(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.DeleteIndexEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1770,7 +1764,6 @@ def test_delete_index_endpoint_field_headers(): type(client.transport.delete_index_endpoint), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1786,12 +1779,13 @@ def test_delete_index_endpoint_field_headers(): @pytest.mark.asyncio async def test_delete_index_endpoint_field_headers_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.DeleteIndexEndpointRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1801,7 +1795,6 @@ async def test_delete_index_endpoint_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_index_endpoint(request) # Establish that the underlying gRPC stub method was called. @@ -1815,7 +1808,9 @@ async def test_delete_index_endpoint_field_headers_async(): def test_delete_index_endpoint_flattened(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1823,7 +1818,6 @@ def test_delete_index_endpoint_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_index_endpoint(name="name_value",) @@ -1832,12 +1826,13 @@ def test_delete_index_endpoint_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_index_endpoint_flattened_error(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1850,7 +1845,7 @@ def test_delete_index_endpoint_flattened_error(): @pytest.mark.asyncio async def test_delete_index_endpoint_flattened_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1871,14 +1866,13 @@ async def test_delete_index_endpoint_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_index_endpoint_flattened_error_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1893,7 +1887,7 @@ def test_deploy_index( transport: str = "grpc", request_type=index_endpoint_service.DeployIndexRequest ): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1904,13 +1898,11 @@ def test_deploy_index( with mock.patch.object(type(client.transport.deploy_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.deploy_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.DeployIndexRequest() # Establish that the response is the type that we expect. @@ -1925,7 +1917,7 @@ def test_deploy_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1933,7 +1925,6 @@ def test_deploy_index_empty_call(): client.deploy_index() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.DeployIndexRequest() @@ -1943,7 +1934,7 @@ async def test_deploy_index_async( request_type=index_endpoint_service.DeployIndexRequest, ): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1956,13 +1947,11 @@ async def test_deploy_index_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.deploy_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.DeployIndexRequest() # Establish that the response is the type that we expect. @@ -1975,17 +1964,19 @@ async def test_deploy_index_async_from_dict(): def test_deploy_index_field_headers(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.DeployIndexRequest() + request.index_endpoint = "index_endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_index), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.deploy_index(request) # Establish that the underlying gRPC stub method was called. @@ -2003,12 +1994,13 @@ def test_deploy_index_field_headers(): @pytest.mark.asyncio async def test_deploy_index_field_headers_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.DeployIndexRequest() + request.index_endpoint = "index_endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2016,7 +2008,6 @@ async def test_deploy_index_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.deploy_index(request) # Establish that the underlying gRPC stub method was called. @@ -2032,13 +2023,14 @@ async def test_deploy_index_field_headers_async(): def test_deploy_index_flattened(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.deploy_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.deploy_index( @@ -2050,14 +2042,14 @@ def test_deploy_index_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].index_endpoint == "index_endpoint_value" - assert args[0].deployed_index == gca_index_endpoint.DeployedIndex(id="id_value") def test_deploy_index_flattened_error(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2072,7 +2064,7 @@ def test_deploy_index_flattened_error(): @pytest.mark.asyncio async def test_deploy_index_flattened_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2094,16 +2086,14 @@ async def test_deploy_index_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].index_endpoint == "index_endpoint_value" - assert args[0].deployed_index == gca_index_endpoint.DeployedIndex(id="id_value") @pytest.mark.asyncio async def test_deploy_index_flattened_error_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2120,7 +2110,7 @@ def test_undeploy_index( transport: str = "grpc", request_type=index_endpoint_service.UndeployIndexRequest ): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2131,13 +2121,11 @@ def test_undeploy_index( with mock.patch.object(type(client.transport.undeploy_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.undeploy_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.UndeployIndexRequest() # Establish that the response is the type that we expect. @@ -2152,7 +2140,7 @@ def test_undeploy_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2160,7 +2148,6 @@ def test_undeploy_index_empty_call(): client.undeploy_index() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.UndeployIndexRequest() @@ -2170,7 +2157,7 @@ async def test_undeploy_index_async( request_type=index_endpoint_service.UndeployIndexRequest, ): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2183,13 +2170,11 @@ async def test_undeploy_index_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.undeploy_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_endpoint_service.UndeployIndexRequest() # Establish that the response is the type that we expect. @@ -2202,17 +2187,19 @@ async def test_undeploy_index_async_from_dict(): def test_undeploy_index_field_headers(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.UndeployIndexRequest() + request.index_endpoint = "index_endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_index), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.undeploy_index(request) # Establish that the underlying gRPC stub method was called. @@ -2230,12 +2217,13 @@ def test_undeploy_index_field_headers(): @pytest.mark.asyncio async def test_undeploy_index_field_headers_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_endpoint_service.UndeployIndexRequest() + request.index_endpoint = "index_endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2243,7 +2231,6 @@ async def test_undeploy_index_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.undeploy_index(request) # Establish that the underlying gRPC stub method was called. @@ -2259,13 +2246,14 @@ async def test_undeploy_index_field_headers_async(): def test_undeploy_index_flattened(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undeploy_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.undeploy_index( @@ -2277,14 +2265,14 @@ def test_undeploy_index_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].index_endpoint == "index_endpoint_value" - assert args[0].deployed_index_id == "deployed_index_id_value" def test_undeploy_index_flattened_error(): - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2299,7 +2287,7 @@ def test_undeploy_index_flattened_error(): @pytest.mark.asyncio async def test_undeploy_index_flattened_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2321,16 +2309,14 @@ async def test_undeploy_index_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].index_endpoint == "index_endpoint_value" - assert args[0].deployed_index_id == "deployed_index_id_value" @pytest.mark.asyncio async def test_undeploy_index_flattened_error_async(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2346,16 +2332,16 @@ async def test_undeploy_index_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.IndexEndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.IndexEndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = IndexEndpointServiceClient( @@ -2365,7 +2351,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.IndexEndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = IndexEndpointServiceClient( @@ -2376,7 +2362,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.IndexEndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = IndexEndpointServiceClient(transport=transport) assert client.transport is transport @@ -2385,13 +2371,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.IndexEndpointServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.IndexEndpointServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -2406,23 +2392,25 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = IndexEndpointServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexEndpointServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) assert isinstance(client.transport, transports.IndexEndpointServiceGrpcTransport,) def test_index_endpoint_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.IndexEndpointServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -2434,7 +2422,7 @@ def test_index_endpoint_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.IndexEndpointServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -2458,15 +2446,37 @@ def test_index_endpoint_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_index_endpoint_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.IndexEndpointServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.IndexEndpointServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_index_endpoint_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.IndexEndpointServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.IndexEndpointServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -2479,19 +2489,33 @@ def test_index_endpoint_service_base_transport_with_credentials_file(): def test_index_endpoint_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.IndexEndpointServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.IndexEndpointServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_index_endpoint_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + IndexEndpointServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_index_endpoint_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) IndexEndpointServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -2499,20 +2523,156 @@ def test_index_endpoint_service_auth_adc(): ) -def test_index_endpoint_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.IndexEndpointServiceGrpcTransport, + transports.IndexEndpointServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_index_endpoint_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.IndexEndpointServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.IndexEndpointServiceGrpcTransport, + transports.IndexEndpointServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_index_endpoint_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.IndexEndpointServiceGrpcTransport, grpc_helpers), + (transports.IndexEndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_index_endpoint_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.IndexEndpointServiceGrpcTransport, grpc_helpers), + (transports.IndexEndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_index_endpoint_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.IndexEndpointServiceGrpcTransport, grpc_helpers), + (transports.IndexEndpointServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_index_endpoint_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -2523,7 +2683,7 @@ def test_index_endpoint_service_transport_auth_adc(): def test_index_endpoint_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -2562,7 +2722,7 @@ def test_index_endpoint_service_grpc_transport_client_cert_source_for_mtls( def test_index_endpoint_service_host_no_port(): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -2572,7 +2732,7 @@ def test_index_endpoint_service_host_no_port(): def test_index_endpoint_service_host_with_port(): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -2628,9 +2788,9 @@ def test_index_endpoint_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2706,7 +2866,7 @@ def test_index_endpoint_service_transport_channel_mtls_with_adc(transport_class) def test_index_endpoint_service_grpc_lro_client(): client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -2719,7 +2879,7 @@ def test_index_endpoint_service_grpc_lro_client(): def test_index_endpoint_service_grpc_lro_async_client(): client = IndexEndpointServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -2734,7 +2894,6 @@ def test_index_path(): project = "squid" location = "clam" index = "whelk" - expected = "projects/{project}/locations/{location}/indexes/{index}".format( project=project, location=location, index=index, ) @@ -2759,7 +2918,6 @@ def test_index_endpoint_path(): project = "cuttlefish" location = "mussel" index_endpoint = "winkle" - expected = "projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}".format( project=project, location=location, index_endpoint=index_endpoint, ) @@ -2784,7 +2942,6 @@ def test_parse_index_endpoint_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2805,7 +2962,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = IndexEndpointServiceClient.common_folder_path(folder) assert expected == actual @@ -2824,7 +2980,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = IndexEndpointServiceClient.common_organization_path(organization) assert expected == actual @@ -2843,7 +2998,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = IndexEndpointServiceClient.common_project_path(project) assert expected == actual @@ -2863,7 +3017,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2890,7 +3043,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.IndexEndpointServiceTransport, "_prep_wrapped_messages" ) as prep: client = IndexEndpointServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2899,6 +3052,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = IndexEndpointServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py index 5d9586883e..4996d1a173 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_index_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.index_service import ( IndexServiceAsyncClient, @@ -41,6 +40,12 @@ from google.cloud.aiplatform_v1beta1.services.index_service import IndexServiceClient from google.cloud.aiplatform_v1beta1.services.index_service import pagers from google.cloud.aiplatform_v1beta1.services.index_service import transports +from google.cloud.aiplatform_v1beta1.services.index_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.index_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import deployed_index_ref from google.cloud.aiplatform_v1beta1.types import index from google.cloud.aiplatform_v1beta1.types import index as gca_index @@ -48,9 +53,33 @@ from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -96,7 +125,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [IndexServiceClient, IndexServiceAsyncClient,]) def test_index_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -111,7 +140,7 @@ def test_index_service_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [IndexServiceClient, IndexServiceAsyncClient,]) def test_index_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -162,7 +191,7 @@ def test_index_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(IndexServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -446,7 +475,7 @@ def test_create_index( transport: str = "grpc", request_type=index_service.CreateIndexRequest ): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -457,13 +486,11 @@ def test_create_index( with mock.patch.object(type(client.transport.create_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_service.CreateIndexRequest() # Establish that the response is the type that we expect. @@ -478,7 +505,7 @@ def test_create_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -486,7 +513,6 @@ def test_create_index_empty_call(): client.create_index() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_service.CreateIndexRequest() @@ -495,7 +521,7 @@ async def test_create_index_async( transport: str = "grpc_asyncio", request_type=index_service.CreateIndexRequest ): client = IndexServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -508,13 +534,11 @@ async def test_create_index_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_service.CreateIndexRequest() # Establish that the response is the type that we expect. @@ -527,17 +551,17 @@ async def test_create_index_async_from_dict(): def test_create_index_field_headers(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.CreateIndexRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_index), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_index(request) # Establish that the underlying gRPC stub method was called. @@ -552,11 +576,12 @@ def test_create_index_field_headers(): @pytest.mark.asyncio async def test_create_index_field_headers_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.CreateIndexRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -564,7 +589,6 @@ async def test_create_index_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_index(request) # Establish that the underlying gRPC stub method was called. @@ -578,13 +602,12 @@ async def test_create_index_field_headers_async(): def test_create_index_flattened(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_index( @@ -595,14 +618,12 @@ def test_create_index_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].index == gca_index.Index(name="name_value") def test_create_index_flattened_error(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -616,7 +637,7 @@ def test_create_index_flattened_error(): @pytest.mark.asyncio async def test_create_index_flattened_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_index), "__call__") as call: @@ -636,15 +657,13 @@ async def test_create_index_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].index == gca_index.Index(name="name_value") @pytest.mark.asyncio async def test_create_index_flattened_error_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -658,7 +677,7 @@ async def test_create_index_flattened_error_async(): def test_get_index(transport: str = "grpc", request_type=index_service.GetIndexRequest): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -675,27 +694,19 @@ def test_get_index(transport: str = "grpc", request_type=index_service.GetIndexR metadata_schema_uri="metadata_schema_uri_value", etag="etag_value", ) - response = client.get_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_service.GetIndexRequest() # Establish that the response is the type that we expect. - assert isinstance(response, index.Index) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -707,7 +718,7 @@ def test_get_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -715,7 +726,6 @@ def test_get_index_empty_call(): client.get_index() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_service.GetIndexRequest() @@ -724,7 +734,7 @@ async def test_get_index_async( transport: str = "grpc_asyncio", request_type=index_service.GetIndexRequest ): client = IndexServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -743,26 +753,19 @@ async def test_get_index_async( etag="etag_value", ) ) - response = await client.get_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_service.GetIndexRequest() # Establish that the response is the type that we expect. assert isinstance(response, index.Index) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.etag == "etag_value" @@ -772,17 +775,17 @@ async def test_get_index_async_from_dict(): def test_get_index_field_headers(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.GetIndexRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_index), "__call__") as call: call.return_value = index.Index() - client.get_index(request) # Establish that the underlying gRPC stub method was called. @@ -797,17 +800,17 @@ def test_get_index_field_headers(): @pytest.mark.asyncio async def test_get_index_field_headers_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.GetIndexRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_index), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(index.Index()) - await client.get_index(request) # Establish that the underlying gRPC stub method was called. @@ -821,13 +824,12 @@ async def test_get_index_field_headers_async(): def test_get_index_flattened(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = index.Index() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_index(name="name_value",) @@ -836,12 +838,11 @@ def test_get_index_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_index_flattened_error(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -853,7 +854,7 @@ def test_get_index_flattened_error(): @pytest.mark.asyncio async def test_get_index_flattened_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_index), "__call__") as call: @@ -869,13 +870,12 @@ async def test_get_index_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_index_flattened_error_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -889,7 +889,7 @@ def test_list_indexes( transport: str = "grpc", request_type=index_service.ListIndexesRequest ): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -902,19 +902,15 @@ def test_list_indexes( call.return_value = index_service.ListIndexesResponse( next_page_token="next_page_token_value", ) - response = client.list_indexes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_service.ListIndexesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListIndexesPager) - assert response.next_page_token == "next_page_token_value" @@ -926,7 +922,7 @@ def test_list_indexes_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -934,7 +930,6 @@ def test_list_indexes_empty_call(): client.list_indexes() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_service.ListIndexesRequest() @@ -943,7 +938,7 @@ async def test_list_indexes_async( transport: str = "grpc_asyncio", request_type=index_service.ListIndexesRequest ): client = IndexServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -956,18 +951,15 @@ async def test_list_indexes_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( index_service.ListIndexesResponse(next_page_token="next_page_token_value",) ) - response = await client.list_indexes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_service.ListIndexesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListIndexesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -977,17 +969,17 @@ async def test_list_indexes_async_from_dict(): def test_list_indexes_field_headers(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.ListIndexesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: call.return_value = index_service.ListIndexesResponse() - client.list_indexes(request) # Establish that the underlying gRPC stub method was called. @@ -1002,11 +994,12 @@ def test_list_indexes_field_headers(): @pytest.mark.asyncio async def test_list_indexes_field_headers_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.ListIndexesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1014,7 +1007,6 @@ async def test_list_indexes_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( index_service.ListIndexesResponse() ) - await client.list_indexes(request) # Establish that the underlying gRPC stub method was called. @@ -1028,13 +1020,12 @@ async def test_list_indexes_field_headers_async(): def test_list_indexes_flattened(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = index_service.ListIndexesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_indexes(parent="parent_value",) @@ -1043,12 +1034,11 @@ def test_list_indexes_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_indexes_flattened_error(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1060,7 +1050,7 @@ def test_list_indexes_flattened_error(): @pytest.mark.asyncio async def test_list_indexes_flattened_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: @@ -1078,13 +1068,12 @@ async def test_list_indexes_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_indexes_flattened_error_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1095,7 +1084,7 @@ async def test_list_indexes_flattened_error_async(): def test_list_indexes_pager(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials,) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: @@ -1127,7 +1116,7 @@ def test_list_indexes_pager(): def test_list_indexes_pages(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials,) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_indexes), "__call__") as call: @@ -1151,7 +1140,7 @@ def test_list_indexes_pages(): @pytest.mark.asyncio async def test_list_indexes_async_pager(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1182,7 +1171,7 @@ async def test_list_indexes_async_pager(): @pytest.mark.asyncio async def test_list_indexes_async_pages(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1212,7 +1201,7 @@ def test_update_index( transport: str = "grpc", request_type=index_service.UpdateIndexRequest ): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1223,13 +1212,11 @@ def test_update_index( with mock.patch.object(type(client.transport.update_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_service.UpdateIndexRequest() # Establish that the response is the type that we expect. @@ -1244,7 +1231,7 @@ def test_update_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1252,7 +1239,6 @@ def test_update_index_empty_call(): client.update_index() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_service.UpdateIndexRequest() @@ -1261,7 +1247,7 @@ async def test_update_index_async( transport: str = "grpc_asyncio", request_type=index_service.UpdateIndexRequest ): client = IndexServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1274,13 +1260,11 @@ async def test_update_index_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_service.UpdateIndexRequest() # Establish that the response is the type that we expect. @@ -1293,17 +1277,17 @@ async def test_update_index_async_from_dict(): def test_update_index_field_headers(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.UpdateIndexRequest() + request.index.name = "index.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_index), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_index(request) # Establish that the underlying gRPC stub method was called. @@ -1318,11 +1302,12 @@ def test_update_index_field_headers(): @pytest.mark.asyncio async def test_update_index_field_headers_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.UpdateIndexRequest() + request.index.name = "index.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1330,7 +1315,6 @@ async def test_update_index_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_index(request) # Establish that the underlying gRPC stub method was called. @@ -1344,32 +1328,29 @@ async def test_update_index_field_headers_async(): def test_update_index_flattened(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_index( index=gca_index.Index(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].index == gca_index.Index(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_index_flattened_error(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1377,13 +1358,13 @@ def test_update_index_flattened_error(): client.update_index( index_service.UpdateIndexRequest(), index=gca_index.Index(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_index_flattened_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_index), "__call__") as call: @@ -1397,22 +1378,20 @@ async def test_update_index_flattened_async(): # using the keyword arguments to the method. response = await client.update_index( index=gca_index.Index(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].index == gca_index.Index(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_index_flattened_error_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1420,7 +1399,7 @@ async def test_update_index_flattened_error_async(): await client.update_index( index_service.UpdateIndexRequest(), index=gca_index.Index(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1428,7 +1407,7 @@ def test_delete_index( transport: str = "grpc", request_type=index_service.DeleteIndexRequest ): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1439,13 +1418,11 @@ def test_delete_index( with mock.patch.object(type(client.transport.delete_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == index_service.DeleteIndexRequest() # Establish that the response is the type that we expect. @@ -1460,7 +1437,7 @@ def test_delete_index_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1468,7 +1445,6 @@ def test_delete_index_empty_call(): client.delete_index() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == index_service.DeleteIndexRequest() @@ -1477,7 +1453,7 @@ async def test_delete_index_async( transport: str = "grpc_asyncio", request_type=index_service.DeleteIndexRequest ): client = IndexServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1490,13 +1466,11 @@ async def test_delete_index_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_index(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == index_service.DeleteIndexRequest() # Establish that the response is the type that we expect. @@ -1509,17 +1483,17 @@ async def test_delete_index_async_from_dict(): def test_delete_index_field_headers(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.DeleteIndexRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_index), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_index(request) # Establish that the underlying gRPC stub method was called. @@ -1534,11 +1508,12 @@ def test_delete_index_field_headers(): @pytest.mark.asyncio async def test_delete_index_field_headers_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = index_service.DeleteIndexRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1546,7 +1521,6 @@ async def test_delete_index_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_index(request) # Establish that the underlying gRPC stub method was called. @@ -1560,13 +1534,12 @@ async def test_delete_index_field_headers_async(): def test_delete_index_flattened(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_index), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_index(name="name_value",) @@ -1575,12 +1548,11 @@ def test_delete_index_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_index_flattened_error(): - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1592,7 +1564,7 @@ def test_delete_index_flattened_error(): @pytest.mark.asyncio async def test_delete_index_flattened_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_index), "__call__") as call: @@ -1610,13 +1582,12 @@ async def test_delete_index_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_index_flattened_error_async(): - client = IndexServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1629,16 +1600,16 @@ async def test_delete_index_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.IndexServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.IndexServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = IndexServiceClient( @@ -1648,7 +1619,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.IndexServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = IndexServiceClient( @@ -1659,7 +1630,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.IndexServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = IndexServiceClient(transport=transport) assert client.transport is transport @@ -1668,13 +1639,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.IndexServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.IndexServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -1689,23 +1660,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = IndexServiceClient(credentials=credentials.AnonymousCredentials(),) + client = IndexServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.IndexServiceGrpcTransport,) def test_index_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.IndexServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1717,7 +1688,7 @@ def test_index_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.IndexServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -1739,15 +1710,37 @@ def test_index_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_index_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.index_service.transports.IndexServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.IndexServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_index_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.index_service.transports.IndexServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.IndexServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -1760,19 +1753,33 @@ def test_index_service_base_transport_with_credentials_file(): def test_index_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.index_service.transports.IndexServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.IndexServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_index_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + IndexServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_index_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) IndexServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -1780,26 +1787,162 @@ def test_index_service_auth_adc(): ) -def test_index_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.IndexServiceGrpcTransport, + transports.IndexServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_index_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.IndexServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.IndexServiceGrpcTransport, + transports.IndexServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_index_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.IndexServiceGrpcTransport, grpc_helpers), + (transports.IndexServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_index_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.IndexServiceGrpcTransport, grpc_helpers), + (transports.IndexServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_index_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.IndexServiceGrpcTransport, grpc_helpers), + (transports.IndexServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_index_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [transports.IndexServiceGrpcTransport, transports.IndexServiceGrpcAsyncIOTransport], ) def test_index_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -1838,7 +1981,7 @@ def test_index_service_grpc_transport_client_cert_source_for_mtls(transport_clas def test_index_service_host_no_port(): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -1848,7 +1991,7 @@ def test_index_service_host_no_port(): def test_index_service_host_with_port(): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -1899,9 +2042,9 @@ def test_index_service_transport_channel_mtls_with_client_cert_source(transport_ mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -1974,7 +2117,7 @@ def test_index_service_transport_channel_mtls_with_adc(transport_class): def test_index_service_grpc_lro_client(): client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -1987,7 +2130,7 @@ def test_index_service_grpc_lro_client(): def test_index_service_grpc_lro_async_client(): client = IndexServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -2002,7 +2145,6 @@ def test_index_path(): project = "squid" location = "clam" index = "whelk" - expected = "projects/{project}/locations/{location}/indexes/{index}".format( project=project, location=location, index=index, ) @@ -2027,7 +2169,6 @@ def test_index_endpoint_path(): project = "cuttlefish" location = "mussel" index_endpoint = "winkle" - expected = "projects/{project}/locations/{location}/indexEndpoints/{index_endpoint}".format( project=project, location=location, index_endpoint=index_endpoint, ) @@ -2050,7 +2191,6 @@ def test_parse_index_endpoint_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2071,7 +2211,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = IndexServiceClient.common_folder_path(folder) assert expected == actual @@ -2090,7 +2229,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = IndexServiceClient.common_organization_path(organization) assert expected == actual @@ -2109,7 +2247,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = IndexServiceClient.common_project_path(project) assert expected == actual @@ -2129,7 +2266,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2156,7 +2292,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.IndexServiceTransport, "_prep_wrapped_messages" ) as prep: client = IndexServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2165,6 +2301,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = IndexServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py index 6acb3e7b86..700ebee54b 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_job_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,21 +23,27 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.job_service import JobServiceAsyncClient from google.cloud.aiplatform_v1beta1.services.job_service import JobServiceClient from google.cloud.aiplatform_v1beta1.services.job_service import pagers from google.cloud.aiplatform_v1beta1.services.job_service import transports +from google.cloud.aiplatform_v1beta1.services.job_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.job_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import accelerator_type from google.cloud.aiplatform_v1beta1.types import batch_prediction_job from google.cloud.aiplatform_v1beta1.types import ( @@ -72,13 +77,37 @@ from google.cloud.aiplatform_v1beta1.types import study from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore -from google.type import money_pb2 as money # type: ignore +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -124,7 +153,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [JobServiceClient, JobServiceAsyncClient,]) def test_job_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -139,7 +168,7 @@ def test_job_service_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [JobServiceClient, JobServiceAsyncClient,]) def test_job_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -190,7 +219,7 @@ def test_job_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(JobServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -474,7 +503,7 @@ def test_create_custom_job( transport: str = "grpc", request_type=job_service.CreateCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -491,23 +520,17 @@ def test_create_custom_job( display_name="display_name_value", state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateCustomJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -519,7 +542,7 @@ def test_create_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -529,7 +552,6 @@ def test_create_custom_job_empty_call(): client.create_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateCustomJobRequest() @@ -538,7 +560,7 @@ async def test_create_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.CreateCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -557,22 +579,17 @@ async def test_create_custom_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateCustomJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -582,11 +599,12 @@ async def test_create_custom_job_async_from_dict(): def test_create_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateCustomJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -594,7 +612,6 @@ def test_create_custom_job_field_headers(): type(client.transport.create_custom_job), "__call__" ) as call: call.return_value = gca_custom_job.CustomJob() - client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -609,11 +626,12 @@ def test_create_custom_job_field_headers(): @pytest.mark.asyncio async def test_create_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateCustomJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -623,7 +641,6 @@ async def test_create_custom_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_custom_job.CustomJob() ) - await client.create_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -637,7 +654,7 @@ async def test_create_custom_job_field_headers_async(): def test_create_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -645,7 +662,6 @@ def test_create_custom_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_custom_job.CustomJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_custom_job( @@ -657,14 +673,12 @@ def test_create_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].custom_job == gca_custom_job.CustomJob(name="name_value") def test_create_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -678,7 +692,7 @@ def test_create_custom_job_flattened_error(): @pytest.mark.asyncio async def test_create_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -701,15 +715,13 @@ async def test_create_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].custom_job == gca_custom_job.CustomJob(name="name_value") @pytest.mark.asyncio async def test_create_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -725,7 +737,7 @@ def test_get_custom_job( transport: str = "grpc", request_type=job_service.GetCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -740,23 +752,17 @@ def test_get_custom_job( display_name="display_name_value", state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetCustomJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -768,7 +774,7 @@ def test_get_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -776,7 +782,6 @@ def test_get_custom_job_empty_call(): client.get_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetCustomJobRequest() @@ -785,7 +790,7 @@ async def test_get_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.GetCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -802,22 +807,17 @@ async def test_get_custom_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetCustomJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, custom_job.CustomJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -827,17 +827,17 @@ async def test_get_custom_job_async_from_dict(): def test_get_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_custom_job), "__call__") as call: call.return_value = custom_job.CustomJob() - client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -852,11 +852,12 @@ def test_get_custom_job_field_headers(): @pytest.mark.asyncio async def test_get_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -864,7 +865,6 @@ async def test_get_custom_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( custom_job.CustomJob() ) - await client.get_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -878,13 +878,12 @@ async def test_get_custom_job_field_headers_async(): def test_get_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_custom_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = custom_job.CustomJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_custom_job(name="name_value",) @@ -893,12 +892,11 @@ def test_get_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -910,7 +908,7 @@ def test_get_custom_job_flattened_error(): @pytest.mark.asyncio async def test_get_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_custom_job), "__call__") as call: @@ -928,13 +926,12 @@ async def test_get_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -948,7 +945,7 @@ def test_list_custom_jobs( transport: str = "grpc", request_type=job_service.ListCustomJobsRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -961,19 +958,15 @@ def test_list_custom_jobs( call.return_value = job_service.ListCustomJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListCustomJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCustomJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -985,7 +978,7 @@ def test_list_custom_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -993,7 +986,6 @@ def test_list_custom_jobs_empty_call(): client.list_custom_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListCustomJobsRequest() @@ -1002,7 +994,7 @@ async def test_list_custom_jobs_async( transport: str = "grpc_asyncio", request_type=job_service.ListCustomJobsRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1015,18 +1007,15 @@ async def test_list_custom_jobs_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListCustomJobsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListCustomJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCustomJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1036,17 +1025,17 @@ async def test_list_custom_jobs_async_from_dict(): def test_list_custom_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListCustomJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: call.return_value = job_service.ListCustomJobsResponse() - client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -1061,11 +1050,12 @@ def test_list_custom_jobs_field_headers(): @pytest.mark.asyncio async def test_list_custom_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListCustomJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1073,7 +1063,6 @@ async def test_list_custom_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListCustomJobsResponse() ) - await client.list_custom_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -1087,13 +1076,12 @@ async def test_list_custom_jobs_field_headers_async(): def test_list_custom_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListCustomJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_custom_jobs(parent="parent_value",) @@ -1102,12 +1090,11 @@ def test_list_custom_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_custom_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1119,7 +1106,7 @@ def test_list_custom_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_custom_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: @@ -1137,13 +1124,12 @@ async def test_list_custom_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_custom_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1154,7 +1140,7 @@ async def test_list_custom_jobs_flattened_error_async(): def test_list_custom_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: @@ -1192,7 +1178,7 @@ def test_list_custom_jobs_pager(): def test_list_custom_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_custom_jobs), "__call__") as call: @@ -1222,7 +1208,7 @@ def test_list_custom_jobs_pages(): @pytest.mark.asyncio async def test_list_custom_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1259,7 +1245,7 @@ async def test_list_custom_jobs_async_pager(): @pytest.mark.asyncio async def test_list_custom_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1295,7 +1281,7 @@ def test_delete_custom_job( transport: str = "grpc", request_type=job_service.DeleteCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1308,13 +1294,11 @@ def test_delete_custom_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteCustomJobRequest() # Establish that the response is the type that we expect. @@ -1329,7 +1313,7 @@ def test_delete_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1339,7 +1323,6 @@ def test_delete_custom_job_empty_call(): client.delete_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteCustomJobRequest() @@ -1348,7 +1331,7 @@ async def test_delete_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.DeleteCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1363,13 +1346,11 @@ async def test_delete_custom_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteCustomJobRequest() # Establish that the response is the type that we expect. @@ -1382,11 +1363,12 @@ async def test_delete_custom_job_async_from_dict(): def test_delete_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1394,7 +1376,6 @@ def test_delete_custom_job_field_headers(): type(client.transport.delete_custom_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1409,11 +1390,12 @@ def test_delete_custom_job_field_headers(): @pytest.mark.asyncio async def test_delete_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1423,7 +1405,6 @@ async def test_delete_custom_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1437,7 +1418,7 @@ async def test_delete_custom_job_field_headers_async(): def test_delete_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1445,7 +1426,6 @@ def test_delete_custom_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_custom_job(name="name_value",) @@ -1454,12 +1434,11 @@ def test_delete_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1471,7 +1450,7 @@ def test_delete_custom_job_flattened_error(): @pytest.mark.asyncio async def test_delete_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1491,13 +1470,12 @@ async def test_delete_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1511,7 +1489,7 @@ def test_cancel_custom_job( transport: str = "grpc", request_type=job_service.CancelCustomJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1524,13 +1502,11 @@ def test_cancel_custom_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelCustomJobRequest() # Establish that the response is the type that we expect. @@ -1545,7 +1521,7 @@ def test_cancel_custom_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1555,7 +1531,6 @@ def test_cancel_custom_job_empty_call(): client.cancel_custom_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelCustomJobRequest() @@ -1564,7 +1539,7 @@ async def test_cancel_custom_job_async( transport: str = "grpc_asyncio", request_type=job_service.CancelCustomJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1577,13 +1552,11 @@ async def test_cancel_custom_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelCustomJobRequest() # Establish that the response is the type that we expect. @@ -1596,11 +1569,12 @@ async def test_cancel_custom_job_async_from_dict(): def test_cancel_custom_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1608,7 +1582,6 @@ def test_cancel_custom_job_field_headers(): type(client.transport.cancel_custom_job), "__call__" ) as call: call.return_value = None - client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1623,11 +1596,12 @@ def test_cancel_custom_job_field_headers(): @pytest.mark.asyncio async def test_cancel_custom_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelCustomJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1635,7 +1609,6 @@ async def test_cancel_custom_job_field_headers_async(): type(client.transport.cancel_custom_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_custom_job(request) # Establish that the underlying gRPC stub method was called. @@ -1649,7 +1622,7 @@ async def test_cancel_custom_job_field_headers_async(): def test_cancel_custom_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1657,7 +1630,6 @@ def test_cancel_custom_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_custom_job(name="name_value",) @@ -1666,12 +1638,11 @@ def test_cancel_custom_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_custom_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1683,7 +1654,7 @@ def test_cancel_custom_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_custom_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1701,13 +1672,12 @@ async def test_cancel_custom_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_custom_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1721,7 +1691,7 @@ def test_create_data_labeling_job( transport: str = "grpc", request_type=job_service.CreateDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1744,35 +1714,23 @@ def test_create_data_labeling_job( labeling_progress=1810, specialist_pools=["specialist_pools_value"], ) - response = client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateDataLabelingJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -1784,7 +1742,7 @@ def test_create_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1794,7 +1752,6 @@ def test_create_data_labeling_job_empty_call(): client.create_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateDataLabelingJobRequest() @@ -1804,7 +1761,7 @@ async def test_create_data_labeling_job_async( request_type=job_service.CreateDataLabelingJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1829,34 +1786,23 @@ async def test_create_data_labeling_job_async( specialist_pools=["specialist_pools_value"], ) ) - response = await client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateDataLabelingJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -1866,11 +1812,12 @@ async def test_create_data_labeling_job_async_from_dict(): def test_create_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateDataLabelingJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1878,7 +1825,6 @@ def test_create_data_labeling_job_field_headers(): type(client.transport.create_data_labeling_job), "__call__" ) as call: call.return_value = gca_data_labeling_job.DataLabelingJob() - client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -1893,11 +1839,12 @@ def test_create_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_create_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateDataLabelingJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1907,7 +1854,6 @@ async def test_create_data_labeling_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_data_labeling_job.DataLabelingJob() ) - await client.create_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -1921,7 +1867,7 @@ async def test_create_data_labeling_job_field_headers_async(): def test_create_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1929,7 +1875,6 @@ def test_create_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_data_labeling_job.DataLabelingJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_data_labeling_job( @@ -1941,16 +1886,14 @@ def test_create_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].data_labeling_job == gca_data_labeling_job.DataLabelingJob( name="name_value" ) def test_create_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1964,7 +1907,7 @@ def test_create_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_create_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1987,9 +1930,7 @@ async def test_create_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].data_labeling_job == gca_data_labeling_job.DataLabelingJob( name="name_value" ) @@ -1997,7 +1938,7 @@ async def test_create_data_labeling_job_flattened_async(): @pytest.mark.asyncio async def test_create_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2013,7 +1954,7 @@ def test_get_data_labeling_job( transport: str = "grpc", request_type=job_service.GetDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2036,35 +1977,23 @@ def test_get_data_labeling_job( labeling_progress=1810, specialist_pools=["specialist_pools_value"], ) - response = client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetDataLabelingJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -2076,7 +2005,7 @@ def test_get_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2086,7 +2015,6 @@ def test_get_data_labeling_job_empty_call(): client.get_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetDataLabelingJobRequest() @@ -2095,7 +2023,7 @@ async def test_get_data_labeling_job_async( transport: str = "grpc_asyncio", request_type=job_service.GetDataLabelingJobRequest ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2120,34 +2048,23 @@ async def test_get_data_labeling_job_async( specialist_pools=["specialist_pools_value"], ) ) - response = await client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetDataLabelingJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, data_labeling_job.DataLabelingJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.datasets == ["datasets_value"] - assert response.labeler_count == 1375 - assert response.instruction_uri == "instruction_uri_value" - assert response.inputs_schema_uri == "inputs_schema_uri_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert response.labeling_progress == 1810 - assert response.specialist_pools == ["specialist_pools_value"] @@ -2157,11 +2074,12 @@ async def test_get_data_labeling_job_async_from_dict(): def test_get_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2169,7 +2087,6 @@ def test_get_data_labeling_job_field_headers(): type(client.transport.get_data_labeling_job), "__call__" ) as call: call.return_value = data_labeling_job.DataLabelingJob() - client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2184,11 +2101,12 @@ def test_get_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_get_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2198,7 +2116,6 @@ async def test_get_data_labeling_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( data_labeling_job.DataLabelingJob() ) - await client.get_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2212,7 +2129,7 @@ async def test_get_data_labeling_job_field_headers_async(): def test_get_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2220,7 +2137,6 @@ def test_get_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = data_labeling_job.DataLabelingJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_data_labeling_job(name="name_value",) @@ -2229,12 +2145,11 @@ def test_get_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2246,7 +2161,7 @@ def test_get_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_get_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2266,13 +2181,12 @@ async def test_get_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2286,7 +2200,7 @@ def test_list_data_labeling_jobs( transport: str = "grpc", request_type=job_service.ListDataLabelingJobsRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2301,19 +2215,15 @@ def test_list_data_labeling_jobs( call.return_value = job_service.ListDataLabelingJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListDataLabelingJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDataLabelingJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -2325,7 +2235,7 @@ def test_list_data_labeling_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2335,7 +2245,6 @@ def test_list_data_labeling_jobs_empty_call(): client.list_data_labeling_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListDataLabelingJobsRequest() @@ -2345,7 +2254,7 @@ async def test_list_data_labeling_jobs_async( request_type=job_service.ListDataLabelingJobsRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2362,18 +2271,15 @@ async def test_list_data_labeling_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListDataLabelingJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListDataLabelingJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2383,11 +2289,12 @@ async def test_list_data_labeling_jobs_async_from_dict(): def test_list_data_labeling_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListDataLabelingJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2395,7 +2302,6 @@ def test_list_data_labeling_jobs_field_headers(): type(client.transport.list_data_labeling_jobs), "__call__" ) as call: call.return_value = job_service.ListDataLabelingJobsResponse() - client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -2410,11 +2316,12 @@ def test_list_data_labeling_jobs_field_headers(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListDataLabelingJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2424,7 +2331,6 @@ async def test_list_data_labeling_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListDataLabelingJobsResponse() ) - await client.list_data_labeling_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -2438,7 +2344,7 @@ async def test_list_data_labeling_jobs_field_headers_async(): def test_list_data_labeling_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2446,7 +2352,6 @@ def test_list_data_labeling_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListDataLabelingJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_data_labeling_jobs(parent="parent_value",) @@ -2455,12 +2360,11 @@ def test_list_data_labeling_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_data_labeling_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2472,7 +2376,7 @@ def test_list_data_labeling_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2492,13 +2396,12 @@ async def test_list_data_labeling_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_data_labeling_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2509,7 +2412,7 @@ async def test_list_data_labeling_jobs_flattened_error_async(): def test_list_data_labeling_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2555,7 +2458,7 @@ def test_list_data_labeling_jobs_pager(): def test_list_data_labeling_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2593,7 +2496,7 @@ def test_list_data_labeling_jobs_pages(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2638,7 +2541,7 @@ async def test_list_data_labeling_jobs_async_pager(): @pytest.mark.asyncio async def test_list_data_labeling_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2682,7 +2585,7 @@ def test_delete_data_labeling_job( transport: str = "grpc", request_type=job_service.DeleteDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2695,13 +2598,11 @@ def test_delete_data_labeling_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2716,7 +2617,7 @@ def test_delete_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2726,7 +2627,6 @@ def test_delete_data_labeling_job_empty_call(): client.delete_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteDataLabelingJobRequest() @@ -2736,7 +2636,7 @@ async def test_delete_data_labeling_job_async( request_type=job_service.DeleteDataLabelingJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2751,13 +2651,11 @@ async def test_delete_data_labeling_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2770,11 +2668,12 @@ async def test_delete_data_labeling_job_async_from_dict(): def test_delete_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2782,7 +2681,6 @@ def test_delete_data_labeling_job_field_headers(): type(client.transport.delete_data_labeling_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2797,11 +2695,12 @@ def test_delete_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_delete_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2811,7 +2710,6 @@ async def test_delete_data_labeling_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -2825,7 +2723,7 @@ async def test_delete_data_labeling_job_field_headers_async(): def test_delete_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2833,7 +2731,6 @@ def test_delete_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_data_labeling_job(name="name_value",) @@ -2842,12 +2739,11 @@ def test_delete_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2859,7 +2755,7 @@ def test_delete_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_delete_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2879,13 +2775,12 @@ async def test_delete_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2899,7 +2794,7 @@ def test_cancel_data_labeling_job( transport: str = "grpc", request_type=job_service.CancelDataLabelingJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2912,13 +2807,11 @@ def test_cancel_data_labeling_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2933,7 +2826,7 @@ def test_cancel_data_labeling_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2943,7 +2836,6 @@ def test_cancel_data_labeling_job_empty_call(): client.cancel_data_labeling_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelDataLabelingJobRequest() @@ -2953,7 +2845,7 @@ async def test_cancel_data_labeling_job_async( request_type=job_service.CancelDataLabelingJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2966,13 +2858,11 @@ async def test_cancel_data_labeling_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelDataLabelingJobRequest() # Establish that the response is the type that we expect. @@ -2985,11 +2875,12 @@ async def test_cancel_data_labeling_job_async_from_dict(): def test_cancel_data_labeling_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2997,7 +2888,6 @@ def test_cancel_data_labeling_job_field_headers(): type(client.transport.cancel_data_labeling_job), "__call__" ) as call: call.return_value = None - client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -3012,11 +2902,12 @@ def test_cancel_data_labeling_job_field_headers(): @pytest.mark.asyncio async def test_cancel_data_labeling_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelDataLabelingJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3024,7 +2915,6 @@ async def test_cancel_data_labeling_job_field_headers_async(): type(client.transport.cancel_data_labeling_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_data_labeling_job(request) # Establish that the underlying gRPC stub method was called. @@ -3038,7 +2928,7 @@ async def test_cancel_data_labeling_job_field_headers_async(): def test_cancel_data_labeling_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3046,7 +2936,6 @@ def test_cancel_data_labeling_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_data_labeling_job(name="name_value",) @@ -3055,12 +2944,11 @@ def test_cancel_data_labeling_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_data_labeling_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3072,7 +2960,7 @@ def test_cancel_data_labeling_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_data_labeling_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3090,13 +2978,12 @@ async def test_cancel_data_labeling_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_data_labeling_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3111,7 +2998,7 @@ def test_create_hyperparameter_tuning_job( request_type=job_service.CreateHyperparameterTuningJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3131,29 +3018,20 @@ def test_create_hyperparameter_tuning_job( max_failed_trial_count=2317, state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3165,7 +3043,7 @@ def test_create_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3175,7 +3053,6 @@ def test_create_hyperparameter_tuning_job_empty_call(): client.create_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateHyperparameterTuningJobRequest() @@ -3185,7 +3062,7 @@ async def test_create_hyperparameter_tuning_job_async( request_type=job_service.CreateHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3207,28 +3084,20 @@ async def test_create_hyperparameter_tuning_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3238,11 +3107,12 @@ async def test_create_hyperparameter_tuning_job_async_from_dict(): def test_create_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateHyperparameterTuningJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3250,7 +3120,6 @@ def test_create_hyperparameter_tuning_job_field_headers(): type(client.transport.create_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = gca_hyperparameter_tuning_job.HyperparameterTuningJob() - client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3265,11 +3134,12 @@ def test_create_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_create_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateHyperparameterTuningJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3279,7 +3149,6 @@ async def test_create_hyperparameter_tuning_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_hyperparameter_tuning_job.HyperparameterTuningJob() ) - await client.create_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3293,7 +3162,7 @@ async def test_create_hyperparameter_tuning_job_field_headers_async(): def test_create_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3301,7 +3170,6 @@ def test_create_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_hyperparameter_tuning_job.HyperparameterTuningJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_hyperparameter_tuning_job( @@ -3315,9 +3183,7 @@ def test_create_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].hyperparameter_tuning_job == gca_hyperparameter_tuning_job.HyperparameterTuningJob( @@ -3326,7 +3192,7 @@ def test_create_hyperparameter_tuning_job_flattened(): def test_create_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3342,7 +3208,7 @@ def test_create_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_create_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3367,9 +3233,7 @@ async def test_create_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].hyperparameter_tuning_job == gca_hyperparameter_tuning_job.HyperparameterTuningJob( @@ -3379,7 +3243,7 @@ async def test_create_hyperparameter_tuning_job_flattened_async(): @pytest.mark.asyncio async def test_create_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3397,7 +3261,7 @@ def test_get_hyperparameter_tuning_job( transport: str = "grpc", request_type=job_service.GetHyperparameterTuningJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3417,29 +3281,20 @@ def test_get_hyperparameter_tuning_job( max_failed_trial_count=2317, state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3451,7 +3306,7 @@ def test_get_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3461,7 +3316,6 @@ def test_get_hyperparameter_tuning_job_empty_call(): client.get_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetHyperparameterTuningJobRequest() @@ -3471,7 +3325,7 @@ async def test_get_hyperparameter_tuning_job_async( request_type=job_service.GetHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3493,28 +3347,20 @@ async def test_get_hyperparameter_tuning_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, hyperparameter_tuning_job.HyperparameterTuningJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.max_trial_count == 1609 - assert response.parallel_trial_count == 2128 - assert response.max_failed_trial_count == 2317 - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -3524,11 +3370,12 @@ async def test_get_hyperparameter_tuning_job_async_from_dict(): def test_get_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3536,7 +3383,6 @@ def test_get_hyperparameter_tuning_job_field_headers(): type(client.transport.get_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = hyperparameter_tuning_job.HyperparameterTuningJob() - client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3551,11 +3397,12 @@ def test_get_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_get_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3565,7 +3412,6 @@ async def test_get_hyperparameter_tuning_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( hyperparameter_tuning_job.HyperparameterTuningJob() ) - await client.get_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -3579,7 +3425,7 @@ async def test_get_hyperparameter_tuning_job_field_headers_async(): def test_get_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3587,7 +3433,6 @@ def test_get_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = hyperparameter_tuning_job.HyperparameterTuningJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_hyperparameter_tuning_job(name="name_value",) @@ -3596,12 +3441,11 @@ def test_get_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3613,7 +3457,7 @@ def test_get_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_get_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3633,13 +3477,12 @@ async def test_get_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3654,7 +3497,7 @@ def test_list_hyperparameter_tuning_jobs( request_type=job_service.ListHyperparameterTuningJobsRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3669,19 +3512,15 @@ def test_list_hyperparameter_tuning_jobs( call.return_value = job_service.ListHyperparameterTuningJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListHyperparameterTuningJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListHyperparameterTuningJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -3693,7 +3532,7 @@ def test_list_hyperparameter_tuning_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3703,7 +3542,6 @@ def test_list_hyperparameter_tuning_jobs_empty_call(): client.list_hyperparameter_tuning_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListHyperparameterTuningJobsRequest() @@ -3713,7 +3551,7 @@ async def test_list_hyperparameter_tuning_jobs_async( request_type=job_service.ListHyperparameterTuningJobsRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3730,18 +3568,15 @@ async def test_list_hyperparameter_tuning_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListHyperparameterTuningJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListHyperparameterTuningJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3751,11 +3586,12 @@ async def test_list_hyperparameter_tuning_jobs_async_from_dict(): def test_list_hyperparameter_tuning_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListHyperparameterTuningJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3763,7 +3599,6 @@ def test_list_hyperparameter_tuning_jobs_field_headers(): type(client.transport.list_hyperparameter_tuning_jobs), "__call__" ) as call: call.return_value = job_service.ListHyperparameterTuningJobsResponse() - client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -3778,11 +3613,12 @@ def test_list_hyperparameter_tuning_jobs_field_headers(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListHyperparameterTuningJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3792,7 +3628,6 @@ async def test_list_hyperparameter_tuning_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListHyperparameterTuningJobsResponse() ) - await client.list_hyperparameter_tuning_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -3806,7 +3641,7 @@ async def test_list_hyperparameter_tuning_jobs_field_headers_async(): def test_list_hyperparameter_tuning_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3814,7 +3649,6 @@ def test_list_hyperparameter_tuning_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListHyperparameterTuningJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_hyperparameter_tuning_jobs(parent="parent_value",) @@ -3823,12 +3657,11 @@ def test_list_hyperparameter_tuning_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_hyperparameter_tuning_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3840,7 +3673,7 @@ def test_list_hyperparameter_tuning_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3860,13 +3693,12 @@ async def test_list_hyperparameter_tuning_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3877,7 +3709,7 @@ async def test_list_hyperparameter_tuning_jobs_flattened_error_async(): def test_list_hyperparameter_tuning_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3928,7 +3760,7 @@ def test_list_hyperparameter_tuning_jobs_pager(): def test_list_hyperparameter_tuning_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3968,7 +3800,7 @@ def test_list_hyperparameter_tuning_jobs_pages(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4018,7 +3850,7 @@ async def test_list_hyperparameter_tuning_jobs_async_pager(): @pytest.mark.asyncio async def test_list_hyperparameter_tuning_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4067,7 +3899,7 @@ def test_delete_hyperparameter_tuning_job( request_type=job_service.DeleteHyperparameterTuningJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4080,13 +3912,11 @@ def test_delete_hyperparameter_tuning_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4101,7 +3931,7 @@ def test_delete_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4111,7 +3941,6 @@ def test_delete_hyperparameter_tuning_job_empty_call(): client.delete_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteHyperparameterTuningJobRequest() @@ -4121,7 +3950,7 @@ async def test_delete_hyperparameter_tuning_job_async( request_type=job_service.DeleteHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4136,13 +3965,11 @@ async def test_delete_hyperparameter_tuning_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4155,11 +3982,12 @@ async def test_delete_hyperparameter_tuning_job_async_from_dict(): def test_delete_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4167,7 +3995,6 @@ def test_delete_hyperparameter_tuning_job_field_headers(): type(client.transport.delete_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4182,11 +4009,12 @@ def test_delete_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_delete_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4196,7 +4024,6 @@ async def test_delete_hyperparameter_tuning_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4210,7 +4037,7 @@ async def test_delete_hyperparameter_tuning_job_field_headers_async(): def test_delete_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4218,7 +4045,6 @@ def test_delete_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_hyperparameter_tuning_job(name="name_value",) @@ -4227,12 +4053,11 @@ def test_delete_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4244,7 +4069,7 @@ def test_delete_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_delete_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4264,13 +4089,12 @@ async def test_delete_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4285,7 +4109,7 @@ def test_cancel_hyperparameter_tuning_job( request_type=job_service.CancelHyperparameterTuningJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4298,13 +4122,11 @@ def test_cancel_hyperparameter_tuning_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4319,7 +4141,7 @@ def test_cancel_hyperparameter_tuning_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4329,7 +4151,6 @@ def test_cancel_hyperparameter_tuning_job_empty_call(): client.cancel_hyperparameter_tuning_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelHyperparameterTuningJobRequest() @@ -4339,7 +4160,7 @@ async def test_cancel_hyperparameter_tuning_job_async( request_type=job_service.CancelHyperparameterTuningJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4352,13 +4173,11 @@ async def test_cancel_hyperparameter_tuning_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelHyperparameterTuningJobRequest() # Establish that the response is the type that we expect. @@ -4371,11 +4190,12 @@ async def test_cancel_hyperparameter_tuning_job_async_from_dict(): def test_cancel_hyperparameter_tuning_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4383,7 +4203,6 @@ def test_cancel_hyperparameter_tuning_job_field_headers(): type(client.transport.cancel_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = None - client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4398,11 +4217,12 @@ def test_cancel_hyperparameter_tuning_job_field_headers(): @pytest.mark.asyncio async def test_cancel_hyperparameter_tuning_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelHyperparameterTuningJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4410,7 +4230,6 @@ async def test_cancel_hyperparameter_tuning_job_field_headers_async(): type(client.transport.cancel_hyperparameter_tuning_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_hyperparameter_tuning_job(request) # Establish that the underlying gRPC stub method was called. @@ -4424,7 +4243,7 @@ async def test_cancel_hyperparameter_tuning_job_field_headers_async(): def test_cancel_hyperparameter_tuning_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4432,7 +4251,6 @@ def test_cancel_hyperparameter_tuning_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_hyperparameter_tuning_job(name="name_value",) @@ -4441,12 +4259,11 @@ def test_cancel_hyperparameter_tuning_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_hyperparameter_tuning_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4458,7 +4275,7 @@ def test_cancel_hyperparameter_tuning_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_hyperparameter_tuning_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4476,13 +4293,12 @@ async def test_cancel_hyperparameter_tuning_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_hyperparameter_tuning_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4496,7 +4312,7 @@ def test_create_batch_prediction_job( transport: str = "grpc", request_type=job_service.CreateBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4515,27 +4331,19 @@ def test_create_batch_prediction_job( generate_explanation=True, state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateBatchPredictionJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.generate_explanation is True - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4547,7 +4355,7 @@ def test_create_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4557,7 +4365,6 @@ def test_create_batch_prediction_job_empty_call(): client.create_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateBatchPredictionJobRequest() @@ -4567,7 +4374,7 @@ async def test_create_batch_prediction_job_async( request_type=job_service.CreateBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4588,26 +4395,19 @@ async def test_create_batch_prediction_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateBatchPredictionJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.generate_explanation is True - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4617,11 +4417,12 @@ async def test_create_batch_prediction_job_async_from_dict(): def test_create_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateBatchPredictionJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4629,7 +4430,6 @@ def test_create_batch_prediction_job_field_headers(): type(client.transport.create_batch_prediction_job), "__call__" ) as call: call.return_value = gca_batch_prediction_job.BatchPredictionJob() - client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4644,11 +4444,12 @@ def test_create_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_create_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateBatchPredictionJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4658,7 +4459,6 @@ async def test_create_batch_prediction_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_batch_prediction_job.BatchPredictionJob() ) - await client.create_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4672,7 +4472,7 @@ async def test_create_batch_prediction_job_field_headers_async(): def test_create_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4680,7 +4480,6 @@ def test_create_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_batch_prediction_job.BatchPredictionJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_batch_prediction_job( @@ -4694,9 +4493,7 @@ def test_create_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].batch_prediction_job == gca_batch_prediction_job.BatchPredictionJob( @@ -4705,7 +4502,7 @@ def test_create_batch_prediction_job_flattened(): def test_create_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4721,7 +4518,7 @@ def test_create_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_create_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4746,9 +4543,7 @@ async def test_create_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].batch_prediction_job == gca_batch_prediction_job.BatchPredictionJob( @@ -4758,7 +4553,7 @@ async def test_create_batch_prediction_job_flattened_async(): @pytest.mark.asyncio async def test_create_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4776,7 +4571,7 @@ def test_get_batch_prediction_job( transport: str = "grpc", request_type=job_service.GetBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4795,27 +4590,19 @@ def test_get_batch_prediction_job( generate_explanation=True, state=job_state.JobState.JOB_STATE_QUEUED, ) - response = client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetBatchPredictionJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.generate_explanation is True - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4827,7 +4614,7 @@ def test_get_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4837,7 +4624,6 @@ def test_get_batch_prediction_job_empty_call(): client.get_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetBatchPredictionJobRequest() @@ -4847,7 +4633,7 @@ async def test_get_batch_prediction_job_async( request_type=job_service.GetBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4868,26 +4654,19 @@ async def test_get_batch_prediction_job_async( state=job_state.JobState.JOB_STATE_QUEUED, ) ) - response = await client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetBatchPredictionJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, batch_prediction_job.BatchPredictionJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.model == "model_value" - assert response.generate_explanation is True - assert response.state == job_state.JobState.JOB_STATE_QUEUED @@ -4897,11 +4676,12 @@ async def test_get_batch_prediction_job_async_from_dict(): def test_get_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4909,7 +4689,6 @@ def test_get_batch_prediction_job_field_headers(): type(client.transport.get_batch_prediction_job), "__call__" ) as call: call.return_value = batch_prediction_job.BatchPredictionJob() - client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4924,11 +4703,12 @@ def test_get_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_get_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4938,7 +4718,6 @@ async def test_get_batch_prediction_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( batch_prediction_job.BatchPredictionJob() ) - await client.get_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -4952,7 +4731,7 @@ async def test_get_batch_prediction_job_field_headers_async(): def test_get_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4960,7 +4739,6 @@ def test_get_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = batch_prediction_job.BatchPredictionJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_batch_prediction_job(name="name_value",) @@ -4969,12 +4747,11 @@ def test_get_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4986,7 +4763,7 @@ def test_get_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_get_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5006,13 +4783,12 @@ async def test_get_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5026,7 +4802,7 @@ def test_list_batch_prediction_jobs( transport: str = "grpc", request_type=job_service.ListBatchPredictionJobsRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5041,19 +4817,15 @@ def test_list_batch_prediction_jobs( call.return_value = job_service.ListBatchPredictionJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListBatchPredictionJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBatchPredictionJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -5065,7 +4837,7 @@ def test_list_batch_prediction_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5075,7 +4847,6 @@ def test_list_batch_prediction_jobs_empty_call(): client.list_batch_prediction_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListBatchPredictionJobsRequest() @@ -5085,7 +4856,7 @@ async def test_list_batch_prediction_jobs_async( request_type=job_service.ListBatchPredictionJobsRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5102,18 +4873,15 @@ async def test_list_batch_prediction_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListBatchPredictionJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListBatchPredictionJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -5123,11 +4891,12 @@ async def test_list_batch_prediction_jobs_async_from_dict(): def test_list_batch_prediction_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListBatchPredictionJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5135,7 +4904,6 @@ def test_list_batch_prediction_jobs_field_headers(): type(client.transport.list_batch_prediction_jobs), "__call__" ) as call: call.return_value = job_service.ListBatchPredictionJobsResponse() - client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -5150,11 +4918,12 @@ def test_list_batch_prediction_jobs_field_headers(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListBatchPredictionJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5164,7 +4933,6 @@ async def test_list_batch_prediction_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListBatchPredictionJobsResponse() ) - await client.list_batch_prediction_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -5178,7 +4946,7 @@ async def test_list_batch_prediction_jobs_field_headers_async(): def test_list_batch_prediction_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5186,7 +4954,6 @@ def test_list_batch_prediction_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListBatchPredictionJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_batch_prediction_jobs(parent="parent_value",) @@ -5195,12 +4962,11 @@ def test_list_batch_prediction_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_batch_prediction_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5212,7 +4978,7 @@ def test_list_batch_prediction_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5232,13 +4998,12 @@ async def test_list_batch_prediction_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_batch_prediction_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5249,7 +5014,7 @@ async def test_list_batch_prediction_jobs_flattened_error_async(): def test_list_batch_prediction_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5297,7 +5062,7 @@ def test_list_batch_prediction_jobs_pager(): def test_list_batch_prediction_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5335,7 +5100,7 @@ def test_list_batch_prediction_jobs_pages(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5382,7 +5147,7 @@ async def test_list_batch_prediction_jobs_async_pager(): @pytest.mark.asyncio async def test_list_batch_prediction_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5426,7 +5191,7 @@ def test_delete_batch_prediction_job( transport: str = "grpc", request_type=job_service.DeleteBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5439,13 +5204,11 @@ def test_delete_batch_prediction_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5460,7 +5223,7 @@ def test_delete_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5470,7 +5233,6 @@ def test_delete_batch_prediction_job_empty_call(): client.delete_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteBatchPredictionJobRequest() @@ -5480,7 +5242,7 @@ async def test_delete_batch_prediction_job_async( request_type=job_service.DeleteBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5495,13 +5257,11 @@ async def test_delete_batch_prediction_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5514,11 +5274,12 @@ async def test_delete_batch_prediction_job_async_from_dict(): def test_delete_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5526,7 +5287,6 @@ def test_delete_batch_prediction_job_field_headers(): type(client.transport.delete_batch_prediction_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5541,11 +5301,12 @@ def test_delete_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_delete_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5555,7 +5316,6 @@ async def test_delete_batch_prediction_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5569,7 +5329,7 @@ async def test_delete_batch_prediction_job_field_headers_async(): def test_delete_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5577,7 +5337,6 @@ def test_delete_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_batch_prediction_job(name="name_value",) @@ -5586,12 +5345,11 @@ def test_delete_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5603,7 +5361,7 @@ def test_delete_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_delete_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5623,13 +5381,12 @@ async def test_delete_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5643,7 +5400,7 @@ def test_cancel_batch_prediction_job( transport: str = "grpc", request_type=job_service.CancelBatchPredictionJobRequest ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5656,13 +5413,11 @@ def test_cancel_batch_prediction_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5677,7 +5432,7 @@ def test_cancel_batch_prediction_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5687,7 +5442,6 @@ def test_cancel_batch_prediction_job_empty_call(): client.cancel_batch_prediction_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelBatchPredictionJobRequest() @@ -5697,7 +5451,7 @@ async def test_cancel_batch_prediction_job_async( request_type=job_service.CancelBatchPredictionJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5710,13 +5464,11 @@ async def test_cancel_batch_prediction_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CancelBatchPredictionJobRequest() # Establish that the response is the type that we expect. @@ -5729,11 +5481,12 @@ async def test_cancel_batch_prediction_job_async_from_dict(): def test_cancel_batch_prediction_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5741,7 +5494,6 @@ def test_cancel_batch_prediction_job_field_headers(): type(client.transport.cancel_batch_prediction_job), "__call__" ) as call: call.return_value = None - client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5756,11 +5508,12 @@ def test_cancel_batch_prediction_job_field_headers(): @pytest.mark.asyncio async def test_cancel_batch_prediction_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CancelBatchPredictionJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5768,7 +5521,6 @@ async def test_cancel_batch_prediction_job_field_headers_async(): type(client.transport.cancel_batch_prediction_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_batch_prediction_job(request) # Establish that the underlying gRPC stub method was called. @@ -5782,7 +5534,7 @@ async def test_cancel_batch_prediction_job_field_headers_async(): def test_cancel_batch_prediction_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5790,7 +5542,6 @@ def test_cancel_batch_prediction_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_batch_prediction_job(name="name_value",) @@ -5799,12 +5550,11 @@ def test_cancel_batch_prediction_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_batch_prediction_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5816,7 +5566,7 @@ def test_cancel_batch_prediction_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_batch_prediction_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5834,13 +5584,12 @@ async def test_cancel_batch_prediction_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_batch_prediction_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5855,7 +5604,7 @@ def test_create_model_deployment_monitoring_job( request_type=job_service.CreateModelDeploymentMonitoringJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5876,36 +5625,26 @@ def test_create_model_deployment_monitoring_job( predict_instance_schema_uri="predict_instance_schema_uri_value", analysis_instance_schema_uri="analysis_instance_schema_uri_value", ) - response = client.create_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. - assert isinstance( response, gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob ) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.endpoint == "endpoint_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert ( response.schedule_state == gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob.MonitoringScheduleState.PENDING ) - assert response.predict_instance_schema_uri == "predict_instance_schema_uri_value" - assert response.analysis_instance_schema_uri == "analysis_instance_schema_uri_value" @@ -5917,7 +5656,7 @@ def test_create_model_deployment_monitoring_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5927,7 +5666,6 @@ def test_create_model_deployment_monitoring_job_empty_call(): client.create_model_deployment_monitoring_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateModelDeploymentMonitoringJobRequest() @@ -5937,7 +5675,7 @@ async def test_create_model_deployment_monitoring_job_async( request_type=job_service.CreateModelDeploymentMonitoringJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5960,35 +5698,26 @@ async def test_create_model_deployment_monitoring_job_async( analysis_instance_schema_uri="analysis_instance_schema_uri_value", ) ) - response = await client.create_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.CreateModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. assert isinstance( response, gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob ) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.endpoint == "endpoint_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert ( response.schedule_state == gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob.MonitoringScheduleState.PENDING ) - assert response.predict_instance_schema_uri == "predict_instance_schema_uri_value" - assert response.analysis_instance_schema_uri == "analysis_instance_schema_uri_value" @@ -5998,11 +5727,12 @@ async def test_create_model_deployment_monitoring_job_async_from_dict(): def test_create_model_deployment_monitoring_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateModelDeploymentMonitoringJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6012,7 +5742,6 @@ def test_create_model_deployment_monitoring_job_field_headers(): call.return_value = ( gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob() ) - client.create_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -6027,11 +5756,12 @@ def test_create_model_deployment_monitoring_job_field_headers(): @pytest.mark.asyncio async def test_create_model_deployment_monitoring_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.CreateModelDeploymentMonitoringJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6041,7 +5771,6 @@ async def test_create_model_deployment_monitoring_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob() ) - await client.create_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -6055,7 +5784,7 @@ async def test_create_model_deployment_monitoring_job_field_headers_async(): def test_create_model_deployment_monitoring_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6065,7 +5794,6 @@ def test_create_model_deployment_monitoring_job_flattened(): call.return_value = ( gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob() ) - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_model_deployment_monitoring_job( @@ -6079,9 +5807,7 @@ def test_create_model_deployment_monitoring_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].model_deployment_monitoring_job == gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( @@ -6090,7 +5816,7 @@ def test_create_model_deployment_monitoring_job_flattened(): def test_create_model_deployment_monitoring_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6106,7 +5832,7 @@ def test_create_model_deployment_monitoring_job_flattened_error(): @pytest.mark.asyncio async def test_create_model_deployment_monitoring_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6133,9 +5859,7 @@ async def test_create_model_deployment_monitoring_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].model_deployment_monitoring_job == gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( @@ -6145,7 +5869,7 @@ async def test_create_model_deployment_monitoring_job_flattened_async(): @pytest.mark.asyncio async def test_create_model_deployment_monitoring_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6164,7 +5888,7 @@ def test_search_model_deployment_monitoring_stats_anomalies( request_type=job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6180,24 +5904,20 @@ def test_search_model_deployment_monitoring_stats_anomalies( call.return_value = job_service.SearchModelDeploymentMonitoringStatsAnomaliesResponse( next_page_token="next_page_token_value", ) - response = client.search_model_deployment_monitoring_stats_anomalies(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert ( args[0] == job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ) # Establish that the response is the type that we expect. - assert isinstance( response, pagers.SearchModelDeploymentMonitoringStatsAnomaliesPager ) - assert response.next_page_token == "next_page_token_value" @@ -6209,7 +5929,7 @@ def test_search_model_deployment_monitoring_stats_anomalies_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6220,7 +5940,6 @@ def test_search_model_deployment_monitoring_stats_anomalies_empty_call(): client.search_model_deployment_monitoring_stats_anomalies() call.assert_called() _, args, _ = call.mock_calls[0] - assert ( args[0] == job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest() @@ -6233,7 +5952,7 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async( request_type=job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6251,7 +5970,6 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async( next_page_token="next_page_token_value", ) ) - response = await client.search_model_deployment_monitoring_stats_anomalies( request ) @@ -6259,7 +5977,6 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async( # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert ( args[0] == job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest() @@ -6269,7 +5986,6 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async( assert isinstance( response, pagers.SearchModelDeploymentMonitoringStatsAnomaliesAsyncPager ) - assert response.next_page_token == "next_page_token_value" @@ -6281,11 +5997,12 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async_from_dic def test_search_model_deployment_monitoring_stats_anomalies_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest() + request.model_deployment_monitoring_job = "model_deployment_monitoring_job/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6296,7 +6013,6 @@ def test_search_model_deployment_monitoring_stats_anomalies_field_headers(): call.return_value = ( job_service.SearchModelDeploymentMonitoringStatsAnomaliesResponse() ) - client.search_model_deployment_monitoring_stats_anomalies(request) # Establish that the underlying gRPC stub method was called. @@ -6314,11 +6030,12 @@ def test_search_model_deployment_monitoring_stats_anomalies_field_headers(): @pytest.mark.asyncio async def test_search_model_deployment_monitoring_stats_anomalies_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.SearchModelDeploymentMonitoringStatsAnomaliesRequest() + request.model_deployment_monitoring_job = "model_deployment_monitoring_job/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6329,7 +6046,6 @@ async def test_search_model_deployment_monitoring_stats_anomalies_field_headers_ call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.SearchModelDeploymentMonitoringStatsAnomaliesResponse() ) - await client.search_model_deployment_monitoring_stats_anomalies(request) # Establish that the underlying gRPC stub method was called. @@ -6346,7 +6062,7 @@ async def test_search_model_deployment_monitoring_stats_anomalies_field_headers_ def test_search_model_deployment_monitoring_stats_anomalies_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6357,7 +6073,6 @@ def test_search_model_deployment_monitoring_stats_anomalies_flattened(): call.return_value = ( job_service.SearchModelDeploymentMonitoringStatsAnomaliesResponse() ) - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_model_deployment_monitoring_stats_anomalies( @@ -6369,17 +6084,15 @@ def test_search_model_deployment_monitoring_stats_anomalies_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert ( args[0].model_deployment_monitoring_job == "model_deployment_monitoring_job_value" ) - assert args[0].deployed_model_id == "deployed_model_id_value" def test_search_model_deployment_monitoring_stats_anomalies_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6393,7 +6106,7 @@ def test_search_model_deployment_monitoring_stats_anomalies_flattened_error(): @pytest.mark.asyncio async def test_search_model_deployment_monitoring_stats_anomalies_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6419,18 +6132,16 @@ async def test_search_model_deployment_monitoring_stats_anomalies_flattened_asyn # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert ( args[0].model_deployment_monitoring_job == "model_deployment_monitoring_job_value" ) - assert args[0].deployed_model_id == "deployed_model_id_value" @pytest.mark.asyncio async def test_search_model_deployment_monitoring_stats_anomalies_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6443,7 +6154,7 @@ async def test_search_model_deployment_monitoring_stats_anomalies_flattened_erro def test_search_model_deployment_monitoring_stats_anomalies_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6499,7 +6210,7 @@ def test_search_model_deployment_monitoring_stats_anomalies_pager(): def test_search_model_deployment_monitoring_stats_anomalies_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6542,7 +6253,7 @@ def test_search_model_deployment_monitoring_stats_anomalies_pages(): @pytest.mark.asyncio async def test_search_model_deployment_monitoring_stats_anomalies_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6596,7 +6307,7 @@ async def test_search_model_deployment_monitoring_stats_anomalies_async_pager(): @pytest.mark.asyncio async def test_search_model_deployment_monitoring_stats_anomalies_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6645,7 +6356,7 @@ def test_get_model_deployment_monitoring_job( request_type=job_service.GetModelDeploymentMonitoringJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6666,36 +6377,26 @@ def test_get_model_deployment_monitoring_job( predict_instance_schema_uri="predict_instance_schema_uri_value", analysis_instance_schema_uri="analysis_instance_schema_uri_value", ) - response = client.get_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. - assert isinstance( response, model_deployment_monitoring_job.ModelDeploymentMonitoringJob ) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.endpoint == "endpoint_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert ( response.schedule_state == model_deployment_monitoring_job.ModelDeploymentMonitoringJob.MonitoringScheduleState.PENDING ) - assert response.predict_instance_schema_uri == "predict_instance_schema_uri_value" - assert response.analysis_instance_schema_uri == "analysis_instance_schema_uri_value" @@ -6707,7 +6408,7 @@ def test_get_model_deployment_monitoring_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6717,7 +6418,6 @@ def test_get_model_deployment_monitoring_job_empty_call(): client.get_model_deployment_monitoring_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetModelDeploymentMonitoringJobRequest() @@ -6727,7 +6427,7 @@ async def test_get_model_deployment_monitoring_job_async( request_type=job_service.GetModelDeploymentMonitoringJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6750,35 +6450,26 @@ async def test_get_model_deployment_monitoring_job_async( analysis_instance_schema_uri="analysis_instance_schema_uri_value", ) ) - response = await client.get_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.GetModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. assert isinstance( response, model_deployment_monitoring_job.ModelDeploymentMonitoringJob ) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.endpoint == "endpoint_value" - assert response.state == job_state.JobState.JOB_STATE_QUEUED - assert ( response.schedule_state == model_deployment_monitoring_job.ModelDeploymentMonitoringJob.MonitoringScheduleState.PENDING ) - assert response.predict_instance_schema_uri == "predict_instance_schema_uri_value" - assert response.analysis_instance_schema_uri == "analysis_instance_schema_uri_value" @@ -6788,11 +6479,12 @@ async def test_get_model_deployment_monitoring_job_async_from_dict(): def test_get_model_deployment_monitoring_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6802,7 +6494,6 @@ def test_get_model_deployment_monitoring_job_field_headers(): call.return_value = ( model_deployment_monitoring_job.ModelDeploymentMonitoringJob() ) - client.get_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -6817,11 +6508,12 @@ def test_get_model_deployment_monitoring_job_field_headers(): @pytest.mark.asyncio async def test_get_model_deployment_monitoring_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.GetModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6831,7 +6523,6 @@ async def test_get_model_deployment_monitoring_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_deployment_monitoring_job.ModelDeploymentMonitoringJob() ) - await client.get_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -6845,7 +6536,7 @@ async def test_get_model_deployment_monitoring_job_field_headers_async(): def test_get_model_deployment_monitoring_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6855,7 +6546,6 @@ def test_get_model_deployment_monitoring_job_flattened(): call.return_value = ( model_deployment_monitoring_job.ModelDeploymentMonitoringJob() ) - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_model_deployment_monitoring_job(name="name_value",) @@ -6864,12 +6554,11 @@ def test_get_model_deployment_monitoring_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_model_deployment_monitoring_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6881,7 +6570,7 @@ def test_get_model_deployment_monitoring_job_flattened_error(): @pytest.mark.asyncio async def test_get_model_deployment_monitoring_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6903,13 +6592,12 @@ async def test_get_model_deployment_monitoring_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_model_deployment_monitoring_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6924,7 +6612,7 @@ def test_list_model_deployment_monitoring_jobs( request_type=job_service.ListModelDeploymentMonitoringJobsRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6939,19 +6627,15 @@ def test_list_model_deployment_monitoring_jobs( call.return_value = job_service.ListModelDeploymentMonitoringJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_model_deployment_monitoring_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListModelDeploymentMonitoringJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListModelDeploymentMonitoringJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -6963,7 +6647,7 @@ def test_list_model_deployment_monitoring_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6973,7 +6657,6 @@ def test_list_model_deployment_monitoring_jobs_empty_call(): client.list_model_deployment_monitoring_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListModelDeploymentMonitoringJobsRequest() @@ -6983,7 +6666,7 @@ async def test_list_model_deployment_monitoring_jobs_async( request_type=job_service.ListModelDeploymentMonitoringJobsRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7000,18 +6683,15 @@ async def test_list_model_deployment_monitoring_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_model_deployment_monitoring_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ListModelDeploymentMonitoringJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListModelDeploymentMonitoringJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -7021,11 +6701,12 @@ async def test_list_model_deployment_monitoring_jobs_async_from_dict(): def test_list_model_deployment_monitoring_jobs_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListModelDeploymentMonitoringJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7033,7 +6714,6 @@ def test_list_model_deployment_monitoring_jobs_field_headers(): type(client.transport.list_model_deployment_monitoring_jobs), "__call__" ) as call: call.return_value = job_service.ListModelDeploymentMonitoringJobsResponse() - client.list_model_deployment_monitoring_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -7048,11 +6728,12 @@ def test_list_model_deployment_monitoring_jobs_field_headers(): @pytest.mark.asyncio async def test_list_model_deployment_monitoring_jobs_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ListModelDeploymentMonitoringJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7062,7 +6743,6 @@ async def test_list_model_deployment_monitoring_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListModelDeploymentMonitoringJobsResponse() ) - await client.list_model_deployment_monitoring_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -7076,7 +6756,7 @@ async def test_list_model_deployment_monitoring_jobs_field_headers_async(): def test_list_model_deployment_monitoring_jobs_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7084,7 +6764,6 @@ def test_list_model_deployment_monitoring_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListModelDeploymentMonitoringJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_model_deployment_monitoring_jobs(parent="parent_value",) @@ -7093,12 +6772,11 @@ def test_list_model_deployment_monitoring_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_model_deployment_monitoring_jobs_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7111,7 +6789,7 @@ def test_list_model_deployment_monitoring_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_model_deployment_monitoring_jobs_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7133,13 +6811,12 @@ async def test_list_model_deployment_monitoring_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_model_deployment_monitoring_jobs_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7151,7 +6828,7 @@ async def test_list_model_deployment_monitoring_jobs_flattened_error_async(): def test_list_model_deployment_monitoring_jobs_pager(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7202,7 +6879,7 @@ def test_list_model_deployment_monitoring_jobs_pager(): def test_list_model_deployment_monitoring_jobs_pages(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7242,7 +6919,7 @@ def test_list_model_deployment_monitoring_jobs_pages(): @pytest.mark.asyncio async def test_list_model_deployment_monitoring_jobs_async_pager(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7292,7 +6969,7 @@ async def test_list_model_deployment_monitoring_jobs_async_pager(): @pytest.mark.asyncio async def test_list_model_deployment_monitoring_jobs_async_pages(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7341,7 +7018,7 @@ def test_update_model_deployment_monitoring_job( request_type=job_service.UpdateModelDeploymentMonitoringJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7354,13 +7031,11 @@ def test_update_model_deployment_monitoring_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -7375,7 +7050,7 @@ def test_update_model_deployment_monitoring_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7385,7 +7060,6 @@ def test_update_model_deployment_monitoring_job_empty_call(): client.update_model_deployment_monitoring_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateModelDeploymentMonitoringJobRequest() @@ -7395,7 +7069,7 @@ async def test_update_model_deployment_monitoring_job_async( request_type=job_service.UpdateModelDeploymentMonitoringJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7410,13 +7084,11 @@ async def test_update_model_deployment_monitoring_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.UpdateModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -7429,11 +7101,12 @@ async def test_update_model_deployment_monitoring_job_async_from_dict(): def test_update_model_deployment_monitoring_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.UpdateModelDeploymentMonitoringJobRequest() + request.model_deployment_monitoring_job.name = ( "model_deployment_monitoring_job.name/value" ) @@ -7443,7 +7116,6 @@ def test_update_model_deployment_monitoring_job_field_headers(): type(client.transport.update_model_deployment_monitoring_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -7461,11 +7133,12 @@ def test_update_model_deployment_monitoring_job_field_headers(): @pytest.mark.asyncio async def test_update_model_deployment_monitoring_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.UpdateModelDeploymentMonitoringJobRequest() + request.model_deployment_monitoring_job.name = ( "model_deployment_monitoring_job.name/value" ) @@ -7477,7 +7150,6 @@ async def test_update_model_deployment_monitoring_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -7494,7 +7166,7 @@ async def test_update_model_deployment_monitoring_job_field_headers_async(): def test_update_model_deployment_monitoring_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7502,32 +7174,29 @@ def test_update_model_deployment_monitoring_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_model_deployment_monitoring_job( model_deployment_monitoring_job=gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[ 0 ].model_deployment_monitoring_job == gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_model_deployment_monitoring_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7537,13 +7206,13 @@ def test_update_model_deployment_monitoring_job_flattened_error(): model_deployment_monitoring_job=gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_model_deployment_monitoring_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7561,26 +7230,24 @@ async def test_update_model_deployment_monitoring_job_flattened_async(): model_deployment_monitoring_job=gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[ 0 ].model_deployment_monitoring_job == gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_model_deployment_monitoring_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7590,7 +7257,7 @@ async def test_update_model_deployment_monitoring_job_flattened_error_async(): model_deployment_monitoring_job=gca_model_deployment_monitoring_job.ModelDeploymentMonitoringJob( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -7599,7 +7266,7 @@ def test_delete_model_deployment_monitoring_job( request_type=job_service.DeleteModelDeploymentMonitoringJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7612,13 +7279,11 @@ def test_delete_model_deployment_monitoring_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -7633,7 +7298,7 @@ def test_delete_model_deployment_monitoring_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7643,7 +7308,6 @@ def test_delete_model_deployment_monitoring_job_empty_call(): client.delete_model_deployment_monitoring_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteModelDeploymentMonitoringJobRequest() @@ -7653,7 +7317,7 @@ async def test_delete_model_deployment_monitoring_job_async( request_type=job_service.DeleteModelDeploymentMonitoringJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7668,13 +7332,11 @@ async def test_delete_model_deployment_monitoring_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.DeleteModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -7687,11 +7349,12 @@ async def test_delete_model_deployment_monitoring_job_async_from_dict(): def test_delete_model_deployment_monitoring_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7699,7 +7362,6 @@ def test_delete_model_deployment_monitoring_job_field_headers(): type(client.transport.delete_model_deployment_monitoring_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -7714,11 +7376,12 @@ def test_delete_model_deployment_monitoring_job_field_headers(): @pytest.mark.asyncio async def test_delete_model_deployment_monitoring_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.DeleteModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7728,7 +7391,6 @@ async def test_delete_model_deployment_monitoring_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -7742,7 +7404,7 @@ async def test_delete_model_deployment_monitoring_job_field_headers_async(): def test_delete_model_deployment_monitoring_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7750,7 +7412,6 @@ def test_delete_model_deployment_monitoring_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_model_deployment_monitoring_job(name="name_value",) @@ -7759,12 +7420,11 @@ def test_delete_model_deployment_monitoring_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_model_deployment_monitoring_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7776,7 +7436,7 @@ def test_delete_model_deployment_monitoring_job_flattened_error(): @pytest.mark.asyncio async def test_delete_model_deployment_monitoring_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7798,13 +7458,12 @@ async def test_delete_model_deployment_monitoring_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_model_deployment_monitoring_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7819,7 +7478,7 @@ def test_pause_model_deployment_monitoring_job( request_type=job_service.PauseModelDeploymentMonitoringJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7832,13 +7491,11 @@ def test_pause_model_deployment_monitoring_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.pause_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.PauseModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -7853,7 +7510,7 @@ def test_pause_model_deployment_monitoring_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7863,7 +7520,6 @@ def test_pause_model_deployment_monitoring_job_empty_call(): client.pause_model_deployment_monitoring_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.PauseModelDeploymentMonitoringJobRequest() @@ -7873,7 +7529,7 @@ async def test_pause_model_deployment_monitoring_job_async( request_type=job_service.PauseModelDeploymentMonitoringJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7886,13 +7542,11 @@ async def test_pause_model_deployment_monitoring_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.pause_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.PauseModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -7905,11 +7559,12 @@ async def test_pause_model_deployment_monitoring_job_async_from_dict(): def test_pause_model_deployment_monitoring_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.PauseModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7917,7 +7572,6 @@ def test_pause_model_deployment_monitoring_job_field_headers(): type(client.transport.pause_model_deployment_monitoring_job), "__call__" ) as call: call.return_value = None - client.pause_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -7932,11 +7586,12 @@ def test_pause_model_deployment_monitoring_job_field_headers(): @pytest.mark.asyncio async def test_pause_model_deployment_monitoring_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.PauseModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7944,7 +7599,6 @@ async def test_pause_model_deployment_monitoring_job_field_headers_async(): type(client.transport.pause_model_deployment_monitoring_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.pause_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -7958,7 +7612,7 @@ async def test_pause_model_deployment_monitoring_job_field_headers_async(): def test_pause_model_deployment_monitoring_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7966,7 +7620,6 @@ def test_pause_model_deployment_monitoring_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.pause_model_deployment_monitoring_job(name="name_value",) @@ -7975,12 +7628,11 @@ def test_pause_model_deployment_monitoring_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_pause_model_deployment_monitoring_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7992,7 +7644,7 @@ def test_pause_model_deployment_monitoring_job_flattened_error(): @pytest.mark.asyncio async def test_pause_model_deployment_monitoring_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8012,13 +7664,12 @@ async def test_pause_model_deployment_monitoring_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_pause_model_deployment_monitoring_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -8033,7 +7684,7 @@ def test_resume_model_deployment_monitoring_job( request_type=job_service.ResumeModelDeploymentMonitoringJobRequest, ): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8046,13 +7697,11 @@ def test_resume_model_deployment_monitoring_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.resume_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ResumeModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -8067,7 +7716,7 @@ def test_resume_model_deployment_monitoring_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -8077,7 +7726,6 @@ def test_resume_model_deployment_monitoring_job_empty_call(): client.resume_model_deployment_monitoring_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ResumeModelDeploymentMonitoringJobRequest() @@ -8087,7 +7735,7 @@ async def test_resume_model_deployment_monitoring_job_async( request_type=job_service.ResumeModelDeploymentMonitoringJobRequest, ): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -8100,13 +7748,11 @@ async def test_resume_model_deployment_monitoring_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.resume_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == job_service.ResumeModelDeploymentMonitoringJobRequest() # Establish that the response is the type that we expect. @@ -8119,11 +7765,12 @@ async def test_resume_model_deployment_monitoring_job_async_from_dict(): def test_resume_model_deployment_monitoring_job_field_headers(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ResumeModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8131,7 +7778,6 @@ def test_resume_model_deployment_monitoring_job_field_headers(): type(client.transport.resume_model_deployment_monitoring_job), "__call__" ) as call: call.return_value = None - client.resume_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -8146,11 +7792,12 @@ def test_resume_model_deployment_monitoring_job_field_headers(): @pytest.mark.asyncio async def test_resume_model_deployment_monitoring_job_field_headers_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = job_service.ResumeModelDeploymentMonitoringJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -8158,7 +7805,6 @@ async def test_resume_model_deployment_monitoring_job_field_headers_async(): type(client.transport.resume_model_deployment_monitoring_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.resume_model_deployment_monitoring_job(request) # Establish that the underlying gRPC stub method was called. @@ -8172,7 +7818,7 @@ async def test_resume_model_deployment_monitoring_job_field_headers_async(): def test_resume_model_deployment_monitoring_job_flattened(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8180,7 +7826,6 @@ def test_resume_model_deployment_monitoring_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.resume_model_deployment_monitoring_job(name="name_value",) @@ -8189,12 +7834,11 @@ def test_resume_model_deployment_monitoring_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_resume_model_deployment_monitoring_job_flattened_error(): - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -8206,7 +7850,7 @@ def test_resume_model_deployment_monitoring_job_flattened_error(): @pytest.mark.asyncio async def test_resume_model_deployment_monitoring_job_flattened_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -8226,13 +7870,12 @@ async def test_resume_model_deployment_monitoring_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_resume_model_deployment_monitoring_job_flattened_error_async(): - client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -8245,16 +7888,16 @@ async def test_resume_model_deployment_monitoring_job_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = JobServiceClient( @@ -8264,7 +7907,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = JobServiceClient( @@ -8275,7 +7918,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = JobServiceClient(transport=transport) assert client.transport is transport @@ -8284,13 +7927,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.JobServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.JobServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -8302,23 +7945,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) + client = JobServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.JobServiceGrpcTransport,) def test_job_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.JobServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -8330,7 +7973,7 @@ def test_job_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.JobServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -8375,15 +8018,37 @@ def test_job_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_job_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.job_service.transports.JobServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.JobServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_job_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.job_service.transports.JobServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.JobServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -8396,19 +8061,33 @@ def test_job_service_base_transport_with_credentials_file(): def test_job_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.job_service.transports.JobServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.JobServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_job_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + JobServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_job_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) JobServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -8416,26 +8095,156 @@ def test_job_service_auth_adc(): ) -def test_job_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [transports.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport,], +) +@requires_google_auth_gte_1_25_0 +def test_job_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.JobServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [transports.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport,], +) +@requires_google_auth_lt_1_25_0 +def test_job_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_job_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_job_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.JobServiceGrpcTransport, grpc_helpers), + (transports.JobServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_job_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [transports.JobServiceGrpcTransport, transports.JobServiceGrpcAsyncIOTransport], ) def test_job_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -8474,7 +8283,7 @@ def test_job_service_grpc_transport_client_cert_source_for_mtls(transport_class) def test_job_service_host_no_port(): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -8484,7 +8293,7 @@ def test_job_service_host_no_port(): def test_job_service_host_with_port(): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -8535,9 +8344,9 @@ def test_job_service_transport_channel_mtls_with_client_cert_source(transport_cl mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -8610,7 +8419,7 @@ def test_job_service_transport_channel_mtls_with_adc(transport_class): def test_job_service_grpc_lro_client(): client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -8623,7 +8432,7 @@ def test_job_service_grpc_lro_client(): def test_job_service_grpc_lro_async_client(): client = JobServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -8638,7 +8447,6 @@ def test_batch_prediction_job_path(): project = "squid" location = "clam" batch_prediction_job = "whelk" - expected = "projects/{project}/locations/{location}/batchPredictionJobs/{batch_prediction_job}".format( project=project, location=location, batch_prediction_job=batch_prediction_job, ) @@ -8665,7 +8473,6 @@ def test_custom_job_path(): project = "cuttlefish" location = "mussel" custom_job = "winkle" - expected = "projects/{project}/locations/{location}/customJobs/{custom_job}".format( project=project, location=location, custom_job=custom_job, ) @@ -8690,7 +8497,6 @@ def test_data_labeling_job_path(): project = "squid" location = "clam" data_labeling_job = "whelk" - expected = "projects/{project}/locations/{location}/dataLabelingJobs/{data_labeling_job}".format( project=project, location=location, data_labeling_job=data_labeling_job, ) @@ -8717,7 +8523,6 @@ def test_dataset_path(): project = "cuttlefish" location = "mussel" dataset = "winkle" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( project=project, location=location, dataset=dataset, ) @@ -8742,7 +8547,6 @@ def test_endpoint_path(): project = "squid" location = "clam" endpoint = "whelk" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -8767,7 +8571,6 @@ def test_hyperparameter_tuning_job_path(): project = "cuttlefish" location = "mussel" hyperparameter_tuning_job = "winkle" - expected = "projects/{project}/locations/{location}/hyperparameterTuningJobs/{hyperparameter_tuning_job}".format( project=project, location=location, @@ -8796,7 +8599,6 @@ def test_model_path(): project = "squid" location = "clam" model = "whelk" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -8821,7 +8623,6 @@ def test_model_deployment_monitoring_job_path(): project = "cuttlefish" location = "mussel" model_deployment_monitoring_job = "winkle" - expected = "projects/{project}/locations/{location}/modelDeploymentMonitoringJobs/{model_deployment_monitoring_job}".format( project=project, location=location, @@ -8849,7 +8650,6 @@ def test_parse_model_deployment_monitoring_job_path(): def test_network_path(): project = "squid" network = "clam" - expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, ) @@ -8873,7 +8673,6 @@ def test_tensorboard_path(): project = "oyster" location = "nudibranch" tensorboard = "cuttlefish" - expected = "projects/{project}/locations/{location}/tensorboards/{tensorboard}".format( project=project, location=location, tensorboard=tensorboard, ) @@ -8899,7 +8698,6 @@ def test_trial_path(): location = "abalone" study = "squid" trial = "clam" - expected = "projects/{project}/locations/{location}/studies/{study}/trials/{trial}".format( project=project, location=location, study=study, trial=trial, ) @@ -8923,7 +8721,6 @@ def test_parse_trial_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -8944,7 +8741,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = JobServiceClient.common_folder_path(folder) assert expected == actual @@ -8963,7 +8759,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = JobServiceClient.common_organization_path(organization) assert expected == actual @@ -8982,7 +8777,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = JobServiceClient.common_project_path(project) assert expected == actual @@ -9002,7 +8796,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -9029,7 +8822,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.JobServiceTransport, "_prep_wrapped_messages" ) as prep: client = JobServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -9038,6 +8831,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = JobServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py index 45fd76e099..2b2ce80c5c 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_metadata_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.metadata_service import ( MetadataServiceAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.aiplatform_v1beta1.services.metadata_service import pagers from google.cloud.aiplatform_v1beta1.services.metadata_service import transports +from google.cloud.aiplatform_v1beta1.services.metadata_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.metadata_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import artifact from google.cloud.aiplatform_v1beta1.types import artifact as gca_artifact from google.cloud.aiplatform_v1beta1.types import context @@ -60,9 +65,33 @@ from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -113,7 +142,7 @@ def test__get_default_mtls_endpoint(): "client_class", [MetadataServiceClient, MetadataServiceAsyncClient,] ) def test_metadata_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -130,7 +159,7 @@ def test_metadata_service_client_from_service_account_info(client_class): "client_class", [MetadataServiceClient, MetadataServiceAsyncClient,] ) def test_metadata_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -183,7 +212,7 @@ def test_metadata_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(MetadataServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -481,7 +510,7 @@ def test_create_metadata_store( transport: str = "grpc", request_type=metadata_service.CreateMetadataStoreRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -494,13 +523,11 @@ def test_create_metadata_store( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_metadata_store(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateMetadataStoreRequest() # Establish that the response is the type that we expect. @@ -515,7 +542,7 @@ def test_create_metadata_store_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -525,7 +552,6 @@ def test_create_metadata_store_empty_call(): client.create_metadata_store() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateMetadataStoreRequest() @@ -535,7 +561,7 @@ async def test_create_metadata_store_async( request_type=metadata_service.CreateMetadataStoreRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -550,13 +576,11 @@ async def test_create_metadata_store_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_metadata_store(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateMetadataStoreRequest() # Establish that the response is the type that we expect. @@ -569,11 +593,12 @@ async def test_create_metadata_store_async_from_dict(): def test_create_metadata_store_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateMetadataStoreRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -581,7 +606,6 @@ def test_create_metadata_store_field_headers(): type(client.transport.create_metadata_store), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_metadata_store(request) # Establish that the underlying gRPC stub method was called. @@ -596,11 +620,14 @@ def test_create_metadata_store_field_headers(): @pytest.mark.asyncio async def test_create_metadata_store_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateMetadataStoreRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -610,7 +637,6 @@ async def test_create_metadata_store_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_metadata_store(request) # Establish that the underlying gRPC stub method was called. @@ -624,7 +650,7 @@ async def test_create_metadata_store_field_headers_async(): def test_create_metadata_store_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -632,7 +658,6 @@ def test_create_metadata_store_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_metadata_store( @@ -645,18 +670,15 @@ def test_create_metadata_store_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].metadata_store == gca_metadata_store.MetadataStore( name="name_value" ) - assert args[0].metadata_store_id == "metadata_store_id_value" def test_create_metadata_store_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -671,7 +693,9 @@ def test_create_metadata_store_flattened_error(): @pytest.mark.asyncio async def test_create_metadata_store_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -695,19 +719,18 @@ async def test_create_metadata_store_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].metadata_store == gca_metadata_store.MetadataStore( name="name_value" ) - assert args[0].metadata_store_id == "metadata_store_id_value" @pytest.mark.asyncio async def test_create_metadata_store_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -724,7 +747,7 @@ def test_get_metadata_store( transport: str = "grpc", request_type=metadata_service.GetMetadataStoreRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -739,21 +762,16 @@ def test_get_metadata_store( call.return_value = metadata_store.MetadataStore( name="name_value", description="description_value", ) - response = client.get_metadata_store(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetMetadataStoreRequest() # Establish that the response is the type that we expect. - assert isinstance(response, metadata_store.MetadataStore) - assert response.name == "name_value" - assert response.description == "description_value" @@ -765,7 +783,7 @@ def test_get_metadata_store_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -775,7 +793,6 @@ def test_get_metadata_store_empty_call(): client.get_metadata_store() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetMetadataStoreRequest() @@ -785,7 +802,7 @@ async def test_get_metadata_store_async( request_type=metadata_service.GetMetadataStoreRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -802,20 +819,16 @@ async def test_get_metadata_store_async( name="name_value", description="description_value", ) ) - response = await client.get_metadata_store(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetMetadataStoreRequest() # Establish that the response is the type that we expect. assert isinstance(response, metadata_store.MetadataStore) - assert response.name == "name_value" - assert response.description == "description_value" @@ -825,11 +838,12 @@ async def test_get_metadata_store_async_from_dict(): def test_get_metadata_store_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetMetadataStoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -837,7 +851,6 @@ def test_get_metadata_store_field_headers(): type(client.transport.get_metadata_store), "__call__" ) as call: call.return_value = metadata_store.MetadataStore() - client.get_metadata_store(request) # Establish that the underlying gRPC stub method was called. @@ -852,11 +865,14 @@ def test_get_metadata_store_field_headers(): @pytest.mark.asyncio async def test_get_metadata_store_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetMetadataStoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -866,7 +882,6 @@ async def test_get_metadata_store_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_store.MetadataStore() ) - await client.get_metadata_store(request) # Establish that the underlying gRPC stub method was called. @@ -880,7 +895,7 @@ async def test_get_metadata_store_field_headers_async(): def test_get_metadata_store_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -888,7 +903,6 @@ def test_get_metadata_store_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_store.MetadataStore() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_metadata_store(name="name_value",) @@ -897,12 +911,11 @@ def test_get_metadata_store_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_metadata_store_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -914,7 +927,9 @@ def test_get_metadata_store_flattened_error(): @pytest.mark.asyncio async def test_get_metadata_store_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -934,13 +949,14 @@ async def test_get_metadata_store_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_metadata_store_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -954,7 +970,7 @@ def test_list_metadata_stores( transport: str = "grpc", request_type=metadata_service.ListMetadataStoresRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -969,19 +985,15 @@ def test_list_metadata_stores( call.return_value = metadata_service.ListMetadataStoresResponse( next_page_token="next_page_token_value", ) - response = client.list_metadata_stores(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListMetadataStoresRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMetadataStoresPager) - assert response.next_page_token == "next_page_token_value" @@ -993,7 +1005,7 @@ def test_list_metadata_stores_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1003,7 +1015,6 @@ def test_list_metadata_stores_empty_call(): client.list_metadata_stores() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListMetadataStoresRequest() @@ -1013,7 +1024,7 @@ async def test_list_metadata_stores_async( request_type=metadata_service.ListMetadataStoresRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1030,18 +1041,15 @@ async def test_list_metadata_stores_async( next_page_token="next_page_token_value", ) ) - response = await client.list_metadata_stores(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListMetadataStoresRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListMetadataStoresAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1051,11 +1059,12 @@ async def test_list_metadata_stores_async_from_dict(): def test_list_metadata_stores_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListMetadataStoresRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1063,7 +1072,6 @@ def test_list_metadata_stores_field_headers(): type(client.transport.list_metadata_stores), "__call__" ) as call: call.return_value = metadata_service.ListMetadataStoresResponse() - client.list_metadata_stores(request) # Establish that the underlying gRPC stub method was called. @@ -1078,11 +1086,14 @@ def test_list_metadata_stores_field_headers(): @pytest.mark.asyncio async def test_list_metadata_stores_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListMetadataStoresRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1092,7 +1103,6 @@ async def test_list_metadata_stores_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.ListMetadataStoresResponse() ) - await client.list_metadata_stores(request) # Establish that the underlying gRPC stub method was called. @@ -1106,7 +1116,7 @@ async def test_list_metadata_stores_field_headers_async(): def test_list_metadata_stores_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1114,7 +1124,6 @@ def test_list_metadata_stores_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.ListMetadataStoresResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_metadata_stores(parent="parent_value",) @@ -1123,12 +1132,11 @@ def test_list_metadata_stores_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_metadata_stores_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1140,7 +1148,9 @@ def test_list_metadata_stores_flattened_error(): @pytest.mark.asyncio async def test_list_metadata_stores_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1160,13 +1170,14 @@ async def test_list_metadata_stores_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_metadata_stores_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1177,7 +1188,7 @@ async def test_list_metadata_stores_flattened_error_async(): def test_list_metadata_stores_pager(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1223,7 +1234,7 @@ def test_list_metadata_stores_pager(): def test_list_metadata_stores_pages(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1261,7 +1272,9 @@ def test_list_metadata_stores_pages(): @pytest.mark.asyncio async def test_list_metadata_stores_async_pager(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1306,7 +1319,9 @@ async def test_list_metadata_stores_async_pager(): @pytest.mark.asyncio async def test_list_metadata_stores_async_pages(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1350,7 +1365,7 @@ def test_delete_metadata_store( transport: str = "grpc", request_type=metadata_service.DeleteMetadataStoreRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1363,13 +1378,11 @@ def test_delete_metadata_store( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_metadata_store(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.DeleteMetadataStoreRequest() # Establish that the response is the type that we expect. @@ -1384,7 +1397,7 @@ def test_delete_metadata_store_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1394,7 +1407,6 @@ def test_delete_metadata_store_empty_call(): client.delete_metadata_store() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.DeleteMetadataStoreRequest() @@ -1404,7 +1416,7 @@ async def test_delete_metadata_store_async( request_type=metadata_service.DeleteMetadataStoreRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1419,13 +1431,11 @@ async def test_delete_metadata_store_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_metadata_store(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.DeleteMetadataStoreRequest() # Establish that the response is the type that we expect. @@ -1438,11 +1448,12 @@ async def test_delete_metadata_store_async_from_dict(): def test_delete_metadata_store_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.DeleteMetadataStoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1450,7 +1461,6 @@ def test_delete_metadata_store_field_headers(): type(client.transport.delete_metadata_store), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_metadata_store(request) # Establish that the underlying gRPC stub method was called. @@ -1465,11 +1475,14 @@ def test_delete_metadata_store_field_headers(): @pytest.mark.asyncio async def test_delete_metadata_store_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.DeleteMetadataStoreRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1479,7 +1492,6 @@ async def test_delete_metadata_store_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_metadata_store(request) # Establish that the underlying gRPC stub method was called. @@ -1493,7 +1505,7 @@ async def test_delete_metadata_store_field_headers_async(): def test_delete_metadata_store_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1501,7 +1513,6 @@ def test_delete_metadata_store_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_metadata_store(name="name_value",) @@ -1510,12 +1521,11 @@ def test_delete_metadata_store_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_metadata_store_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1527,7 +1537,9 @@ def test_delete_metadata_store_flattened_error(): @pytest.mark.asyncio async def test_delete_metadata_store_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1547,13 +1559,14 @@ async def test_delete_metadata_store_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_metadata_store_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1567,7 +1580,7 @@ def test_create_artifact( transport: str = "grpc", request_type=metadata_service.CreateArtifactRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1587,33 +1600,22 @@ def test_create_artifact( schema_version="schema_version_value", description="description_value", ) - response = client.create_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateArtifactRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_artifact.Artifact) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.uri == "uri_value" - assert response.etag == "etag_value" - assert response.state == gca_artifact.Artifact.State.PENDING - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -1625,7 +1627,7 @@ def test_create_artifact_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1633,7 +1635,6 @@ def test_create_artifact_empty_call(): client.create_artifact() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateArtifactRequest() @@ -1642,7 +1643,7 @@ async def test_create_artifact_async( transport: str = "grpc_asyncio", request_type=metadata_service.CreateArtifactRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1664,32 +1665,22 @@ async def test_create_artifact_async( description="description_value", ) ) - response = await client.create_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateArtifactRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_artifact.Artifact) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.uri == "uri_value" - assert response.etag == "etag_value" - assert response.state == gca_artifact.Artifact.State.PENDING - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -1699,17 +1690,17 @@ async def test_create_artifact_async_from_dict(): def test_create_artifact_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateArtifactRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_artifact), "__call__") as call: call.return_value = gca_artifact.Artifact() - client.create_artifact(request) # Establish that the underlying gRPC stub method was called. @@ -1724,11 +1715,14 @@ def test_create_artifact_field_headers(): @pytest.mark.asyncio async def test_create_artifact_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateArtifactRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1736,7 +1730,6 @@ async def test_create_artifact_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_artifact.Artifact() ) - await client.create_artifact(request) # Establish that the underlying gRPC stub method was called. @@ -1750,13 +1743,12 @@ async def test_create_artifact_field_headers_async(): def test_create_artifact_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_artifact), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_artifact.Artifact() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_artifact( @@ -1769,16 +1761,13 @@ def test_create_artifact_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].artifact == gca_artifact.Artifact(name="name_value") - assert args[0].artifact_id == "artifact_id_value" def test_create_artifact_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1793,7 +1782,9 @@ def test_create_artifact_flattened_error(): @pytest.mark.asyncio async def test_create_artifact_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_artifact), "__call__") as call: @@ -1815,17 +1806,16 @@ async def test_create_artifact_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].artifact == gca_artifact.Artifact(name="name_value") - assert args[0].artifact_id == "artifact_id_value" @pytest.mark.asyncio async def test_create_artifact_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1842,7 +1832,7 @@ def test_get_artifact( transport: str = "grpc", request_type=metadata_service.GetArtifactRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1862,33 +1852,22 @@ def test_get_artifact( schema_version="schema_version_value", description="description_value", ) - response = client.get_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetArtifactRequest() # Establish that the response is the type that we expect. - assert isinstance(response, artifact.Artifact) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.uri == "uri_value" - assert response.etag == "etag_value" - assert response.state == artifact.Artifact.State.PENDING - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -1900,7 +1879,7 @@ def test_get_artifact_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1908,7 +1887,6 @@ def test_get_artifact_empty_call(): client.get_artifact() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetArtifactRequest() @@ -1917,7 +1895,7 @@ async def test_get_artifact_async( transport: str = "grpc_asyncio", request_type=metadata_service.GetArtifactRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1939,32 +1917,22 @@ async def test_get_artifact_async( description="description_value", ) ) - response = await client.get_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetArtifactRequest() # Establish that the response is the type that we expect. assert isinstance(response, artifact.Artifact) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.uri == "uri_value" - assert response.etag == "etag_value" - assert response.state == artifact.Artifact.State.PENDING - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -1974,17 +1942,17 @@ async def test_get_artifact_async_from_dict(): def test_get_artifact_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetArtifactRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_artifact), "__call__") as call: call.return_value = artifact.Artifact() - client.get_artifact(request) # Establish that the underlying gRPC stub method was called. @@ -1999,17 +1967,19 @@ def test_get_artifact_field_headers(): @pytest.mark.asyncio async def test_get_artifact_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetArtifactRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_artifact), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(artifact.Artifact()) - await client.get_artifact(request) # Establish that the underlying gRPC stub method was called. @@ -2023,13 +1993,12 @@ async def test_get_artifact_field_headers_async(): def test_get_artifact_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_artifact), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = artifact.Artifact() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_artifact(name="name_value",) @@ -2038,12 +2007,11 @@ def test_get_artifact_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_artifact_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2055,7 +2023,9 @@ def test_get_artifact_flattened_error(): @pytest.mark.asyncio async def test_get_artifact_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_artifact), "__call__") as call: @@ -2071,13 +2041,14 @@ async def test_get_artifact_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_artifact_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2091,7 +2062,7 @@ def test_list_artifacts( transport: str = "grpc", request_type=metadata_service.ListArtifactsRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2104,19 +2075,15 @@ def test_list_artifacts( call.return_value = metadata_service.ListArtifactsResponse( next_page_token="next_page_token_value", ) - response = client.list_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListArtifactsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListArtifactsPager) - assert response.next_page_token == "next_page_token_value" @@ -2128,7 +2095,7 @@ def test_list_artifacts_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2136,7 +2103,6 @@ def test_list_artifacts_empty_call(): client.list_artifacts() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListArtifactsRequest() @@ -2145,7 +2111,7 @@ async def test_list_artifacts_async( transport: str = "grpc_asyncio", request_type=metadata_service.ListArtifactsRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2160,18 +2126,15 @@ async def test_list_artifacts_async( next_page_token="next_page_token_value", ) ) - response = await client.list_artifacts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListArtifactsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListArtifactsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2181,17 +2144,17 @@ async def test_list_artifacts_async_from_dict(): def test_list_artifacts_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListArtifactsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_artifacts), "__call__") as call: call.return_value = metadata_service.ListArtifactsResponse() - client.list_artifacts(request) # Establish that the underlying gRPC stub method was called. @@ -2206,11 +2169,14 @@ def test_list_artifacts_field_headers(): @pytest.mark.asyncio async def test_list_artifacts_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListArtifactsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2218,7 +2184,6 @@ async def test_list_artifacts_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.ListArtifactsResponse() ) - await client.list_artifacts(request) # Establish that the underlying gRPC stub method was called. @@ -2232,13 +2197,12 @@ async def test_list_artifacts_field_headers_async(): def test_list_artifacts_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_artifacts), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.ListArtifactsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_artifacts(parent="parent_value",) @@ -2247,12 +2211,11 @@ def test_list_artifacts_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_artifacts_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2264,7 +2227,9 @@ def test_list_artifacts_flattened_error(): @pytest.mark.asyncio async def test_list_artifacts_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_artifacts), "__call__") as call: @@ -2282,13 +2247,14 @@ async def test_list_artifacts_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_artifacts_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2299,7 +2265,7 @@ async def test_list_artifacts_flattened_error_async(): def test_list_artifacts_pager(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_artifacts), "__call__") as call: @@ -2339,7 +2305,7 @@ def test_list_artifacts_pager(): def test_list_artifacts_pages(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_artifacts), "__call__") as call: @@ -2371,7 +2337,9 @@ def test_list_artifacts_pages(): @pytest.mark.asyncio async def test_list_artifacts_async_pager(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2410,7 +2378,9 @@ async def test_list_artifacts_async_pager(): @pytest.mark.asyncio async def test_list_artifacts_async_pages(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2448,7 +2418,7 @@ def test_update_artifact( transport: str = "grpc", request_type=metadata_service.UpdateArtifactRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2468,33 +2438,22 @@ def test_update_artifact( schema_version="schema_version_value", description="description_value", ) - response = client.update_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateArtifactRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_artifact.Artifact) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.uri == "uri_value" - assert response.etag == "etag_value" - assert response.state == gca_artifact.Artifact.State.PENDING - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -2506,7 +2465,7 @@ def test_update_artifact_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2514,7 +2473,6 @@ def test_update_artifact_empty_call(): client.update_artifact() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateArtifactRequest() @@ -2523,7 +2481,7 @@ async def test_update_artifact_async( transport: str = "grpc_asyncio", request_type=metadata_service.UpdateArtifactRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2545,32 +2503,22 @@ async def test_update_artifact_async( description="description_value", ) ) - response = await client.update_artifact(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateArtifactRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_artifact.Artifact) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.uri == "uri_value" - assert response.etag == "etag_value" - assert response.state == gca_artifact.Artifact.State.PENDING - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -2580,17 +2528,17 @@ async def test_update_artifact_async_from_dict(): def test_update_artifact_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.UpdateArtifactRequest() + request.artifact.name = "artifact.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_artifact), "__call__") as call: call.return_value = gca_artifact.Artifact() - client.update_artifact(request) # Establish that the underlying gRPC stub method was called. @@ -2607,11 +2555,14 @@ def test_update_artifact_field_headers(): @pytest.mark.asyncio async def test_update_artifact_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.UpdateArtifactRequest() + request.artifact.name = "artifact.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2619,7 +2570,6 @@ async def test_update_artifact_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_artifact.Artifact() ) - await client.update_artifact(request) # Establish that the underlying gRPC stub method was called. @@ -2635,32 +2585,29 @@ async def test_update_artifact_field_headers_async(): def test_update_artifact_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_artifact), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_artifact.Artifact() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_artifact( artifact=gca_artifact.Artifact(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].artifact == gca_artifact.Artifact(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_artifact_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2668,13 +2615,15 @@ def test_update_artifact_flattened_error(): client.update_artifact( metadata_service.UpdateArtifactRequest(), artifact=gca_artifact.Artifact(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_artifact_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_artifact), "__call__") as call: @@ -2688,22 +2637,22 @@ async def test_update_artifact_flattened_async(): # using the keyword arguments to the method. response = await client.update_artifact( artifact=gca_artifact.Artifact(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].artifact == gca_artifact.Artifact(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_artifact_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2711,7 +2660,7 @@ async def test_update_artifact_flattened_error_async(): await client.update_artifact( metadata_service.UpdateArtifactRequest(), artifact=gca_artifact.Artifact(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2719,7 +2668,7 @@ def test_create_context( transport: str = "grpc", request_type=metadata_service.CreateContextRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2738,31 +2687,21 @@ def test_create_context( schema_version="schema_version_value", description="description_value", ) - response = client.create_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateContextRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_context.Context) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.parent_contexts == ["parent_contexts_value"] - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -2774,7 +2713,7 @@ def test_create_context_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2782,7 +2721,6 @@ def test_create_context_empty_call(): client.create_context() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateContextRequest() @@ -2791,7 +2729,7 @@ async def test_create_context_async( transport: str = "grpc_asyncio", request_type=metadata_service.CreateContextRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2812,30 +2750,21 @@ async def test_create_context_async( description="description_value", ) ) - response = await client.create_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateContextRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_context.Context) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.parent_contexts == ["parent_contexts_value"] - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -2845,17 +2774,17 @@ async def test_create_context_async_from_dict(): def test_create_context_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateContextRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_context), "__call__") as call: call.return_value = gca_context.Context() - client.create_context(request) # Establish that the underlying gRPC stub method was called. @@ -2870,17 +2799,19 @@ def test_create_context_field_headers(): @pytest.mark.asyncio async def test_create_context_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateContextRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_context), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_context.Context()) - await client.create_context(request) # Establish that the underlying gRPC stub method was called. @@ -2894,13 +2825,12 @@ async def test_create_context_field_headers_async(): def test_create_context_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_context), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_context.Context() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_context( @@ -2913,16 +2843,13 @@ def test_create_context_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].context == gca_context.Context(name="name_value") - assert args[0].context_id == "context_id_value" def test_create_context_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2937,7 +2864,9 @@ def test_create_context_flattened_error(): @pytest.mark.asyncio async def test_create_context_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_context), "__call__") as call: @@ -2957,17 +2886,16 @@ async def test_create_context_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].context == gca_context.Context(name="name_value") - assert args[0].context_id == "context_id_value" @pytest.mark.asyncio async def test_create_context_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2984,7 +2912,7 @@ def test_get_context( transport: str = "grpc", request_type=metadata_service.GetContextRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3003,31 +2931,21 @@ def test_get_context( schema_version="schema_version_value", description="description_value", ) - response = client.get_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetContextRequest() # Establish that the response is the type that we expect. - assert isinstance(response, context.Context) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.parent_contexts == ["parent_contexts_value"] - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -3039,7 +2957,7 @@ def test_get_context_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3047,7 +2965,6 @@ def test_get_context_empty_call(): client.get_context() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetContextRequest() @@ -3056,7 +2973,7 @@ async def test_get_context_async( transport: str = "grpc_asyncio", request_type=metadata_service.GetContextRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3077,30 +2994,21 @@ async def test_get_context_async( description="description_value", ) ) - response = await client.get_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetContextRequest() # Establish that the response is the type that we expect. assert isinstance(response, context.Context) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.parent_contexts == ["parent_contexts_value"] - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -3110,17 +3018,17 @@ async def test_get_context_async_from_dict(): def test_get_context_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetContextRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_context), "__call__") as call: call.return_value = context.Context() - client.get_context(request) # Establish that the underlying gRPC stub method was called. @@ -3135,17 +3043,19 @@ def test_get_context_field_headers(): @pytest.mark.asyncio async def test_get_context_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetContextRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_context), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(context.Context()) - await client.get_context(request) # Establish that the underlying gRPC stub method was called. @@ -3159,13 +3069,12 @@ async def test_get_context_field_headers_async(): def test_get_context_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_context), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = context.Context() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_context(name="name_value",) @@ -3174,12 +3083,11 @@ def test_get_context_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_context_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3191,7 +3099,9 @@ def test_get_context_flattened_error(): @pytest.mark.asyncio async def test_get_context_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_context), "__call__") as call: @@ -3207,13 +3117,14 @@ async def test_get_context_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_context_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3227,7 +3138,7 @@ def test_list_contexts( transport: str = "grpc", request_type=metadata_service.ListContextsRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3240,19 +3151,15 @@ def test_list_contexts( call.return_value = metadata_service.ListContextsResponse( next_page_token="next_page_token_value", ) - response = client.list_contexts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListContextsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListContextsPager) - assert response.next_page_token == "next_page_token_value" @@ -3264,7 +3171,7 @@ def test_list_contexts_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3272,7 +3179,6 @@ def test_list_contexts_empty_call(): client.list_contexts() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListContextsRequest() @@ -3281,7 +3187,7 @@ async def test_list_contexts_async( transport: str = "grpc_asyncio", request_type=metadata_service.ListContextsRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3296,18 +3202,15 @@ async def test_list_contexts_async( next_page_token="next_page_token_value", ) ) - response = await client.list_contexts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListContextsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListContextsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -3317,17 +3220,17 @@ async def test_list_contexts_async_from_dict(): def test_list_contexts_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListContextsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_contexts), "__call__") as call: call.return_value = metadata_service.ListContextsResponse() - client.list_contexts(request) # Establish that the underlying gRPC stub method was called. @@ -3342,11 +3245,14 @@ def test_list_contexts_field_headers(): @pytest.mark.asyncio async def test_list_contexts_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListContextsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3354,7 +3260,6 @@ async def test_list_contexts_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.ListContextsResponse() ) - await client.list_contexts(request) # Establish that the underlying gRPC stub method was called. @@ -3368,13 +3273,12 @@ async def test_list_contexts_field_headers_async(): def test_list_contexts_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_contexts), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.ListContextsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_contexts(parent="parent_value",) @@ -3383,12 +3287,11 @@ def test_list_contexts_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_contexts_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3400,7 +3303,9 @@ def test_list_contexts_flattened_error(): @pytest.mark.asyncio async def test_list_contexts_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_contexts), "__call__") as call: @@ -3418,13 +3323,14 @@ async def test_list_contexts_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_contexts_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3435,7 +3341,7 @@ async def test_list_contexts_flattened_error_async(): def test_list_contexts_pager(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_contexts), "__call__") as call: @@ -3469,7 +3375,7 @@ def test_list_contexts_pager(): def test_list_contexts_pages(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_contexts), "__call__") as call: @@ -3495,7 +3401,9 @@ def test_list_contexts_pages(): @pytest.mark.asyncio async def test_list_contexts_async_pager(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3528,7 +3436,9 @@ async def test_list_contexts_async_pager(): @pytest.mark.asyncio async def test_list_contexts_async_pages(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3560,7 +3470,7 @@ def test_update_context( transport: str = "grpc", request_type=metadata_service.UpdateContextRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3579,31 +3489,21 @@ def test_update_context( schema_version="schema_version_value", description="description_value", ) - response = client.update_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateContextRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_context.Context) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.parent_contexts == ["parent_contexts_value"] - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -3615,7 +3515,7 @@ def test_update_context_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3623,7 +3523,6 @@ def test_update_context_empty_call(): client.update_context() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateContextRequest() @@ -3632,7 +3531,7 @@ async def test_update_context_async( transport: str = "grpc_asyncio", request_type=metadata_service.UpdateContextRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3653,30 +3552,21 @@ async def test_update_context_async( description="description_value", ) ) - response = await client.update_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateContextRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_context.Context) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.etag == "etag_value" - assert response.parent_contexts == ["parent_contexts_value"] - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -3686,17 +3576,17 @@ async def test_update_context_async_from_dict(): def test_update_context_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.UpdateContextRequest() + request.context.name = "context.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_context), "__call__") as call: call.return_value = gca_context.Context() - client.update_context(request) # Establish that the underlying gRPC stub method was called. @@ -3713,17 +3603,19 @@ def test_update_context_field_headers(): @pytest.mark.asyncio async def test_update_context_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.UpdateContextRequest() + request.context.name = "context.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_context), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_context.Context()) - await client.update_context(request) # Establish that the underlying gRPC stub method was called. @@ -3739,32 +3631,29 @@ async def test_update_context_field_headers_async(): def test_update_context_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_context), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_context.Context() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_context( context=gca_context.Context(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].context == gca_context.Context(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_context_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3772,13 +3661,15 @@ def test_update_context_flattened_error(): client.update_context( metadata_service.UpdateContextRequest(), context=gca_context.Context(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_context_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_context), "__call__") as call: @@ -3790,22 +3681,22 @@ async def test_update_context_flattened_async(): # using the keyword arguments to the method. response = await client.update_context( context=gca_context.Context(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].context == gca_context.Context(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_context_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3813,7 +3704,7 @@ async def test_update_context_flattened_error_async(): await client.update_context( metadata_service.UpdateContextRequest(), context=gca_context.Context(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -3821,7 +3712,7 @@ def test_delete_context( transport: str = "grpc", request_type=metadata_service.DeleteContextRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3832,13 +3723,11 @@ def test_delete_context( with mock.patch.object(type(client.transport.delete_context), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.DeleteContextRequest() # Establish that the response is the type that we expect. @@ -3853,7 +3742,7 @@ def test_delete_context_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3861,7 +3750,6 @@ def test_delete_context_empty_call(): client.delete_context() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.DeleteContextRequest() @@ -3870,7 +3758,7 @@ async def test_delete_context_async( transport: str = "grpc_asyncio", request_type=metadata_service.DeleteContextRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3883,13 +3771,11 @@ async def test_delete_context_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_context(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.DeleteContextRequest() # Establish that the response is the type that we expect. @@ -3902,17 +3788,17 @@ async def test_delete_context_async_from_dict(): def test_delete_context_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.DeleteContextRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_context), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_context(request) # Establish that the underlying gRPC stub method was called. @@ -3927,11 +3813,14 @@ def test_delete_context_field_headers(): @pytest.mark.asyncio async def test_delete_context_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.DeleteContextRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3939,7 +3828,6 @@ async def test_delete_context_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_context(request) # Establish that the underlying gRPC stub method was called. @@ -3953,13 +3841,12 @@ async def test_delete_context_field_headers_async(): def test_delete_context_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_context), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_context(name="name_value",) @@ -3968,12 +3855,11 @@ def test_delete_context_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_context_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3985,7 +3871,9 @@ def test_delete_context_flattened_error(): @pytest.mark.asyncio async def test_delete_context_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_context), "__call__") as call: @@ -4003,13 +3891,14 @@ async def test_delete_context_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_context_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4024,7 +3913,7 @@ def test_add_context_artifacts_and_executions( request_type=metadata_service.AddContextArtifactsAndExecutionsRequest, ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4037,17 +3926,14 @@ def test_add_context_artifacts_and_executions( ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.AddContextArtifactsAndExecutionsResponse() - response = client.add_context_artifacts_and_executions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddContextArtifactsAndExecutionsRequest() # Establish that the response is the type that we expect. - assert isinstance( response, metadata_service.AddContextArtifactsAndExecutionsResponse ) @@ -4061,7 +3947,7 @@ def test_add_context_artifacts_and_executions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4071,7 +3957,6 @@ def test_add_context_artifacts_and_executions_empty_call(): client.add_context_artifacts_and_executions() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddContextArtifactsAndExecutionsRequest() @@ -4081,7 +3966,7 @@ async def test_add_context_artifacts_and_executions_async( request_type=metadata_service.AddContextArtifactsAndExecutionsRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4096,13 +3981,11 @@ async def test_add_context_artifacts_and_executions_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.AddContextArtifactsAndExecutionsResponse() ) - response = await client.add_context_artifacts_and_executions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddContextArtifactsAndExecutionsRequest() # Establish that the response is the type that we expect. @@ -4117,11 +4000,12 @@ async def test_add_context_artifacts_and_executions_async_from_dict(): def test_add_context_artifacts_and_executions_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.AddContextArtifactsAndExecutionsRequest() + request.context = "context/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4129,7 +4013,6 @@ def test_add_context_artifacts_and_executions_field_headers(): type(client.transport.add_context_artifacts_and_executions), "__call__" ) as call: call.return_value = metadata_service.AddContextArtifactsAndExecutionsResponse() - client.add_context_artifacts_and_executions(request) # Establish that the underlying gRPC stub method was called. @@ -4144,11 +4027,14 @@ def test_add_context_artifacts_and_executions_field_headers(): @pytest.mark.asyncio async def test_add_context_artifacts_and_executions_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.AddContextArtifactsAndExecutionsRequest() + request.context = "context/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4158,7 +4044,6 @@ async def test_add_context_artifacts_and_executions_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.AddContextArtifactsAndExecutionsResponse() ) - await client.add_context_artifacts_and_executions(request) # Establish that the underlying gRPC stub method was called. @@ -4172,7 +4057,7 @@ async def test_add_context_artifacts_and_executions_field_headers_async(): def test_add_context_artifacts_and_executions_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4180,7 +4065,6 @@ def test_add_context_artifacts_and_executions_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.AddContextArtifactsAndExecutionsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.add_context_artifacts_and_executions( @@ -4193,16 +4077,13 @@ def test_add_context_artifacts_and_executions_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].context == "context_value" - assert args[0].artifacts == ["artifacts_value"] - assert args[0].executions == ["executions_value"] def test_add_context_artifacts_and_executions_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4217,7 +4098,9 @@ def test_add_context_artifacts_and_executions_flattened_error(): @pytest.mark.asyncio async def test_add_context_artifacts_and_executions_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4241,17 +4124,16 @@ async def test_add_context_artifacts_and_executions_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].context == "context_value" - assert args[0].artifacts == ["artifacts_value"] - assert args[0].executions == ["executions_value"] @pytest.mark.asyncio async def test_add_context_artifacts_and_executions_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4268,7 +4150,7 @@ def test_add_context_children( transport: str = "grpc", request_type=metadata_service.AddContextChildrenRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4281,17 +4163,14 @@ def test_add_context_children( ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.AddContextChildrenResponse() - response = client.add_context_children(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddContextChildrenRequest() # Establish that the response is the type that we expect. - assert isinstance(response, metadata_service.AddContextChildrenResponse) @@ -4303,7 +4182,7 @@ def test_add_context_children_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4313,7 +4192,6 @@ def test_add_context_children_empty_call(): client.add_context_children() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddContextChildrenRequest() @@ -4323,7 +4201,7 @@ async def test_add_context_children_async( request_type=metadata_service.AddContextChildrenRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4338,13 +4216,11 @@ async def test_add_context_children_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.AddContextChildrenResponse() ) - response = await client.add_context_children(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddContextChildrenRequest() # Establish that the response is the type that we expect. @@ -4357,11 +4233,12 @@ async def test_add_context_children_async_from_dict(): def test_add_context_children_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.AddContextChildrenRequest() + request.context = "context/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4369,7 +4246,6 @@ def test_add_context_children_field_headers(): type(client.transport.add_context_children), "__call__" ) as call: call.return_value = metadata_service.AddContextChildrenResponse() - client.add_context_children(request) # Establish that the underlying gRPC stub method was called. @@ -4384,11 +4260,14 @@ def test_add_context_children_field_headers(): @pytest.mark.asyncio async def test_add_context_children_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.AddContextChildrenRequest() + request.context = "context/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4398,7 +4277,6 @@ async def test_add_context_children_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.AddContextChildrenResponse() ) - await client.add_context_children(request) # Establish that the underlying gRPC stub method was called. @@ -4412,7 +4290,7 @@ async def test_add_context_children_field_headers_async(): def test_add_context_children_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4420,7 +4298,6 @@ def test_add_context_children_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.AddContextChildrenResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.add_context_children( @@ -4431,14 +4308,12 @@ def test_add_context_children_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].context == "context_value" - assert args[0].child_contexts == ["child_contexts_value"] def test_add_context_children_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4452,7 +4327,9 @@ def test_add_context_children_flattened_error(): @pytest.mark.asyncio async def test_add_context_children_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4474,15 +4351,15 @@ async def test_add_context_children_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].context == "context_value" - assert args[0].child_contexts == ["child_contexts_value"] @pytest.mark.asyncio async def test_add_context_children_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4499,7 +4376,7 @@ def test_query_context_lineage_subgraph( request_type=metadata_service.QueryContextLineageSubgraphRequest, ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4512,17 +4389,14 @@ def test_query_context_lineage_subgraph( ) as call: # Designate an appropriate return value for the call. call.return_value = lineage_subgraph.LineageSubgraph() - response = client.query_context_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryContextLineageSubgraphRequest() # Establish that the response is the type that we expect. - assert isinstance(response, lineage_subgraph.LineageSubgraph) @@ -4534,7 +4408,7 @@ def test_query_context_lineage_subgraph_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4544,7 +4418,6 @@ def test_query_context_lineage_subgraph_empty_call(): client.query_context_lineage_subgraph() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryContextLineageSubgraphRequest() @@ -4554,7 +4427,7 @@ async def test_query_context_lineage_subgraph_async( request_type=metadata_service.QueryContextLineageSubgraphRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4569,13 +4442,11 @@ async def test_query_context_lineage_subgraph_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( lineage_subgraph.LineageSubgraph() ) - response = await client.query_context_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryContextLineageSubgraphRequest() # Establish that the response is the type that we expect. @@ -4588,11 +4459,12 @@ async def test_query_context_lineage_subgraph_async_from_dict(): def test_query_context_lineage_subgraph_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.QueryContextLineageSubgraphRequest() + request.context = "context/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4600,7 +4472,6 @@ def test_query_context_lineage_subgraph_field_headers(): type(client.transport.query_context_lineage_subgraph), "__call__" ) as call: call.return_value = lineage_subgraph.LineageSubgraph() - client.query_context_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. @@ -4615,11 +4486,14 @@ def test_query_context_lineage_subgraph_field_headers(): @pytest.mark.asyncio async def test_query_context_lineage_subgraph_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.QueryContextLineageSubgraphRequest() + request.context = "context/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4629,7 +4503,6 @@ async def test_query_context_lineage_subgraph_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( lineage_subgraph.LineageSubgraph() ) - await client.query_context_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. @@ -4643,7 +4516,7 @@ async def test_query_context_lineage_subgraph_field_headers_async(): def test_query_context_lineage_subgraph_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4651,7 +4524,6 @@ def test_query_context_lineage_subgraph_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = lineage_subgraph.LineageSubgraph() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.query_context_lineage_subgraph(context="context_value",) @@ -4660,12 +4532,11 @@ def test_query_context_lineage_subgraph_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].context == "context_value" def test_query_context_lineage_subgraph_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4678,7 +4549,9 @@ def test_query_context_lineage_subgraph_flattened_error(): @pytest.mark.asyncio async def test_query_context_lineage_subgraph_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4698,13 +4571,14 @@ async def test_query_context_lineage_subgraph_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].context == "context_value" @pytest.mark.asyncio async def test_query_context_lineage_subgraph_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4719,7 +4593,7 @@ def test_create_execution( transport: str = "grpc", request_type=metadata_service.CreateExecutionRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4738,31 +4612,21 @@ def test_create_execution( schema_version="schema_version_value", description="description_value", ) - response = client.create_execution(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateExecutionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_execution.Execution) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == gca_execution.Execution.State.NEW - assert response.etag == "etag_value" - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -4774,7 +4638,7 @@ def test_create_execution_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4782,7 +4646,6 @@ def test_create_execution_empty_call(): client.create_execution() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateExecutionRequest() @@ -4792,7 +4655,7 @@ async def test_create_execution_async( request_type=metadata_service.CreateExecutionRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4813,30 +4676,21 @@ async def test_create_execution_async( description="description_value", ) ) - response = await client.create_execution(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateExecutionRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_execution.Execution) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == gca_execution.Execution.State.NEW - assert response.etag == "etag_value" - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -4846,17 +4700,17 @@ async def test_create_execution_async_from_dict(): def test_create_execution_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateExecutionRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_execution), "__call__") as call: call.return_value = gca_execution.Execution() - client.create_execution(request) # Establish that the underlying gRPC stub method was called. @@ -4871,11 +4725,14 @@ def test_create_execution_field_headers(): @pytest.mark.asyncio async def test_create_execution_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateExecutionRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4883,7 +4740,6 @@ async def test_create_execution_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_execution.Execution() ) - await client.create_execution(request) # Establish that the underlying gRPC stub method was called. @@ -4897,13 +4753,12 @@ async def test_create_execution_field_headers_async(): def test_create_execution_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_execution), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_execution.Execution() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_execution( @@ -4916,16 +4771,13 @@ def test_create_execution_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].execution == gca_execution.Execution(name="name_value") - assert args[0].execution_id == "execution_id_value" def test_create_execution_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4940,7 +4792,9 @@ def test_create_execution_flattened_error(): @pytest.mark.asyncio async def test_create_execution_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_execution), "__call__") as call: @@ -4962,17 +4816,16 @@ async def test_create_execution_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].execution == gca_execution.Execution(name="name_value") - assert args[0].execution_id == "execution_id_value" @pytest.mark.asyncio async def test_create_execution_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4989,7 +4842,7 @@ def test_get_execution( transport: str = "grpc", request_type=metadata_service.GetExecutionRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5008,31 +4861,21 @@ def test_get_execution( schema_version="schema_version_value", description="description_value", ) - response = client.get_execution(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetExecutionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, execution.Execution) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == execution.Execution.State.NEW - assert response.etag == "etag_value" - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -5044,7 +4887,7 @@ def test_get_execution_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5052,7 +4895,6 @@ def test_get_execution_empty_call(): client.get_execution() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetExecutionRequest() @@ -5061,7 +4903,7 @@ async def test_get_execution_async( transport: str = "grpc_asyncio", request_type=metadata_service.GetExecutionRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5082,30 +4924,21 @@ async def test_get_execution_async( description="description_value", ) ) - response = await client.get_execution(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetExecutionRequest() # Establish that the response is the type that we expect. assert isinstance(response, execution.Execution) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == execution.Execution.State.NEW - assert response.etag == "etag_value" - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -5115,17 +4948,17 @@ async def test_get_execution_async_from_dict(): def test_get_execution_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetExecutionRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_execution), "__call__") as call: call.return_value = execution.Execution() - client.get_execution(request) # Establish that the underlying gRPC stub method was called. @@ -5140,17 +4973,19 @@ def test_get_execution_field_headers(): @pytest.mark.asyncio async def test_get_execution_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetExecutionRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_execution), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(execution.Execution()) - await client.get_execution(request) # Establish that the underlying gRPC stub method was called. @@ -5164,13 +4999,12 @@ async def test_get_execution_field_headers_async(): def test_get_execution_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_execution), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = execution.Execution() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_execution(name="name_value",) @@ -5179,12 +5013,11 @@ def test_get_execution_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_execution_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5196,7 +5029,9 @@ def test_get_execution_flattened_error(): @pytest.mark.asyncio async def test_get_execution_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_execution), "__call__") as call: @@ -5212,13 +5047,14 @@ async def test_get_execution_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_execution_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5232,7 +5068,7 @@ def test_list_executions( transport: str = "grpc", request_type=metadata_service.ListExecutionsRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5245,19 +5081,15 @@ def test_list_executions( call.return_value = metadata_service.ListExecutionsResponse( next_page_token="next_page_token_value", ) - response = client.list_executions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListExecutionsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListExecutionsPager) - assert response.next_page_token == "next_page_token_value" @@ -5269,7 +5101,7 @@ def test_list_executions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5277,7 +5109,6 @@ def test_list_executions_empty_call(): client.list_executions() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListExecutionsRequest() @@ -5286,7 +5117,7 @@ async def test_list_executions_async( transport: str = "grpc_asyncio", request_type=metadata_service.ListExecutionsRequest ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5301,18 +5132,15 @@ async def test_list_executions_async( next_page_token="next_page_token_value", ) ) - response = await client.list_executions(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListExecutionsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListExecutionsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -5322,17 +5150,17 @@ async def test_list_executions_async_from_dict(): def test_list_executions_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListExecutionsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_executions), "__call__") as call: call.return_value = metadata_service.ListExecutionsResponse() - client.list_executions(request) # Establish that the underlying gRPC stub method was called. @@ -5347,11 +5175,14 @@ def test_list_executions_field_headers(): @pytest.mark.asyncio async def test_list_executions_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListExecutionsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5359,7 +5190,6 @@ async def test_list_executions_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.ListExecutionsResponse() ) - await client.list_executions(request) # Establish that the underlying gRPC stub method was called. @@ -5373,13 +5203,12 @@ async def test_list_executions_field_headers_async(): def test_list_executions_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_executions), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.ListExecutionsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_executions(parent="parent_value",) @@ -5388,12 +5217,11 @@ def test_list_executions_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_executions_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5405,7 +5233,9 @@ def test_list_executions_flattened_error(): @pytest.mark.asyncio async def test_list_executions_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_executions), "__call__") as call: @@ -5423,13 +5253,14 @@ async def test_list_executions_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_executions_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5440,7 +5271,7 @@ async def test_list_executions_flattened_error_async(): def test_list_executions_pager(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_executions), "__call__") as call: @@ -5480,7 +5311,7 @@ def test_list_executions_pager(): def test_list_executions_pages(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_executions), "__call__") as call: @@ -5512,7 +5343,9 @@ def test_list_executions_pages(): @pytest.mark.asyncio async def test_list_executions_async_pager(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5551,7 +5384,9 @@ async def test_list_executions_async_pager(): @pytest.mark.asyncio async def test_list_executions_async_pages(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5589,7 +5424,7 @@ def test_update_execution( transport: str = "grpc", request_type=metadata_service.UpdateExecutionRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5608,31 +5443,21 @@ def test_update_execution( schema_version="schema_version_value", description="description_value", ) - response = client.update_execution(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateExecutionRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_execution.Execution) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == gca_execution.Execution.State.NEW - assert response.etag == "etag_value" - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -5644,7 +5469,7 @@ def test_update_execution_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5652,7 +5477,6 @@ def test_update_execution_empty_call(): client.update_execution() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateExecutionRequest() @@ -5662,7 +5486,7 @@ async def test_update_execution_async( request_type=metadata_service.UpdateExecutionRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5683,30 +5507,21 @@ async def test_update_execution_async( description="description_value", ) ) - response = await client.update_execution(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.UpdateExecutionRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_execution.Execution) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == gca_execution.Execution.State.NEW - assert response.etag == "etag_value" - assert response.schema_title == "schema_title_value" - assert response.schema_version == "schema_version_value" - assert response.description == "description_value" @@ -5716,17 +5531,17 @@ async def test_update_execution_async_from_dict(): def test_update_execution_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.UpdateExecutionRequest() + request.execution.name = "execution.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_execution), "__call__") as call: call.return_value = gca_execution.Execution() - client.update_execution(request) # Establish that the underlying gRPC stub method was called. @@ -5743,11 +5558,14 @@ def test_update_execution_field_headers(): @pytest.mark.asyncio async def test_update_execution_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.UpdateExecutionRequest() + request.execution.name = "execution.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5755,7 +5573,6 @@ async def test_update_execution_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_execution.Execution() ) - await client.update_execution(request) # Establish that the underlying gRPC stub method was called. @@ -5771,32 +5588,29 @@ async def test_update_execution_field_headers_async(): def test_update_execution_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_execution), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_execution.Execution() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_execution( execution=gca_execution.Execution(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].execution == gca_execution.Execution(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_execution_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5804,13 +5618,15 @@ def test_update_execution_flattened_error(): client.update_execution( metadata_service.UpdateExecutionRequest(), execution=gca_execution.Execution(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_execution_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_execution), "__call__") as call: @@ -5824,22 +5640,22 @@ async def test_update_execution_flattened_async(): # using the keyword arguments to the method. response = await client.update_execution( execution=gca_execution.Execution(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].execution == gca_execution.Execution(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_execution_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5847,7 +5663,7 @@ async def test_update_execution_flattened_error_async(): await client.update_execution( metadata_service.UpdateExecutionRequest(), execution=gca_execution.Execution(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -5855,7 +5671,7 @@ def test_add_execution_events( transport: str = "grpc", request_type=metadata_service.AddExecutionEventsRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5868,17 +5684,14 @@ def test_add_execution_events( ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.AddExecutionEventsResponse() - response = client.add_execution_events(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddExecutionEventsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, metadata_service.AddExecutionEventsResponse) @@ -5890,7 +5703,7 @@ def test_add_execution_events_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5900,7 +5713,6 @@ def test_add_execution_events_empty_call(): client.add_execution_events() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddExecutionEventsRequest() @@ -5910,7 +5722,7 @@ async def test_add_execution_events_async( request_type=metadata_service.AddExecutionEventsRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5925,13 +5737,11 @@ async def test_add_execution_events_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.AddExecutionEventsResponse() ) - response = await client.add_execution_events(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.AddExecutionEventsRequest() # Establish that the response is the type that we expect. @@ -5944,11 +5754,12 @@ async def test_add_execution_events_async_from_dict(): def test_add_execution_events_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.AddExecutionEventsRequest() + request.execution = "execution/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5956,7 +5767,6 @@ def test_add_execution_events_field_headers(): type(client.transport.add_execution_events), "__call__" ) as call: call.return_value = metadata_service.AddExecutionEventsResponse() - client.add_execution_events(request) # Establish that the underlying gRPC stub method was called. @@ -5971,11 +5781,14 @@ def test_add_execution_events_field_headers(): @pytest.mark.asyncio async def test_add_execution_events_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.AddExecutionEventsRequest() + request.execution = "execution/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5985,7 +5798,6 @@ async def test_add_execution_events_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.AddExecutionEventsResponse() ) - await client.add_execution_events(request) # Establish that the underlying gRPC stub method was called. @@ -5999,7 +5811,7 @@ async def test_add_execution_events_field_headers_async(): def test_add_execution_events_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6007,7 +5819,6 @@ def test_add_execution_events_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.AddExecutionEventsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.add_execution_events( @@ -6019,14 +5830,12 @@ def test_add_execution_events_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].execution == "execution_value" - assert args[0].events == [event.Event(artifact="artifact_value")] def test_add_execution_events_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6040,7 +5849,9 @@ def test_add_execution_events_flattened_error(): @pytest.mark.asyncio async def test_add_execution_events_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6063,15 +5874,15 @@ async def test_add_execution_events_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].execution == "execution_value" - assert args[0].events == [event.Event(artifact="artifact_value")] @pytest.mark.asyncio async def test_add_execution_events_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6088,7 +5899,7 @@ def test_query_execution_inputs_and_outputs( request_type=metadata_service.QueryExecutionInputsAndOutputsRequest, ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6101,17 +5912,14 @@ def test_query_execution_inputs_and_outputs( ) as call: # Designate an appropriate return value for the call. call.return_value = lineage_subgraph.LineageSubgraph() - response = client.query_execution_inputs_and_outputs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryExecutionInputsAndOutputsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, lineage_subgraph.LineageSubgraph) @@ -6123,7 +5931,7 @@ def test_query_execution_inputs_and_outputs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6133,7 +5941,6 @@ def test_query_execution_inputs_and_outputs_empty_call(): client.query_execution_inputs_and_outputs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryExecutionInputsAndOutputsRequest() @@ -6143,7 +5950,7 @@ async def test_query_execution_inputs_and_outputs_async( request_type=metadata_service.QueryExecutionInputsAndOutputsRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6158,13 +5965,11 @@ async def test_query_execution_inputs_and_outputs_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( lineage_subgraph.LineageSubgraph() ) - response = await client.query_execution_inputs_and_outputs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryExecutionInputsAndOutputsRequest() # Establish that the response is the type that we expect. @@ -6177,11 +5982,12 @@ async def test_query_execution_inputs_and_outputs_async_from_dict(): def test_query_execution_inputs_and_outputs_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.QueryExecutionInputsAndOutputsRequest() + request.execution = "execution/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6189,7 +5995,6 @@ def test_query_execution_inputs_and_outputs_field_headers(): type(client.transport.query_execution_inputs_and_outputs), "__call__" ) as call: call.return_value = lineage_subgraph.LineageSubgraph() - client.query_execution_inputs_and_outputs(request) # Establish that the underlying gRPC stub method was called. @@ -6204,11 +6009,14 @@ def test_query_execution_inputs_and_outputs_field_headers(): @pytest.mark.asyncio async def test_query_execution_inputs_and_outputs_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.QueryExecutionInputsAndOutputsRequest() + request.execution = "execution/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6218,7 +6026,6 @@ async def test_query_execution_inputs_and_outputs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( lineage_subgraph.LineageSubgraph() ) - await client.query_execution_inputs_and_outputs(request) # Establish that the underlying gRPC stub method was called. @@ -6232,7 +6039,7 @@ async def test_query_execution_inputs_and_outputs_field_headers_async(): def test_query_execution_inputs_and_outputs_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6240,7 +6047,6 @@ def test_query_execution_inputs_and_outputs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = lineage_subgraph.LineageSubgraph() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.query_execution_inputs_and_outputs(execution="execution_value",) @@ -6249,12 +6055,11 @@ def test_query_execution_inputs_and_outputs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].execution == "execution_value" def test_query_execution_inputs_and_outputs_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6267,7 +6072,9 @@ def test_query_execution_inputs_and_outputs_flattened_error(): @pytest.mark.asyncio async def test_query_execution_inputs_and_outputs_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6289,13 +6096,14 @@ async def test_query_execution_inputs_and_outputs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].execution == "execution_value" @pytest.mark.asyncio async def test_query_execution_inputs_and_outputs_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6310,7 +6118,7 @@ def test_create_metadata_schema( transport: str = "grpc", request_type=metadata_service.CreateMetadataSchemaRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6329,30 +6137,22 @@ def test_create_metadata_schema( schema_type=gca_metadata_schema.MetadataSchema.MetadataSchemaType.ARTIFACT_TYPE, description="description_value", ) - response = client.create_metadata_schema(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateMetadataSchemaRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_metadata_schema.MetadataSchema) - assert response.name == "name_value" - assert response.schema_version == "schema_version_value" - assert response.schema == "schema_value" - assert ( response.schema_type == gca_metadata_schema.MetadataSchema.MetadataSchemaType.ARTIFACT_TYPE ) - assert response.description == "description_value" @@ -6364,7 +6164,7 @@ def test_create_metadata_schema_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6374,7 +6174,6 @@ def test_create_metadata_schema_empty_call(): client.create_metadata_schema() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateMetadataSchemaRequest() @@ -6384,7 +6183,7 @@ async def test_create_metadata_schema_async( request_type=metadata_service.CreateMetadataSchemaRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6405,29 +6204,22 @@ async def test_create_metadata_schema_async( description="description_value", ) ) - response = await client.create_metadata_schema(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.CreateMetadataSchemaRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_metadata_schema.MetadataSchema) - assert response.name == "name_value" - assert response.schema_version == "schema_version_value" - assert response.schema == "schema_value" - assert ( response.schema_type == gca_metadata_schema.MetadataSchema.MetadataSchemaType.ARTIFACT_TYPE ) - assert response.description == "description_value" @@ -6437,11 +6229,12 @@ async def test_create_metadata_schema_async_from_dict(): def test_create_metadata_schema_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateMetadataSchemaRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6449,7 +6242,6 @@ def test_create_metadata_schema_field_headers(): type(client.transport.create_metadata_schema), "__call__" ) as call: call.return_value = gca_metadata_schema.MetadataSchema() - client.create_metadata_schema(request) # Establish that the underlying gRPC stub method was called. @@ -6464,11 +6256,14 @@ def test_create_metadata_schema_field_headers(): @pytest.mark.asyncio async def test_create_metadata_schema_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.CreateMetadataSchemaRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6478,7 +6273,6 @@ async def test_create_metadata_schema_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_metadata_schema.MetadataSchema() ) - await client.create_metadata_schema(request) # Establish that the underlying gRPC stub method was called. @@ -6492,7 +6286,7 @@ async def test_create_metadata_schema_field_headers_async(): def test_create_metadata_schema_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6500,7 +6294,6 @@ def test_create_metadata_schema_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_metadata_schema.MetadataSchema() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_metadata_schema( @@ -6513,18 +6306,15 @@ def test_create_metadata_schema_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].metadata_schema == gca_metadata_schema.MetadataSchema( name="name_value" ) - assert args[0].metadata_schema_id == "metadata_schema_id_value" def test_create_metadata_schema_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6539,7 +6329,9 @@ def test_create_metadata_schema_flattened_error(): @pytest.mark.asyncio async def test_create_metadata_schema_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6563,19 +6355,18 @@ async def test_create_metadata_schema_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].metadata_schema == gca_metadata_schema.MetadataSchema( name="name_value" ) - assert args[0].metadata_schema_id == "metadata_schema_id_value" @pytest.mark.asyncio async def test_create_metadata_schema_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6592,7 +6383,7 @@ def test_get_metadata_schema( transport: str = "grpc", request_type=metadata_service.GetMetadataSchemaRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6611,30 +6402,22 @@ def test_get_metadata_schema( schema_type=metadata_schema.MetadataSchema.MetadataSchemaType.ARTIFACT_TYPE, description="description_value", ) - response = client.get_metadata_schema(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetMetadataSchemaRequest() # Establish that the response is the type that we expect. - assert isinstance(response, metadata_schema.MetadataSchema) - assert response.name == "name_value" - assert response.schema_version == "schema_version_value" - assert response.schema == "schema_value" - assert ( response.schema_type == metadata_schema.MetadataSchema.MetadataSchemaType.ARTIFACT_TYPE ) - assert response.description == "description_value" @@ -6646,7 +6429,7 @@ def test_get_metadata_schema_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6656,7 +6439,6 @@ def test_get_metadata_schema_empty_call(): client.get_metadata_schema() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetMetadataSchemaRequest() @@ -6666,7 +6448,7 @@ async def test_get_metadata_schema_async( request_type=metadata_service.GetMetadataSchemaRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6687,29 +6469,22 @@ async def test_get_metadata_schema_async( description="description_value", ) ) - response = await client.get_metadata_schema(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.GetMetadataSchemaRequest() # Establish that the response is the type that we expect. assert isinstance(response, metadata_schema.MetadataSchema) - assert response.name == "name_value" - assert response.schema_version == "schema_version_value" - assert response.schema == "schema_value" - assert ( response.schema_type == metadata_schema.MetadataSchema.MetadataSchemaType.ARTIFACT_TYPE ) - assert response.description == "description_value" @@ -6719,11 +6494,12 @@ async def test_get_metadata_schema_async_from_dict(): def test_get_metadata_schema_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetMetadataSchemaRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6731,7 +6507,6 @@ def test_get_metadata_schema_field_headers(): type(client.transport.get_metadata_schema), "__call__" ) as call: call.return_value = metadata_schema.MetadataSchema() - client.get_metadata_schema(request) # Establish that the underlying gRPC stub method was called. @@ -6746,11 +6521,14 @@ def test_get_metadata_schema_field_headers(): @pytest.mark.asyncio async def test_get_metadata_schema_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.GetMetadataSchemaRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6760,7 +6538,6 @@ async def test_get_metadata_schema_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_schema.MetadataSchema() ) - await client.get_metadata_schema(request) # Establish that the underlying gRPC stub method was called. @@ -6774,7 +6551,7 @@ async def test_get_metadata_schema_field_headers_async(): def test_get_metadata_schema_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6782,7 +6559,6 @@ def test_get_metadata_schema_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_schema.MetadataSchema() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_metadata_schema(name="name_value",) @@ -6791,12 +6567,11 @@ def test_get_metadata_schema_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_metadata_schema_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6808,7 +6583,9 @@ def test_get_metadata_schema_flattened_error(): @pytest.mark.asyncio async def test_get_metadata_schema_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6828,13 +6605,14 @@ async def test_get_metadata_schema_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_metadata_schema_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6848,7 +6626,7 @@ def test_list_metadata_schemas( transport: str = "grpc", request_type=metadata_service.ListMetadataSchemasRequest ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6863,19 +6641,15 @@ def test_list_metadata_schemas( call.return_value = metadata_service.ListMetadataSchemasResponse( next_page_token="next_page_token_value", ) - response = client.list_metadata_schemas(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListMetadataSchemasRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListMetadataSchemasPager) - assert response.next_page_token == "next_page_token_value" @@ -6887,7 +6661,7 @@ def test_list_metadata_schemas_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6897,7 +6671,6 @@ def test_list_metadata_schemas_empty_call(): client.list_metadata_schemas() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListMetadataSchemasRequest() @@ -6907,7 +6680,7 @@ async def test_list_metadata_schemas_async( request_type=metadata_service.ListMetadataSchemasRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6924,18 +6697,15 @@ async def test_list_metadata_schemas_async( next_page_token="next_page_token_value", ) ) - response = await client.list_metadata_schemas(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.ListMetadataSchemasRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListMetadataSchemasAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -6945,11 +6715,12 @@ async def test_list_metadata_schemas_async_from_dict(): def test_list_metadata_schemas_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListMetadataSchemasRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6957,7 +6728,6 @@ def test_list_metadata_schemas_field_headers(): type(client.transport.list_metadata_schemas), "__call__" ) as call: call.return_value = metadata_service.ListMetadataSchemasResponse() - client.list_metadata_schemas(request) # Establish that the underlying gRPC stub method was called. @@ -6972,11 +6742,14 @@ def test_list_metadata_schemas_field_headers(): @pytest.mark.asyncio async def test_list_metadata_schemas_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.ListMetadataSchemasRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6986,7 +6759,6 @@ async def test_list_metadata_schemas_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( metadata_service.ListMetadataSchemasResponse() ) - await client.list_metadata_schemas(request) # Establish that the underlying gRPC stub method was called. @@ -7000,7 +6772,7 @@ async def test_list_metadata_schemas_field_headers_async(): def test_list_metadata_schemas_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7008,7 +6780,6 @@ def test_list_metadata_schemas_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = metadata_service.ListMetadataSchemasResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_metadata_schemas(parent="parent_value",) @@ -7017,12 +6788,11 @@ def test_list_metadata_schemas_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_metadata_schemas_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7034,7 +6804,9 @@ def test_list_metadata_schemas_flattened_error(): @pytest.mark.asyncio async def test_list_metadata_schemas_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7054,13 +6826,14 @@ async def test_list_metadata_schemas_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_metadata_schemas_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7071,7 +6844,7 @@ async def test_list_metadata_schemas_flattened_error_async(): def test_list_metadata_schemas_pager(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7117,7 +6890,7 @@ def test_list_metadata_schemas_pager(): def test_list_metadata_schemas_pages(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7155,7 +6928,9 @@ def test_list_metadata_schemas_pages(): @pytest.mark.asyncio async def test_list_metadata_schemas_async_pager(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7200,7 +6975,9 @@ async def test_list_metadata_schemas_async_pager(): @pytest.mark.asyncio async def test_list_metadata_schemas_async_pages(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7245,7 +7022,7 @@ def test_query_artifact_lineage_subgraph( request_type=metadata_service.QueryArtifactLineageSubgraphRequest, ): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7258,17 +7035,14 @@ def test_query_artifact_lineage_subgraph( ) as call: # Designate an appropriate return value for the call. call.return_value = lineage_subgraph.LineageSubgraph() - response = client.query_artifact_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryArtifactLineageSubgraphRequest() # Establish that the response is the type that we expect. - assert isinstance(response, lineage_subgraph.LineageSubgraph) @@ -7280,7 +7054,7 @@ def test_query_artifact_lineage_subgraph_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7290,7 +7064,6 @@ def test_query_artifact_lineage_subgraph_empty_call(): client.query_artifact_lineage_subgraph() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryArtifactLineageSubgraphRequest() @@ -7300,7 +7073,7 @@ async def test_query_artifact_lineage_subgraph_async( request_type=metadata_service.QueryArtifactLineageSubgraphRequest, ): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7315,13 +7088,11 @@ async def test_query_artifact_lineage_subgraph_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( lineage_subgraph.LineageSubgraph() ) - response = await client.query_artifact_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == metadata_service.QueryArtifactLineageSubgraphRequest() # Establish that the response is the type that we expect. @@ -7334,11 +7105,12 @@ async def test_query_artifact_lineage_subgraph_async_from_dict(): def test_query_artifact_lineage_subgraph_field_headers(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.QueryArtifactLineageSubgraphRequest() + request.artifact = "artifact/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7346,7 +7118,6 @@ def test_query_artifact_lineage_subgraph_field_headers(): type(client.transport.query_artifact_lineage_subgraph), "__call__" ) as call: call.return_value = lineage_subgraph.LineageSubgraph() - client.query_artifact_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. @@ -7361,11 +7132,14 @@ def test_query_artifact_lineage_subgraph_field_headers(): @pytest.mark.asyncio async def test_query_artifact_lineage_subgraph_field_headers_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = metadata_service.QueryArtifactLineageSubgraphRequest() + request.artifact = "artifact/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7375,7 +7149,6 @@ async def test_query_artifact_lineage_subgraph_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( lineage_subgraph.LineageSubgraph() ) - await client.query_artifact_lineage_subgraph(request) # Establish that the underlying gRPC stub method was called. @@ -7389,7 +7162,7 @@ async def test_query_artifact_lineage_subgraph_field_headers_async(): def test_query_artifact_lineage_subgraph_flattened(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7397,7 +7170,6 @@ def test_query_artifact_lineage_subgraph_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = lineage_subgraph.LineageSubgraph() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.query_artifact_lineage_subgraph(artifact="artifact_value",) @@ -7406,12 +7178,11 @@ def test_query_artifact_lineage_subgraph_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].artifact == "artifact_value" def test_query_artifact_lineage_subgraph_flattened_error(): - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7424,7 +7195,9 @@ def test_query_artifact_lineage_subgraph_flattened_error(): @pytest.mark.asyncio async def test_query_artifact_lineage_subgraph_flattened_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7446,13 +7219,14 @@ async def test_query_artifact_lineage_subgraph_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].artifact == "artifact_value" @pytest.mark.asyncio async def test_query_artifact_lineage_subgraph_flattened_error_async(): - client = MetadataServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7466,16 +7240,16 @@ async def test_query_artifact_lineage_subgraph_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.MetadataServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.MetadataServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MetadataServiceClient( @@ -7485,7 +7259,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.MetadataServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MetadataServiceClient( @@ -7496,7 +7270,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.MetadataServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = MetadataServiceClient(transport=transport) assert client.transport is transport @@ -7505,13 +7279,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.MetadataServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.MetadataServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -7526,23 +7300,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = MetadataServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MetadataServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.MetadataServiceGrpcTransport,) def test_metadata_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.MetadataServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -7554,7 +7328,7 @@ def test_metadata_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.MetadataServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -7597,15 +7371,37 @@ def test_metadata_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_metadata_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.metadata_service.transports.MetadataServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.MetadataServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_metadata_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.metadata_service.transports.MetadataServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.MetadataServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -7618,19 +7414,33 @@ def test_metadata_service_base_transport_with_credentials_file(): def test_metadata_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.metadata_service.transports.MetadataServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.MetadataServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_metadata_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + MetadataServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_metadata_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) MetadataServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -7638,20 +7448,156 @@ def test_metadata_service_auth_adc(): ) -def test_metadata_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.MetadataServiceGrpcTransport, + transports.MetadataServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_metadata_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.MetadataServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.MetadataServiceGrpcTransport, + transports.MetadataServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_metadata_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MetadataServiceGrpcTransport, grpc_helpers), + (transports.MetadataServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_metadata_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MetadataServiceGrpcTransport, grpc_helpers), + (transports.MetadataServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_metadata_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MetadataServiceGrpcTransport, grpc_helpers), + (transports.MetadataServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_metadata_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -7660,7 +7606,7 @@ def test_metadata_service_transport_auth_adc(): ], ) def test_metadata_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -7699,7 +7645,7 @@ def test_metadata_service_grpc_transport_client_cert_source_for_mtls(transport_c def test_metadata_service_host_no_port(): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -7709,7 +7655,7 @@ def test_metadata_service_host_no_port(): def test_metadata_service_host_with_port(): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -7765,9 +7711,9 @@ def test_metadata_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -7843,7 +7789,7 @@ def test_metadata_service_transport_channel_mtls_with_adc(transport_class): def test_metadata_service_grpc_lro_client(): client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -7856,7 +7802,7 @@ def test_metadata_service_grpc_lro_client(): def test_metadata_service_grpc_lro_async_client(): client = MetadataServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -7872,7 +7818,6 @@ def test_artifact_path(): location = "clam" metadata_store = "whelk" artifact = "octopus" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact}".format( project=project, location=location, @@ -7904,7 +7849,6 @@ def test_context_path(): location = "nautilus" metadata_store = "scallop" context = "abalone" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context}".format( project=project, location=location, @@ -7936,7 +7880,6 @@ def test_execution_path(): location = "nudibranch" metadata_store = "cuttlefish" execution = "mussel" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution}".format( project=project, location=location, @@ -7968,7 +7911,6 @@ def test_metadata_schema_path(): location = "clam" metadata_store = "whelk" metadata_schema = "octopus" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}/metadataSchemas/{metadata_schema}".format( project=project, location=location, @@ -7999,7 +7941,6 @@ def test_metadata_store_path(): project = "winkle" location = "nautilus" metadata_store = "scallop" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}".format( project=project, location=location, metadata_store=metadata_store, ) @@ -8024,7 +7965,6 @@ def test_parse_metadata_store_path(): def test_common_billing_account_path(): billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -8045,7 +7985,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) actual = MetadataServiceClient.common_folder_path(folder) assert expected == actual @@ -8064,7 +8003,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) actual = MetadataServiceClient.common_organization_path(organization) assert expected == actual @@ -8083,7 +8021,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) actual = MetadataServiceClient.common_project_path(project) assert expected == actual @@ -8103,7 +8040,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "scallop" location = "abalone" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -8130,7 +8066,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.MetadataServiceTransport, "_prep_wrapped_messages" ) as prep: client = MetadataServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -8139,6 +8075,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = MetadataServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py index f547beb6bf..c5bfb7e766 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_migration_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.migration_service import ( MigrationServiceAsyncClient, @@ -43,10 +42,40 @@ ) from google.cloud.aiplatform_v1beta1.services.migration_service import pagers from google.cloud.aiplatform_v1beta1.services.migration_service import transports +from google.cloud.aiplatform_v1beta1.services.migration_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.migration_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import migratable_resource from google.cloud.aiplatform_v1beta1.types import migration_service from google.longrunning import operations_pb2 from google.oauth2 import service_account +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -98,7 +127,7 @@ def test__get_default_mtls_endpoint(): "client_class", [MigrationServiceClient, MigrationServiceAsyncClient,] ) def test_migration_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -115,7 +144,7 @@ def test_migration_service_client_from_service_account_info(client_class): "client_class", [MigrationServiceClient, MigrationServiceAsyncClient,] ) def test_migration_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -168,7 +197,7 @@ def test_migration_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(MigrationServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -467,7 +496,7 @@ def test_search_migratable_resources( request_type=migration_service.SearchMigratableResourcesRequest, ): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -482,19 +511,15 @@ def test_search_migratable_resources( call.return_value = migration_service.SearchMigratableResourcesResponse( next_page_token="next_page_token_value", ) - response = client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.SearchMigratableResourcesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchMigratableResourcesPager) - assert response.next_page_token == "next_page_token_value" @@ -506,7 +531,7 @@ def test_search_migratable_resources_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -516,7 +541,6 @@ def test_search_migratable_resources_empty_call(): client.search_migratable_resources() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.SearchMigratableResourcesRequest() @@ -526,7 +550,7 @@ async def test_search_migratable_resources_async( request_type=migration_service.SearchMigratableResourcesRequest, ): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -543,18 +567,15 @@ async def test_search_migratable_resources_async( next_page_token="next_page_token_value", ) ) - response = await client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.SearchMigratableResourcesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchMigratableResourcesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -564,11 +585,12 @@ async def test_search_migratable_resources_async_from_dict(): def test_search_migratable_resources_field_headers(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.SearchMigratableResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -576,7 +598,6 @@ def test_search_migratable_resources_field_headers(): type(client.transport.search_migratable_resources), "__call__" ) as call: call.return_value = migration_service.SearchMigratableResourcesResponse() - client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. @@ -592,12 +613,13 @@ def test_search_migratable_resources_field_headers(): @pytest.mark.asyncio async def test_search_migratable_resources_field_headers_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.SearchMigratableResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -607,7 +629,6 @@ async def test_search_migratable_resources_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( migration_service.SearchMigratableResourcesResponse() ) - await client.search_migratable_resources(request) # Establish that the underlying gRPC stub method was called. @@ -621,7 +642,7 @@ async def test_search_migratable_resources_field_headers_async(): def test_search_migratable_resources_flattened(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -629,7 +650,6 @@ def test_search_migratable_resources_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = migration_service.SearchMigratableResourcesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_migratable_resources(parent="parent_value",) @@ -638,12 +658,11 @@ def test_search_migratable_resources_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_search_migratable_resources_flattened_error(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -656,7 +675,7 @@ def test_search_migratable_resources_flattened_error(): @pytest.mark.asyncio async def test_search_migratable_resources_flattened_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -677,14 +696,13 @@ async def test_search_migratable_resources_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_search_migratable_resources_flattened_error_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -696,7 +714,7 @@ async def test_search_migratable_resources_flattened_error_async(): def test_search_migratable_resources_pager(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -744,7 +762,7 @@ def test_search_migratable_resources_pager(): def test_search_migratable_resources_pages(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -782,7 +800,9 @@ def test_search_migratable_resources_pages(): @pytest.mark.asyncio async def test_search_migratable_resources_async_pager(): - client = MigrationServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -829,7 +849,9 @@ async def test_search_migratable_resources_async_pager(): @pytest.mark.asyncio async def test_search_migratable_resources_async_pages(): - client = MigrationServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = MigrationServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -873,7 +895,7 @@ def test_batch_migrate_resources( transport: str = "grpc", request_type=migration_service.BatchMigrateResourcesRequest ): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -886,13 +908,11 @@ def test_batch_migrate_resources( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.BatchMigrateResourcesRequest() # Establish that the response is the type that we expect. @@ -907,7 +927,7 @@ def test_batch_migrate_resources_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -917,7 +937,6 @@ def test_batch_migrate_resources_empty_call(): client.batch_migrate_resources() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.BatchMigrateResourcesRequest() @@ -927,7 +946,7 @@ async def test_batch_migrate_resources_async( request_type=migration_service.BatchMigrateResourcesRequest, ): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -942,13 +961,11 @@ async def test_batch_migrate_resources_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == migration_service.BatchMigrateResourcesRequest() # Establish that the response is the type that we expect. @@ -961,11 +978,12 @@ async def test_batch_migrate_resources_async_from_dict(): def test_batch_migrate_resources_field_headers(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.BatchMigrateResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -973,7 +991,6 @@ def test_batch_migrate_resources_field_headers(): type(client.transport.batch_migrate_resources), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. @@ -989,12 +1006,13 @@ def test_batch_migrate_resources_field_headers(): @pytest.mark.asyncio async def test_batch_migrate_resources_field_headers_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = migration_service.BatchMigrateResourcesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1004,7 +1022,6 @@ async def test_batch_migrate_resources_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.batch_migrate_resources(request) # Establish that the underlying gRPC stub method was called. @@ -1018,7 +1035,7 @@ async def test_batch_migrate_resources_field_headers_async(): def test_batch_migrate_resources_flattened(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1026,7 +1043,6 @@ def test_batch_migrate_resources_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.batch_migrate_resources( @@ -1044,9 +1060,7 @@ def test_batch_migrate_resources_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].migrate_resource_requests == [ migration_service.MigrateResourceRequest( migrate_ml_engine_model_version_config=migration_service.MigrateResourceRequest.MigrateMlEngineModelVersionConfig( @@ -1057,7 +1071,7 @@ def test_batch_migrate_resources_flattened(): def test_batch_migrate_resources_flattened_error(): - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1078,7 +1092,7 @@ def test_batch_migrate_resources_flattened_error(): @pytest.mark.asyncio async def test_batch_migrate_resources_flattened_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1108,9 +1122,7 @@ async def test_batch_migrate_resources_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].migrate_resource_requests == [ migration_service.MigrateResourceRequest( migrate_ml_engine_model_version_config=migration_service.MigrateResourceRequest.MigrateMlEngineModelVersionConfig( @@ -1123,7 +1135,7 @@ async def test_batch_migrate_resources_flattened_async(): @pytest.mark.asyncio async def test_batch_migrate_resources_flattened_error_async(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1145,16 +1157,16 @@ async def test_batch_migrate_resources_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MigrationServiceClient( @@ -1164,7 +1176,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = MigrationServiceClient( @@ -1175,7 +1187,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = MigrationServiceClient(transport=transport) assert client.transport is transport @@ -1184,13 +1196,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.MigrationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.MigrationServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -1205,23 +1217,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = MigrationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = MigrationServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.MigrationServiceGrpcTransport,) def test_migration_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.MigrationServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1233,7 +1245,7 @@ def test_migration_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.MigrationServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -1252,15 +1264,37 @@ def test_migration_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_migration_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.MigrationServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_migration_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.MigrationServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -1273,19 +1307,33 @@ def test_migration_service_base_transport_with_credentials_file(): def test_migration_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.migration_service.transports.MigrationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.MigrationServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_migration_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + MigrationServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_migration_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) MigrationServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -1293,20 +1341,156 @@ def test_migration_service_auth_adc(): ) -def test_migration_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.MigrationServiceGrpcTransport, + transports.MigrationServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_migration_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.MigrationServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.MigrationServiceGrpcTransport, + transports.MigrationServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_migration_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MigrationServiceGrpcTransport, grpc_helpers), + (transports.MigrationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_migration_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MigrationServiceGrpcTransport, grpc_helpers), + (transports.MigrationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_migration_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.MigrationServiceGrpcTransport, grpc_helpers), + (transports.MigrationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_migration_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -1315,7 +1499,7 @@ def test_migration_service_transport_auth_adc(): ], ) def test_migration_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -1354,7 +1538,7 @@ def test_migration_service_grpc_transport_client_cert_source_for_mtls(transport_ def test_migration_service_host_no_port(): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -1364,7 +1548,7 @@ def test_migration_service_host_no_port(): def test_migration_service_host_with_port(): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -1420,9 +1604,9 @@ def test_migration_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -1498,7 +1682,7 @@ def test_migration_service_transport_channel_mtls_with_adc(transport_class): def test_migration_service_grpc_lro_client(): client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -1511,7 +1695,7 @@ def test_migration_service_grpc_lro_client(): def test_migration_service_grpc_lro_async_client(): client = MigrationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -1526,7 +1710,6 @@ def test_annotated_dataset_path(): project = "squid" dataset = "clam" annotated_dataset = "whelk" - expected = "projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}".format( project=project, dataset=dataset, annotated_dataset=annotated_dataset, ) @@ -1553,7 +1736,6 @@ def test_dataset_path(): project = "cuttlefish" location = "mussel" dataset = "winkle" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( project=project, location=location, dataset=dataset, ) @@ -1577,7 +1759,6 @@ def test_parse_dataset_path(): def test_dataset_path(): project = "squid" dataset = "clam" - expected = "projects/{project}/datasets/{dataset}".format( project=project, dataset=dataset, ) @@ -1601,7 +1782,6 @@ def test_dataset_path(): project = "oyster" location = "nudibranch" dataset = "cuttlefish" - expected = "projects/{project}/locations/{location}/datasets/{dataset}".format( project=project, location=location, dataset=dataset, ) @@ -1626,7 +1806,6 @@ def test_model_path(): project = "scallop" location = "abalone" model = "squid" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -1651,7 +1830,6 @@ def test_model_path(): project = "oyster" location = "nudibranch" model = "cuttlefish" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -1676,7 +1854,6 @@ def test_version_path(): project = "scallop" model = "abalone" version = "squid" - expected = "projects/{project}/models/{model}/versions/{version}".format( project=project, model=model, version=version, ) @@ -1699,7 +1876,6 @@ def test_parse_version_path(): def test_common_billing_account_path(): billing_account = "oyster" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -1720,7 +1896,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) actual = MigrationServiceClient.common_folder_path(folder) assert expected == actual @@ -1739,7 +1914,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) actual = MigrationServiceClient.common_organization_path(organization) assert expected == actual @@ -1758,7 +1932,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) actual = MigrationServiceClient.common_project_path(project) assert expected == actual @@ -1778,7 +1951,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "squid" location = "clam" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -1805,7 +1977,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.MigrationServiceTransport, "_prep_wrapped_messages" ) as prep: client = MigrationServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1814,6 +1986,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = MigrationServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py index a31f13c873..d28fff4307 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_model_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.model_service import ( ModelServiceAsyncClient, @@ -41,6 +40,12 @@ from google.cloud.aiplatform_v1beta1.services.model_service import ModelServiceClient from google.cloud.aiplatform_v1beta1.services.model_service import pagers from google.cloud.aiplatform_v1beta1.services.model_service import transports +from google.cloud.aiplatform_v1beta1.services.model_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.model_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import deployed_model_ref from google.cloud.aiplatform_v1beta1.types import encryption_spec from google.cloud.aiplatform_v1beta1.types import env_var @@ -55,9 +60,33 @@ from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -103,7 +132,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [ModelServiceClient, ModelServiceAsyncClient,]) def test_model_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -118,7 +147,7 @@ def test_model_service_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [ModelServiceClient, ModelServiceAsyncClient,]) def test_model_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -169,7 +198,7 @@ def test_model_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(ModelServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -453,7 +482,7 @@ def test_upload_model( transport: str = "grpc", request_type=model_service.UploadModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -464,13 +493,11 @@ def test_upload_model( with mock.patch.object(type(client.transport.upload_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.upload_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UploadModelRequest() # Establish that the response is the type that we expect. @@ -485,7 +512,7 @@ def test_upload_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -493,7 +520,6 @@ def test_upload_model_empty_call(): client.upload_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UploadModelRequest() @@ -502,7 +528,7 @@ async def test_upload_model_async( transport: str = "grpc_asyncio", request_type=model_service.UploadModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -515,13 +541,11 @@ async def test_upload_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.upload_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UploadModelRequest() # Establish that the response is the type that we expect. @@ -534,17 +558,17 @@ async def test_upload_model_async_from_dict(): def test_upload_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UploadModelRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.upload_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.upload_model(request) # Establish that the underlying gRPC stub method was called. @@ -559,11 +583,12 @@ def test_upload_model_field_headers(): @pytest.mark.asyncio async def test_upload_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UploadModelRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -571,7 +596,6 @@ async def test_upload_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.upload_model(request) # Establish that the underlying gRPC stub method was called. @@ -585,13 +609,12 @@ async def test_upload_model_field_headers_async(): def test_upload_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.upload_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.upload_model( @@ -602,14 +625,12 @@ def test_upload_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == gca_model.Model(name="name_value") def test_upload_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -623,7 +644,7 @@ def test_upload_model_flattened_error(): @pytest.mark.asyncio async def test_upload_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.upload_model), "__call__") as call: @@ -643,15 +664,13 @@ async def test_upload_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].model == gca_model.Model(name="name_value") @pytest.mark.asyncio async def test_upload_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -665,7 +684,7 @@ async def test_upload_model_flattened_error_async(): def test_get_model(transport: str = "grpc", request_type=model_service.GetModelRequest): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -689,43 +708,30 @@ def test_get_model(transport: str = "grpc", request_type=model_service.GetModelR supported_output_storage_formats=["supported_output_storage_formats_value"], etag="etag_value", ) - response = client.get_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -737,7 +743,7 @@ def test_get_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -745,7 +751,6 @@ def test_get_model_empty_call(): client.get_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelRequest() @@ -754,7 +759,7 @@ async def test_get_model_async( transport: str = "grpc_asyncio", request_type=model_service.GetModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -784,42 +789,30 @@ async def test_get_model_async( etag="etag_value", ) ) - response = await client.get_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelRequest() # Establish that the response is the type that we expect. assert isinstance(response, model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -829,17 +822,17 @@ async def test_get_model_async_from_dict(): def test_get_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: call.return_value = model.Model() - client.get_model(request) # Establish that the underlying gRPC stub method was called. @@ -854,17 +847,17 @@ def test_get_model_field_headers(): @pytest.mark.asyncio async def test_get_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(model.Model()) - await client.get_model(request) # Establish that the underlying gRPC stub method was called. @@ -878,13 +871,12 @@ async def test_get_model_field_headers_async(): def test_get_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = model.Model() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_model(name="name_value",) @@ -893,12 +885,11 @@ def test_get_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -910,7 +901,7 @@ def test_get_model_flattened_error(): @pytest.mark.asyncio async def test_get_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_model), "__call__") as call: @@ -926,13 +917,12 @@ async def test_get_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -946,7 +936,7 @@ def test_list_models( transport: str = "grpc", request_type=model_service.ListModelsRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -959,19 +949,15 @@ def test_list_models( call.return_value = model_service.ListModelsResponse( next_page_token="next_page_token_value", ) - response = client.list_models(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListModelsPager) - assert response.next_page_token == "next_page_token_value" @@ -983,7 +969,7 @@ def test_list_models_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -991,7 +977,6 @@ def test_list_models_empty_call(): client.list_models() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelsRequest() @@ -1000,7 +985,7 @@ async def test_list_models_async( transport: str = "grpc_asyncio", request_type=model_service.ListModelsRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1013,18 +998,15 @@ async def test_list_models_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_models(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListModelsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1034,17 +1016,17 @@ async def test_list_models_async_from_dict(): def test_list_models_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: call.return_value = model_service.ListModelsResponse() - client.list_models(request) # Establish that the underlying gRPC stub method was called. @@ -1059,11 +1041,12 @@ def test_list_models_field_headers(): @pytest.mark.asyncio async def test_list_models_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1071,7 +1054,6 @@ async def test_list_models_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelsResponse() ) - await client.list_models(request) # Establish that the underlying gRPC stub method was called. @@ -1085,13 +1067,12 @@ async def test_list_models_field_headers_async(): def test_list_models_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = model_service.ListModelsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_models(parent="parent_value",) @@ -1100,12 +1081,11 @@ def test_list_models_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_models_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1117,7 +1097,7 @@ def test_list_models_flattened_error(): @pytest.mark.asyncio async def test_list_models_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: @@ -1135,13 +1115,12 @@ async def test_list_models_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_models_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1152,7 +1131,7 @@ async def test_list_models_flattened_error_async(): def test_list_models_pager(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: @@ -1184,7 +1163,7 @@ def test_list_models_pager(): def test_list_models_pages(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_models), "__call__") as call: @@ -1208,7 +1187,7 @@ def test_list_models_pages(): @pytest.mark.asyncio async def test_list_models_async_pager(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1239,7 +1218,7 @@ async def test_list_models_async_pager(): @pytest.mark.asyncio async def test_list_models_async_pages(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1269,7 +1248,7 @@ def test_update_model( transport: str = "grpc", request_type=model_service.UpdateModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1293,43 +1272,30 @@ def test_update_model( supported_output_storage_formats=["supported_output_storage_formats_value"], etag="etag_value", ) - response = client.update_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UpdateModelRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ gca_model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -1341,7 +1307,7 @@ def test_update_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1349,7 +1315,6 @@ def test_update_model_empty_call(): client.update_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UpdateModelRequest() @@ -1358,7 +1323,7 @@ async def test_update_model_async( transport: str = "grpc_asyncio", request_type=model_service.UpdateModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1388,42 +1353,30 @@ async def test_update_model_async( etag="etag_value", ) ) - response = await client.update_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.UpdateModelRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_model.Model) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.metadata_schema_uri == "metadata_schema_uri_value" - assert response.training_pipeline == "training_pipeline_value" - assert response.artifact_uri == "artifact_uri_value" - assert response.supported_deployment_resources_types == [ gca_model.Model.DeploymentResourcesType.DEDICATED_RESOURCES ] - assert response.supported_input_storage_formats == [ "supported_input_storage_formats_value" ] - assert response.supported_output_storage_formats == [ "supported_output_storage_formats_value" ] - assert response.etag == "etag_value" @@ -1433,17 +1386,17 @@ async def test_update_model_async_from_dict(): def test_update_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UpdateModelRequest() + request.model.name = "model.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: call.return_value = gca_model.Model() - client.update_model(request) # Establish that the underlying gRPC stub method was called. @@ -1458,17 +1411,17 @@ def test_update_model_field_headers(): @pytest.mark.asyncio async def test_update_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.UpdateModelRequest() + request.model.name = "model.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_model.Model()) - await client.update_model(request) # Establish that the underlying gRPC stub method was called. @@ -1482,32 +1435,29 @@ async def test_update_model_field_headers_async(): def test_update_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_model.Model() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_model( model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].model == gca_model.Model(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1515,13 +1465,13 @@ def test_update_model_flattened_error(): client.update_model( model_service.UpdateModelRequest(), model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_model), "__call__") as call: @@ -1533,22 +1483,20 @@ async def test_update_model_flattened_async(): # using the keyword arguments to the method. response = await client.update_model( model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].model == gca_model.Model(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1556,7 +1504,7 @@ async def test_update_model_flattened_error_async(): await client.update_model( model_service.UpdateModelRequest(), model=gca_model.Model(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1564,7 +1512,7 @@ def test_delete_model( transport: str = "grpc", request_type=model_service.DeleteModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1575,13 +1523,11 @@ def test_delete_model( with mock.patch.object(type(client.transport.delete_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.DeleteModelRequest() # Establish that the response is the type that we expect. @@ -1596,7 +1542,7 @@ def test_delete_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1604,7 +1550,6 @@ def test_delete_model_empty_call(): client.delete_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.DeleteModelRequest() @@ -1613,7 +1558,7 @@ async def test_delete_model_async( transport: str = "grpc_asyncio", request_type=model_service.DeleteModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1626,13 +1571,11 @@ async def test_delete_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.DeleteModelRequest() # Establish that the response is the type that we expect. @@ -1645,17 +1588,17 @@ async def test_delete_model_async_from_dict(): def test_delete_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.DeleteModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_model(request) # Establish that the underlying gRPC stub method was called. @@ -1670,11 +1613,12 @@ def test_delete_model_field_headers(): @pytest.mark.asyncio async def test_delete_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.DeleteModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1682,7 +1626,6 @@ async def test_delete_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_model(request) # Establish that the underlying gRPC stub method was called. @@ -1696,13 +1639,12 @@ async def test_delete_model_field_headers_async(): def test_delete_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_model(name="name_value",) @@ -1711,12 +1653,11 @@ def test_delete_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1728,7 +1669,7 @@ def test_delete_model_flattened_error(): @pytest.mark.asyncio async def test_delete_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_model), "__call__") as call: @@ -1746,13 +1687,12 @@ async def test_delete_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1766,7 +1706,7 @@ def test_export_model( transport: str = "grpc", request_type=model_service.ExportModelRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1777,13 +1717,11 @@ def test_export_model( with mock.patch.object(type(client.transport.export_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.export_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ExportModelRequest() # Establish that the response is the type that we expect. @@ -1798,7 +1736,7 @@ def test_export_model_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1806,7 +1744,6 @@ def test_export_model_empty_call(): client.export_model() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ExportModelRequest() @@ -1815,7 +1752,7 @@ async def test_export_model_async( transport: str = "grpc_asyncio", request_type=model_service.ExportModelRequest ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1828,13 +1765,11 @@ async def test_export_model_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.export_model(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ExportModelRequest() # Establish that the response is the type that we expect. @@ -1847,17 +1782,17 @@ async def test_export_model_async_from_dict(): def test_export_model_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ExportModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_model), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.export_model(request) # Establish that the underlying gRPC stub method was called. @@ -1872,11 +1807,12 @@ def test_export_model_field_headers(): @pytest.mark.asyncio async def test_export_model_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ExportModelRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1884,7 +1820,6 @@ async def test_export_model_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.export_model(request) # Establish that the underlying gRPC stub method was called. @@ -1898,13 +1833,12 @@ async def test_export_model_field_headers_async(): def test_export_model_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_model), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.export_model( @@ -1918,16 +1852,14 @@ def test_export_model_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == model_service.ExportModelRequest.OutputConfig( export_format_id="export_format_id_value" ) def test_export_model_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1943,7 +1875,7 @@ def test_export_model_flattened_error(): @pytest.mark.asyncio async def test_export_model_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.export_model), "__call__") as call: @@ -1966,9 +1898,7 @@ async def test_export_model_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].output_config == model_service.ExportModelRequest.OutputConfig( export_format_id="export_format_id_value" ) @@ -1976,7 +1906,7 @@ async def test_export_model_flattened_async(): @pytest.mark.asyncio async def test_export_model_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1994,7 +1924,7 @@ def test_get_model_evaluation( transport: str = "grpc", request_type=model_service.GetModelEvaluationRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2011,23 +1941,17 @@ def test_get_model_evaluation( metrics_schema_uri="metrics_schema_uri_value", slice_dimensions=["slice_dimensions_value"], ) - response = client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, model_evaluation.ModelEvaluation) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" - assert response.slice_dimensions == ["slice_dimensions_value"] @@ -2039,7 +1963,7 @@ def test_get_model_evaluation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2049,7 +1973,6 @@ def test_get_model_evaluation_empty_call(): client.get_model_evaluation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationRequest() @@ -2059,7 +1982,7 @@ async def test_get_model_evaluation_async( request_type=model_service.GetModelEvaluationRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2078,22 +2001,17 @@ async def test_get_model_evaluation_async( slice_dimensions=["slice_dimensions_value"], ) ) - response = await client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationRequest() # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation.ModelEvaluation) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" - assert response.slice_dimensions == ["slice_dimensions_value"] @@ -2103,11 +2021,12 @@ async def test_get_model_evaluation_async_from_dict(): def test_get_model_evaluation_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2115,7 +2034,6 @@ def test_get_model_evaluation_field_headers(): type(client.transport.get_model_evaluation), "__call__" ) as call: call.return_value = model_evaluation.ModelEvaluation() - client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. @@ -2130,11 +2048,12 @@ def test_get_model_evaluation_field_headers(): @pytest.mark.asyncio async def test_get_model_evaluation_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2144,7 +2063,6 @@ async def test_get_model_evaluation_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_evaluation.ModelEvaluation() ) - await client.get_model_evaluation(request) # Establish that the underlying gRPC stub method was called. @@ -2158,7 +2076,7 @@ async def test_get_model_evaluation_field_headers_async(): def test_get_model_evaluation_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2166,7 +2084,6 @@ def test_get_model_evaluation_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_evaluation.ModelEvaluation() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_model_evaluation(name="name_value",) @@ -2175,12 +2092,11 @@ def test_get_model_evaluation_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_model_evaluation_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2192,7 +2108,7 @@ def test_get_model_evaluation_flattened_error(): @pytest.mark.asyncio async def test_get_model_evaluation_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2212,13 +2128,12 @@ async def test_get_model_evaluation_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_model_evaluation_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2232,7 +2147,7 @@ def test_list_model_evaluations( transport: str = "grpc", request_type=model_service.ListModelEvaluationsRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2247,19 +2162,15 @@ def test_list_model_evaluations( call.return_value = model_service.ListModelEvaluationsResponse( next_page_token="next_page_token_value", ) - response = client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListModelEvaluationsPager) - assert response.next_page_token == "next_page_token_value" @@ -2271,7 +2182,7 @@ def test_list_model_evaluations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2281,7 +2192,6 @@ def test_list_model_evaluations_empty_call(): client.list_model_evaluations() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationsRequest() @@ -2291,7 +2201,7 @@ async def test_list_model_evaluations_async( request_type=model_service.ListModelEvaluationsRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2308,18 +2218,15 @@ async def test_list_model_evaluations_async( next_page_token="next_page_token_value", ) ) - response = await client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListModelEvaluationsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2329,11 +2236,12 @@ async def test_list_model_evaluations_async_from_dict(): def test_list_model_evaluations_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2341,7 +2249,6 @@ def test_list_model_evaluations_field_headers(): type(client.transport.list_model_evaluations), "__call__" ) as call: call.return_value = model_service.ListModelEvaluationsResponse() - client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. @@ -2356,11 +2263,12 @@ def test_list_model_evaluations_field_headers(): @pytest.mark.asyncio async def test_list_model_evaluations_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2370,7 +2278,6 @@ async def test_list_model_evaluations_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelEvaluationsResponse() ) - await client.list_model_evaluations(request) # Establish that the underlying gRPC stub method was called. @@ -2384,7 +2291,7 @@ async def test_list_model_evaluations_field_headers_async(): def test_list_model_evaluations_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2392,7 +2299,6 @@ def test_list_model_evaluations_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_service.ListModelEvaluationsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_model_evaluations(parent="parent_value",) @@ -2401,12 +2307,11 @@ def test_list_model_evaluations_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_model_evaluations_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2418,7 +2323,7 @@ def test_list_model_evaluations_flattened_error(): @pytest.mark.asyncio async def test_list_model_evaluations_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2438,13 +2343,12 @@ async def test_list_model_evaluations_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_model_evaluations_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2455,7 +2359,7 @@ async def test_list_model_evaluations_flattened_error_async(): def test_list_model_evaluations_pager(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2501,7 +2405,7 @@ def test_list_model_evaluations_pager(): def test_list_model_evaluations_pages(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2539,7 +2443,7 @@ def test_list_model_evaluations_pages(): @pytest.mark.asyncio async def test_list_model_evaluations_async_pager(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2584,7 +2488,7 @@ async def test_list_model_evaluations_async_pager(): @pytest.mark.asyncio async def test_list_model_evaluations_async_pages(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2628,7 +2532,7 @@ def test_get_model_evaluation_slice( transport: str = "grpc", request_type=model_service.GetModelEvaluationSliceRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2643,21 +2547,16 @@ def test_get_model_evaluation_slice( call.return_value = model_evaluation_slice.ModelEvaluationSlice( name="name_value", metrics_schema_uri="metrics_schema_uri_value", ) - response = client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationSliceRequest() # Establish that the response is the type that we expect. - assert isinstance(response, model_evaluation_slice.ModelEvaluationSlice) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" @@ -2669,7 +2568,7 @@ def test_get_model_evaluation_slice_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2679,7 +2578,6 @@ def test_get_model_evaluation_slice_empty_call(): client.get_model_evaluation_slice() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationSliceRequest() @@ -2689,7 +2587,7 @@ async def test_get_model_evaluation_slice_async( request_type=model_service.GetModelEvaluationSliceRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2706,20 +2604,16 @@ async def test_get_model_evaluation_slice_async( name="name_value", metrics_schema_uri="metrics_schema_uri_value", ) ) - response = await client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.GetModelEvaluationSliceRequest() # Establish that the response is the type that we expect. assert isinstance(response, model_evaluation_slice.ModelEvaluationSlice) - assert response.name == "name_value" - assert response.metrics_schema_uri == "metrics_schema_uri_value" @@ -2729,11 +2623,12 @@ async def test_get_model_evaluation_slice_async_from_dict(): def test_get_model_evaluation_slice_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationSliceRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2741,7 +2636,6 @@ def test_get_model_evaluation_slice_field_headers(): type(client.transport.get_model_evaluation_slice), "__call__" ) as call: call.return_value = model_evaluation_slice.ModelEvaluationSlice() - client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. @@ -2756,11 +2650,12 @@ def test_get_model_evaluation_slice_field_headers(): @pytest.mark.asyncio async def test_get_model_evaluation_slice_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.GetModelEvaluationSliceRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2770,7 +2665,6 @@ async def test_get_model_evaluation_slice_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_evaluation_slice.ModelEvaluationSlice() ) - await client.get_model_evaluation_slice(request) # Establish that the underlying gRPC stub method was called. @@ -2784,7 +2678,7 @@ async def test_get_model_evaluation_slice_field_headers_async(): def test_get_model_evaluation_slice_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2792,7 +2686,6 @@ def test_get_model_evaluation_slice_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_evaluation_slice.ModelEvaluationSlice() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_model_evaluation_slice(name="name_value",) @@ -2801,12 +2694,11 @@ def test_get_model_evaluation_slice_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_model_evaluation_slice_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2818,7 +2710,7 @@ def test_get_model_evaluation_slice_flattened_error(): @pytest.mark.asyncio async def test_get_model_evaluation_slice_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2838,13 +2730,12 @@ async def test_get_model_evaluation_slice_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_model_evaluation_slice_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2858,7 +2749,7 @@ def test_list_model_evaluation_slices( transport: str = "grpc", request_type=model_service.ListModelEvaluationSlicesRequest ): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2873,19 +2764,15 @@ def test_list_model_evaluation_slices( call.return_value = model_service.ListModelEvaluationSlicesResponse( next_page_token="next_page_token_value", ) - response = client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationSlicesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListModelEvaluationSlicesPager) - assert response.next_page_token == "next_page_token_value" @@ -2897,7 +2784,7 @@ def test_list_model_evaluation_slices_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2907,7 +2794,6 @@ def test_list_model_evaluation_slices_empty_call(): client.list_model_evaluation_slices() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationSlicesRequest() @@ -2917,7 +2803,7 @@ async def test_list_model_evaluation_slices_async( request_type=model_service.ListModelEvaluationSlicesRequest, ): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2934,18 +2820,15 @@ async def test_list_model_evaluation_slices_async( next_page_token="next_page_token_value", ) ) - response = await client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == model_service.ListModelEvaluationSlicesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListModelEvaluationSlicesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2955,11 +2838,12 @@ async def test_list_model_evaluation_slices_async_from_dict(): def test_list_model_evaluation_slices_field_headers(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationSlicesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2967,7 +2851,6 @@ def test_list_model_evaluation_slices_field_headers(): type(client.transport.list_model_evaluation_slices), "__call__" ) as call: call.return_value = model_service.ListModelEvaluationSlicesResponse() - client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. @@ -2982,11 +2865,12 @@ def test_list_model_evaluation_slices_field_headers(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_field_headers_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = model_service.ListModelEvaluationSlicesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2996,7 +2880,6 @@ async def test_list_model_evaluation_slices_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( model_service.ListModelEvaluationSlicesResponse() ) - await client.list_model_evaluation_slices(request) # Establish that the underlying gRPC stub method was called. @@ -3010,7 +2893,7 @@ async def test_list_model_evaluation_slices_field_headers_async(): def test_list_model_evaluation_slices_flattened(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3018,7 +2901,6 @@ def test_list_model_evaluation_slices_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = model_service.ListModelEvaluationSlicesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_model_evaluation_slices(parent="parent_value",) @@ -3027,12 +2909,11 @@ def test_list_model_evaluation_slices_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_model_evaluation_slices_flattened_error(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3044,7 +2925,7 @@ def test_list_model_evaluation_slices_flattened_error(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_flattened_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3064,13 +2945,12 @@ async def test_list_model_evaluation_slices_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_model_evaluation_slices_flattened_error_async(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3081,7 +2961,7 @@ async def test_list_model_evaluation_slices_flattened_error_async(): def test_list_model_evaluation_slices_pager(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3131,7 +3011,7 @@ def test_list_model_evaluation_slices_pager(): def test_list_model_evaluation_slices_pages(): - client = ModelServiceClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3171,7 +3051,7 @@ def test_list_model_evaluation_slices_pages(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_async_pager(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3221,7 +3101,7 @@ async def test_list_model_evaluation_slices_async_pager(): @pytest.mark.asyncio async def test_list_model_evaluation_slices_async_pages(): - client = ModelServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ModelServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3268,16 +3148,16 @@ async def test_list_model_evaluation_slices_async_pages(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ModelServiceClient( @@ -3287,7 +3167,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ModelServiceClient( @@ -3298,7 +3178,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = ModelServiceClient(transport=transport) assert client.transport is transport @@ -3307,13 +3187,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.ModelServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.ModelServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3328,23 +3208,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = ModelServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ModelServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.ModelServiceGrpcTransport,) def test_model_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.ModelServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3356,7 +3236,7 @@ def test_model_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.ModelServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3383,15 +3263,37 @@ def test_model_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_model_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.model_service.transports.ModelServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ModelServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_model_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.model_service.transports.ModelServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ModelServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3404,19 +3306,33 @@ def test_model_service_base_transport_with_credentials_file(): def test_model_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.model_service.transports.ModelServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ModelServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_model_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + ModelServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_model_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) ModelServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3424,26 +3340,162 @@ def test_model_service_auth_adc(): ) -def test_model_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.ModelServiceGrpcTransport, + transports.ModelServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_model_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.ModelServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ModelServiceGrpcTransport, + transports.ModelServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_model_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ModelServiceGrpcTransport, grpc_helpers), + (transports.ModelServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_model_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ModelServiceGrpcTransport, grpc_helpers), + (transports.ModelServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_model_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ModelServiceGrpcTransport, grpc_helpers), + (transports.ModelServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_model_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [transports.ModelServiceGrpcTransport, transports.ModelServiceGrpcAsyncIOTransport], ) def test_model_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3482,7 +3534,7 @@ def test_model_service_grpc_transport_client_cert_source_for_mtls(transport_clas def test_model_service_host_no_port(): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -3492,7 +3544,7 @@ def test_model_service_host_no_port(): def test_model_service_host_with_port(): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -3543,9 +3595,9 @@ def test_model_service_transport_channel_mtls_with_client_cert_source(transport_ mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3618,7 +3670,7 @@ def test_model_service_transport_channel_mtls_with_adc(transport_class): def test_model_service_grpc_lro_client(): client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3631,7 +3683,7 @@ def test_model_service_grpc_lro_client(): def test_model_service_grpc_lro_async_client(): client = ModelServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3646,7 +3698,6 @@ def test_endpoint_path(): project = "squid" location = "clam" endpoint = "whelk" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -3671,7 +3722,6 @@ def test_model_path(): project = "cuttlefish" location = "mussel" model = "winkle" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -3697,7 +3747,6 @@ def test_model_evaluation_path(): location = "clam" model = "whelk" evaluation = "octopus" - expected = "projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}".format( project=project, location=location, model=model, evaluation=evaluation, ) @@ -3727,7 +3776,6 @@ def test_model_evaluation_slice_path(): model = "scallop" evaluation = "abalone" slice = "squid" - expected = "projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}/slices/{slice}".format( project=project, location=location, @@ -3760,7 +3808,6 @@ def test_training_pipeline_path(): project = "cuttlefish" location = "mussel" training_pipeline = "winkle" - expected = "projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}".format( project=project, location=location, training_pipeline=training_pipeline, ) @@ -3785,7 +3832,6 @@ def test_parse_training_pipeline_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3806,7 +3852,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = ModelServiceClient.common_folder_path(folder) assert expected == actual @@ -3825,7 +3870,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = ModelServiceClient.common_organization_path(organization) assert expected == actual @@ -3844,7 +3888,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = ModelServiceClient.common_project_path(project) assert expected == actual @@ -3864,7 +3907,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3891,7 +3933,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ModelServiceTransport, "_prep_wrapped_messages" ) as prep: client = ModelServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3900,6 +3942,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ModelServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py index 59218c0ed9..7c78097cd6 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_pipeline_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.pipeline_service import ( PipelineServiceAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.aiplatform_v1beta1.services.pipeline_service import pagers from google.cloud.aiplatform_v1beta1.services.pipeline_service import transports +from google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import artifact from google.cloud.aiplatform_v1beta1.types import context from google.cloud.aiplatform_v1beta1.types import deployed_model_ref @@ -65,11 +70,35 @@ from google.cloud.aiplatform_v1beta1.types import value from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -120,7 +149,7 @@ def test__get_default_mtls_endpoint(): "client_class", [PipelineServiceClient, PipelineServiceAsyncClient,] ) def test_pipeline_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -137,7 +166,7 @@ def test_pipeline_service_client_from_service_account_info(client_class): "client_class", [PipelineServiceClient, PipelineServiceAsyncClient,] ) def test_pipeline_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -190,7 +219,7 @@ def test_pipeline_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(PipelineServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -488,7 +517,7 @@ def test_create_training_pipeline( transport: str = "grpc", request_type=pipeline_service.CreateTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -506,25 +535,18 @@ def test_create_training_pipeline( training_task_definition="training_task_definition_value", state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) - response = client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreateTrainingPipelineRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -536,7 +558,7 @@ def test_create_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -546,7 +568,6 @@ def test_create_training_pipeline_empty_call(): client.create_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreateTrainingPipelineRequest() @@ -556,7 +577,7 @@ async def test_create_training_pipeline_async( request_type=pipeline_service.CreateTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -576,24 +597,18 @@ async def test_create_training_pipeline_async( state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) ) - response = await client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreateTrainingPipelineRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -603,11 +618,12 @@ async def test_create_training_pipeline_async_from_dict(): def test_create_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CreateTrainingPipelineRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -615,7 +631,6 @@ def test_create_training_pipeline_field_headers(): type(client.transport.create_training_pipeline), "__call__" ) as call: call.return_value = gca_training_pipeline.TrainingPipeline() - client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -630,11 +645,14 @@ def test_create_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_create_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CreateTrainingPipelineRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -644,7 +662,6 @@ async def test_create_training_pipeline_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_training_pipeline.TrainingPipeline() ) - await client.create_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -658,7 +675,7 @@ async def test_create_training_pipeline_field_headers_async(): def test_create_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -666,7 +683,6 @@ def test_create_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_training_pipeline.TrainingPipeline() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_training_pipeline( @@ -678,16 +694,14 @@ def test_create_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].training_pipeline == gca_training_pipeline.TrainingPipeline( name="name_value" ) def test_create_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -701,7 +715,9 @@ def test_create_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_create_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -724,9 +740,7 @@ async def test_create_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].training_pipeline == gca_training_pipeline.TrainingPipeline( name="name_value" ) @@ -734,7 +748,9 @@ async def test_create_training_pipeline_flattened_async(): @pytest.mark.asyncio async def test_create_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -750,7 +766,7 @@ def test_get_training_pipeline( transport: str = "grpc", request_type=pipeline_service.GetTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -768,25 +784,18 @@ def test_get_training_pipeline( training_task_definition="training_task_definition_value", state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) - response = client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetTrainingPipelineRequest() # Establish that the response is the type that we expect. - assert isinstance(response, training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -798,7 +807,7 @@ def test_get_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -808,7 +817,6 @@ def test_get_training_pipeline_empty_call(): client.get_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetTrainingPipelineRequest() @@ -818,7 +826,7 @@ async def test_get_training_pipeline_async( request_type=pipeline_service.GetTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -838,24 +846,18 @@ async def test_get_training_pipeline_async( state=pipeline_state.PipelineState.PIPELINE_STATE_QUEUED, ) ) - response = await client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetTrainingPipelineRequest() # Establish that the response is the type that we expect. assert isinstance(response, training_pipeline.TrainingPipeline) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.training_task_definition == "training_task_definition_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED @@ -865,11 +867,12 @@ async def test_get_training_pipeline_async_from_dict(): def test_get_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.GetTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -877,7 +880,6 @@ def test_get_training_pipeline_field_headers(): type(client.transport.get_training_pipeline), "__call__" ) as call: call.return_value = training_pipeline.TrainingPipeline() - client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -892,11 +894,14 @@ def test_get_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_get_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.GetTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -906,7 +911,6 @@ async def test_get_training_pipeline_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( training_pipeline.TrainingPipeline() ) - await client.get_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -920,7 +924,7 @@ async def test_get_training_pipeline_field_headers_async(): def test_get_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -928,7 +932,6 @@ def test_get_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = training_pipeline.TrainingPipeline() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_training_pipeline(name="name_value",) @@ -937,12 +940,11 @@ def test_get_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -954,7 +956,9 @@ def test_get_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_get_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -974,13 +978,14 @@ async def test_get_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -994,7 +999,7 @@ def test_list_training_pipelines( transport: str = "grpc", request_type=pipeline_service.ListTrainingPipelinesRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1009,19 +1014,15 @@ def test_list_training_pipelines( call.return_value = pipeline_service.ListTrainingPipelinesResponse( next_page_token="next_page_token_value", ) - response = client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListTrainingPipelinesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTrainingPipelinesPager) - assert response.next_page_token == "next_page_token_value" @@ -1033,7 +1034,7 @@ def test_list_training_pipelines_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1043,7 +1044,6 @@ def test_list_training_pipelines_empty_call(): client.list_training_pipelines() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListTrainingPipelinesRequest() @@ -1053,7 +1053,7 @@ async def test_list_training_pipelines_async( request_type=pipeline_service.ListTrainingPipelinesRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1070,18 +1070,15 @@ async def test_list_training_pipelines_async( next_page_token="next_page_token_value", ) ) - response = await client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListTrainingPipelinesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTrainingPipelinesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1091,11 +1088,12 @@ async def test_list_training_pipelines_async_from_dict(): def test_list_training_pipelines_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.ListTrainingPipelinesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1103,7 +1101,6 @@ def test_list_training_pipelines_field_headers(): type(client.transport.list_training_pipelines), "__call__" ) as call: call.return_value = pipeline_service.ListTrainingPipelinesResponse() - client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. @@ -1118,11 +1115,14 @@ def test_list_training_pipelines_field_headers(): @pytest.mark.asyncio async def test_list_training_pipelines_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.ListTrainingPipelinesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1132,7 +1132,6 @@ async def test_list_training_pipelines_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( pipeline_service.ListTrainingPipelinesResponse() ) - await client.list_training_pipelines(request) # Establish that the underlying gRPC stub method was called. @@ -1146,7 +1145,7 @@ async def test_list_training_pipelines_field_headers_async(): def test_list_training_pipelines_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1154,7 +1153,6 @@ def test_list_training_pipelines_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = pipeline_service.ListTrainingPipelinesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_training_pipelines(parent="parent_value",) @@ -1163,12 +1161,11 @@ def test_list_training_pipelines_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_training_pipelines_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1180,7 +1177,9 @@ def test_list_training_pipelines_flattened_error(): @pytest.mark.asyncio async def test_list_training_pipelines_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1200,13 +1199,14 @@ async def test_list_training_pipelines_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_training_pipelines_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1217,7 +1217,7 @@ async def test_list_training_pipelines_flattened_error_async(): def test_list_training_pipelines_pager(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1263,7 +1263,7 @@ def test_list_training_pipelines_pager(): def test_list_training_pipelines_pages(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1301,7 +1301,9 @@ def test_list_training_pipelines_pages(): @pytest.mark.asyncio async def test_list_training_pipelines_async_pager(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1346,7 +1348,9 @@ async def test_list_training_pipelines_async_pager(): @pytest.mark.asyncio async def test_list_training_pipelines_async_pages(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1390,7 +1394,7 @@ def test_delete_training_pipeline( transport: str = "grpc", request_type=pipeline_service.DeleteTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1403,13 +1407,11 @@ def test_delete_training_pipeline( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeleteTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1424,7 +1426,7 @@ def test_delete_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1434,7 +1436,6 @@ def test_delete_training_pipeline_empty_call(): client.delete_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeleteTrainingPipelineRequest() @@ -1444,7 +1445,7 @@ async def test_delete_training_pipeline_async( request_type=pipeline_service.DeleteTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1459,13 +1460,11 @@ async def test_delete_training_pipeline_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeleteTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1478,11 +1477,12 @@ async def test_delete_training_pipeline_async_from_dict(): def test_delete_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.DeleteTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1490,7 +1490,6 @@ def test_delete_training_pipeline_field_headers(): type(client.transport.delete_training_pipeline), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1505,11 +1504,14 @@ def test_delete_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_delete_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.DeleteTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1519,7 +1521,6 @@ async def test_delete_training_pipeline_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1533,7 +1534,7 @@ async def test_delete_training_pipeline_field_headers_async(): def test_delete_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1541,7 +1542,6 @@ def test_delete_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_training_pipeline(name="name_value",) @@ -1550,12 +1550,11 @@ def test_delete_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1567,7 +1566,9 @@ def test_delete_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_delete_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1587,13 +1588,14 @@ async def test_delete_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1607,7 +1609,7 @@ def test_cancel_training_pipeline( transport: str = "grpc", request_type=pipeline_service.CancelTrainingPipelineRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1620,13 +1622,11 @@ def test_cancel_training_pipeline( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1641,7 +1641,7 @@ def test_cancel_training_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1651,7 +1651,6 @@ def test_cancel_training_pipeline_empty_call(): client.cancel_training_pipeline() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelTrainingPipelineRequest() @@ -1661,7 +1660,7 @@ async def test_cancel_training_pipeline_async( request_type=pipeline_service.CancelTrainingPipelineRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1674,13 +1673,11 @@ async def test_cancel_training_pipeline_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelTrainingPipelineRequest() # Establish that the response is the type that we expect. @@ -1693,11 +1690,12 @@ async def test_cancel_training_pipeline_async_from_dict(): def test_cancel_training_pipeline_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CancelTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1705,7 +1703,6 @@ def test_cancel_training_pipeline_field_headers(): type(client.transport.cancel_training_pipeline), "__call__" ) as call: call.return_value = None - client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1720,11 +1717,14 @@ def test_cancel_training_pipeline_field_headers(): @pytest.mark.asyncio async def test_cancel_training_pipeline_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CancelTrainingPipelineRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1732,7 +1732,6 @@ async def test_cancel_training_pipeline_field_headers_async(): type(client.transport.cancel_training_pipeline), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_training_pipeline(request) # Establish that the underlying gRPC stub method was called. @@ -1746,7 +1745,7 @@ async def test_cancel_training_pipeline_field_headers_async(): def test_cancel_training_pipeline_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1754,7 +1753,6 @@ def test_cancel_training_pipeline_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_training_pipeline(name="name_value",) @@ -1763,12 +1761,11 @@ def test_cancel_training_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_training_pipeline_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1780,7 +1777,9 @@ def test_cancel_training_pipeline_flattened_error(): @pytest.mark.asyncio async def test_cancel_training_pipeline_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1798,13 +1797,14 @@ async def test_cancel_training_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_training_pipeline_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1818,7 +1818,7 @@ def test_create_pipeline_job( transport: str = "grpc", request_type=pipeline_service.CreatePipelineJobRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1837,27 +1837,19 @@ def test_create_pipeline_job( service_account="service_account_value", network="network_value", ) - response = client.create_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreatePipelineJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_pipeline_job.PipelineJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED - assert response.service_account == "service_account_value" - assert response.network == "network_value" @@ -1869,7 +1861,7 @@ def test_create_pipeline_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1879,7 +1871,6 @@ def test_create_pipeline_job_empty_call(): client.create_pipeline_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreatePipelineJobRequest() @@ -1889,7 +1880,7 @@ async def test_create_pipeline_job_async( request_type=pipeline_service.CreatePipelineJobRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1910,26 +1901,19 @@ async def test_create_pipeline_job_async( network="network_value", ) ) - response = await client.create_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CreatePipelineJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_pipeline_job.PipelineJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED - assert response.service_account == "service_account_value" - assert response.network == "network_value" @@ -1939,11 +1923,12 @@ async def test_create_pipeline_job_async_from_dict(): def test_create_pipeline_job_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CreatePipelineJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1951,7 +1936,6 @@ def test_create_pipeline_job_field_headers(): type(client.transport.create_pipeline_job), "__call__" ) as call: call.return_value = gca_pipeline_job.PipelineJob() - client.create_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -1966,11 +1950,14 @@ def test_create_pipeline_job_field_headers(): @pytest.mark.asyncio async def test_create_pipeline_job_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CreatePipelineJobRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1980,7 +1967,6 @@ async def test_create_pipeline_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_pipeline_job.PipelineJob() ) - await client.create_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -1994,7 +1980,7 @@ async def test_create_pipeline_job_field_headers_async(): def test_create_pipeline_job_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2002,7 +1988,6 @@ def test_create_pipeline_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_pipeline_job.PipelineJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_pipeline_job( @@ -2015,16 +2000,13 @@ def test_create_pipeline_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].pipeline_job == gca_pipeline_job.PipelineJob(name="name_value") - assert args[0].pipeline_job_id == "pipeline_job_id_value" def test_create_pipeline_job_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2039,7 +2021,9 @@ def test_create_pipeline_job_flattened_error(): @pytest.mark.asyncio async def test_create_pipeline_job_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2063,17 +2047,16 @@ async def test_create_pipeline_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].pipeline_job == gca_pipeline_job.PipelineJob(name="name_value") - assert args[0].pipeline_job_id == "pipeline_job_id_value" @pytest.mark.asyncio async def test_create_pipeline_job_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2090,7 +2073,7 @@ def test_get_pipeline_job( transport: str = "grpc", request_type=pipeline_service.GetPipelineJobRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2107,27 +2090,19 @@ def test_get_pipeline_job( service_account="service_account_value", network="network_value", ) - response = client.get_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetPipelineJobRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pipeline_job.PipelineJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED - assert response.service_account == "service_account_value" - assert response.network == "network_value" @@ -2139,7 +2114,7 @@ def test_get_pipeline_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2147,7 +2122,6 @@ def test_get_pipeline_job_empty_call(): client.get_pipeline_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetPipelineJobRequest() @@ -2156,7 +2130,7 @@ async def test_get_pipeline_job_async( transport: str = "grpc_asyncio", request_type=pipeline_service.GetPipelineJobRequest ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2175,26 +2149,19 @@ async def test_get_pipeline_job_async( network="network_value", ) ) - response = await client.get_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.GetPipelineJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, pipeline_job.PipelineJob) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == pipeline_state.PipelineState.PIPELINE_STATE_QUEUED - assert response.service_account == "service_account_value" - assert response.network == "network_value" @@ -2204,17 +2171,17 @@ async def test_get_pipeline_job_async_from_dict(): def test_get_pipeline_job_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.GetPipelineJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_pipeline_job), "__call__") as call: call.return_value = pipeline_job.PipelineJob() - client.get_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -2229,11 +2196,14 @@ def test_get_pipeline_job_field_headers(): @pytest.mark.asyncio async def test_get_pipeline_job_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.GetPipelineJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2241,7 +2211,6 @@ async def test_get_pipeline_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( pipeline_job.PipelineJob() ) - await client.get_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -2255,13 +2224,12 @@ async def test_get_pipeline_job_field_headers_async(): def test_get_pipeline_job_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_pipeline_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = pipeline_job.PipelineJob() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_pipeline_job(name="name_value",) @@ -2270,12 +2238,11 @@ def test_get_pipeline_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_pipeline_job_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2287,7 +2254,9 @@ def test_get_pipeline_job_flattened_error(): @pytest.mark.asyncio async def test_get_pipeline_job_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_pipeline_job), "__call__") as call: @@ -2305,13 +2274,14 @@ async def test_get_pipeline_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_pipeline_job_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2325,7 +2295,7 @@ def test_list_pipeline_jobs( transport: str = "grpc", request_type=pipeline_service.ListPipelineJobsRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2340,19 +2310,15 @@ def test_list_pipeline_jobs( call.return_value = pipeline_service.ListPipelineJobsResponse( next_page_token="next_page_token_value", ) - response = client.list_pipeline_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListPipelineJobsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListPipelineJobsPager) - assert response.next_page_token == "next_page_token_value" @@ -2364,7 +2330,7 @@ def test_list_pipeline_jobs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2374,7 +2340,6 @@ def test_list_pipeline_jobs_empty_call(): client.list_pipeline_jobs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListPipelineJobsRequest() @@ -2384,7 +2349,7 @@ async def test_list_pipeline_jobs_async( request_type=pipeline_service.ListPipelineJobsRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2401,18 +2366,15 @@ async def test_list_pipeline_jobs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_pipeline_jobs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.ListPipelineJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListPipelineJobsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2422,11 +2384,12 @@ async def test_list_pipeline_jobs_async_from_dict(): def test_list_pipeline_jobs_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.ListPipelineJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2434,7 +2397,6 @@ def test_list_pipeline_jobs_field_headers(): type(client.transport.list_pipeline_jobs), "__call__" ) as call: call.return_value = pipeline_service.ListPipelineJobsResponse() - client.list_pipeline_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -2449,11 +2411,14 @@ def test_list_pipeline_jobs_field_headers(): @pytest.mark.asyncio async def test_list_pipeline_jobs_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.ListPipelineJobsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2463,7 +2428,6 @@ async def test_list_pipeline_jobs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( pipeline_service.ListPipelineJobsResponse() ) - await client.list_pipeline_jobs(request) # Establish that the underlying gRPC stub method was called. @@ -2477,7 +2441,7 @@ async def test_list_pipeline_jobs_field_headers_async(): def test_list_pipeline_jobs_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2485,7 +2449,6 @@ def test_list_pipeline_jobs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = pipeline_service.ListPipelineJobsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_pipeline_jobs(parent="parent_value",) @@ -2494,12 +2457,11 @@ def test_list_pipeline_jobs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_pipeline_jobs_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2511,7 +2473,9 @@ def test_list_pipeline_jobs_flattened_error(): @pytest.mark.asyncio async def test_list_pipeline_jobs_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2531,13 +2495,14 @@ async def test_list_pipeline_jobs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_pipeline_jobs_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2548,7 +2513,7 @@ async def test_list_pipeline_jobs_flattened_error_async(): def test_list_pipeline_jobs_pager(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2590,7 +2555,7 @@ def test_list_pipeline_jobs_pager(): def test_list_pipeline_jobs_pages(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2624,7 +2589,9 @@ def test_list_pipeline_jobs_pages(): @pytest.mark.asyncio async def test_list_pipeline_jobs_async_pager(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2665,7 +2632,9 @@ async def test_list_pipeline_jobs_async_pager(): @pytest.mark.asyncio async def test_list_pipeline_jobs_async_pages(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2705,7 +2674,7 @@ def test_delete_pipeline_job( transport: str = "grpc", request_type=pipeline_service.DeletePipelineJobRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2718,13 +2687,11 @@ def test_delete_pipeline_job( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeletePipelineJobRequest() # Establish that the response is the type that we expect. @@ -2739,7 +2706,7 @@ def test_delete_pipeline_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2749,7 +2716,6 @@ def test_delete_pipeline_job_empty_call(): client.delete_pipeline_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeletePipelineJobRequest() @@ -2759,7 +2725,7 @@ async def test_delete_pipeline_job_async( request_type=pipeline_service.DeletePipelineJobRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2774,13 +2740,11 @@ async def test_delete_pipeline_job_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.DeletePipelineJobRequest() # Establish that the response is the type that we expect. @@ -2793,11 +2757,12 @@ async def test_delete_pipeline_job_async_from_dict(): def test_delete_pipeline_job_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.DeletePipelineJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2805,7 +2770,6 @@ def test_delete_pipeline_job_field_headers(): type(client.transport.delete_pipeline_job), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -2820,11 +2784,14 @@ def test_delete_pipeline_job_field_headers(): @pytest.mark.asyncio async def test_delete_pipeline_job_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.DeletePipelineJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2834,7 +2801,6 @@ async def test_delete_pipeline_job_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -2848,7 +2814,7 @@ async def test_delete_pipeline_job_field_headers_async(): def test_delete_pipeline_job_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2856,7 +2822,6 @@ def test_delete_pipeline_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_pipeline_job(name="name_value",) @@ -2865,12 +2830,11 @@ def test_delete_pipeline_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_pipeline_job_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2882,7 +2846,9 @@ def test_delete_pipeline_job_flattened_error(): @pytest.mark.asyncio async def test_delete_pipeline_job_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2902,13 +2868,14 @@ async def test_delete_pipeline_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_pipeline_job_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2922,7 +2889,7 @@ def test_cancel_pipeline_job( transport: str = "grpc", request_type=pipeline_service.CancelPipelineJobRequest ): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2935,13 +2902,11 @@ def test_cancel_pipeline_job( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.cancel_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelPipelineJobRequest() # Establish that the response is the type that we expect. @@ -2956,7 +2921,7 @@ def test_cancel_pipeline_job_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2966,7 +2931,6 @@ def test_cancel_pipeline_job_empty_call(): client.cancel_pipeline_job() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelPipelineJobRequest() @@ -2976,7 +2940,7 @@ async def test_cancel_pipeline_job_async( request_type=pipeline_service.CancelPipelineJobRequest, ): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2989,13 +2953,11 @@ async def test_cancel_pipeline_job_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.cancel_pipeline_job(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == pipeline_service.CancelPipelineJobRequest() # Establish that the response is the type that we expect. @@ -3008,11 +2970,12 @@ async def test_cancel_pipeline_job_async_from_dict(): def test_cancel_pipeline_job_field_headers(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CancelPipelineJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3020,7 +2983,6 @@ def test_cancel_pipeline_job_field_headers(): type(client.transport.cancel_pipeline_job), "__call__" ) as call: call.return_value = None - client.cancel_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -3035,11 +2997,14 @@ def test_cancel_pipeline_job_field_headers(): @pytest.mark.asyncio async def test_cancel_pipeline_job_field_headers_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = pipeline_service.CancelPipelineJobRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3047,7 +3012,6 @@ async def test_cancel_pipeline_job_field_headers_async(): type(client.transport.cancel_pipeline_job), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.cancel_pipeline_job(request) # Establish that the underlying gRPC stub method was called. @@ -3061,7 +3025,7 @@ async def test_cancel_pipeline_job_field_headers_async(): def test_cancel_pipeline_job_flattened(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3069,7 +3033,6 @@ def test_cancel_pipeline_job_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_pipeline_job(name="name_value",) @@ -3078,12 +3041,11 @@ def test_cancel_pipeline_job_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_cancel_pipeline_job_flattened_error(): - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3095,7 +3057,9 @@ def test_cancel_pipeline_job_flattened_error(): @pytest.mark.asyncio async def test_cancel_pipeline_job_flattened_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3113,13 +3077,14 @@ async def test_cancel_pipeline_job_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_cancel_pipeline_job_flattened_error_async(): - client = PipelineServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3132,16 +3097,16 @@ async def test_cancel_pipeline_job_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PipelineServiceClient( @@ -3151,7 +3116,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PipelineServiceClient( @@ -3162,7 +3127,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = PipelineServiceClient(transport=transport) assert client.transport is transport @@ -3171,13 +3136,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.PipelineServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.PipelineServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3192,23 +3157,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = PipelineServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PipelineServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.PipelineServiceGrpcTransport,) def test_pipeline_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.PipelineServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3220,7 +3185,7 @@ def test_pipeline_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.PipelineServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3247,15 +3212,37 @@ def test_pipeline_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_pipeline_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.PipelineServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.PipelineServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_pipeline_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.PipelineServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PipelineServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3268,19 +3255,33 @@ def test_pipeline_service_base_transport_with_credentials_file(): def test_pipeline_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.PipelineServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PipelineServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_pipeline_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + PipelineServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_pipeline_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) PipelineServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3288,20 +3289,156 @@ def test_pipeline_service_auth_adc(): ) -def test_pipeline_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.PipelineServiceGrpcTransport, + transports.PipelineServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_pipeline_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.PipelineServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.PipelineServiceGrpcTransport, + transports.PipelineServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_pipeline_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PipelineServiceGrpcTransport, grpc_helpers), + (transports.PipelineServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_pipeline_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PipelineServiceGrpcTransport, grpc_helpers), + (transports.PipelineServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_pipeline_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PipelineServiceGrpcTransport, grpc_helpers), + (transports.PipelineServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_pipeline_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -3310,7 +3447,7 @@ def test_pipeline_service_transport_auth_adc(): ], ) def test_pipeline_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3349,7 +3486,7 @@ def test_pipeline_service_grpc_transport_client_cert_source_for_mtls(transport_c def test_pipeline_service_host_no_port(): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -3359,7 +3496,7 @@ def test_pipeline_service_host_no_port(): def test_pipeline_service_host_with_port(): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -3415,9 +3552,9 @@ def test_pipeline_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3493,7 +3630,7 @@ def test_pipeline_service_transport_channel_mtls_with_adc(transport_class): def test_pipeline_service_grpc_lro_client(): client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3506,7 +3643,7 @@ def test_pipeline_service_grpc_lro_client(): def test_pipeline_service_grpc_lro_async_client(): client = PipelineServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3522,7 +3659,6 @@ def test_artifact_path(): location = "clam" metadata_store = "whelk" artifact = "octopus" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}/artifacts/{artifact}".format( project=project, location=location, @@ -3554,7 +3690,6 @@ def test_context_path(): location = "nautilus" metadata_store = "scallop" context = "abalone" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}/contexts/{context}".format( project=project, location=location, @@ -3585,7 +3720,6 @@ def test_custom_job_path(): project = "oyster" location = "nudibranch" custom_job = "cuttlefish" - expected = "projects/{project}/locations/{location}/customJobs/{custom_job}".format( project=project, location=location, custom_job=custom_job, ) @@ -3610,7 +3744,6 @@ def test_endpoint_path(): project = "scallop" location = "abalone" endpoint = "squid" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -3636,7 +3769,6 @@ def test_execution_path(): location = "nudibranch" metadata_store = "cuttlefish" execution = "mussel" - expected = "projects/{project}/locations/{location}/metadataStores/{metadata_store}/executions/{execution}".format( project=project, location=location, @@ -3667,7 +3799,6 @@ def test_model_path(): project = "squid" location = "clam" model = "whelk" - expected = "projects/{project}/locations/{location}/models/{model}".format( project=project, location=location, model=model, ) @@ -3691,7 +3822,6 @@ def test_parse_model_path(): def test_network_path(): project = "cuttlefish" network = "mussel" - expected = "projects/{project}/global/networks/{network}".format( project=project, network=network, ) @@ -3715,7 +3845,6 @@ def test_pipeline_job_path(): project = "scallop" location = "abalone" pipeline_job = "squid" - expected = "projects/{project}/locations/{location}/pipelineJobs/{pipeline_job}".format( project=project, location=location, pipeline_job=pipeline_job, ) @@ -3740,7 +3869,6 @@ def test_training_pipeline_path(): project = "oyster" location = "nudibranch" training_pipeline = "cuttlefish" - expected = "projects/{project}/locations/{location}/trainingPipelines/{training_pipeline}".format( project=project, location=location, training_pipeline=training_pipeline, ) @@ -3765,7 +3893,6 @@ def test_parse_training_pipeline_path(): def test_common_billing_account_path(): billing_account = "scallop" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3786,7 +3913,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "squid" - expected = "folders/{folder}".format(folder=folder,) actual = PipelineServiceClient.common_folder_path(folder) assert expected == actual @@ -3805,7 +3931,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "whelk" - expected = "organizations/{organization}".format(organization=organization,) actual = PipelineServiceClient.common_organization_path(organization) assert expected == actual @@ -3824,7 +3949,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "oyster" - expected = "projects/{project}".format(project=project,) actual = PipelineServiceClient.common_project_path(project) assert expected == actual @@ -3844,7 +3968,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "cuttlefish" location = "mussel" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3871,7 +3994,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.PipelineServiceTransport, "_prep_wrapped_messages" ) as prep: client = PipelineServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3880,6 +4003,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = PipelineServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py index ba5333c0fa..a36714bb87 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_prediction_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,13 +23,13 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.prediction_service import ( PredictionServiceAsyncClient, @@ -39,10 +38,40 @@ PredictionServiceClient, ) from google.cloud.aiplatform_v1beta1.services.prediction_service import transports +from google.cloud.aiplatform_v1beta1.services.prediction_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.prediction_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import explanation from google.cloud.aiplatform_v1beta1.types import prediction_service from google.oauth2 import service_account -from google.protobuf import struct_pb2 as struct # type: ignore +from google.protobuf import struct_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -90,33 +119,39 @@ def test__get_default_mtls_endpoint(): ) -def test_prediction_service_client_from_service_account_info(): - creds = credentials.AnonymousCredentials() +@pytest.mark.parametrize( + "client_class", [PredictionServiceClient, PredictionServiceAsyncClient,] +) +def test_prediction_service_client_from_service_account_info(client_class): + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = PredictionServiceClient.from_service_account_info(info) + client = client_class.from_service_account_info(info) assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "aiplatform.googleapis.com:443" @pytest.mark.parametrize( - "client_class", [PredictionServiceClient, PredictionServiceAsyncClient,], + "client_class", [PredictionServiceClient, PredictionServiceAsyncClient,] ) def test_prediction_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) client = client_class.from_service_account_json("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "aiplatform.googleapis.com:443" @@ -158,7 +193,7 @@ def test_prediction_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(PredictionServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -456,7 +491,7 @@ def test_predict( transport: str = "grpc", request_type=prediction_service.PredictRequest ): client = PredictionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -469,19 +504,15 @@ def test_predict( call.return_value = prediction_service.PredictResponse( deployed_model_id="deployed_model_id_value", ) - response = client.predict(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == prediction_service.PredictRequest() # Establish that the response is the type that we expect. - assert isinstance(response, prediction_service.PredictResponse) - assert response.deployed_model_id == "deployed_model_id_value" @@ -489,12 +520,27 @@ def test_predict_from_dict(): test_predict(request_type=dict) +def test_predict_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.predict), "__call__") as call: + client.predict() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == prediction_service.PredictRequest() + + @pytest.mark.asyncio async def test_predict_async( transport: str = "grpc_asyncio", request_type=prediction_service.PredictRequest ): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -509,18 +555,15 @@ async def test_predict_async( deployed_model_id="deployed_model_id_value", ) ) - response = await client.predict(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == prediction_service.PredictRequest() # Establish that the response is the type that we expect. assert isinstance(response, prediction_service.PredictResponse) - assert response.deployed_model_id == "deployed_model_id_value" @@ -530,17 +573,17 @@ async def test_predict_async_from_dict(): def test_predict_field_headers(): - client = PredictionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = prediction_service.PredictRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.predict), "__call__") as call: call.return_value = prediction_service.PredictResponse() - client.predict(request) # Establish that the underlying gRPC stub method was called. @@ -556,12 +599,13 @@ def test_predict_field_headers(): @pytest.mark.asyncio async def test_predict_field_headers_async(): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = prediction_service.PredictRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -569,7 +613,6 @@ async def test_predict_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( prediction_service.PredictResponse() ) - await client.predict(request) # Establish that the underlying gRPC stub method was called. @@ -583,40 +626,34 @@ async def test_predict_field_headers_async(): def test_predict_flattened(): - client = PredictionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.predict), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = prediction_service.PredictResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.predict( endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].instances == [ - struct.Value(null_value=struct.NullValue.NULL_VALUE) + struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) ] - # https://github.com/googleapis/gapic-generator-python/issues/414 - # assert args[0].parameters == struct.Value( - # null_value=struct.NullValue.NULL_VALUE - # ) + # assert args[0].parameters == struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) def test_predict_flattened_error(): - client = PredictionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -624,15 +661,15 @@ def test_predict_flattened_error(): client.predict( prediction_service.PredictRequest(), endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), ) @pytest.mark.asyncio async def test_predict_flattened_async(): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -647,31 +684,26 @@ async def test_predict_flattened_async(): # using the keyword arguments to the method. response = await client.predict( endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].instances == [ - struct.Value(null_value=struct.NullValue.NULL_VALUE) + struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) ] - # https://github.com/googleapis/gapic-generator-python/issues/414 - # assert args[0].parameters == struct.Value( - # null_value=struct.NullValue.NULL_VALUE - # ) + # assert args[0].parameters == struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) @pytest.mark.asyncio async def test_predict_flattened_error_async(): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -680,8 +712,8 @@ async def test_predict_flattened_error_async(): await client.predict( prediction_service.PredictRequest(), endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), ) @@ -689,7 +721,7 @@ def test_explain( transport: str = "grpc", request_type=prediction_service.ExplainRequest ): client = PredictionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -702,19 +734,15 @@ def test_explain( call.return_value = prediction_service.ExplainResponse( deployed_model_id="deployed_model_id_value", ) - response = client.explain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == prediction_service.ExplainRequest() # Establish that the response is the type that we expect. - assert isinstance(response, prediction_service.ExplainResponse) - assert response.deployed_model_id == "deployed_model_id_value" @@ -722,12 +750,27 @@ def test_explain_from_dict(): test_explain(request_type=dict) +def test_explain_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = PredictionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.explain), "__call__") as call: + client.explain() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == prediction_service.ExplainRequest() + + @pytest.mark.asyncio async def test_explain_async( transport: str = "grpc_asyncio", request_type=prediction_service.ExplainRequest ): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -742,18 +785,15 @@ async def test_explain_async( deployed_model_id="deployed_model_id_value", ) ) - response = await client.explain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == prediction_service.ExplainRequest() # Establish that the response is the type that we expect. assert isinstance(response, prediction_service.ExplainResponse) - assert response.deployed_model_id == "deployed_model_id_value" @@ -763,17 +803,17 @@ async def test_explain_async_from_dict(): def test_explain_field_headers(): - client = PredictionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = prediction_service.ExplainRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.explain), "__call__") as call: call.return_value = prediction_service.ExplainResponse() - client.explain(request) # Establish that the underlying gRPC stub method was called. @@ -789,12 +829,13 @@ def test_explain_field_headers(): @pytest.mark.asyncio async def test_explain_field_headers_async(): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = prediction_service.ExplainRequest() + request.endpoint = "endpoint/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -802,7 +843,6 @@ async def test_explain_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( prediction_service.ExplainResponse() ) - await client.explain(request) # Establish that the underlying gRPC stub method was called. @@ -816,19 +856,18 @@ async def test_explain_field_headers_async(): def test_explain_flattened(): - client = PredictionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.explain), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = prediction_service.ExplainResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.explain( endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), deployed_model_id="deployed_model_id_value", ) @@ -836,23 +875,17 @@ def test_explain_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].instances == [ - struct.Value(null_value=struct.NullValue.NULL_VALUE) + struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) ] - # https://github.com/googleapis/gapic-generator-python/issues/414 - # assert args[0].parameters == struct.Value( - # null_value=struct.NullValue.NULL_VALUE - # ) - + # assert args[0].parameters == struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) assert args[0].deployed_model_id == "deployed_model_id_value" def test_explain_flattened_error(): - client = PredictionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -860,8 +893,8 @@ def test_explain_flattened_error(): client.explain( prediction_service.ExplainRequest(), endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), deployed_model_id="deployed_model_id_value", ) @@ -869,7 +902,7 @@ def test_explain_flattened_error(): @pytest.mark.asyncio async def test_explain_flattened_async(): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -884,8 +917,8 @@ async def test_explain_flattened_async(): # using the keyword arguments to the method. response = await client.explain( endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), deployed_model_id="deployed_model_id_value", ) @@ -893,25 +926,19 @@ async def test_explain_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].endpoint == "endpoint_value" - assert args[0].instances == [ - struct.Value(null_value=struct.NullValue.NULL_VALUE) + struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) ] - # https://github.com/googleapis/gapic-generator-python/issues/414 - # assert args[0].parameters == struct.Value( - # null_value=struct.NullValue.NULL_VALUE - # ) - + # assert args[0].parameters == struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE) assert args[0].deployed_model_id == "deployed_model_id_value" @pytest.mark.asyncio async def test_explain_flattened_error_async(): client = PredictionServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -920,8 +947,8 @@ async def test_explain_flattened_error_async(): await client.explain( prediction_service.ExplainRequest(), endpoint="endpoint_value", - instances=[struct.Value(null_value=struct.NullValue.NULL_VALUE)], - parameters=struct.Value(null_value=struct.NullValue.NULL_VALUE), + instances=[struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE)], + parameters=struct_pb2.Value(null_value=struct_pb2.NullValue.NULL_VALUE), deployed_model_id="deployed_model_id_value", ) @@ -929,16 +956,16 @@ async def test_explain_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.PredictionServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PredictionServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.PredictionServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PredictionServiceClient( @@ -948,7 +975,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.PredictionServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = PredictionServiceClient( @@ -959,7 +986,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.PredictionServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = PredictionServiceClient(transport=transport) assert client.transport is transport @@ -968,13 +995,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.PredictionServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.PredictionServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -989,23 +1016,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = PredictionServiceClient(credentials=credentials.AnonymousCredentials(),) + client = PredictionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.PredictionServiceGrpcTransport,) def test_prediction_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.PredictionServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1017,7 +1044,7 @@ def test_prediction_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.PredictionServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -1031,15 +1058,37 @@ def test_prediction_service_base_transport(): getattr(transport, method)(request=object()) +@requires_google_auth_gte_1_25_0 def test_prediction_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.prediction_service.transports.PredictionServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.PredictionServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_prediction_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.prediction_service.transports.PredictionServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PredictionServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -1052,19 +1101,33 @@ def test_prediction_service_base_transport_with_credentials_file(): def test_prediction_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.prediction_service.transports.PredictionServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PredictionServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_prediction_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + PredictionServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_prediction_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) PredictionServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -1072,20 +1135,156 @@ def test_prediction_service_auth_adc(): ) -def test_prediction_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_prediction_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.PredictionServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.PredictionServiceGrpcTransport, + transports.PredictionServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_prediction_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PredictionServiceGrpcTransport, grpc_helpers), + (transports.PredictionServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_prediction_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PredictionServiceGrpcTransport, grpc_helpers), + (transports.PredictionServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_prediction_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.PredictionServiceGrpcTransport, grpc_helpers), + (transports.PredictionServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_prediction_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -1094,7 +1293,7 @@ def test_prediction_service_transport_auth_adc(): ], ) def test_prediction_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -1133,7 +1332,7 @@ def test_prediction_service_grpc_transport_client_cert_source_for_mtls(transport def test_prediction_service_host_no_port(): client = PredictionServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -1143,7 +1342,7 @@ def test_prediction_service_host_no_port(): def test_prediction_service_host_with_port(): client = PredictionServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -1199,9 +1398,9 @@ def test_prediction_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -1279,7 +1478,6 @@ def test_endpoint_path(): project = "squid" location = "clam" endpoint = "whelk" - expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( project=project, location=location, endpoint=endpoint, ) @@ -1302,7 +1500,6 @@ def test_parse_endpoint_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -1323,7 +1520,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = PredictionServiceClient.common_folder_path(folder) assert expected == actual @@ -1342,7 +1538,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = PredictionServiceClient.common_organization_path(organization) assert expected == actual @@ -1361,7 +1556,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = PredictionServiceClient.common_project_path(project) assert expected == actual @@ -1381,7 +1575,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -1408,7 +1601,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.PredictionServiceTransport, "_prep_wrapped_messages" ) as prep: client = PredictionServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1417,6 +1610,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = PredictionServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py index 3daed56994..d9f0d11522 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_specialist_pool_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.specialist_pool_service import ( SpecialistPoolServiceAsyncClient, @@ -43,13 +42,43 @@ ) from google.cloud.aiplatform_v1beta1.services.specialist_pool_service import pagers from google.cloud.aiplatform_v1beta1.services.specialist_pool_service import transports +from google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.cloud.aiplatform_v1beta1.types import specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool as gca_specialist_pool from google.cloud.aiplatform_v1beta1.types import specialist_pool_service from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -101,7 +130,7 @@ def test__get_default_mtls_endpoint(): "client_class", [SpecialistPoolServiceClient, SpecialistPoolServiceAsyncClient,] ) def test_specialist_pool_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -118,7 +147,7 @@ def test_specialist_pool_service_client_from_service_account_info(client_class): "client_class", [SpecialistPoolServiceClient, SpecialistPoolServiceAsyncClient,] ) def test_specialist_pool_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -175,7 +204,7 @@ def test_specialist_pool_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(SpecialistPoolServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -482,7 +511,7 @@ def test_create_specialist_pool( request_type=specialist_pool_service.CreateSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -495,13 +524,11 @@ def test_create_specialist_pool( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.CreateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -516,7 +543,7 @@ def test_create_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -526,7 +553,6 @@ def test_create_specialist_pool_empty_call(): client.create_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.CreateSpecialistPoolRequest() @@ -536,7 +562,7 @@ async def test_create_specialist_pool_async( request_type=specialist_pool_service.CreateSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -551,13 +577,11 @@ async def test_create_specialist_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.CreateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -571,12 +595,13 @@ async def test_create_specialist_pool_async_from_dict(): def test_create_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.CreateSpecialistPoolRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -584,7 +609,6 @@ def test_create_specialist_pool_field_headers(): type(client.transport.create_specialist_pool), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -600,12 +624,13 @@ def test_create_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_create_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.CreateSpecialistPoolRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -615,7 +640,6 @@ async def test_create_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -630,7 +654,7 @@ async def test_create_specialist_pool_field_headers_async(): def test_create_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -639,7 +663,6 @@ def test_create_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_specialist_pool( @@ -651,9 +674,7 @@ def test_create_specialist_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) @@ -661,7 +682,7 @@ def test_create_specialist_pool_flattened(): def test_create_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -677,7 +698,7 @@ def test_create_specialist_pool_flattened_error(): @pytest.mark.asyncio async def test_create_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -701,9 +722,7 @@ async def test_create_specialist_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) @@ -712,7 +731,7 @@ async def test_create_specialist_pool_flattened_async(): @pytest.mark.asyncio async def test_create_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -730,7 +749,7 @@ def test_get_specialist_pool( request_type=specialist_pool_service.GetSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -749,27 +768,19 @@ def test_get_specialist_pool( specialist_manager_emails=["specialist_manager_emails_value"], pending_data_labeling_jobs=["pending_data_labeling_jobs_value"], ) - response = client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.GetSpecialistPoolRequest() # Establish that the response is the type that we expect. - assert isinstance(response, specialist_pool.SpecialistPool) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.specialist_managers_count == 2662 - assert response.specialist_manager_emails == ["specialist_manager_emails_value"] - assert response.pending_data_labeling_jobs == ["pending_data_labeling_jobs_value"] @@ -781,7 +792,7 @@ def test_get_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -791,7 +802,6 @@ def test_get_specialist_pool_empty_call(): client.get_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.GetSpecialistPoolRequest() @@ -801,7 +811,7 @@ async def test_get_specialist_pool_async( request_type=specialist_pool_service.GetSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -822,26 +832,19 @@ async def test_get_specialist_pool_async( pending_data_labeling_jobs=["pending_data_labeling_jobs_value"], ) ) - response = await client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.GetSpecialistPoolRequest() # Establish that the response is the type that we expect. assert isinstance(response, specialist_pool.SpecialistPool) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.specialist_managers_count == 2662 - assert response.specialist_manager_emails == ["specialist_manager_emails_value"] - assert response.pending_data_labeling_jobs == ["pending_data_labeling_jobs_value"] @@ -852,12 +855,13 @@ async def test_get_specialist_pool_async_from_dict(): def test_get_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.GetSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -865,7 +869,6 @@ def test_get_specialist_pool_field_headers(): type(client.transport.get_specialist_pool), "__call__" ) as call: call.return_value = specialist_pool.SpecialistPool() - client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -881,12 +884,13 @@ def test_get_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_get_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.GetSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -896,7 +900,6 @@ async def test_get_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( specialist_pool.SpecialistPool() ) - await client.get_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -911,7 +914,7 @@ async def test_get_specialist_pool_field_headers_async(): def test_get_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -920,7 +923,6 @@ def test_get_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = specialist_pool.SpecialistPool() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_specialist_pool(name="name_value",) @@ -929,13 +931,12 @@ def test_get_specialist_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -949,7 +950,7 @@ def test_get_specialist_pool_flattened_error(): @pytest.mark.asyncio async def test_get_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -970,14 +971,13 @@ async def test_get_specialist_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -993,7 +993,7 @@ def test_list_specialist_pools( request_type=specialist_pool_service.ListSpecialistPoolsRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1008,19 +1008,15 @@ def test_list_specialist_pools( call.return_value = specialist_pool_service.ListSpecialistPoolsResponse( next_page_token="next_page_token_value", ) - response = client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.ListSpecialistPoolsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSpecialistPoolsPager) - assert response.next_page_token == "next_page_token_value" @@ -1032,7 +1028,7 @@ def test_list_specialist_pools_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1042,7 +1038,6 @@ def test_list_specialist_pools_empty_call(): client.list_specialist_pools() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.ListSpecialistPoolsRequest() @@ -1052,7 +1047,7 @@ async def test_list_specialist_pools_async( request_type=specialist_pool_service.ListSpecialistPoolsRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1069,18 +1064,15 @@ async def test_list_specialist_pools_async( next_page_token="next_page_token_value", ) ) - response = await client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.ListSpecialistPoolsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSpecialistPoolsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1091,12 +1083,13 @@ async def test_list_specialist_pools_async_from_dict(): def test_list_specialist_pools_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.ListSpecialistPoolsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1104,7 +1097,6 @@ def test_list_specialist_pools_field_headers(): type(client.transport.list_specialist_pools), "__call__" ) as call: call.return_value = specialist_pool_service.ListSpecialistPoolsResponse() - client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. @@ -1120,12 +1112,13 @@ def test_list_specialist_pools_field_headers(): @pytest.mark.asyncio async def test_list_specialist_pools_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.ListSpecialistPoolsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1135,7 +1128,6 @@ async def test_list_specialist_pools_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( specialist_pool_service.ListSpecialistPoolsResponse() ) - await client.list_specialist_pools(request) # Establish that the underlying gRPC stub method was called. @@ -1150,7 +1142,7 @@ async def test_list_specialist_pools_field_headers_async(): def test_list_specialist_pools_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1159,7 +1151,6 @@ def test_list_specialist_pools_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = specialist_pool_service.ListSpecialistPoolsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_specialist_pools(parent="parent_value",) @@ -1168,13 +1159,12 @@ def test_list_specialist_pools_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_specialist_pools_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1188,7 +1178,7 @@ def test_list_specialist_pools_flattened_error(): @pytest.mark.asyncio async def test_list_specialist_pools_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1209,14 +1199,13 @@ async def test_list_specialist_pools_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_specialist_pools_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1228,7 +1217,9 @@ async def test_list_specialist_pools_flattened_error_async(): def test_list_specialist_pools_pager(): - client = SpecialistPoolServiceClient(credentials=credentials.AnonymousCredentials,) + client = SpecialistPoolServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1274,7 +1265,9 @@ def test_list_specialist_pools_pager(): def test_list_specialist_pools_pages(): - client = SpecialistPoolServiceClient(credentials=credentials.AnonymousCredentials,) + client = SpecialistPoolServiceClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1313,7 +1306,7 @@ def test_list_specialist_pools_pages(): @pytest.mark.asyncio async def test_list_specialist_pools_async_pager(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1360,7 +1353,7 @@ async def test_list_specialist_pools_async_pager(): @pytest.mark.asyncio async def test_list_specialist_pools_async_pages(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1406,7 +1399,7 @@ def test_delete_specialist_pool( request_type=specialist_pool_service.DeleteSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1419,13 +1412,11 @@ def test_delete_specialist_pool( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.DeleteSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1440,7 +1431,7 @@ def test_delete_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1450,7 +1441,6 @@ def test_delete_specialist_pool_empty_call(): client.delete_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.DeleteSpecialistPoolRequest() @@ -1460,7 +1450,7 @@ async def test_delete_specialist_pool_async( request_type=specialist_pool_service.DeleteSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1475,13 +1465,11 @@ async def test_delete_specialist_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.DeleteSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1495,12 +1483,13 @@ async def test_delete_specialist_pool_async_from_dict(): def test_delete_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.DeleteSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1508,7 +1497,6 @@ def test_delete_specialist_pool_field_headers(): type(client.transport.delete_specialist_pool), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1524,12 +1512,13 @@ def test_delete_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_delete_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.DeleteSpecialistPoolRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1539,7 +1528,6 @@ async def test_delete_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1554,7 +1542,7 @@ async def test_delete_specialist_pool_field_headers_async(): def test_delete_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1563,7 +1551,6 @@ def test_delete_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_specialist_pool(name="name_value",) @@ -1572,13 +1559,12 @@ def test_delete_specialist_pool_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1592,7 +1578,7 @@ def test_delete_specialist_pool_flattened_error(): @pytest.mark.asyncio async def test_delete_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1613,14 +1599,13 @@ async def test_delete_specialist_pool_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1636,7 +1621,7 @@ def test_update_specialist_pool( request_type=specialist_pool_service.UpdateSpecialistPoolRequest, ): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1649,13 +1634,11 @@ def test_update_specialist_pool( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.UpdateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1670,7 +1653,7 @@ def test_update_specialist_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1680,7 +1663,6 @@ def test_update_specialist_pool_empty_call(): client.update_specialist_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.UpdateSpecialistPoolRequest() @@ -1690,7 +1672,7 @@ async def test_update_specialist_pool_async( request_type=specialist_pool_service.UpdateSpecialistPoolRequest, ): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1705,13 +1687,11 @@ async def test_update_specialist_pool_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == specialist_pool_service.UpdateSpecialistPoolRequest() # Establish that the response is the type that we expect. @@ -1725,12 +1705,13 @@ async def test_update_specialist_pool_async_from_dict(): def test_update_specialist_pool_field_headers(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.UpdateSpecialistPoolRequest() + request.specialist_pool.name = "specialist_pool.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1738,7 +1719,6 @@ def test_update_specialist_pool_field_headers(): type(client.transport.update_specialist_pool), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1757,12 +1737,13 @@ def test_update_specialist_pool_field_headers(): @pytest.mark.asyncio async def test_update_specialist_pool_field_headers_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = specialist_pool_service.UpdateSpecialistPoolRequest() + request.specialist_pool.name = "specialist_pool.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1772,7 +1753,6 @@ async def test_update_specialist_pool_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_specialist_pool(request) # Establish that the underlying gRPC stub method was called. @@ -1790,7 +1770,7 @@ async def test_update_specialist_pool_field_headers_async(): def test_update_specialist_pool_flattened(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1799,29 +1779,26 @@ def test_update_specialist_pool_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_specialist_pool( specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_specialist_pool_flattened_error(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1830,14 +1807,14 @@ def test_update_specialist_pool_flattened_error(): client.update_specialist_pool( specialist_pool_service.UpdateSpecialistPoolRequest(), specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_specialist_pool_flattened_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1854,25 +1831,23 @@ async def test_update_specialist_pool_flattened_async(): # using the keyword arguments to the method. response = await client.update_specialist_pool( specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].specialist_pool == gca_specialist_pool.SpecialistPool( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_specialist_pool_flattened_error_async(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1881,23 +1856,23 @@ async def test_update_specialist_pool_flattened_error_async(): await client.update_specialist_pool( specialist_pool_service.UpdateSpecialistPoolRequest(), specialist_pool=gca_specialist_pool.SpecialistPool(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SpecialistPoolServiceClient( @@ -1907,7 +1882,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = SpecialistPoolServiceClient( @@ -1918,7 +1893,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = SpecialistPoolServiceClient(transport=transport) assert client.transport is transport @@ -1927,13 +1902,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.SpecialistPoolServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.SpecialistPoolServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -1948,8 +1923,8 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() @@ -1957,16 +1932,16 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance(client.transport, transports.SpecialistPoolServiceGrpcTransport,) def test_specialist_pool_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.SpecialistPoolServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -1978,7 +1953,7 @@ def test_specialist_pool_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.SpecialistPoolServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -2000,15 +1975,37 @@ def test_specialist_pool_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_specialist_pool_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.SpecialistPoolServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.SpecialistPoolServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_specialist_pool_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.SpecialistPoolServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SpecialistPoolServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -2021,19 +2018,33 @@ def test_specialist_pool_service_base_transport_with_credentials_file(): def test_specialist_pool_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.SpecialistPoolServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SpecialistPoolServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_specialist_pool_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + SpecialistPoolServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_specialist_pool_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) SpecialistPoolServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -2041,20 +2052,158 @@ def test_specialist_pool_service_auth_adc(): ) -def test_specialist_pool_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.SpecialistPoolServiceGrpcTransport, + transports.SpecialistPoolServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_specialist_pool_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.SpecialistPoolServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.SpecialistPoolServiceGrpcTransport, + transports.SpecialistPoolServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_specialist_pool_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SpecialistPoolServiceGrpcTransport, grpc_helpers), + (transports.SpecialistPoolServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_specialist_pool_service_transport_create_channel( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SpecialistPoolServiceGrpcTransport, grpc_helpers), + (transports.SpecialistPoolServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_specialist_pool_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SpecialistPoolServiceGrpcTransport, grpc_helpers), + (transports.SpecialistPoolServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_specialist_pool_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -2065,7 +2214,7 @@ def test_specialist_pool_service_transport_auth_adc(): def test_specialist_pool_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -2104,7 +2253,7 @@ def test_specialist_pool_service_grpc_transport_client_cert_source_for_mtls( def test_specialist_pool_service_host_no_port(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -2114,7 +2263,7 @@ def test_specialist_pool_service_host_no_port(): def test_specialist_pool_service_host_with_port(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -2170,9 +2319,9 @@ def test_specialist_pool_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -2248,7 +2397,7 @@ def test_specialist_pool_service_transport_channel_mtls_with_adc(transport_class def test_specialist_pool_service_grpc_lro_client(): client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -2261,7 +2410,7 @@ def test_specialist_pool_service_grpc_lro_client(): def test_specialist_pool_service_grpc_lro_async_client(): client = SpecialistPoolServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -2276,7 +2425,6 @@ def test_specialist_pool_path(): project = "squid" location = "clam" specialist_pool = "whelk" - expected = "projects/{project}/locations/{location}/specialistPools/{specialist_pool}".format( project=project, location=location, specialist_pool=specialist_pool, ) @@ -2301,7 +2449,6 @@ def test_parse_specialist_pool_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2322,7 +2469,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = SpecialistPoolServiceClient.common_folder_path(folder) assert expected == actual @@ -2341,7 +2487,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = SpecialistPoolServiceClient.common_organization_path(organization) assert expected == actual @@ -2360,7 +2505,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = SpecialistPoolServiceClient.common_project_path(project) assert expected == actual @@ -2380,7 +2524,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2407,7 +2550,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.SpecialistPoolServiceTransport, "_prep_wrapped_messages" ) as prep: client = SpecialistPoolServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2416,6 +2559,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = SpecialistPoolServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py index cfbde666ce..aab827e031 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_tensorboard_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.tensorboard_service import ( TensorboardServiceAsyncClient, @@ -43,6 +42,12 @@ ) from google.cloud.aiplatform_v1beta1.services.tensorboard_service import pagers from google.cloud.aiplatform_v1beta1.services.tensorboard_service import transports +from google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import encryption_spec from google.cloud.aiplatform_v1beta1.types import operation as gca_operation from google.cloud.aiplatform_v1beta1.types import tensorboard @@ -61,8 +66,32 @@ ) from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -114,7 +143,7 @@ def test__get_default_mtls_endpoint(): "client_class", [TensorboardServiceClient, TensorboardServiceAsyncClient,] ) def test_tensorboard_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -131,7 +160,7 @@ def test_tensorboard_service_client_from_service_account_info(client_class): "client_class", [TensorboardServiceClient, TensorboardServiceAsyncClient,] ) def test_tensorboard_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -184,7 +213,7 @@ def test_tensorboard_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(TensorboardServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -482,7 +511,7 @@ def test_create_tensorboard( transport: str = "grpc", request_type=tensorboard_service.CreateTensorboardRequest ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -495,13 +524,11 @@ def test_create_tensorboard( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardRequest() # Establish that the response is the type that we expect. @@ -516,7 +543,7 @@ def test_create_tensorboard_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -526,7 +553,6 @@ def test_create_tensorboard_empty_call(): client.create_tensorboard() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardRequest() @@ -536,7 +562,7 @@ async def test_create_tensorboard_async( request_type=tensorboard_service.CreateTensorboardRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -551,13 +577,11 @@ async def test_create_tensorboard_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardRequest() # Establish that the response is the type that we expect. @@ -570,11 +594,14 @@ async def test_create_tensorboard_async_from_dict(): def test_create_tensorboard_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -582,7 +609,6 @@ def test_create_tensorboard_field_headers(): type(client.transport.create_tensorboard), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -598,12 +624,13 @@ def test_create_tensorboard_field_headers(): @pytest.mark.asyncio async def test_create_tensorboard_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -613,7 +640,6 @@ async def test_create_tensorboard_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -627,7 +653,9 @@ async def test_create_tensorboard_field_headers_async(): def test_create_tensorboard_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -635,7 +663,6 @@ def test_create_tensorboard_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_tensorboard( @@ -647,14 +674,14 @@ def test_create_tensorboard_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].tensorboard == gca_tensorboard.Tensorboard(name="name_value") def test_create_tensorboard_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -669,7 +696,7 @@ def test_create_tensorboard_flattened_error(): @pytest.mark.asyncio async def test_create_tensorboard_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -693,16 +720,14 @@ async def test_create_tensorboard_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].tensorboard == gca_tensorboard.Tensorboard(name="name_value") @pytest.mark.asyncio async def test_create_tensorboard_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -719,7 +744,7 @@ def test_get_tensorboard( transport: str = "grpc", request_type=tensorboard_service.GetTensorboardRequest ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -737,29 +762,20 @@ def test_get_tensorboard( run_count=989, etag="etag_value", ) - response = client.get_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tensorboard.Tensorboard) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.blob_storage_path_prefix == "blob_storage_path_prefix_value" - assert response.run_count == 989 - assert response.etag == "etag_value" @@ -771,7 +787,7 @@ def test_get_tensorboard_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -779,7 +795,6 @@ def test_get_tensorboard_empty_call(): client.get_tensorboard() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardRequest() @@ -789,7 +804,7 @@ async def test_get_tensorboard_async( request_type=tensorboard_service.GetTensorboardRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -809,28 +824,20 @@ async def test_get_tensorboard_async( etag="etag_value", ) ) - response = await client.get_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardRequest() # Establish that the response is the type that we expect. assert isinstance(response, tensorboard.Tensorboard) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.blob_storage_path_prefix == "blob_storage_path_prefix_value" - assert response.run_count == 989 - assert response.etag == "etag_value" @@ -840,17 +847,19 @@ async def test_get_tensorboard_async_from_dict(): def test_get_tensorboard_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_tensorboard), "__call__") as call: call.return_value = tensorboard.Tensorboard() - client.get_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -866,12 +875,13 @@ def test_get_tensorboard_field_headers(): @pytest.mark.asyncio async def test_get_tensorboard_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -879,7 +889,6 @@ async def test_get_tensorboard_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard.Tensorboard() ) - await client.get_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -893,13 +902,14 @@ async def test_get_tensorboard_field_headers_async(): def test_get_tensorboard_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_tensorboard), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tensorboard.Tensorboard() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_tensorboard(name="name_value",) @@ -908,12 +918,13 @@ def test_get_tensorboard_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_tensorboard_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -926,7 +937,7 @@ def test_get_tensorboard_flattened_error(): @pytest.mark.asyncio async def test_get_tensorboard_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -945,14 +956,13 @@ async def test_get_tensorboard_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_tensorboard_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -967,7 +977,7 @@ def test_update_tensorboard( transport: str = "grpc", request_type=tensorboard_service.UpdateTensorboardRequest ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -980,13 +990,11 @@ def test_update_tensorboard( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardRequest() # Establish that the response is the type that we expect. @@ -1001,7 +1009,7 @@ def test_update_tensorboard_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1011,7 +1019,6 @@ def test_update_tensorboard_empty_call(): client.update_tensorboard() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardRequest() @@ -1021,7 +1028,7 @@ async def test_update_tensorboard_async( request_type=tensorboard_service.UpdateTensorboardRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1036,13 +1043,11 @@ async def test_update_tensorboard_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardRequest() # Establish that the response is the type that we expect. @@ -1055,11 +1060,14 @@ async def test_update_tensorboard_async_from_dict(): def test_update_tensorboard_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardRequest() + request.tensorboard.name = "tensorboard.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1067,7 +1075,6 @@ def test_update_tensorboard_field_headers(): type(client.transport.update_tensorboard), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -1085,12 +1092,13 @@ def test_update_tensorboard_field_headers(): @pytest.mark.asyncio async def test_update_tensorboard_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardRequest() + request.tensorboard.name = "tensorboard.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1100,7 +1108,6 @@ async def test_update_tensorboard_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -1116,7 +1123,9 @@ async def test_update_tensorboard_field_headers_async(): def test_update_tensorboard_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1124,26 +1133,25 @@ def test_update_tensorboard_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_tensorboard( tensorboard=gca_tensorboard.Tensorboard(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].tensorboard == gca_tensorboard.Tensorboard(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_tensorboard_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1151,14 +1159,14 @@ def test_update_tensorboard_flattened_error(): client.update_tensorboard( tensorboard_service.UpdateTensorboardRequest(), tensorboard=gca_tensorboard.Tensorboard(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_tensorboard_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1175,23 +1183,21 @@ async def test_update_tensorboard_flattened_async(): # using the keyword arguments to the method. response = await client.update_tensorboard( tensorboard=gca_tensorboard.Tensorboard(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].tensorboard == gca_tensorboard.Tensorboard(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_tensorboard_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1200,7 +1206,7 @@ async def test_update_tensorboard_flattened_error_async(): await client.update_tensorboard( tensorboard_service.UpdateTensorboardRequest(), tensorboard=gca_tensorboard.Tensorboard(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1208,7 +1214,7 @@ def test_list_tensorboards( transport: str = "grpc", request_type=tensorboard_service.ListTensorboardsRequest ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1223,19 +1229,15 @@ def test_list_tensorboards( call.return_value = tensorboard_service.ListTensorboardsResponse( next_page_token="next_page_token_value", ) - response = client.list_tensorboards(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTensorboardsPager) - assert response.next_page_token == "next_page_token_value" @@ -1247,7 +1249,7 @@ def test_list_tensorboards_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1257,7 +1259,6 @@ def test_list_tensorboards_empty_call(): client.list_tensorboards() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardsRequest() @@ -1267,7 +1268,7 @@ async def test_list_tensorboards_async( request_type=tensorboard_service.ListTensorboardsRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1284,18 +1285,15 @@ async def test_list_tensorboards_async( next_page_token="next_page_token_value", ) ) - response = await client.list_tensorboards(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTensorboardsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1305,11 +1303,14 @@ async def test_list_tensorboards_async_from_dict(): def test_list_tensorboards_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1317,7 +1318,6 @@ def test_list_tensorboards_field_headers(): type(client.transport.list_tensorboards), "__call__" ) as call: call.return_value = tensorboard_service.ListTensorboardsResponse() - client.list_tensorboards(request) # Establish that the underlying gRPC stub method was called. @@ -1333,12 +1333,13 @@ def test_list_tensorboards_field_headers(): @pytest.mark.asyncio async def test_list_tensorboards_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1348,7 +1349,6 @@ async def test_list_tensorboards_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.ListTensorboardsResponse() ) - await client.list_tensorboards(request) # Establish that the underlying gRPC stub method was called. @@ -1362,7 +1362,9 @@ async def test_list_tensorboards_field_headers_async(): def test_list_tensorboards_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1370,7 +1372,6 @@ def test_list_tensorboards_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.ListTensorboardsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_tensorboards(parent="parent_value",) @@ -1379,12 +1380,13 @@ def test_list_tensorboards_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_tensorboards_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1397,7 +1399,7 @@ def test_list_tensorboards_flattened_error(): @pytest.mark.asyncio async def test_list_tensorboards_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1418,14 +1420,13 @@ async def test_list_tensorboards_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_tensorboards_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1437,7 +1438,7 @@ async def test_list_tensorboards_flattened_error_async(): def test_list_tensorboards_pager(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1479,7 +1480,7 @@ def test_list_tensorboards_pager(): def test_list_tensorboards_pages(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1514,7 +1515,7 @@ def test_list_tensorboards_pages(): @pytest.mark.asyncio async def test_list_tensorboards_async_pager(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1557,7 +1558,7 @@ async def test_list_tensorboards_async_pager(): @pytest.mark.asyncio async def test_list_tensorboards_async_pages(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1598,7 +1599,7 @@ def test_delete_tensorboard( transport: str = "grpc", request_type=tensorboard_service.DeleteTensorboardRequest ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1611,13 +1612,11 @@ def test_delete_tensorboard( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardRequest() # Establish that the response is the type that we expect. @@ -1632,7 +1631,7 @@ def test_delete_tensorboard_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1642,7 +1641,6 @@ def test_delete_tensorboard_empty_call(): client.delete_tensorboard() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardRequest() @@ -1652,7 +1650,7 @@ async def test_delete_tensorboard_async( request_type=tensorboard_service.DeleteTensorboardRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1667,13 +1665,11 @@ async def test_delete_tensorboard_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_tensorboard(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardRequest() # Establish that the response is the type that we expect. @@ -1686,11 +1682,14 @@ async def test_delete_tensorboard_async_from_dict(): def test_delete_tensorboard_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1698,7 +1697,6 @@ def test_delete_tensorboard_field_headers(): type(client.transport.delete_tensorboard), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -1714,12 +1712,13 @@ def test_delete_tensorboard_field_headers(): @pytest.mark.asyncio async def test_delete_tensorboard_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1729,7 +1728,6 @@ async def test_delete_tensorboard_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_tensorboard(request) # Establish that the underlying gRPC stub method was called. @@ -1743,7 +1741,9 @@ async def test_delete_tensorboard_field_headers_async(): def test_delete_tensorboard_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1751,7 +1751,6 @@ def test_delete_tensorboard_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_tensorboard(name="name_value",) @@ -1760,12 +1759,13 @@ def test_delete_tensorboard_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_tensorboard_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1778,7 +1778,7 @@ def test_delete_tensorboard_flattened_error(): @pytest.mark.asyncio async def test_delete_tensorboard_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1799,14 +1799,13 @@ async def test_delete_tensorboard_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_tensorboard_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1822,7 +1821,7 @@ def test_create_tensorboard_experiment( request_type=tensorboard_service.CreateTensorboardExperimentRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1841,27 +1840,19 @@ def test_create_tensorboard_experiment( etag="etag_value", source="source_value", ) - response = client.create_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardExperimentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_tensorboard_experiment.TensorboardExperiment) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.source == "source_value" @@ -1873,7 +1864,7 @@ def test_create_tensorboard_experiment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1883,7 +1874,6 @@ def test_create_tensorboard_experiment_empty_call(): client.create_tensorboard_experiment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardExperimentRequest() @@ -1893,7 +1883,7 @@ async def test_create_tensorboard_experiment_async( request_type=tensorboard_service.CreateTensorboardExperimentRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1914,26 +1904,19 @@ async def test_create_tensorboard_experiment_async( source="source_value", ) ) - response = await client.create_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardExperimentRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_tensorboard_experiment.TensorboardExperiment) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.source == "source_value" @@ -1943,11 +1926,14 @@ async def test_create_tensorboard_experiment_async_from_dict(): def test_create_tensorboard_experiment_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardExperimentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1955,7 +1941,6 @@ def test_create_tensorboard_experiment_field_headers(): type(client.transport.create_tensorboard_experiment), "__call__" ) as call: call.return_value = gca_tensorboard_experiment.TensorboardExperiment() - client.create_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -1971,12 +1956,13 @@ def test_create_tensorboard_experiment_field_headers(): @pytest.mark.asyncio async def test_create_tensorboard_experiment_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardExperimentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1986,7 +1972,6 @@ async def test_create_tensorboard_experiment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_tensorboard_experiment.TensorboardExperiment() ) - await client.create_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -2000,7 +1985,9 @@ async def test_create_tensorboard_experiment_field_headers_async(): def test_create_tensorboard_experiment_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2008,7 +1995,6 @@ def test_create_tensorboard_experiment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_tensorboard_experiment.TensorboardExperiment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_tensorboard_experiment( @@ -2023,20 +2009,19 @@ def test_create_tensorboard_experiment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].tensorboard_experiment == gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ) - assert args[0].tensorboard_experiment_id == "tensorboard_experiment_id_value" def test_create_tensorboard_experiment_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2054,7 +2039,7 @@ def test_create_tensorboard_experiment_flattened_error(): @pytest.mark.asyncio async def test_create_tensorboard_experiment_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2081,22 +2066,19 @@ async def test_create_tensorboard_experiment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].tensorboard_experiment == gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ) - assert args[0].tensorboard_experiment_id == "tensorboard_experiment_id_value" @pytest.mark.asyncio async def test_create_tensorboard_experiment_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2117,7 +2099,7 @@ def test_get_tensorboard_experiment( request_type=tensorboard_service.GetTensorboardExperimentRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2136,27 +2118,19 @@ def test_get_tensorboard_experiment( etag="etag_value", source="source_value", ) - response = client.get_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardExperimentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tensorboard_experiment.TensorboardExperiment) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.source == "source_value" @@ -2168,7 +2142,7 @@ def test_get_tensorboard_experiment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2178,7 +2152,6 @@ def test_get_tensorboard_experiment_empty_call(): client.get_tensorboard_experiment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardExperimentRequest() @@ -2188,7 +2161,7 @@ async def test_get_tensorboard_experiment_async( request_type=tensorboard_service.GetTensorboardExperimentRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2209,26 +2182,19 @@ async def test_get_tensorboard_experiment_async( source="source_value", ) ) - response = await client.get_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardExperimentRequest() # Establish that the response is the type that we expect. assert isinstance(response, tensorboard_experiment.TensorboardExperiment) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.source == "source_value" @@ -2238,11 +2204,14 @@ async def test_get_tensorboard_experiment_async_from_dict(): def test_get_tensorboard_experiment_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardExperimentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2250,7 +2219,6 @@ def test_get_tensorboard_experiment_field_headers(): type(client.transport.get_tensorboard_experiment), "__call__" ) as call: call.return_value = tensorboard_experiment.TensorboardExperiment() - client.get_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -2266,12 +2234,13 @@ def test_get_tensorboard_experiment_field_headers(): @pytest.mark.asyncio async def test_get_tensorboard_experiment_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardExperimentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2281,7 +2250,6 @@ async def test_get_tensorboard_experiment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_experiment.TensorboardExperiment() ) - await client.get_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -2295,7 +2263,9 @@ async def test_get_tensorboard_experiment_field_headers_async(): def test_get_tensorboard_experiment_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2303,7 +2273,6 @@ def test_get_tensorboard_experiment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_experiment.TensorboardExperiment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_tensorboard_experiment(name="name_value",) @@ -2312,12 +2281,13 @@ def test_get_tensorboard_experiment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_tensorboard_experiment_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2330,7 +2300,7 @@ def test_get_tensorboard_experiment_flattened_error(): @pytest.mark.asyncio async def test_get_tensorboard_experiment_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2351,14 +2321,13 @@ async def test_get_tensorboard_experiment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_tensorboard_experiment_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2374,7 +2343,7 @@ def test_update_tensorboard_experiment( request_type=tensorboard_service.UpdateTensorboardExperimentRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2393,27 +2362,19 @@ def test_update_tensorboard_experiment( etag="etag_value", source="source_value", ) - response = client.update_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardExperimentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_tensorboard_experiment.TensorboardExperiment) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.source == "source_value" @@ -2425,7 +2386,7 @@ def test_update_tensorboard_experiment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2435,7 +2396,6 @@ def test_update_tensorboard_experiment_empty_call(): client.update_tensorboard_experiment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardExperimentRequest() @@ -2445,7 +2405,7 @@ async def test_update_tensorboard_experiment_async( request_type=tensorboard_service.UpdateTensorboardExperimentRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2466,26 +2426,19 @@ async def test_update_tensorboard_experiment_async( source="source_value", ) ) - response = await client.update_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardExperimentRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_tensorboard_experiment.TensorboardExperiment) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" - assert response.source == "source_value" @@ -2495,11 +2448,14 @@ async def test_update_tensorboard_experiment_async_from_dict(): def test_update_tensorboard_experiment_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardExperimentRequest() + request.tensorboard_experiment.name = "tensorboard_experiment.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2507,7 +2463,6 @@ def test_update_tensorboard_experiment_field_headers(): type(client.transport.update_tensorboard_experiment), "__call__" ) as call: call.return_value = gca_tensorboard_experiment.TensorboardExperiment() - client.update_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -2526,12 +2481,13 @@ def test_update_tensorboard_experiment_field_headers(): @pytest.mark.asyncio async def test_update_tensorboard_experiment_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardExperimentRequest() + request.tensorboard_experiment.name = "tensorboard_experiment.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2541,7 +2497,6 @@ async def test_update_tensorboard_experiment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_tensorboard_experiment.TensorboardExperiment() ) - await client.update_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -2558,7 +2513,9 @@ async def test_update_tensorboard_experiment_field_headers_async(): def test_update_tensorboard_experiment_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2566,32 +2523,31 @@ def test_update_tensorboard_experiment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_tensorboard_experiment.TensorboardExperiment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_tensorboard_experiment( tensorboard_experiment=gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[ 0 ].tensorboard_experiment == gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_tensorboard_experiment_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2601,14 +2557,14 @@ def test_update_tensorboard_experiment_flattened_error(): tensorboard_experiment=gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_tensorboard_experiment_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2627,27 +2583,25 @@ async def test_update_tensorboard_experiment_flattened_async(): tensorboard_experiment=gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[ 0 ].tensorboard_experiment == gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_tensorboard_experiment_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2658,7 +2612,7 @@ async def test_update_tensorboard_experiment_flattened_error_async(): tensorboard_experiment=gca_tensorboard_experiment.TensorboardExperiment( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2667,7 +2621,7 @@ def test_list_tensorboard_experiments( request_type=tensorboard_service.ListTensorboardExperimentsRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2682,19 +2636,15 @@ def test_list_tensorboard_experiments( call.return_value = tensorboard_service.ListTensorboardExperimentsResponse( next_page_token="next_page_token_value", ) - response = client.list_tensorboard_experiments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardExperimentsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTensorboardExperimentsPager) - assert response.next_page_token == "next_page_token_value" @@ -2706,7 +2656,7 @@ def test_list_tensorboard_experiments_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2716,7 +2666,6 @@ def test_list_tensorboard_experiments_empty_call(): client.list_tensorboard_experiments() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardExperimentsRequest() @@ -2726,7 +2675,7 @@ async def test_list_tensorboard_experiments_async( request_type=tensorboard_service.ListTensorboardExperimentsRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2743,18 +2692,15 @@ async def test_list_tensorboard_experiments_async( next_page_token="next_page_token_value", ) ) - response = await client.list_tensorboard_experiments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardExperimentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTensorboardExperimentsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2764,11 +2710,14 @@ async def test_list_tensorboard_experiments_async_from_dict(): def test_list_tensorboard_experiments_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardExperimentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2776,7 +2725,6 @@ def test_list_tensorboard_experiments_field_headers(): type(client.transport.list_tensorboard_experiments), "__call__" ) as call: call.return_value = tensorboard_service.ListTensorboardExperimentsResponse() - client.list_tensorboard_experiments(request) # Establish that the underlying gRPC stub method was called. @@ -2792,12 +2740,13 @@ def test_list_tensorboard_experiments_field_headers(): @pytest.mark.asyncio async def test_list_tensorboard_experiments_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardExperimentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2807,7 +2756,6 @@ async def test_list_tensorboard_experiments_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.ListTensorboardExperimentsResponse() ) - await client.list_tensorboard_experiments(request) # Establish that the underlying gRPC stub method was called. @@ -2821,7 +2769,9 @@ async def test_list_tensorboard_experiments_field_headers_async(): def test_list_tensorboard_experiments_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2829,7 +2779,6 @@ def test_list_tensorboard_experiments_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.ListTensorboardExperimentsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_tensorboard_experiments(parent="parent_value",) @@ -2838,12 +2787,13 @@ def test_list_tensorboard_experiments_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_tensorboard_experiments_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2857,7 +2807,7 @@ def test_list_tensorboard_experiments_flattened_error(): @pytest.mark.asyncio async def test_list_tensorboard_experiments_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2878,14 +2828,13 @@ async def test_list_tensorboard_experiments_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_tensorboard_experiments_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2898,7 +2847,7 @@ async def test_list_tensorboard_experiments_flattened_error_async(): def test_list_tensorboard_experiments_pager(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2948,7 +2897,7 @@ def test_list_tensorboard_experiments_pager(): def test_list_tensorboard_experiments_pages(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2989,7 +2938,7 @@ def test_list_tensorboard_experiments_pages(): @pytest.mark.asyncio async def test_list_tensorboard_experiments_async_pager(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3041,7 +2990,7 @@ async def test_list_tensorboard_experiments_async_pager(): @pytest.mark.asyncio async def test_list_tensorboard_experiments_async_pages(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3091,7 +3040,7 @@ def test_delete_tensorboard_experiment( request_type=tensorboard_service.DeleteTensorboardExperimentRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3104,13 +3053,11 @@ def test_delete_tensorboard_experiment( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardExperimentRequest() # Establish that the response is the type that we expect. @@ -3125,7 +3072,7 @@ def test_delete_tensorboard_experiment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3135,7 +3082,6 @@ def test_delete_tensorboard_experiment_empty_call(): client.delete_tensorboard_experiment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardExperimentRequest() @@ -3145,7 +3091,7 @@ async def test_delete_tensorboard_experiment_async( request_type=tensorboard_service.DeleteTensorboardExperimentRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3160,13 +3106,11 @@ async def test_delete_tensorboard_experiment_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardExperimentRequest() # Establish that the response is the type that we expect. @@ -3179,11 +3123,14 @@ async def test_delete_tensorboard_experiment_async_from_dict(): def test_delete_tensorboard_experiment_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardExperimentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3191,7 +3138,6 @@ def test_delete_tensorboard_experiment_field_headers(): type(client.transport.delete_tensorboard_experiment), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -3207,12 +3153,13 @@ def test_delete_tensorboard_experiment_field_headers(): @pytest.mark.asyncio async def test_delete_tensorboard_experiment_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardExperimentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3222,7 +3169,6 @@ async def test_delete_tensorboard_experiment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_tensorboard_experiment(request) # Establish that the underlying gRPC stub method was called. @@ -3236,7 +3182,9 @@ async def test_delete_tensorboard_experiment_field_headers_async(): def test_delete_tensorboard_experiment_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3244,7 +3192,6 @@ def test_delete_tensorboard_experiment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_tensorboard_experiment(name="name_value",) @@ -3253,12 +3200,13 @@ def test_delete_tensorboard_experiment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_tensorboard_experiment_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3271,7 +3219,7 @@ def test_delete_tensorboard_experiment_flattened_error(): @pytest.mark.asyncio async def test_delete_tensorboard_experiment_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3292,14 +3240,13 @@ async def test_delete_tensorboard_experiment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_tensorboard_experiment_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3315,7 +3262,7 @@ def test_create_tensorboard_run( request_type=tensorboard_service.CreateTensorboardRunRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3333,25 +3280,18 @@ def test_create_tensorboard_run( description="description_value", etag="etag_value", ) - response = client.create_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardRunRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_tensorboard_run.TensorboardRun) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -3363,7 +3303,7 @@ def test_create_tensorboard_run_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3373,7 +3313,6 @@ def test_create_tensorboard_run_empty_call(): client.create_tensorboard_run() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardRunRequest() @@ -3383,7 +3322,7 @@ async def test_create_tensorboard_run_async( request_type=tensorboard_service.CreateTensorboardRunRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3403,24 +3342,18 @@ async def test_create_tensorboard_run_async( etag="etag_value", ) ) - response = await client.create_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardRunRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_tensorboard_run.TensorboardRun) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -3430,11 +3363,14 @@ async def test_create_tensorboard_run_async_from_dict(): def test_create_tensorboard_run_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardRunRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3442,7 +3378,6 @@ def test_create_tensorboard_run_field_headers(): type(client.transport.create_tensorboard_run), "__call__" ) as call: call.return_value = gca_tensorboard_run.TensorboardRun() - client.create_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -3458,12 +3393,13 @@ def test_create_tensorboard_run_field_headers(): @pytest.mark.asyncio async def test_create_tensorboard_run_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardRunRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3473,7 +3409,6 @@ async def test_create_tensorboard_run_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_tensorboard_run.TensorboardRun() ) - await client.create_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -3487,7 +3422,9 @@ async def test_create_tensorboard_run_field_headers_async(): def test_create_tensorboard_run_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3495,7 +3432,6 @@ def test_create_tensorboard_run_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_tensorboard_run.TensorboardRun() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_tensorboard_run( @@ -3508,18 +3444,17 @@ def test_create_tensorboard_run_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].tensorboard_run == gca_tensorboard_run.TensorboardRun( name="name_value" ) - assert args[0].tensorboard_run_id == "tensorboard_run_id_value" def test_create_tensorboard_run_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3535,7 +3470,7 @@ def test_create_tensorboard_run_flattened_error(): @pytest.mark.asyncio async def test_create_tensorboard_run_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3560,20 +3495,17 @@ async def test_create_tensorboard_run_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].tensorboard_run == gca_tensorboard_run.TensorboardRun( name="name_value" ) - assert args[0].tensorboard_run_id == "tensorboard_run_id_value" @pytest.mark.asyncio async def test_create_tensorboard_run_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3591,7 +3523,7 @@ def test_get_tensorboard_run( transport: str = "grpc", request_type=tensorboard_service.GetTensorboardRunRequest ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3609,25 +3541,18 @@ def test_get_tensorboard_run( description="description_value", etag="etag_value", ) - response = client.get_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardRunRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tensorboard_run.TensorboardRun) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -3639,7 +3564,7 @@ def test_get_tensorboard_run_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3649,7 +3574,6 @@ def test_get_tensorboard_run_empty_call(): client.get_tensorboard_run() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardRunRequest() @@ -3659,7 +3583,7 @@ async def test_get_tensorboard_run_async( request_type=tensorboard_service.GetTensorboardRunRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3679,24 +3603,18 @@ async def test_get_tensorboard_run_async( etag="etag_value", ) ) - response = await client.get_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardRunRequest() # Establish that the response is the type that we expect. assert isinstance(response, tensorboard_run.TensorboardRun) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -3706,11 +3624,14 @@ async def test_get_tensorboard_run_async_from_dict(): def test_get_tensorboard_run_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardRunRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3718,7 +3639,6 @@ def test_get_tensorboard_run_field_headers(): type(client.transport.get_tensorboard_run), "__call__" ) as call: call.return_value = tensorboard_run.TensorboardRun() - client.get_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -3734,12 +3654,13 @@ def test_get_tensorboard_run_field_headers(): @pytest.mark.asyncio async def test_get_tensorboard_run_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardRunRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3749,7 +3670,6 @@ async def test_get_tensorboard_run_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_run.TensorboardRun() ) - await client.get_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -3763,7 +3683,9 @@ async def test_get_tensorboard_run_field_headers_async(): def test_get_tensorboard_run_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3771,7 +3693,6 @@ def test_get_tensorboard_run_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_run.TensorboardRun() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_tensorboard_run(name="name_value",) @@ -3780,12 +3701,13 @@ def test_get_tensorboard_run_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_tensorboard_run_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3798,7 +3720,7 @@ def test_get_tensorboard_run_flattened_error(): @pytest.mark.asyncio async def test_get_tensorboard_run_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3819,14 +3741,13 @@ async def test_get_tensorboard_run_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_tensorboard_run_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3842,7 +3763,7 @@ def test_update_tensorboard_run( request_type=tensorboard_service.UpdateTensorboardRunRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3860,25 +3781,18 @@ def test_update_tensorboard_run( description="description_value", etag="etag_value", ) - response = client.update_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardRunRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_tensorboard_run.TensorboardRun) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -3890,7 +3804,7 @@ def test_update_tensorboard_run_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3900,7 +3814,6 @@ def test_update_tensorboard_run_empty_call(): client.update_tensorboard_run() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardRunRequest() @@ -3910,7 +3823,7 @@ async def test_update_tensorboard_run_async( request_type=tensorboard_service.UpdateTensorboardRunRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3930,24 +3843,18 @@ async def test_update_tensorboard_run_async( etag="etag_value", ) ) - response = await client.update_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardRunRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_tensorboard_run.TensorboardRun) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert response.etag == "etag_value" @@ -3957,11 +3864,14 @@ async def test_update_tensorboard_run_async_from_dict(): def test_update_tensorboard_run_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardRunRequest() + request.tensorboard_run.name = "tensorboard_run.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3969,7 +3879,6 @@ def test_update_tensorboard_run_field_headers(): type(client.transport.update_tensorboard_run), "__call__" ) as call: call.return_value = gca_tensorboard_run.TensorboardRun() - client.update_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -3988,12 +3897,13 @@ def test_update_tensorboard_run_field_headers(): @pytest.mark.asyncio async def test_update_tensorboard_run_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardRunRequest() + request.tensorboard_run.name = "tensorboard_run.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4003,7 +3913,6 @@ async def test_update_tensorboard_run_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_tensorboard_run.TensorboardRun() ) - await client.update_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -4020,7 +3929,9 @@ async def test_update_tensorboard_run_field_headers_async(): def test_update_tensorboard_run_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4028,28 +3939,27 @@ def test_update_tensorboard_run_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_tensorboard_run.TensorboardRun() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_tensorboard_run( tensorboard_run=gca_tensorboard_run.TensorboardRun(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_run == gca_tensorboard_run.TensorboardRun( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_tensorboard_run_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4057,14 +3967,14 @@ def test_update_tensorboard_run_flattened_error(): client.update_tensorboard_run( tensorboard_service.UpdateTensorboardRunRequest(), tensorboard_run=gca_tensorboard_run.TensorboardRun(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_tensorboard_run_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4081,25 +3991,23 @@ async def test_update_tensorboard_run_flattened_async(): # using the keyword arguments to the method. response = await client.update_tensorboard_run( tensorboard_run=gca_tensorboard_run.TensorboardRun(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_run == gca_tensorboard_run.TensorboardRun( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_tensorboard_run_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4108,7 +4016,7 @@ async def test_update_tensorboard_run_flattened_error_async(): await client.update_tensorboard_run( tensorboard_service.UpdateTensorboardRunRequest(), tensorboard_run=gca_tensorboard_run.TensorboardRun(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -4116,7 +4024,7 @@ def test_list_tensorboard_runs( transport: str = "grpc", request_type=tensorboard_service.ListTensorboardRunsRequest ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4131,19 +4039,15 @@ def test_list_tensorboard_runs( call.return_value = tensorboard_service.ListTensorboardRunsResponse( next_page_token="next_page_token_value", ) - response = client.list_tensorboard_runs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardRunsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTensorboardRunsPager) - assert response.next_page_token == "next_page_token_value" @@ -4155,7 +4059,7 @@ def test_list_tensorboard_runs_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4165,7 +4069,6 @@ def test_list_tensorboard_runs_empty_call(): client.list_tensorboard_runs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardRunsRequest() @@ -4175,7 +4078,7 @@ async def test_list_tensorboard_runs_async( request_type=tensorboard_service.ListTensorboardRunsRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4192,18 +4095,15 @@ async def test_list_tensorboard_runs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_tensorboard_runs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardRunsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTensorboardRunsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -4213,11 +4113,14 @@ async def test_list_tensorboard_runs_async_from_dict(): def test_list_tensorboard_runs_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardRunsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4225,7 +4128,6 @@ def test_list_tensorboard_runs_field_headers(): type(client.transport.list_tensorboard_runs), "__call__" ) as call: call.return_value = tensorboard_service.ListTensorboardRunsResponse() - client.list_tensorboard_runs(request) # Establish that the underlying gRPC stub method was called. @@ -4241,12 +4143,13 @@ def test_list_tensorboard_runs_field_headers(): @pytest.mark.asyncio async def test_list_tensorboard_runs_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardRunsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4256,7 +4159,6 @@ async def test_list_tensorboard_runs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.ListTensorboardRunsResponse() ) - await client.list_tensorboard_runs(request) # Establish that the underlying gRPC stub method was called. @@ -4270,7 +4172,9 @@ async def test_list_tensorboard_runs_field_headers_async(): def test_list_tensorboard_runs_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4278,7 +4182,6 @@ def test_list_tensorboard_runs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.ListTensorboardRunsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_tensorboard_runs(parent="parent_value",) @@ -4287,12 +4190,13 @@ def test_list_tensorboard_runs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_tensorboard_runs_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4305,7 +4209,7 @@ def test_list_tensorboard_runs_flattened_error(): @pytest.mark.asyncio async def test_list_tensorboard_runs_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4326,14 +4230,13 @@ async def test_list_tensorboard_runs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_tensorboard_runs_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4345,7 +4248,7 @@ async def test_list_tensorboard_runs_flattened_error_async(): def test_list_tensorboard_runs_pager(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4391,7 +4294,7 @@ def test_list_tensorboard_runs_pager(): def test_list_tensorboard_runs_pages(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4430,7 +4333,7 @@ def test_list_tensorboard_runs_pages(): @pytest.mark.asyncio async def test_list_tensorboard_runs_async_pager(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4477,7 +4380,7 @@ async def test_list_tensorboard_runs_async_pager(): @pytest.mark.asyncio async def test_list_tensorboard_runs_async_pages(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4523,7 +4426,7 @@ def test_delete_tensorboard_run( request_type=tensorboard_service.DeleteTensorboardRunRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4536,13 +4439,11 @@ def test_delete_tensorboard_run( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardRunRequest() # Establish that the response is the type that we expect. @@ -4557,7 +4458,7 @@ def test_delete_tensorboard_run_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4567,7 +4468,6 @@ def test_delete_tensorboard_run_empty_call(): client.delete_tensorboard_run() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardRunRequest() @@ -4577,7 +4477,7 @@ async def test_delete_tensorboard_run_async( request_type=tensorboard_service.DeleteTensorboardRunRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4592,13 +4492,11 @@ async def test_delete_tensorboard_run_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardRunRequest() # Establish that the response is the type that we expect. @@ -4611,11 +4509,14 @@ async def test_delete_tensorboard_run_async_from_dict(): def test_delete_tensorboard_run_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardRunRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4623,7 +4524,6 @@ def test_delete_tensorboard_run_field_headers(): type(client.transport.delete_tensorboard_run), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -4639,12 +4539,13 @@ def test_delete_tensorboard_run_field_headers(): @pytest.mark.asyncio async def test_delete_tensorboard_run_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardRunRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4654,7 +4555,6 @@ async def test_delete_tensorboard_run_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_tensorboard_run(request) # Establish that the underlying gRPC stub method was called. @@ -4668,7 +4568,9 @@ async def test_delete_tensorboard_run_field_headers_async(): def test_delete_tensorboard_run_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4676,7 +4578,6 @@ def test_delete_tensorboard_run_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_tensorboard_run(name="name_value",) @@ -4685,12 +4586,13 @@ def test_delete_tensorboard_run_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_tensorboard_run_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4703,7 +4605,7 @@ def test_delete_tensorboard_run_flattened_error(): @pytest.mark.asyncio async def test_delete_tensorboard_run_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4724,14 +4626,13 @@ async def test_delete_tensorboard_run_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_tensorboard_run_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4747,7 +4648,7 @@ def test_create_tensorboard_time_series( request_type=tensorboard_service.CreateTensorboardTimeSeriesRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4768,34 +4669,24 @@ def test_create_tensorboard_time_series( plugin_name="plugin_name_value", plugin_data=b"plugin_data_blob", ) - response = client.create_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_tensorboard_time_series.TensorboardTimeSeries) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert ( response.value_type == gca_tensorboard_time_series.TensorboardTimeSeries.ValueType.SCALAR ) - assert response.etag == "etag_value" - assert response.plugin_name == "plugin_name_value" - assert response.plugin_data == b"plugin_data_blob" @@ -4807,7 +4698,7 @@ def test_create_tensorboard_time_series_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4817,7 +4708,6 @@ def test_create_tensorboard_time_series_empty_call(): client.create_tensorboard_time_series() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardTimeSeriesRequest() @@ -4827,7 +4717,7 @@ async def test_create_tensorboard_time_series_async( request_type=tensorboard_service.CreateTensorboardTimeSeriesRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4850,33 +4740,24 @@ async def test_create_tensorboard_time_series_async( plugin_data=b"plugin_data_blob", ) ) - response = await client.create_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.CreateTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_tensorboard_time_series.TensorboardTimeSeries) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert ( response.value_type == gca_tensorboard_time_series.TensorboardTimeSeries.ValueType.SCALAR ) - assert response.etag == "etag_value" - assert response.plugin_name == "plugin_name_value" - assert response.plugin_data == b"plugin_data_blob" @@ -4886,11 +4767,14 @@ async def test_create_tensorboard_time_series_async_from_dict(): def test_create_tensorboard_time_series_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardTimeSeriesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4898,7 +4782,6 @@ def test_create_tensorboard_time_series_field_headers(): type(client.transport.create_tensorboard_time_series), "__call__" ) as call: call.return_value = gca_tensorboard_time_series.TensorboardTimeSeries() - client.create_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -4914,12 +4797,13 @@ def test_create_tensorboard_time_series_field_headers(): @pytest.mark.asyncio async def test_create_tensorboard_time_series_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.CreateTensorboardTimeSeriesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4929,7 +4813,6 @@ async def test_create_tensorboard_time_series_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_tensorboard_time_series.TensorboardTimeSeries() ) - await client.create_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -4943,7 +4826,9 @@ async def test_create_tensorboard_time_series_field_headers_async(): def test_create_tensorboard_time_series_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4951,7 +4836,6 @@ def test_create_tensorboard_time_series_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_tensorboard_time_series.TensorboardTimeSeries() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_tensorboard_time_series( @@ -4965,9 +4849,7 @@ def test_create_tensorboard_time_series_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].tensorboard_time_series == gca_tensorboard_time_series.TensorboardTimeSeries( @@ -4976,7 +4858,9 @@ def test_create_tensorboard_time_series_flattened(): def test_create_tensorboard_time_series_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4993,7 +4877,7 @@ def test_create_tensorboard_time_series_flattened_error(): @pytest.mark.asyncio async def test_create_tensorboard_time_series_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5019,9 +4903,7 @@ async def test_create_tensorboard_time_series_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[ 0 ].tensorboard_time_series == gca_tensorboard_time_series.TensorboardTimeSeries( @@ -5032,7 +4914,7 @@ async def test_create_tensorboard_time_series_flattened_async(): @pytest.mark.asyncio async def test_create_tensorboard_time_series_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5052,7 +4934,7 @@ def test_get_tensorboard_time_series( request_type=tensorboard_service.GetTensorboardTimeSeriesRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5073,34 +4955,24 @@ def test_get_tensorboard_time_series( plugin_name="plugin_name_value", plugin_data=b"plugin_data_blob", ) - response = client.get_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tensorboard_time_series.TensorboardTimeSeries) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert ( response.value_type == tensorboard_time_series.TensorboardTimeSeries.ValueType.SCALAR ) - assert response.etag == "etag_value" - assert response.plugin_name == "plugin_name_value" - assert response.plugin_data == b"plugin_data_blob" @@ -5112,7 +4984,7 @@ def test_get_tensorboard_time_series_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5122,7 +4994,6 @@ def test_get_tensorboard_time_series_empty_call(): client.get_tensorboard_time_series() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardTimeSeriesRequest() @@ -5132,7 +5003,7 @@ async def test_get_tensorboard_time_series_async( request_type=tensorboard_service.GetTensorboardTimeSeriesRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5155,33 +5026,24 @@ async def test_get_tensorboard_time_series_async( plugin_data=b"plugin_data_blob", ) ) - response = await client.get_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.GetTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. assert isinstance(response, tensorboard_time_series.TensorboardTimeSeries) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert ( response.value_type == tensorboard_time_series.TensorboardTimeSeries.ValueType.SCALAR ) - assert response.etag == "etag_value" - assert response.plugin_name == "plugin_name_value" - assert response.plugin_data == b"plugin_data_blob" @@ -5191,11 +5053,14 @@ async def test_get_tensorboard_time_series_async_from_dict(): def test_get_tensorboard_time_series_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardTimeSeriesRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5203,7 +5068,6 @@ def test_get_tensorboard_time_series_field_headers(): type(client.transport.get_tensorboard_time_series), "__call__" ) as call: call.return_value = tensorboard_time_series.TensorboardTimeSeries() - client.get_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -5219,12 +5083,13 @@ def test_get_tensorboard_time_series_field_headers(): @pytest.mark.asyncio async def test_get_tensorboard_time_series_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.GetTensorboardTimeSeriesRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5234,7 +5099,6 @@ async def test_get_tensorboard_time_series_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_time_series.TensorboardTimeSeries() ) - await client.get_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -5248,7 +5112,9 @@ async def test_get_tensorboard_time_series_field_headers_async(): def test_get_tensorboard_time_series_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5256,7 +5122,6 @@ def test_get_tensorboard_time_series_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_time_series.TensorboardTimeSeries() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_tensorboard_time_series(name="name_value",) @@ -5265,12 +5130,13 @@ def test_get_tensorboard_time_series_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_tensorboard_time_series_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5283,7 +5149,7 @@ def test_get_tensorboard_time_series_flattened_error(): @pytest.mark.asyncio async def test_get_tensorboard_time_series_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5304,14 +5170,13 @@ async def test_get_tensorboard_time_series_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_tensorboard_time_series_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5327,7 +5192,7 @@ def test_update_tensorboard_time_series( request_type=tensorboard_service.UpdateTensorboardTimeSeriesRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5348,34 +5213,24 @@ def test_update_tensorboard_time_series( plugin_name="plugin_name_value", plugin_data=b"plugin_data_blob", ) - response = client.update_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_tensorboard_time_series.TensorboardTimeSeries) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert ( response.value_type == gca_tensorboard_time_series.TensorboardTimeSeries.ValueType.SCALAR ) - assert response.etag == "etag_value" - assert response.plugin_name == "plugin_name_value" - assert response.plugin_data == b"plugin_data_blob" @@ -5387,7 +5242,7 @@ def test_update_tensorboard_time_series_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5397,7 +5252,6 @@ def test_update_tensorboard_time_series_empty_call(): client.update_tensorboard_time_series() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardTimeSeriesRequest() @@ -5407,7 +5261,7 @@ async def test_update_tensorboard_time_series_async( request_type=tensorboard_service.UpdateTensorboardTimeSeriesRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5430,33 +5284,24 @@ async def test_update_tensorboard_time_series_async( plugin_data=b"plugin_data_blob", ) ) - response = await client.update_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.UpdateTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_tensorboard_time_series.TensorboardTimeSeries) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.description == "description_value" - assert ( response.value_type == gca_tensorboard_time_series.TensorboardTimeSeries.ValueType.SCALAR ) - assert response.etag == "etag_value" - assert response.plugin_name == "plugin_name_value" - assert response.plugin_data == b"plugin_data_blob" @@ -5466,11 +5311,14 @@ async def test_update_tensorboard_time_series_async_from_dict(): def test_update_tensorboard_time_series_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardTimeSeriesRequest() + request.tensorboard_time_series.name = "tensorboard_time_series.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5478,7 +5326,6 @@ def test_update_tensorboard_time_series_field_headers(): type(client.transport.update_tensorboard_time_series), "__call__" ) as call: call.return_value = gca_tensorboard_time_series.TensorboardTimeSeries() - client.update_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -5497,12 +5344,13 @@ def test_update_tensorboard_time_series_field_headers(): @pytest.mark.asyncio async def test_update_tensorboard_time_series_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.UpdateTensorboardTimeSeriesRequest() + request.tensorboard_time_series.name = "tensorboard_time_series.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5512,7 +5360,6 @@ async def test_update_tensorboard_time_series_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gca_tensorboard_time_series.TensorboardTimeSeries() ) - await client.update_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -5529,7 +5376,9 @@ async def test_update_tensorboard_time_series_field_headers_async(): def test_update_tensorboard_time_series_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5537,32 +5386,31 @@ def test_update_tensorboard_time_series_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gca_tensorboard_time_series.TensorboardTimeSeries() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_tensorboard_time_series( tensorboard_time_series=gca_tensorboard_time_series.TensorboardTimeSeries( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[ 0 ].tensorboard_time_series == gca_tensorboard_time_series.TensorboardTimeSeries( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_tensorboard_time_series_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5572,14 +5420,14 @@ def test_update_tensorboard_time_series_flattened_error(): tensorboard_time_series=gca_tensorboard_time_series.TensorboardTimeSeries( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_tensorboard_time_series_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5598,27 +5446,25 @@ async def test_update_tensorboard_time_series_flattened_async(): tensorboard_time_series=gca_tensorboard_time_series.TensorboardTimeSeries( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[ 0 ].tensorboard_time_series == gca_tensorboard_time_series.TensorboardTimeSeries( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_tensorboard_time_series_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5629,7 +5475,7 @@ async def test_update_tensorboard_time_series_flattened_error_async(): tensorboard_time_series=gca_tensorboard_time_series.TensorboardTimeSeries( name="name_value" ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -5638,7 +5484,7 @@ def test_list_tensorboard_time_series( request_type=tensorboard_service.ListTensorboardTimeSeriesRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5653,19 +5499,15 @@ def test_list_tensorboard_time_series( call.return_value = tensorboard_service.ListTensorboardTimeSeriesResponse( next_page_token="next_page_token_value", ) - response = client.list_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTensorboardTimeSeriesPager) - assert response.next_page_token == "next_page_token_value" @@ -5677,7 +5519,7 @@ def test_list_tensorboard_time_series_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5687,7 +5529,6 @@ def test_list_tensorboard_time_series_empty_call(): client.list_tensorboard_time_series() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardTimeSeriesRequest() @@ -5697,7 +5538,7 @@ async def test_list_tensorboard_time_series_async( request_type=tensorboard_service.ListTensorboardTimeSeriesRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5714,18 +5555,15 @@ async def test_list_tensorboard_time_series_async( next_page_token="next_page_token_value", ) ) - response = await client.list_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ListTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTensorboardTimeSeriesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -5735,11 +5573,14 @@ async def test_list_tensorboard_time_series_async_from_dict(): def test_list_tensorboard_time_series_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardTimeSeriesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5747,7 +5588,6 @@ def test_list_tensorboard_time_series_field_headers(): type(client.transport.list_tensorboard_time_series), "__call__" ) as call: call.return_value = tensorboard_service.ListTensorboardTimeSeriesResponse() - client.list_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -5763,12 +5603,13 @@ def test_list_tensorboard_time_series_field_headers(): @pytest.mark.asyncio async def test_list_tensorboard_time_series_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ListTensorboardTimeSeriesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5778,7 +5619,6 @@ async def test_list_tensorboard_time_series_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.ListTensorboardTimeSeriesResponse() ) - await client.list_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -5792,7 +5632,9 @@ async def test_list_tensorboard_time_series_field_headers_async(): def test_list_tensorboard_time_series_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5800,7 +5642,6 @@ def test_list_tensorboard_time_series_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.ListTensorboardTimeSeriesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_tensorboard_time_series(parent="parent_value",) @@ -5809,12 +5650,13 @@ def test_list_tensorboard_time_series_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_tensorboard_time_series_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5828,7 +5670,7 @@ def test_list_tensorboard_time_series_flattened_error(): @pytest.mark.asyncio async def test_list_tensorboard_time_series_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5849,14 +5691,13 @@ async def test_list_tensorboard_time_series_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_tensorboard_time_series_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5869,7 +5710,7 @@ async def test_list_tensorboard_time_series_flattened_error_async(): def test_list_tensorboard_time_series_pager(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5920,7 +5761,7 @@ def test_list_tensorboard_time_series_pager(): def test_list_tensorboard_time_series_pages(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5961,7 +5802,7 @@ def test_list_tensorboard_time_series_pages(): @pytest.mark.asyncio async def test_list_tensorboard_time_series_async_pager(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6013,7 +5854,7 @@ async def test_list_tensorboard_time_series_async_pager(): @pytest.mark.asyncio async def test_list_tensorboard_time_series_async_pages(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6063,7 +5904,7 @@ def test_delete_tensorboard_time_series( request_type=tensorboard_service.DeleteTensorboardTimeSeriesRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6076,13 +5917,11 @@ def test_delete_tensorboard_time_series( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. @@ -6097,7 +5936,7 @@ def test_delete_tensorboard_time_series_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6107,7 +5946,6 @@ def test_delete_tensorboard_time_series_empty_call(): client.delete_tensorboard_time_series() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardTimeSeriesRequest() @@ -6117,7 +5955,7 @@ async def test_delete_tensorboard_time_series_async( request_type=tensorboard_service.DeleteTensorboardTimeSeriesRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6132,13 +5970,11 @@ async def test_delete_tensorboard_time_series_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.DeleteTensorboardTimeSeriesRequest() # Establish that the response is the type that we expect. @@ -6151,11 +5987,14 @@ async def test_delete_tensorboard_time_series_async_from_dict(): def test_delete_tensorboard_time_series_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardTimeSeriesRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6163,7 +6002,6 @@ def test_delete_tensorboard_time_series_field_headers(): type(client.transport.delete_tensorboard_time_series), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -6179,12 +6017,13 @@ def test_delete_tensorboard_time_series_field_headers(): @pytest.mark.asyncio async def test_delete_tensorboard_time_series_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.DeleteTensorboardTimeSeriesRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6194,7 +6033,6 @@ async def test_delete_tensorboard_time_series_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_tensorboard_time_series(request) # Establish that the underlying gRPC stub method was called. @@ -6208,7 +6046,9 @@ async def test_delete_tensorboard_time_series_field_headers_async(): def test_delete_tensorboard_time_series_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6216,7 +6056,6 @@ def test_delete_tensorboard_time_series_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_tensorboard_time_series(name="name_value",) @@ -6225,12 +6064,13 @@ def test_delete_tensorboard_time_series_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_tensorboard_time_series_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6243,7 +6083,7 @@ def test_delete_tensorboard_time_series_flattened_error(): @pytest.mark.asyncio async def test_delete_tensorboard_time_series_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6264,14 +6104,13 @@ async def test_delete_tensorboard_time_series_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_tensorboard_time_series_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6287,7 +6126,7 @@ def test_read_tensorboard_time_series_data( request_type=tensorboard_service.ReadTensorboardTimeSeriesDataRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6300,17 +6139,14 @@ def test_read_tensorboard_time_series_data( ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.ReadTensorboardTimeSeriesDataResponse() - response = client.read_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ReadTensorboardTimeSeriesDataRequest() # Establish that the response is the type that we expect. - assert isinstance( response, tensorboard_service.ReadTensorboardTimeSeriesDataResponse ) @@ -6324,7 +6160,7 @@ def test_read_tensorboard_time_series_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6334,7 +6170,6 @@ def test_read_tensorboard_time_series_data_empty_call(): client.read_tensorboard_time_series_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ReadTensorboardTimeSeriesDataRequest() @@ -6344,7 +6179,7 @@ async def test_read_tensorboard_time_series_data_async( request_type=tensorboard_service.ReadTensorboardTimeSeriesDataRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6359,13 +6194,11 @@ async def test_read_tensorboard_time_series_data_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.ReadTensorboardTimeSeriesDataResponse() ) - response = await client.read_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ReadTensorboardTimeSeriesDataRequest() # Establish that the response is the type that we expect. @@ -6380,11 +6213,14 @@ async def test_read_tensorboard_time_series_data_async_from_dict(): def test_read_tensorboard_time_series_data_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ReadTensorboardTimeSeriesDataRequest() + request.tensorboard_time_series = "tensorboard_time_series/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6392,7 +6228,6 @@ def test_read_tensorboard_time_series_data_field_headers(): type(client.transport.read_tensorboard_time_series_data), "__call__" ) as call: call.return_value = tensorboard_service.ReadTensorboardTimeSeriesDataResponse() - client.read_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. @@ -6411,12 +6246,13 @@ def test_read_tensorboard_time_series_data_field_headers(): @pytest.mark.asyncio async def test_read_tensorboard_time_series_data_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ReadTensorboardTimeSeriesDataRequest() + request.tensorboard_time_series = "tensorboard_time_series/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6426,7 +6262,6 @@ async def test_read_tensorboard_time_series_data_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.ReadTensorboardTimeSeriesDataResponse() ) - await client.read_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. @@ -6443,7 +6278,9 @@ async def test_read_tensorboard_time_series_data_field_headers_async(): def test_read_tensorboard_time_series_data_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6451,7 +6288,6 @@ def test_read_tensorboard_time_series_data_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.ReadTensorboardTimeSeriesDataResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.read_tensorboard_time_series_data( @@ -6462,12 +6298,13 @@ def test_read_tensorboard_time_series_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_time_series == "tensorboard_time_series_value" def test_read_tensorboard_time_series_data_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6481,7 +6318,7 @@ def test_read_tensorboard_time_series_data_flattened_error(): @pytest.mark.asyncio async def test_read_tensorboard_time_series_data_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6504,14 +6341,13 @@ async def test_read_tensorboard_time_series_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_time_series == "tensorboard_time_series_value" @pytest.mark.asyncio async def test_read_tensorboard_time_series_data_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6528,7 +6364,7 @@ def test_read_tensorboard_blob_data( request_type=tensorboard_service.ReadTensorboardBlobDataRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6543,13 +6379,11 @@ def test_read_tensorboard_blob_data( call.return_value = iter( [tensorboard_service.ReadTensorboardBlobDataResponse()] ) - response = client.read_tensorboard_blob_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ReadTensorboardBlobDataRequest() # Establish that the response is the type that we expect. @@ -6565,7 +6399,7 @@ def test_read_tensorboard_blob_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6575,7 +6409,6 @@ def test_read_tensorboard_blob_data_empty_call(): client.read_tensorboard_blob_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ReadTensorboardBlobDataRequest() @@ -6585,7 +6418,7 @@ async def test_read_tensorboard_blob_data_async( request_type=tensorboard_service.ReadTensorboardBlobDataRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6601,13 +6434,11 @@ async def test_read_tensorboard_blob_data_async( call.return_value.read = mock.AsyncMock( side_effect=[tensorboard_service.ReadTensorboardBlobDataResponse()] ) - response = await client.read_tensorboard_blob_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ReadTensorboardBlobDataRequest() # Establish that the response is the type that we expect. @@ -6621,11 +6452,14 @@ async def test_read_tensorboard_blob_data_async_from_dict(): def test_read_tensorboard_blob_data_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ReadTensorboardBlobDataRequest() + request.time_series = "time_series/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6635,7 +6469,6 @@ def test_read_tensorboard_blob_data_field_headers(): call.return_value = iter( [tensorboard_service.ReadTensorboardBlobDataResponse()] ) - client.read_tensorboard_blob_data(request) # Establish that the underlying gRPC stub method was called. @@ -6651,12 +6484,13 @@ def test_read_tensorboard_blob_data_field_headers(): @pytest.mark.asyncio async def test_read_tensorboard_blob_data_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ReadTensorboardBlobDataRequest() + request.time_series = "time_series/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6667,7 +6501,6 @@ async def test_read_tensorboard_blob_data_field_headers_async(): call.return_value.read = mock.AsyncMock( side_effect=[tensorboard_service.ReadTensorboardBlobDataResponse()] ) - await client.read_tensorboard_blob_data(request) # Establish that the underlying gRPC stub method was called. @@ -6681,7 +6514,9 @@ async def test_read_tensorboard_blob_data_field_headers_async(): def test_read_tensorboard_blob_data_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6691,7 +6526,6 @@ def test_read_tensorboard_blob_data_flattened(): call.return_value = iter( [tensorboard_service.ReadTensorboardBlobDataResponse()] ) - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.read_tensorboard_blob_data(time_series="time_series_value",) @@ -6700,12 +6534,13 @@ def test_read_tensorboard_blob_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].time_series == "time_series_value" def test_read_tensorboard_blob_data_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6719,7 +6554,7 @@ def test_read_tensorboard_blob_data_flattened_error(): @pytest.mark.asyncio async def test_read_tensorboard_blob_data_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6742,14 +6577,13 @@ async def test_read_tensorboard_blob_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].time_series == "time_series_value" @pytest.mark.asyncio async def test_read_tensorboard_blob_data_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -6766,7 +6600,7 @@ def test_write_tensorboard_run_data( request_type=tensorboard_service.WriteTensorboardRunDataRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6779,17 +6613,14 @@ def test_write_tensorboard_run_data( ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.WriteTensorboardRunDataResponse() - response = client.write_tensorboard_run_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.WriteTensorboardRunDataRequest() # Establish that the response is the type that we expect. - assert isinstance(response, tensorboard_service.WriteTensorboardRunDataResponse) @@ -6801,7 +6632,7 @@ def test_write_tensorboard_run_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6811,7 +6642,6 @@ def test_write_tensorboard_run_data_empty_call(): client.write_tensorboard_run_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.WriteTensorboardRunDataRequest() @@ -6821,7 +6651,7 @@ async def test_write_tensorboard_run_data_async( request_type=tensorboard_service.WriteTensorboardRunDataRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -6836,13 +6666,11 @@ async def test_write_tensorboard_run_data_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.WriteTensorboardRunDataResponse() ) - response = await client.write_tensorboard_run_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.WriteTensorboardRunDataRequest() # Establish that the response is the type that we expect. @@ -6855,11 +6683,14 @@ async def test_write_tensorboard_run_data_async_from_dict(): def test_write_tensorboard_run_data_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.WriteTensorboardRunDataRequest() + request.tensorboard_run = "tensorboard_run/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6867,7 +6698,6 @@ def test_write_tensorboard_run_data_field_headers(): type(client.transport.write_tensorboard_run_data), "__call__" ) as call: call.return_value = tensorboard_service.WriteTensorboardRunDataResponse() - client.write_tensorboard_run_data(request) # Establish that the underlying gRPC stub method was called. @@ -6885,12 +6715,13 @@ def test_write_tensorboard_run_data_field_headers(): @pytest.mark.asyncio async def test_write_tensorboard_run_data_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.WriteTensorboardRunDataRequest() + request.tensorboard_run = "tensorboard_run/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -6900,7 +6731,6 @@ async def test_write_tensorboard_run_data_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.WriteTensorboardRunDataResponse() ) - await client.write_tensorboard_run_data(request) # Establish that the underlying gRPC stub method was called. @@ -6916,7 +6746,9 @@ async def test_write_tensorboard_run_data_field_headers_async(): def test_write_tensorboard_run_data_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -6924,7 +6756,6 @@ def test_write_tensorboard_run_data_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = tensorboard_service.WriteTensorboardRunDataResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.write_tensorboard_run_data( @@ -6940,9 +6771,7 @@ def test_write_tensorboard_run_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_run == "tensorboard_run_value" - assert args[0].time_series_data == [ tensorboard_data.TimeSeriesData( tensorboard_time_series_id="tensorboard_time_series_id_value" @@ -6951,7 +6780,9 @@ def test_write_tensorboard_run_data_flattened(): def test_write_tensorboard_run_data_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -6970,7 +6801,7 @@ def test_write_tensorboard_run_data_flattened_error(): @pytest.mark.asyncio async def test_write_tensorboard_run_data_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -6998,9 +6829,7 @@ async def test_write_tensorboard_run_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_run == "tensorboard_run_value" - assert args[0].time_series_data == [ tensorboard_data.TimeSeriesData( tensorboard_time_series_id="tensorboard_time_series_id_value" @@ -7011,7 +6840,7 @@ async def test_write_tensorboard_run_data_flattened_async(): @pytest.mark.asyncio async def test_write_tensorboard_run_data_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7033,7 +6862,7 @@ def test_export_tensorboard_time_series_data( request_type=tensorboard_service.ExportTensorboardTimeSeriesDataRequest, ): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7048,19 +6877,15 @@ def test_export_tensorboard_time_series_data( call.return_value = tensorboard_service.ExportTensorboardTimeSeriesDataResponse( next_page_token="next_page_token_value", ) - response = client.export_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ExportTensorboardTimeSeriesDataRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ExportTensorboardTimeSeriesDataPager) - assert response.next_page_token == "next_page_token_value" @@ -7072,7 +6897,7 @@ def test_export_tensorboard_time_series_data_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7082,7 +6907,6 @@ def test_export_tensorboard_time_series_data_empty_call(): client.export_tensorboard_time_series_data() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ExportTensorboardTimeSeriesDataRequest() @@ -7092,7 +6916,7 @@ async def test_export_tensorboard_time_series_data_async( request_type=tensorboard_service.ExportTensorboardTimeSeriesDataRequest, ): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -7109,18 +6933,15 @@ async def test_export_tensorboard_time_series_data_async( next_page_token="next_page_token_value", ) ) - response = await client.export_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == tensorboard_service.ExportTensorboardTimeSeriesDataRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ExportTensorboardTimeSeriesDataAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -7130,11 +6951,14 @@ async def test_export_tensorboard_time_series_data_async_from_dict(): def test_export_tensorboard_time_series_data_field_headers(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ExportTensorboardTimeSeriesDataRequest() + request.tensorboard_time_series = "tensorboard_time_series/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7144,7 +6968,6 @@ def test_export_tensorboard_time_series_data_field_headers(): call.return_value = ( tensorboard_service.ExportTensorboardTimeSeriesDataResponse() ) - client.export_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. @@ -7163,12 +6986,13 @@ def test_export_tensorboard_time_series_data_field_headers(): @pytest.mark.asyncio async def test_export_tensorboard_time_series_data_field_headers_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = tensorboard_service.ExportTensorboardTimeSeriesDataRequest() + request.tensorboard_time_series = "tensorboard_time_series/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -7178,7 +7002,6 @@ async def test_export_tensorboard_time_series_data_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tensorboard_service.ExportTensorboardTimeSeriesDataResponse() ) - await client.export_tensorboard_time_series_data(request) # Establish that the underlying gRPC stub method was called. @@ -7195,7 +7018,9 @@ async def test_export_tensorboard_time_series_data_field_headers_async(): def test_export_tensorboard_time_series_data_flattened(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7205,7 +7030,6 @@ def test_export_tensorboard_time_series_data_flattened(): call.return_value = ( tensorboard_service.ExportTensorboardTimeSeriesDataResponse() ) - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.export_tensorboard_time_series_data( @@ -7216,12 +7040,13 @@ def test_export_tensorboard_time_series_data_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_time_series == "tensorboard_time_series_value" def test_export_tensorboard_time_series_data_flattened_error(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -7235,7 +7060,7 @@ def test_export_tensorboard_time_series_data_flattened_error(): @pytest.mark.asyncio async def test_export_tensorboard_time_series_data_flattened_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7260,14 +7085,13 @@ async def test_export_tensorboard_time_series_data_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].tensorboard_time_series == "tensorboard_time_series_value" @pytest.mark.asyncio async def test_export_tensorboard_time_series_data_flattened_error_async(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -7280,7 +7104,7 @@ async def test_export_tensorboard_time_series_data_flattened_error_async(): def test_export_tensorboard_time_series_data_pager(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7328,7 +7152,7 @@ def test_export_tensorboard_time_series_data_pager(): def test_export_tensorboard_time_series_data_pages(): - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials,) + client = TensorboardServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -7367,7 +7191,7 @@ def test_export_tensorboard_time_series_data_pages(): @pytest.mark.asyncio async def test_export_tensorboard_time_series_data_async_pager(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7416,7 +7240,7 @@ async def test_export_tensorboard_time_series_data_async_pager(): @pytest.mark.asyncio async def test_export_tensorboard_time_series_data_async_pages(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -7462,16 +7286,16 @@ async def test_export_tensorboard_time_series_data_async_pages(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.TensorboardServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.TensorboardServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = TensorboardServiceClient( @@ -7481,7 +7305,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.TensorboardServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = TensorboardServiceClient( @@ -7492,7 +7316,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.TensorboardServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = TensorboardServiceClient(transport=transport) assert client.transport is transport @@ -7501,13 +7325,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.TensorboardServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.TensorboardServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -7522,23 +7346,25 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = TensorboardServiceClient(credentials=credentials.AnonymousCredentials(),) + client = TensorboardServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) assert isinstance(client.transport, transports.TensorboardServiceGrpcTransport,) def test_tensorboard_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.TensorboardServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -7550,7 +7376,7 @@ def test_tensorboard_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.TensorboardServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -7591,15 +7417,37 @@ def test_tensorboard_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_tensorboard_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.TensorboardServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.TensorboardServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_tensorboard_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.TensorboardServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.TensorboardServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -7612,19 +7460,33 @@ def test_tensorboard_service_base_transport_with_credentials_file(): def test_tensorboard_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.TensorboardServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.TensorboardServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_tensorboard_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + TensorboardServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_tensorboard_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) TensorboardServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -7632,20 +7494,156 @@ def test_tensorboard_service_auth_adc(): ) -def test_tensorboard_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.TensorboardServiceGrpcTransport, + transports.TensorboardServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_tensorboard_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.TensorboardServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.TensorboardServiceGrpcTransport, + transports.TensorboardServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_tensorboard_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.TensorboardServiceGrpcTransport, grpc_helpers), + (transports.TensorboardServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_tensorboard_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.TensorboardServiceGrpcTransport, grpc_helpers), + (transports.TensorboardServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_tensorboard_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.TensorboardServiceGrpcTransport, grpc_helpers), + (transports.TensorboardServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_tensorboard_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -7656,7 +7654,7 @@ def test_tensorboard_service_transport_auth_adc(): def test_tensorboard_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -7695,7 +7693,7 @@ def test_tensorboard_service_grpc_transport_client_cert_source_for_mtls( def test_tensorboard_service_host_no_port(): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -7705,7 +7703,7 @@ def test_tensorboard_service_host_no_port(): def test_tensorboard_service_host_with_port(): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -7761,9 +7759,9 @@ def test_tensorboard_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -7839,7 +7837,7 @@ def test_tensorboard_service_transport_channel_mtls_with_adc(transport_class): def test_tensorboard_service_grpc_lro_client(): client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -7852,7 +7850,7 @@ def test_tensorboard_service_grpc_lro_client(): def test_tensorboard_service_grpc_lro_async_client(): client = TensorboardServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -7867,7 +7865,6 @@ def test_tensorboard_path(): project = "squid" location = "clam" tensorboard = "whelk" - expected = "projects/{project}/locations/{location}/tensorboards/{tensorboard}".format( project=project, location=location, tensorboard=tensorboard, ) @@ -7893,7 +7890,6 @@ def test_tensorboard_experiment_path(): location = "mussel" tensorboard = "winkle" experiment = "nautilus" - expected = "projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}".format( project=project, location=location, @@ -7926,7 +7922,6 @@ def test_tensorboard_run_path(): tensorboard = "oyster" experiment = "nudibranch" run = "cuttlefish" - expected = "projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}".format( project=project, location=location, @@ -7962,7 +7957,6 @@ def test_tensorboard_time_series_path(): experiment = "octopus" run = "oyster" time_series = "nudibranch" - expected = "projects/{project}/locations/{location}/tensorboards/{tensorboard}/experiments/{experiment}/runs/{run}/timeSeries/{time_series}".format( project=project, location=location, @@ -7995,7 +7989,6 @@ def test_parse_tensorboard_time_series_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -8016,7 +8009,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = TensorboardServiceClient.common_folder_path(folder) assert expected == actual @@ -8035,7 +8027,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = TensorboardServiceClient.common_organization_path(organization) assert expected == actual @@ -8054,7 +8045,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = TensorboardServiceClient.common_project_path(project) assert expected == actual @@ -8074,7 +8064,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -8101,7 +8090,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.TensorboardServiceTransport, "_prep_wrapped_messages" ) as prep: client = TensorboardServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -8110,6 +8099,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = TensorboardServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py b/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py index 770c95794f..e4df5b0517 100644 --- a/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py +++ b/tests/unit/gapic/aiplatform_v1beta1/test_vizier_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future from google.api_core import gapic_v1 from google.api_core import grpc_helpers 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.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.aiplatform_v1beta1.services.vizier_service import ( VizierServiceAsyncClient, @@ -41,14 +40,44 @@ from google.cloud.aiplatform_v1beta1.services.vizier_service import VizierServiceClient from google.cloud.aiplatform_v1beta1.services.vizier_service import pagers from google.cloud.aiplatform_v1beta1.services.vizier_service import transports +from google.cloud.aiplatform_v1beta1.services.vizier_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.aiplatform_v1beta1.services.vizier_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.aiplatform_v1beta1.types import study from google.cloud.aiplatform_v1beta1.types import study as gca_study from google.cloud.aiplatform_v1beta1.types import vizier_service from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import struct_pb2 as struct # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -99,7 +128,7 @@ def test__get_default_mtls_endpoint(): "client_class", [VizierServiceClient, VizierServiceAsyncClient,] ) def test_vizier_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -116,7 +145,7 @@ def test_vizier_service_client_from_service_account_info(client_class): "client_class", [VizierServiceClient, VizierServiceAsyncClient,] ) def test_vizier_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -169,7 +198,7 @@ def test_vizier_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(VizierServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -457,7 +486,7 @@ def test_create_study( transport: str = "grpc", request_type=vizier_service.CreateStudyRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -473,25 +502,18 @@ def test_create_study( state=gca_study.Study.State.ACTIVE, inactive_reason="inactive_reason_value", ) - response = client.create_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CreateStudyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gca_study.Study) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == gca_study.Study.State.ACTIVE - assert response.inactive_reason == "inactive_reason_value" @@ -503,7 +525,7 @@ def test_create_study_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -511,7 +533,6 @@ def test_create_study_empty_call(): client.create_study() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CreateStudyRequest() @@ -520,7 +541,7 @@ async def test_create_study_async( transport: str = "grpc_asyncio", request_type=vizier_service.CreateStudyRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -538,24 +559,18 @@ async def test_create_study_async( inactive_reason="inactive_reason_value", ) ) - response = await client.create_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CreateStudyRequest() # Establish that the response is the type that we expect. assert isinstance(response, gca_study.Study) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == gca_study.Study.State.ACTIVE - assert response.inactive_reason == "inactive_reason_value" @@ -565,17 +580,17 @@ async def test_create_study_async_from_dict(): def test_create_study_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CreateStudyRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_study), "__call__") as call: call.return_value = gca_study.Study() - client.create_study(request) # Establish that the underlying gRPC stub method was called. @@ -590,17 +605,19 @@ def test_create_study_field_headers(): @pytest.mark.asyncio async def test_create_study_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CreateStudyRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_study), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gca_study.Study()) - await client.create_study(request) # Establish that the underlying gRPC stub method was called. @@ -614,13 +631,12 @@ async def test_create_study_field_headers_async(): def test_create_study_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_study), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gca_study.Study() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_study( @@ -631,14 +647,12 @@ def test_create_study_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].study == gca_study.Study(name="name_value") def test_create_study_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -652,7 +666,9 @@ def test_create_study_flattened_error(): @pytest.mark.asyncio async def test_create_study_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_study), "__call__") as call: @@ -670,15 +686,15 @@ async def test_create_study_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].study == gca_study.Study(name="name_value") @pytest.mark.asyncio async def test_create_study_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -694,7 +710,7 @@ def test_get_study( transport: str = "grpc", request_type=vizier_service.GetStudyRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -710,25 +726,18 @@ def test_get_study( state=study.Study.State.ACTIVE, inactive_reason="inactive_reason_value", ) - response = client.get_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.GetStudyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, study.Study) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == study.Study.State.ACTIVE - assert response.inactive_reason == "inactive_reason_value" @@ -740,7 +749,7 @@ def test_get_study_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -748,7 +757,6 @@ def test_get_study_empty_call(): client.get_study() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.GetStudyRequest() @@ -757,7 +765,7 @@ async def test_get_study_async( transport: str = "grpc_asyncio", request_type=vizier_service.GetStudyRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -775,24 +783,18 @@ async def test_get_study_async( inactive_reason="inactive_reason_value", ) ) - response = await client.get_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.GetStudyRequest() # Establish that the response is the type that we expect. assert isinstance(response, study.Study) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == study.Study.State.ACTIVE - assert response.inactive_reason == "inactive_reason_value" @@ -802,17 +804,17 @@ async def test_get_study_async_from_dict(): def test_get_study_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.GetStudyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_study), "__call__") as call: call.return_value = study.Study() - client.get_study(request) # Establish that the underlying gRPC stub method was called. @@ -827,17 +829,19 @@ def test_get_study_field_headers(): @pytest.mark.asyncio async def test_get_study_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.GetStudyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_study), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Study()) - await client.get_study(request) # Establish that the underlying gRPC stub method was called. @@ -851,13 +855,12 @@ async def test_get_study_field_headers_async(): def test_get_study_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_study), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = study.Study() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_study(name="name_value",) @@ -866,12 +869,11 @@ def test_get_study_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_study_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -883,7 +885,9 @@ def test_get_study_flattened_error(): @pytest.mark.asyncio async def test_get_study_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_study), "__call__") as call: @@ -899,13 +903,14 @@ async def test_get_study_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_study_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -919,7 +924,7 @@ def test_list_studies( transport: str = "grpc", request_type=vizier_service.ListStudiesRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -932,19 +937,15 @@ def test_list_studies( call.return_value = vizier_service.ListStudiesResponse( next_page_token="next_page_token_value", ) - response = client.list_studies(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListStudiesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListStudiesPager) - assert response.next_page_token == "next_page_token_value" @@ -956,7 +957,7 @@ def test_list_studies_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -964,7 +965,6 @@ def test_list_studies_empty_call(): client.list_studies() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListStudiesRequest() @@ -973,7 +973,7 @@ async def test_list_studies_async( transport: str = "grpc_asyncio", request_type=vizier_service.ListStudiesRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -986,18 +986,15 @@ async def test_list_studies_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( vizier_service.ListStudiesResponse(next_page_token="next_page_token_value",) ) - response = await client.list_studies(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListStudiesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListStudiesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1007,17 +1004,17 @@ async def test_list_studies_async_from_dict(): def test_list_studies_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.ListStudiesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_studies), "__call__") as call: call.return_value = vizier_service.ListStudiesResponse() - client.list_studies(request) # Establish that the underlying gRPC stub method was called. @@ -1032,11 +1029,14 @@ def test_list_studies_field_headers(): @pytest.mark.asyncio async def test_list_studies_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.ListStudiesRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1044,7 +1044,6 @@ async def test_list_studies_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( vizier_service.ListStudiesResponse() ) - await client.list_studies(request) # Establish that the underlying gRPC stub method was called. @@ -1058,13 +1057,12 @@ async def test_list_studies_field_headers_async(): def test_list_studies_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_studies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = vizier_service.ListStudiesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_studies(parent="parent_value",) @@ -1073,12 +1071,11 @@ def test_list_studies_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_studies_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1090,7 +1087,9 @@ def test_list_studies_flattened_error(): @pytest.mark.asyncio async def test_list_studies_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_studies), "__call__") as call: @@ -1108,13 +1107,14 @@ async def test_list_studies_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_studies_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1125,7 +1125,7 @@ async def test_list_studies_flattened_error_async(): def test_list_studies_pager(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_studies), "__call__") as call: @@ -1159,7 +1159,7 @@ def test_list_studies_pager(): def test_list_studies_pages(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_studies), "__call__") as call: @@ -1185,7 +1185,7 @@ def test_list_studies_pages(): @pytest.mark.asyncio async def test_list_studies_async_pager(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1218,7 +1218,7 @@ async def test_list_studies_async_pager(): @pytest.mark.asyncio async def test_list_studies_async_pages(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1250,7 +1250,7 @@ def test_delete_study( transport: str = "grpc", request_type=vizier_service.DeleteStudyRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1261,13 +1261,11 @@ def test_delete_study( with mock.patch.object(type(client.transport.delete_study), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.DeleteStudyRequest() # Establish that the response is the type that we expect. @@ -1282,7 +1280,7 @@ def test_delete_study_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1290,7 +1288,6 @@ def test_delete_study_empty_call(): client.delete_study() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.DeleteStudyRequest() @@ -1299,7 +1296,7 @@ async def test_delete_study_async( transport: str = "grpc_asyncio", request_type=vizier_service.DeleteStudyRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1310,13 +1307,11 @@ async def test_delete_study_async( with mock.patch.object(type(client.transport.delete_study), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.DeleteStudyRequest() # Establish that the response is the type that we expect. @@ -1329,17 +1324,17 @@ async def test_delete_study_async_from_dict(): def test_delete_study_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.DeleteStudyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_study), "__call__") as call: call.return_value = None - client.delete_study(request) # Establish that the underlying gRPC stub method was called. @@ -1354,17 +1349,19 @@ def test_delete_study_field_headers(): @pytest.mark.asyncio async def test_delete_study_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.DeleteStudyRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_study), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_study(request) # Establish that the underlying gRPC stub method was called. @@ -1378,13 +1375,12 @@ async def test_delete_study_field_headers_async(): def test_delete_study_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_study), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_study(name="name_value",) @@ -1393,12 +1389,11 @@ def test_delete_study_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_study_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1410,7 +1405,9 @@ def test_delete_study_flattened_error(): @pytest.mark.asyncio async def test_delete_study_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_study), "__call__") as call: @@ -1426,13 +1423,14 @@ async def test_delete_study_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_study_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1446,7 +1444,7 @@ def test_lookup_study( transport: str = "grpc", request_type=vizier_service.LookupStudyRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1462,25 +1460,18 @@ def test_lookup_study( state=study.Study.State.ACTIVE, inactive_reason="inactive_reason_value", ) - response = client.lookup_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.LookupStudyRequest() # Establish that the response is the type that we expect. - assert isinstance(response, study.Study) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == study.Study.State.ACTIVE - assert response.inactive_reason == "inactive_reason_value" @@ -1492,7 +1483,7 @@ def test_lookup_study_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1500,7 +1491,6 @@ def test_lookup_study_empty_call(): client.lookup_study() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.LookupStudyRequest() @@ -1509,7 +1499,7 @@ async def test_lookup_study_async( transport: str = "grpc_asyncio", request_type=vizier_service.LookupStudyRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1527,24 +1517,18 @@ async def test_lookup_study_async( inactive_reason="inactive_reason_value", ) ) - response = await client.lookup_study(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.LookupStudyRequest() # Establish that the response is the type that we expect. assert isinstance(response, study.Study) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.state == study.Study.State.ACTIVE - assert response.inactive_reason == "inactive_reason_value" @@ -1554,17 +1538,17 @@ async def test_lookup_study_async_from_dict(): def test_lookup_study_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.LookupStudyRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: call.return_value = study.Study() - client.lookup_study(request) # Establish that the underlying gRPC stub method was called. @@ -1579,17 +1563,19 @@ def test_lookup_study_field_headers(): @pytest.mark.asyncio async def test_lookup_study_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.LookupStudyRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Study()) - await client.lookup_study(request) # Establish that the underlying gRPC stub method was called. @@ -1603,13 +1589,12 @@ async def test_lookup_study_field_headers_async(): def test_lookup_study_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = study.Study() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.lookup_study(parent="parent_value",) @@ -1618,12 +1603,11 @@ def test_lookup_study_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_lookup_study_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1635,7 +1619,9 @@ def test_lookup_study_flattened_error(): @pytest.mark.asyncio async def test_lookup_study_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lookup_study), "__call__") as call: @@ -1651,13 +1637,14 @@ async def test_lookup_study_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_lookup_study_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1671,7 +1658,7 @@ def test_suggest_trials( transport: str = "grpc", request_type=vizier_service.SuggestTrialsRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1682,13 +1669,11 @@ def test_suggest_trials( with mock.patch.object(type(client.transport.suggest_trials), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.suggest_trials(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.SuggestTrialsRequest() # Establish that the response is the type that we expect. @@ -1703,7 +1688,7 @@ def test_suggest_trials_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1711,7 +1696,6 @@ def test_suggest_trials_empty_call(): client.suggest_trials() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.SuggestTrialsRequest() @@ -1720,7 +1704,7 @@ async def test_suggest_trials_async( transport: str = "grpc_asyncio", request_type=vizier_service.SuggestTrialsRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1733,13 +1717,11 @@ async def test_suggest_trials_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.suggest_trials(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.SuggestTrialsRequest() # Establish that the response is the type that we expect. @@ -1752,17 +1734,17 @@ async def test_suggest_trials_async_from_dict(): def test_suggest_trials_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.SuggestTrialsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.suggest_trials), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.suggest_trials(request) # Establish that the underlying gRPC stub method was called. @@ -1777,11 +1759,14 @@ def test_suggest_trials_field_headers(): @pytest.mark.asyncio async def test_suggest_trials_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.SuggestTrialsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1789,7 +1774,6 @@ async def test_suggest_trials_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.suggest_trials(request) # Establish that the underlying gRPC stub method was called. @@ -1806,7 +1790,7 @@ def test_create_trial( transport: str = "grpc", request_type=vizier_service.CreateTrialRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1824,29 +1808,20 @@ def test_create_trial( infeasible_reason="infeasible_reason_value", custom_job="custom_job_value", ) - response = client.create_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CreateTrialRequest() # Establish that the response is the type that we expect. - assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -1858,7 +1833,7 @@ def test_create_trial_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1866,7 +1841,6 @@ def test_create_trial_empty_call(): client.create_trial() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CreateTrialRequest() @@ -1875,7 +1849,7 @@ async def test_create_trial_async( transport: str = "grpc_asyncio", request_type=vizier_service.CreateTrialRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1895,28 +1869,20 @@ async def test_create_trial_async( custom_job="custom_job_value", ) ) - response = await client.create_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CreateTrialRequest() # Establish that the response is the type that we expect. assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -1926,17 +1892,17 @@ async def test_create_trial_async_from_dict(): def test_create_trial_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CreateTrialRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_trial), "__call__") as call: call.return_value = study.Trial() - client.create_trial(request) # Establish that the underlying gRPC stub method was called. @@ -1951,17 +1917,19 @@ def test_create_trial_field_headers(): @pytest.mark.asyncio async def test_create_trial_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CreateTrialRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_trial), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) - await client.create_trial(request) # Establish that the underlying gRPC stub method was called. @@ -1975,13 +1943,12 @@ async def test_create_trial_field_headers_async(): def test_create_trial_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_trial), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = study.Trial() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_trial( @@ -1992,14 +1959,12 @@ def test_create_trial_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].trial == study.Trial(name="name_value") def test_create_trial_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2013,7 +1978,9 @@ def test_create_trial_flattened_error(): @pytest.mark.asyncio async def test_create_trial_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_trial), "__call__") as call: @@ -2031,15 +1998,15 @@ async def test_create_trial_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].trial == study.Trial(name="name_value") @pytest.mark.asyncio async def test_create_trial_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2055,7 +2022,7 @@ def test_get_trial( transport: str = "grpc", request_type=vizier_service.GetTrialRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2073,29 +2040,20 @@ def test_get_trial( infeasible_reason="infeasible_reason_value", custom_job="custom_job_value", ) - response = client.get_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.GetTrialRequest() # Establish that the response is the type that we expect. - assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -2107,7 +2065,7 @@ def test_get_trial_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2115,7 +2073,6 @@ def test_get_trial_empty_call(): client.get_trial() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.GetTrialRequest() @@ -2124,7 +2081,7 @@ async def test_get_trial_async( transport: str = "grpc_asyncio", request_type=vizier_service.GetTrialRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2144,28 +2101,20 @@ async def test_get_trial_async( custom_job="custom_job_value", ) ) - response = await client.get_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.GetTrialRequest() # Establish that the response is the type that we expect. assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -2175,17 +2124,17 @@ async def test_get_trial_async_from_dict(): def test_get_trial_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.GetTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_trial), "__call__") as call: call.return_value = study.Trial() - client.get_trial(request) # Establish that the underlying gRPC stub method was called. @@ -2200,17 +2149,19 @@ def test_get_trial_field_headers(): @pytest.mark.asyncio async def test_get_trial_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.GetTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_trial), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) - await client.get_trial(request) # Establish that the underlying gRPC stub method was called. @@ -2224,13 +2175,12 @@ async def test_get_trial_field_headers_async(): def test_get_trial_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_trial), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = study.Trial() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_trial(name="name_value",) @@ -2239,12 +2189,11 @@ def test_get_trial_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_trial_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2256,7 +2205,9 @@ def test_get_trial_flattened_error(): @pytest.mark.asyncio async def test_get_trial_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_trial), "__call__") as call: @@ -2272,13 +2223,14 @@ async def test_get_trial_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_trial_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2292,7 +2244,7 @@ def test_list_trials( transport: str = "grpc", request_type=vizier_service.ListTrialsRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2305,19 +2257,15 @@ def test_list_trials( call.return_value = vizier_service.ListTrialsResponse( next_page_token="next_page_token_value", ) - response = client.list_trials(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListTrialsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListTrialsPager) - assert response.next_page_token == "next_page_token_value" @@ -2329,7 +2277,7 @@ def test_list_trials_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2337,7 +2285,6 @@ def test_list_trials_empty_call(): client.list_trials() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListTrialsRequest() @@ -2346,7 +2293,7 @@ async def test_list_trials_async( transport: str = "grpc_asyncio", request_type=vizier_service.ListTrialsRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2359,18 +2306,15 @@ async def test_list_trials_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( vizier_service.ListTrialsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_trials(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListTrialsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTrialsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2380,17 +2324,17 @@ async def test_list_trials_async_from_dict(): def test_list_trials_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.ListTrialsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_trials), "__call__") as call: call.return_value = vizier_service.ListTrialsResponse() - client.list_trials(request) # Establish that the underlying gRPC stub method was called. @@ -2405,11 +2349,14 @@ def test_list_trials_field_headers(): @pytest.mark.asyncio async def test_list_trials_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.ListTrialsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2417,7 +2364,6 @@ async def test_list_trials_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( vizier_service.ListTrialsResponse() ) - await client.list_trials(request) # Establish that the underlying gRPC stub method was called. @@ -2431,13 +2377,12 @@ async def test_list_trials_field_headers_async(): def test_list_trials_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_trials), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = vizier_service.ListTrialsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_trials(parent="parent_value",) @@ -2446,12 +2391,11 @@ def test_list_trials_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_trials_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2463,7 +2407,9 @@ def test_list_trials_flattened_error(): @pytest.mark.asyncio async def test_list_trials_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_trials), "__call__") as call: @@ -2481,13 +2427,14 @@ async def test_list_trials_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_trials_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2498,7 +2445,7 @@ async def test_list_trials_flattened_error_async(): def test_list_trials_pager(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_trials), "__call__") as call: @@ -2530,7 +2477,7 @@ def test_list_trials_pager(): def test_list_trials_pages(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_trials), "__call__") as call: @@ -2554,7 +2501,7 @@ def test_list_trials_pages(): @pytest.mark.asyncio async def test_list_trials_async_pager(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2585,7 +2532,7 @@ async def test_list_trials_async_pager(): @pytest.mark.asyncio async def test_list_trials_async_pages(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = VizierServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2615,7 +2562,7 @@ def test_add_trial_measurement( transport: str = "grpc", request_type=vizier_service.AddTrialMeasurementRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2635,29 +2582,20 @@ def test_add_trial_measurement( infeasible_reason="infeasible_reason_value", custom_job="custom_job_value", ) - response = client.add_trial_measurement(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.AddTrialMeasurementRequest() # Establish that the response is the type that we expect. - assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -2669,7 +2607,7 @@ def test_add_trial_measurement_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2679,7 +2617,6 @@ def test_add_trial_measurement_empty_call(): client.add_trial_measurement() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.AddTrialMeasurementRequest() @@ -2689,7 +2626,7 @@ async def test_add_trial_measurement_async( request_type=vizier_service.AddTrialMeasurementRequest, ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2711,28 +2648,20 @@ async def test_add_trial_measurement_async( custom_job="custom_job_value", ) ) - response = await client.add_trial_measurement(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.AddTrialMeasurementRequest() # Establish that the response is the type that we expect. assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -2742,11 +2671,12 @@ async def test_add_trial_measurement_async_from_dict(): def test_add_trial_measurement_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.AddTrialMeasurementRequest() + request.trial_name = "trial_name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2754,7 +2684,6 @@ def test_add_trial_measurement_field_headers(): type(client.transport.add_trial_measurement), "__call__" ) as call: call.return_value = study.Trial() - client.add_trial_measurement(request) # Establish that the underlying gRPC stub method was called. @@ -2769,11 +2698,14 @@ def test_add_trial_measurement_field_headers(): @pytest.mark.asyncio async def test_add_trial_measurement_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.AddTrialMeasurementRequest() + request.trial_name = "trial_name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2781,7 +2713,6 @@ async def test_add_trial_measurement_field_headers_async(): type(client.transport.add_trial_measurement), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) - await client.add_trial_measurement(request) # Establish that the underlying gRPC stub method was called. @@ -2798,7 +2729,7 @@ def test_complete_trial( transport: str = "grpc", request_type=vizier_service.CompleteTrialRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2816,29 +2747,20 @@ def test_complete_trial( infeasible_reason="infeasible_reason_value", custom_job="custom_job_value", ) - response = client.complete_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CompleteTrialRequest() # Establish that the response is the type that we expect. - assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -2850,7 +2772,7 @@ def test_complete_trial_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2858,7 +2780,6 @@ def test_complete_trial_empty_call(): client.complete_trial() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CompleteTrialRequest() @@ -2867,7 +2788,7 @@ async def test_complete_trial_async( transport: str = "grpc_asyncio", request_type=vizier_service.CompleteTrialRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2887,28 +2808,20 @@ async def test_complete_trial_async( custom_job="custom_job_value", ) ) - response = await client.complete_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CompleteTrialRequest() # Establish that the response is the type that we expect. assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -2918,17 +2831,17 @@ async def test_complete_trial_async_from_dict(): def test_complete_trial_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CompleteTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.complete_trial), "__call__") as call: call.return_value = study.Trial() - client.complete_trial(request) # Establish that the underlying gRPC stub method was called. @@ -2943,17 +2856,19 @@ def test_complete_trial_field_headers(): @pytest.mark.asyncio async def test_complete_trial_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CompleteTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.complete_trial), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) - await client.complete_trial(request) # Establish that the underlying gRPC stub method was called. @@ -2970,7 +2885,7 @@ def test_delete_trial( transport: str = "grpc", request_type=vizier_service.DeleteTrialRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2981,13 +2896,11 @@ def test_delete_trial( with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.DeleteTrialRequest() # Establish that the response is the type that we expect. @@ -3002,7 +2915,7 @@ def test_delete_trial_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3010,7 +2923,6 @@ def test_delete_trial_empty_call(): client.delete_trial() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.DeleteTrialRequest() @@ -3019,7 +2931,7 @@ async def test_delete_trial_async( transport: str = "grpc_asyncio", request_type=vizier_service.DeleteTrialRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3030,13 +2942,11 @@ async def test_delete_trial_async( with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.DeleteTrialRequest() # Establish that the response is the type that we expect. @@ -3049,17 +2959,17 @@ async def test_delete_trial_async_from_dict(): def test_delete_trial_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.DeleteTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: call.return_value = None - client.delete_trial(request) # Establish that the underlying gRPC stub method was called. @@ -3074,17 +2984,19 @@ def test_delete_trial_field_headers(): @pytest.mark.asyncio async def test_delete_trial_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.DeleteTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_trial(request) # Establish that the underlying gRPC stub method was called. @@ -3098,13 +3010,12 @@ async def test_delete_trial_field_headers_async(): def test_delete_trial_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_trial(name="name_value",) @@ -3113,12 +3024,11 @@ def test_delete_trial_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_trial_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3130,7 +3040,9 @@ def test_delete_trial_flattened_error(): @pytest.mark.asyncio async def test_delete_trial_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_trial), "__call__") as call: @@ -3146,13 +3058,14 @@ async def test_delete_trial_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_trial_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3167,7 +3080,7 @@ def test_check_trial_early_stopping_state( request_type=vizier_service.CheckTrialEarlyStoppingStateRequest, ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3180,13 +3093,11 @@ def test_check_trial_early_stopping_state( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.check_trial_early_stopping_state(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CheckTrialEarlyStoppingStateRequest() # Establish that the response is the type that we expect. @@ -3201,7 +3112,7 @@ def test_check_trial_early_stopping_state_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3211,7 +3122,6 @@ def test_check_trial_early_stopping_state_empty_call(): client.check_trial_early_stopping_state() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CheckTrialEarlyStoppingStateRequest() @@ -3221,7 +3131,7 @@ async def test_check_trial_early_stopping_state_async( request_type=vizier_service.CheckTrialEarlyStoppingStateRequest, ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3236,13 +3146,11 @@ async def test_check_trial_early_stopping_state_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.check_trial_early_stopping_state(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.CheckTrialEarlyStoppingStateRequest() # Establish that the response is the type that we expect. @@ -3255,11 +3163,12 @@ async def test_check_trial_early_stopping_state_async_from_dict(): def test_check_trial_early_stopping_state_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CheckTrialEarlyStoppingStateRequest() + request.trial_name = "trial_name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3267,7 +3176,6 @@ def test_check_trial_early_stopping_state_field_headers(): type(client.transport.check_trial_early_stopping_state), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.check_trial_early_stopping_state(request) # Establish that the underlying gRPC stub method was called. @@ -3282,11 +3190,14 @@ def test_check_trial_early_stopping_state_field_headers(): @pytest.mark.asyncio async def test_check_trial_early_stopping_state_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.CheckTrialEarlyStoppingStateRequest() + request.trial_name = "trial_name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3296,7 +3207,6 @@ async def test_check_trial_early_stopping_state_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.check_trial_early_stopping_state(request) # Establish that the underlying gRPC stub method was called. @@ -3313,7 +3223,7 @@ def test_stop_trial( transport: str = "grpc", request_type=vizier_service.StopTrialRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3331,29 +3241,20 @@ def test_stop_trial( infeasible_reason="infeasible_reason_value", custom_job="custom_job_value", ) - response = client.stop_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.StopTrialRequest() # Establish that the response is the type that we expect. - assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -3365,7 +3266,7 @@ def test_stop_trial_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3373,7 +3274,6 @@ def test_stop_trial_empty_call(): client.stop_trial() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.StopTrialRequest() @@ -3382,7 +3282,7 @@ async def test_stop_trial_async( transport: str = "grpc_asyncio", request_type=vizier_service.StopTrialRequest ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3402,28 +3302,20 @@ async def test_stop_trial_async( custom_job="custom_job_value", ) ) - response = await client.stop_trial(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.StopTrialRequest() # Establish that the response is the type that we expect. assert isinstance(response, study.Trial) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.state == study.Trial.State.REQUESTED - assert response.client_id == "client_id_value" - assert response.infeasible_reason == "infeasible_reason_value" - assert response.custom_job == "custom_job_value" @@ -3433,17 +3325,17 @@ async def test_stop_trial_async_from_dict(): def test_stop_trial_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.StopTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.stop_trial), "__call__") as call: call.return_value = study.Trial() - client.stop_trial(request) # Establish that the underlying gRPC stub method was called. @@ -3458,17 +3350,19 @@ def test_stop_trial_field_headers(): @pytest.mark.asyncio async def test_stop_trial_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.StopTrialRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.stop_trial), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(study.Trial()) - await client.stop_trial(request) # Establish that the underlying gRPC stub method was called. @@ -3485,7 +3379,7 @@ def test_list_optimal_trials( transport: str = "grpc", request_type=vizier_service.ListOptimalTrialsRequest ): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3498,17 +3392,14 @@ def test_list_optimal_trials( ) as call: # Designate an appropriate return value for the call. call.return_value = vizier_service.ListOptimalTrialsResponse() - response = client.list_optimal_trials(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListOptimalTrialsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, vizier_service.ListOptimalTrialsResponse) @@ -3520,7 +3411,7 @@ def test_list_optimal_trials_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3530,7 +3421,6 @@ def test_list_optimal_trials_empty_call(): client.list_optimal_trials() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListOptimalTrialsRequest() @@ -3540,7 +3430,7 @@ async def test_list_optimal_trials_async( request_type=vizier_service.ListOptimalTrialsRequest, ): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3555,13 +3445,11 @@ async def test_list_optimal_trials_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( vizier_service.ListOptimalTrialsResponse() ) - response = await client.list_optimal_trials(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == vizier_service.ListOptimalTrialsRequest() # Establish that the response is the type that we expect. @@ -3574,11 +3462,12 @@ async def test_list_optimal_trials_async_from_dict(): def test_list_optimal_trials_field_headers(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.ListOptimalTrialsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3586,7 +3475,6 @@ def test_list_optimal_trials_field_headers(): type(client.transport.list_optimal_trials), "__call__" ) as call: call.return_value = vizier_service.ListOptimalTrialsResponse() - client.list_optimal_trials(request) # Establish that the underlying gRPC stub method was called. @@ -3601,11 +3489,14 @@ def test_list_optimal_trials_field_headers(): @pytest.mark.asyncio async def test_list_optimal_trials_field_headers_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = vizier_service.ListOptimalTrialsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3615,7 +3506,6 @@ async def test_list_optimal_trials_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( vizier_service.ListOptimalTrialsResponse() ) - await client.list_optimal_trials(request) # Establish that the underlying gRPC stub method was called. @@ -3629,7 +3519,7 @@ async def test_list_optimal_trials_field_headers_async(): def test_list_optimal_trials_flattened(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3637,7 +3527,6 @@ def test_list_optimal_trials_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = vizier_service.ListOptimalTrialsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_optimal_trials(parent="parent_value",) @@ -3646,12 +3535,11 @@ def test_list_optimal_trials_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_optimal_trials_flattened_error(): - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3663,7 +3551,9 @@ def test_list_optimal_trials_flattened_error(): @pytest.mark.asyncio async def test_list_optimal_trials_flattened_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3683,13 +3573,14 @@ async def test_list_optimal_trials_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_optimal_trials_flattened_error_async(): - client = VizierServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3702,16 +3593,16 @@ async def test_list_optimal_trials_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.VizierServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.VizierServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = VizierServiceClient( @@ -3721,7 +3612,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.VizierServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = VizierServiceClient( @@ -3732,7 +3623,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.VizierServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = VizierServiceClient(transport=transport) assert client.transport is transport @@ -3741,13 +3632,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.VizierServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.VizierServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3762,23 +3653,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = VizierServiceClient(credentials=credentials.AnonymousCredentials(),) + client = VizierServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.VizierServiceGrpcTransport,) def test_vizier_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.VizierServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3790,7 +3681,7 @@ def test_vizier_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.VizierServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3822,15 +3713,37 @@ def test_vizier_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_vizier_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.aiplatform_v1beta1.services.vizier_service.transports.VizierServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.VizierServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_vizier_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.aiplatform_v1beta1.services.vizier_service.transports.VizierServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.VizierServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3843,19 +3756,33 @@ def test_vizier_service_base_transport_with_credentials_file(): def test_vizier_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.aiplatform_v1beta1.services.vizier_service.transports.VizierServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.VizierServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_vizier_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + VizierServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_vizier_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) VizierServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3863,20 +3790,156 @@ def test_vizier_service_auth_adc(): ) -def test_vizier_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_vizier_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.VizierServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.VizierServiceGrpcTransport, + transports.VizierServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_vizier_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.VizierServiceGrpcTransport, grpc_helpers), + (transports.VizierServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_vizier_service_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="aiplatform.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.VizierServiceGrpcTransport, grpc_helpers), + (transports.VizierServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_vizier_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.VizierServiceGrpcTransport, grpc_helpers), + (transports.VizierServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_vizier_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "aiplatform.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -3885,7 +3948,7 @@ def test_vizier_service_transport_auth_adc(): ], ) def test_vizier_service_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3924,7 +3987,7 @@ def test_vizier_service_grpc_transport_client_cert_source_for_mtls(transport_cla def test_vizier_service_host_no_port(): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com" ), @@ -3934,7 +3997,7 @@ def test_vizier_service_host_no_port(): def test_vizier_service_host_with_port(): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="aiplatform.googleapis.com:8000" ), @@ -3988,9 +4051,9 @@ def test_vizier_service_transport_channel_mtls_with_client_cert_source(transport mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -4066,7 +4129,7 @@ def test_vizier_service_transport_channel_mtls_with_adc(transport_class): def test_vizier_service_grpc_lro_client(): client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -4079,7 +4142,7 @@ def test_vizier_service_grpc_lro_client(): def test_vizier_service_grpc_lro_async_client(): client = VizierServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -4094,7 +4157,6 @@ def test_custom_job_path(): project = "squid" location = "clam" custom_job = "whelk" - expected = "projects/{project}/locations/{location}/customJobs/{custom_job}".format( project=project, location=location, custom_job=custom_job, ) @@ -4119,7 +4181,6 @@ def test_study_path(): project = "cuttlefish" location = "mussel" study = "winkle" - expected = "projects/{project}/locations/{location}/studies/{study}".format( project=project, location=location, study=study, ) @@ -4145,7 +4206,6 @@ def test_trial_path(): location = "clam" study = "whelk" trial = "octopus" - expected = "projects/{project}/locations/{location}/studies/{study}/trials/{trial}".format( project=project, location=location, study=study, trial=trial, ) @@ -4169,7 +4229,6 @@ def test_parse_trial_path(): def test_common_billing_account_path(): billing_account = "winkle" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4190,7 +4249,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) actual = VizierServiceClient.common_folder_path(folder) assert expected == actual @@ -4209,7 +4267,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) actual = VizierServiceClient.common_organization_path(organization) assert expected == actual @@ -4228,7 +4285,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) actual = VizierServiceClient.common_project_path(project) assert expected == actual @@ -4248,7 +4304,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "oyster" location = "nudibranch" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -4275,7 +4330,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.VizierServiceTransport, "_prep_wrapped_messages" ) as prep: client = VizierServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4284,6 +4339,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = VizierServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)