From 6c435d9b09cd496309ccb311ced28788500746aa Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 26 Nov 2022 07:51:29 -0500 Subject: [PATCH] chore: Update gapic-generator-python to v1.6.1 (#196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: update to gapic-generator-python 1.5.0 feat: add support for `google.cloud..__version__` PiperOrigin-RevId: 484665853 Source-Link: https://github.com/googleapis/googleapis/commit/8eb249a19db926c2fbc4ecf1dc09c0e521a88b22 Source-Link: https://github.com/googleapis/googleapis-gen/commit/c8aa327b5f478865fc3fd91e3c2768e54e26ad44 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzhhYTMyN2I1ZjQ3ODg2NWZjM2ZkOTFlM2MyNzY4ZTU0ZTI2YWQ0NCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update version in gapic_version.py * add .release-please-manifest.json with correct version * add owlbot.py to exclude generated gapic_version.py * set manifest to true in .github/release-please.yml * add release-please-config.json * chore: Update to gapic-generator-python 1.6.0 feat(python): Add typing to proto.Message based class attributes feat(python): Snippetgen handling of repeated enum field PiperOrigin-RevId: 487326846 Source-Link: https://github.com/googleapis/googleapis/commit/da380c77bb87ba0f752baf07605dd1db30e1f7e1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/61ef5762ee6731a0cbbfea22fd0eecee51ab1c8e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNjFlZjU3NjJlZTY3MzFhMGNiYmZlYTIyZmQwZWVjZWU1MWFiMWM4ZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: new APIs added to reflect updates to the filestore service - Add ENTERPRISE Tier - Add snapshot APIs: RevertInstance, ListSnapshots, CreateSnapshot, DeleteSnapshot, UpdateSnapshot - Add multi-share APIs: ListShares, GetShare, CreateShare, DeleteShare, UpdateShare - Add ConnectMode to NetworkConfig (for Private Service Access support) - New status codes (SUSPENDED/SUSPENDING, REVERTING/RESUMING) - Add SuspensionReason (for KMS related suspension) - Add new fields to Instance information: max_capacity_gb, capacity_step_size_gb, max_share_count, capacity_gb, multi_share_enabled PiperOrigin-RevId: 487492758 Source-Link: https://github.com/googleapis/googleapis/commit/5be5981f50322cf0c7388595e0f31ac5d0693469 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ab0e217f560cc2c1afc11441c2eab6b6950efd2b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWIwZTIxN2Y1NjBjYzJjMWFmYzExNDQxYzJlYWI2YjY5NTBlZmQyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update path to snippet metadata json * chore: Update gapic-generator-python to v1.6.1 PiperOrigin-RevId: 488036204 Source-Link: https://github.com/googleapis/googleapis/commit/08f275f5c1c0d99056e1cb68376323414459ee19 Source-Link: https://github.com/googleapis/googleapis-gen/commit/555c0945e60649e38739ae64bc45719cdf72178f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTU1YzA5NDVlNjA2NDllMzg3MzlhZTY0YmM0NTcxOWNkZjcyMTc4ZiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .../.github/release-please.yml | 1 + .../.release-please-manifest.json | 3 + .../google-cloud-tpu/docs/tpu_v1/types.rst | 1 - .../docs/tpu_v2alpha1/types.rst | 1 - .../google/cloud/tpu/__init__.py | 4 + .../google/cloud/tpu/gapic_version.py | 16 ++ .../google/cloud/tpu_v1/__init__.py | 4 + .../cloud/tpu_v1/services/tpu/async_client.py | 102 ++++---- .../cloud/tpu_v1/services/tpu/client.py | 86 ++++--- .../tpu_v1/services/tpu/transports/base.py | 2 +- .../tpu_v1/services/tpu/transports/grpc.py | 20 +- .../services/tpu/transports/grpc_asyncio.py | 16 +- .../google/cloud/tpu_v1/types/cloud_tpu.py | 162 ++++++------- .../google/cloud/tpu_v2alpha1/__init__.py | 4 + .../tpu_v2alpha1/services/tpu/async_client.py | 118 ++++----- .../cloud/tpu_v2alpha1/services/tpu/client.py | 98 ++++---- .../services/tpu/transports/base.py | 2 +- .../services/tpu/transports/grpc.py | 20 +- .../services/tpu/transports/grpc_asyncio.py | 16 +- .../cloud/tpu_v2alpha1/types/cloud_tpu.py | 226 +++++++++--------- packages/google-cloud-tpu/owlbot.py | 56 +++++ .../release-please-config.json | 28 +++ ...snippet_metadata_google.cloud.tpu.v1.json} | 3 +- ...t_metadata_google.cloud.tpu.v2alpha1.json} | 3 +- packages/google-cloud-tpu/setup.py | 33 ++- .../testing/constraints-3.10.txt | 6 + .../testing/constraints-3.11.txt | 6 + .../testing/constraints-3.7.txt | 2 +- .../testing/constraints-3.8.txt | 6 + .../testing/constraints-3.9.txt | 6 + 30 files changed, 625 insertions(+), 426 deletions(-) create mode 100644 packages/google-cloud-tpu/.release-please-manifest.json create mode 100644 packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py create mode 100644 packages/google-cloud-tpu/owlbot.py create mode 100644 packages/google-cloud-tpu/release-please-config.json rename packages/google-cloud-tpu/samples/generated_samples/{snippet_metadata_tpu_v1.json => snippet_metadata_google.cloud.tpu.v1.json} (99%) rename packages/google-cloud-tpu/samples/generated_samples/{snippet_metadata_tpu_v2alpha1.json => snippet_metadata_google.cloud.tpu.v2alpha1.json} (99%) diff --git a/packages/google-cloud-tpu/.github/release-please.yml b/packages/google-cloud-tpu/.github/release-please.yml index 6def37a84c98..e9a4f0085128 100644 --- a/packages/google-cloud-tpu/.github/release-please.yml +++ b/packages/google-cloud-tpu/.github/release-please.yml @@ -1,5 +1,6 @@ releaseType: python handleGHRelease: true +manifest: true # NOTE: this section is generated by synthtool.languages.python # See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py branches: diff --git a/packages/google-cloud-tpu/.release-please-manifest.json b/packages/google-cloud-tpu/.release-please-manifest.json new file mode 100644 index 000000000000..453ca4c5d474 --- /dev/null +++ b/packages/google-cloud-tpu/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.5.2" +} diff --git a/packages/google-cloud-tpu/docs/tpu_v1/types.rst b/packages/google-cloud-tpu/docs/tpu_v1/types.rst index bd1c09a45c97..a79d42c3e3e3 100644 --- a/packages/google-cloud-tpu/docs/tpu_v1/types.rst +++ b/packages/google-cloud-tpu/docs/tpu_v1/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Tpu v1 API .. automodule:: google.cloud.tpu_v1.types :members: - :undoc-members: :show-inheritance: diff --git a/packages/google-cloud-tpu/docs/tpu_v2alpha1/types.rst b/packages/google-cloud-tpu/docs/tpu_v2alpha1/types.rst index 6c1d0f3ee83f..afd9d0b952cd 100644 --- a/packages/google-cloud-tpu/docs/tpu_v2alpha1/types.rst +++ b/packages/google-cloud-tpu/docs/tpu_v2alpha1/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Tpu v2alpha1 API .. automodule:: google.cloud.tpu_v2alpha1.types :members: - :undoc-members: :show-inheritance: diff --git a/packages/google-cloud-tpu/google/cloud/tpu/__init__.py b/packages/google-cloud-tpu/google/cloud/tpu/__init__.py index f9d6f9d6d22c..f15a718dfdd4 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu/__init__.py +++ b/packages/google-cloud-tpu/google/cloud/tpu/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.tpu import gapic_version as package_version + +__version__ = package_version.__version__ + from google.cloud.tpu_v1.services.tpu.async_client import TpuAsyncClient from google.cloud.tpu_v1.services.tpu.client import TpuClient diff --git a/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py new file mode 100644 index 000000000000..9bb24ba52e7d --- /dev/null +++ b/packages/google-cloud-tpu/google/cloud/tpu/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 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. +# +__version__ = "1.5.2" # {x-release-please-version} diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/__init__.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/__init__.py index 6b16da9d0d25..4a7d36b024c9 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/__init__.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.tpu import gapic_version as package_version + +__version__ = package_version.__version__ + from .services.tpu import TpuAsyncClient, TpuClient from .types.cloud_tpu import ( diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py index c185e76b7175..529fc03e1d87 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py @@ -16,7 +16,17 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 @@ -161,9 +171,9 @@ def transport(self) -> TpuTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, TpuTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the tpu client. @@ -207,11 +217,11 @@ def __init__( async def list_nodes( self, - request: Union[cloud_tpu.ListNodesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNodesAsyncPager: r"""Lists nodes. @@ -244,7 +254,7 @@ async def sample_list_nodes(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.ListNodesRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.ListNodesRequest, dict]]): The request object. Request for [ListNodes][google.cloud.tpu.v1.Tpu.ListNodes]. parent (:class:`str`): @@ -320,11 +330,11 @@ async def sample_list_nodes(): async def get_node( self, - request: Union[cloud_tpu.GetNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -356,7 +366,7 @@ async def sample_get_node(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.GetNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.GetNodeRequest, dict]]): The request object. Request for [GetNode][google.cloud.tpu.v1.Tpu.GetNode]. name (:class:`str`): @@ -418,13 +428,13 @@ async def sample_get_node(): async def create_node( self, - request: Union[cloud_tpu.CreateNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.CreateNodeRequest, dict]] = None, *, - parent: str = None, - node: cloud_tpu.Node = None, - node_id: str = None, + parent: Optional[str] = None, + node: Optional[cloud_tpu.Node] = None, + node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Creates a node. @@ -465,7 +475,7 @@ async def sample_create_node(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.CreateNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.CreateNodeRequest, dict]]): The request object. Request for [CreateNode][google.cloud.tpu.v1.Tpu.CreateNode]. parent (:class:`str`): @@ -553,11 +563,11 @@ async def sample_create_node(): async def delete_node( self, - request: Union[cloud_tpu.DeleteNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.DeleteNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a node. @@ -593,7 +603,7 @@ async def sample_delete_node(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.DeleteNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.DeleteNodeRequest, dict]]): The request object. Request for [DeleteNode][google.cloud.tpu.v1.Tpu.DeleteNode]. name (:class:`str`): @@ -667,10 +677,10 @@ async def sample_delete_node(): async def reimage_node( self, - request: Union[cloud_tpu.ReimageNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.ReimageNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Reimages a node's OS. @@ -705,7 +715,7 @@ async def sample_reimage_node(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.ReimageNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.ReimageNodeRequest, dict]]): The request object. Request for [ReimageNode][google.cloud.tpu.v1.Tpu.ReimageNode]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -760,10 +770,10 @@ async def sample_reimage_node(): async def stop_node( self, - request: Union[cloud_tpu.StopNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StopNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Stops a node. @@ -798,7 +808,7 @@ async def sample_stop_node(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.StopNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.StopNodeRequest, dict]]): The request object. Request for [StopNode][google.cloud.tpu.v1.Tpu.StopNode]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -853,10 +863,10 @@ async def sample_stop_node(): async def start_node( self, - request: Union[cloud_tpu.StartNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StartNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Starts a node. @@ -891,7 +901,7 @@ async def sample_start_node(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.StartNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.StartNodeRequest, dict]]): The request object. Request for [StartNode][google.cloud.tpu.v1.Tpu.StartNode]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -946,11 +956,11 @@ async def sample_start_node(): async def list_tensor_flow_versions( self, - request: Union[cloud_tpu.ListTensorFlowVersionsRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListTensorFlowVersionsRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTensorFlowVersionsAsyncPager: r"""List TensorFlow versions supported by this API. @@ -983,7 +993,7 @@ async def sample_list_tensor_flow_versions(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.ListTensorFlowVersionsRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.ListTensorFlowVersionsRequest, dict]]): The request object. Request for [ListTensorFlowVersions][google.cloud.tpu.v1.Tpu.ListTensorFlowVersions]. parent (:class:`str`): @@ -1059,11 +1069,11 @@ async def sample_list_tensor_flow_versions(): async def get_tensor_flow_version( self, - request: Union[cloud_tpu.GetTensorFlowVersionRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetTensorFlowVersionRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.TensorFlowVersion: r"""Gets TensorFlow Version. @@ -1095,7 +1105,7 @@ async def sample_get_tensor_flow_version(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.GetTensorFlowVersionRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.GetTensorFlowVersionRequest, dict]]): The request object. Request for [GetTensorFlowVersion][google.cloud.tpu.v1.Tpu.GetTensorFlowVersion]. name (:class:`str`): @@ -1159,11 +1169,11 @@ async def sample_get_tensor_flow_version(): async def list_accelerator_types( self, - request: Union[cloud_tpu.ListAcceleratorTypesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListAcceleratorTypesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1196,7 +1206,7 @@ async def sample_list_accelerator_types(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.ListAcceleratorTypesRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.ListAcceleratorTypesRequest, dict]]): The request object. Request for [ListAcceleratorTypes][google.cloud.tpu.v1.Tpu.ListAcceleratorTypes]. parent (:class:`str`): @@ -1272,11 +1282,11 @@ async def sample_list_accelerator_types(): async def get_accelerator_type( self, - request: Union[cloud_tpu.GetAcceleratorTypeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetAcceleratorTypeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1308,7 +1318,7 @@ async def sample_get_accelerator_type(): print(response) Args: - request (Union[google.cloud.tpu_v1.types.GetAcceleratorTypeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v1.types.GetAcceleratorTypeRequest, dict]]): The request object. Request for [GetAcceleratorType][google.cloud.tpu.v1.Tpu.GetAcceleratorType]. name (:class:`str`): diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py index a68642fc85a6..d0ae37a03975 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/client.py @@ -16,7 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -60,7 +71,7 @@ class TpuClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[TpuTransport]: """Returns an appropriate transport class. @@ -381,8 +392,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, TpuTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, TpuTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the tpu client. @@ -396,7 +407,7 @@ def __init__( transport (Union[str, TpuTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -426,6 +437,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -478,11 +490,11 @@ def __init__( def list_nodes( self, - request: Union[cloud_tpu.ListNodesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNodesPager: r"""Lists nodes. @@ -591,11 +603,11 @@ def sample_list_nodes(): def get_node( self, - request: Union[cloud_tpu.GetNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -689,13 +701,13 @@ def sample_get_node(): def create_node( self, - request: Union[cloud_tpu.CreateNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.CreateNodeRequest, dict]] = None, *, - parent: str = None, - node: cloud_tpu.Node = None, - node_id: str = None, + parent: Optional[str] = None, + node: Optional[cloud_tpu.Node] = None, + node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a node. @@ -824,11 +836,11 @@ def sample_create_node(): def delete_node( self, - request: Union[cloud_tpu.DeleteNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.DeleteNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes a node. @@ -938,10 +950,10 @@ def sample_delete_node(): def reimage_node( self, - request: Union[cloud_tpu.ReimageNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.ReimageNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Reimages a node's OS. @@ -1032,10 +1044,10 @@ def sample_reimage_node(): def stop_node( self, - request: Union[cloud_tpu.StopNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StopNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Stops a node. @@ -1126,10 +1138,10 @@ def sample_stop_node(): def start_node( self, - request: Union[cloud_tpu.StartNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StartNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Starts a node. @@ -1220,11 +1232,11 @@ def sample_start_node(): def list_tensor_flow_versions( self, - request: Union[cloud_tpu.ListTensorFlowVersionsRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListTensorFlowVersionsRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTensorFlowVersionsPager: r"""List TensorFlow versions supported by this API. @@ -1335,11 +1347,11 @@ def sample_list_tensor_flow_versions(): def get_tensor_flow_version( self, - request: Union[cloud_tpu.GetTensorFlowVersionRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetTensorFlowVersionRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.TensorFlowVersion: r"""Gets TensorFlow Version. @@ -1435,11 +1447,11 @@ def sample_get_tensor_flow_version(): def list_accelerator_types( self, - request: Union[cloud_tpu.ListAcceleratorTypesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListAcceleratorTypesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -1548,11 +1560,11 @@ def sample_list_accelerator_types(): def get_accelerator_type( self, - request: Union[cloud_tpu.GetAcceleratorTypeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetAcceleratorTypeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/base.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/base.py index 8fd2918b8a75..5e28a9256b86 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/base.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/base.py @@ -49,7 +49,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py index 73c3398d07c7..6df38261af4a 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc.py @@ -48,14 +48,14 @@ def __init__( self, *, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -183,8 +183,8 @@ def __init__( def create_channel( cls, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py index e401bb4bbd83..487956d98a52 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/transports/grpc_asyncio.py @@ -50,7 +50,7 @@ class TpuGrpcAsyncIOTransport(TpuTransport): def create_channel( cls, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -93,15 +93,15 @@ def __init__( self, *, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v1/types/cloud_tpu.py b/packages/google-cloud-tpu/google/cloud/tpu_v1/types/cloud_tpu.py index ab93636ea0cb..97fc1f5a827e 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v1/types/cloud_tpu.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v1/types/cloud_tpu.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore @@ -55,11 +57,11 @@ class SchedulingConfig(proto.Message): reservation. """ - preemptible = proto.Field( + preemptible: bool = proto.Field( proto.BOOL, number=1, ) - reserved = proto.Field( + reserved: bool = proto.Field( proto.BOOL, number=2, ) @@ -75,11 +77,11 @@ class NetworkEndpoint(proto.Message): The port of this network endpoint. """ - ip_address = proto.Field( + ip_address: str = proto.Field( proto.STRING, number=1, ) - port = proto.Field( + port: int = proto.Field( proto.INT32, number=2, ) @@ -145,14 +147,14 @@ class Node(proto.Message): created. scheduling_config (google.cloud.tpu_v1.types.SchedulingConfig): The scheduling options for this node. - network_endpoints (Sequence[google.cloud.tpu_v1.types.NetworkEndpoint]): + network_endpoints (MutableSequence[google.cloud.tpu_v1.types.NetworkEndpoint]): Output only. The network endpoints where TPU workers can be accessed and sent work. It is recommended that Tensorflow clients of the node reach out to the 0th entry in this map first. health (google.cloud.tpu_v1.types.Node.Health): The health status of the TPU node. - labels (Mapping[str, str]): + labels (MutableMapping[str, str]): Resource labels to represent user-provided metadata. use_service_networking (bool): @@ -166,7 +168,7 @@ class Node(proto.Message): api_version (google.cloud.tpu_v1.types.Node.ApiVersion): Output only. The API version that created this Node. - symptoms (Sequence[google.cloud.tpu_v1.types.Symptom]): + symptoms (MutableSequence[google.cloud.tpu_v1.types.Symptom]): Output only. The Symptoms that have occurred to the TPU Node. """ @@ -209,86 +211,86 @@ class ApiVersion(proto.Enum): V1 = 2 V2_ALPHA1 = 3 - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - description = proto.Field( + description: str = proto.Field( proto.STRING, number=3, ) - accelerator_type = proto.Field( + accelerator_type: str = proto.Field( proto.STRING, number=5, ) - ip_address = proto.Field( + ip_address: str = proto.Field( proto.STRING, number=8, ) - port = proto.Field( + port: str = proto.Field( proto.STRING, number=14, ) - state = proto.Field( + state: State = proto.Field( proto.ENUM, number=9, enum=State, ) - health_description = proto.Field( + health_description: str = proto.Field( proto.STRING, number=10, ) - tensorflow_version = proto.Field( + tensorflow_version: str = proto.Field( proto.STRING, number=11, ) - network = proto.Field( + network: str = proto.Field( proto.STRING, number=12, ) - cidr_block = proto.Field( + cidr_block: str = proto.Field( proto.STRING, number=13, ) - service_account = proto.Field( + service_account: str = proto.Field( proto.STRING, number=15, ) - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=16, message=timestamp_pb2.Timestamp, ) - scheduling_config = proto.Field( + scheduling_config: "SchedulingConfig" = proto.Field( proto.MESSAGE, number=17, message="SchedulingConfig", ) - network_endpoints = proto.RepeatedField( + network_endpoints: MutableSequence["NetworkEndpoint"] = proto.RepeatedField( proto.MESSAGE, number=21, message="NetworkEndpoint", ) - health = proto.Field( + health: Health = proto.Field( proto.ENUM, number=22, enum=Health, ) - labels = proto.MapField( + labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=24, ) - use_service_networking = proto.Field( + use_service_networking: bool = proto.Field( proto.BOOL, number=27, ) - api_version = proto.Field( + api_version: ApiVersion = proto.Field( proto.ENUM, number=38, enum=ApiVersion, ) - symptoms = proto.RepeatedField( + symptoms: MutableSequence["Symptom"] = proto.RepeatedField( proto.MESSAGE, number=39, message="Symptom", @@ -308,15 +310,15 @@ class ListNodesRequest(proto.Message): request, if any. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) @@ -326,11 +328,11 @@ class ListNodesResponse(proto.Message): r"""Response for [ListNodes][google.cloud.tpu.v1.Tpu.ListNodes]. Attributes: - nodes (Sequence[google.cloud.tpu_v1.types.Node]): + nodes (MutableSequence[google.cloud.tpu_v1.types.Node]): The listed nodes. next_page_token (str): The next page token or empty if none. - unreachable (Sequence[str]): + unreachable (MutableSequence[str]): Locations that could not be reached. """ @@ -338,16 +340,16 @@ class ListNodesResponse(proto.Message): def raw_page(self): return self - nodes = proto.RepeatedField( + nodes: MutableSequence["Node"] = proto.RepeatedField( proto.MESSAGE, number=1, message="Node", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - unreachable = proto.RepeatedField( + unreachable: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) @@ -361,7 +363,7 @@ class GetNodeRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -379,15 +381,15 @@ class CreateNodeRequest(proto.Message): Required. The node. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - node_id = proto.Field( + node_id: str = proto.Field( proto.STRING, number=2, ) - node = proto.Field( + node: "Node" = proto.Field( proto.MESSAGE, number=3, message="Node", @@ -402,7 +404,7 @@ class DeleteNodeRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -418,11 +420,11 @@ class ReimageNodeRequest(proto.Message): The version for reimage to create. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - tensorflow_version = proto.Field( + tensorflow_version: str = proto.Field( proto.STRING, number=2, ) @@ -436,7 +438,7 @@ class StopNodeRequest(proto.Message): The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -450,7 +452,7 @@ class StartNodeRequest(proto.Message): The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -466,11 +468,11 @@ class TensorFlowVersion(proto.Message): the tensorflow version. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - version = proto.Field( + version: str = proto.Field( proto.STRING, number=2, ) @@ -485,7 +487,7 @@ class GetTensorFlowVersionRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -509,23 +511,23 @@ class ListTensorFlowVersionsRequest(proto.Message): Sort results. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=5, ) - order_by = proto.Field( + order_by: str = proto.Field( proto.STRING, number=6, ) @@ -536,11 +538,11 @@ class ListTensorFlowVersionsResponse(proto.Message): [ListTensorFlowVersions][google.cloud.tpu.v1.Tpu.ListTensorFlowVersions]. Attributes: - tensorflow_versions (Sequence[google.cloud.tpu_v1.types.TensorFlowVersion]): + tensorflow_versions (MutableSequence[google.cloud.tpu_v1.types.TensorFlowVersion]): The listed nodes. next_page_token (str): The next page token or empty if none. - unreachable (Sequence[str]): + unreachable (MutableSequence[str]): Locations that could not be reached. """ @@ -548,16 +550,16 @@ class ListTensorFlowVersionsResponse(proto.Message): def raw_page(self): return self - tensorflow_versions = proto.RepeatedField( + tensorflow_versions: MutableSequence["TensorFlowVersion"] = proto.RepeatedField( proto.MESSAGE, number=1, message="TensorFlowVersion", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - unreachable = proto.RepeatedField( + unreachable: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) @@ -573,11 +575,11 @@ class AcceleratorType(proto.Message): the accelerator type. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - type_ = proto.Field( + type_: str = proto.Field( proto.STRING, number=2, ) @@ -592,7 +594,7 @@ class GetAcceleratorTypeRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -616,23 +618,23 @@ class ListAcceleratorTypesRequest(proto.Message): Sort results. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=5, ) - order_by = proto.Field( + order_by: str = proto.Field( proto.STRING, number=6, ) @@ -643,11 +645,11 @@ class ListAcceleratorTypesResponse(proto.Message): [ListAcceleratorTypes][google.cloud.tpu.v1.Tpu.ListAcceleratorTypes]. Attributes: - accelerator_types (Sequence[google.cloud.tpu_v1.types.AcceleratorType]): + accelerator_types (MutableSequence[google.cloud.tpu_v1.types.AcceleratorType]): The listed nodes. next_page_token (str): The next page token or empty if none. - unreachable (Sequence[str]): + unreachable (MutableSequence[str]): Locations that could not be reached. """ @@ -655,16 +657,16 @@ class ListAcceleratorTypesResponse(proto.Message): def raw_page(self): return self - accelerator_types = proto.RepeatedField( + accelerator_types: MutableSequence["AcceleratorType"] = proto.RepeatedField( proto.MESSAGE, number=1, message="AcceleratorType", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - unreachable = proto.RepeatedField( + unreachable: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) @@ -693,33 +695,33 @@ class OperationMetadata(proto.Message): API version. """ - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) - end_time = proto.Field( + end_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, ) - target = proto.Field( + target: str = proto.Field( proto.STRING, number=3, ) - verb = proto.Field( + verb: str = proto.Field( proto.STRING, number=4, ) - status_detail = proto.Field( + status_detail: str = proto.Field( proto.STRING, number=5, ) - cancel_requested = proto.Field( + cancel_requested: bool = proto.Field( proto.BOOL, number=6, ) - api_version = proto.Field( + api_version: str = proto.Field( proto.STRING, number=7, ) @@ -752,21 +754,21 @@ class SymptomType(proto.Enum): HBM_OUT_OF_MEMORY = 5 PROJECT_ABUSE = 6 - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) - symptom_type = proto.Field( + symptom_type: SymptomType = proto.Field( proto.ENUM, number=2, enum=SymptomType, ) - details = proto.Field( + details: str = proto.Field( proto.STRING, number=3, ) - worker_id = proto.Field( + worker_id: str = proto.Field( proto.STRING, number=4, ) diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/__init__.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/__init__.py index 5ebcf4541ab2..3eacb1efeca1 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/__init__.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/__init__.py @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.tpu import gapic_version as package_version + +__version__ = package_version.__version__ + from .services.tpu import TpuAsyncClient, TpuClient from .types.cloud_tpu import ( diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py index 4ea2fccfdea1..e36d439545c7 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/async_client.py @@ -16,7 +16,17 @@ from collections import OrderedDict import functools import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, +) from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 @@ -160,9 +170,9 @@ def transport(self) -> TpuTransport: def __init__( self, *, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, TpuTransport] = "grpc_asyncio", - client_options: ClientOptions = None, + client_options: Optional[ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the tpu client. @@ -206,11 +216,11 @@ def __init__( async def list_nodes( self, - request: Union[cloud_tpu.ListNodesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNodesAsyncPager: r"""Lists nodes. @@ -243,7 +253,7 @@ async def sample_list_nodes(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.ListNodesRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.ListNodesRequest, dict]]): The request object. Request for [ListNodes][google.cloud.tpu.v2alpha1.Tpu.ListNodes]. parent (:class:`str`): @@ -319,11 +329,11 @@ async def sample_list_nodes(): async def get_node( self, - request: Union[cloud_tpu.GetNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -355,7 +365,7 @@ async def sample_get_node(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.GetNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.GetNodeRequest, dict]]): The request object. Request for [GetNode][google.cloud.tpu.v2alpha1.Tpu.GetNode]. name (:class:`str`): @@ -417,13 +427,13 @@ async def sample_get_node(): async def create_node( self, - request: Union[cloud_tpu.CreateNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.CreateNodeRequest, dict]] = None, *, - parent: str = None, - node: cloud_tpu.Node = None, - node_id: str = None, + parent: Optional[str] = None, + node: Optional[cloud_tpu.Node] = None, + node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Creates a node. @@ -464,7 +474,7 @@ async def sample_create_node(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.CreateNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.CreateNodeRequest, dict]]): The request object. Request for [CreateNode][google.cloud.tpu.v2alpha1.Tpu.CreateNode]. parent (:class:`str`): @@ -553,11 +563,11 @@ async def sample_create_node(): async def delete_node( self, - request: Union[cloud_tpu.DeleteNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.DeleteNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a node. @@ -593,7 +603,7 @@ async def sample_delete_node(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.DeleteNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.DeleteNodeRequest, dict]]): The request object. Request for [DeleteNode][google.cloud.tpu.v2alpha1.Tpu.DeleteNode]. name (:class:`str`): @@ -668,10 +678,10 @@ async def sample_delete_node(): async def stop_node( self, - request: Union[cloud_tpu.StopNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StopNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Stops a node. This operation is only available with @@ -707,7 +717,7 @@ async def sample_stop_node(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.StopNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.StopNodeRequest, dict]]): The request object. Request for [StopNode][google.cloud.tpu.v2alpha1.Tpu.StopNode]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -763,10 +773,10 @@ async def sample_stop_node(): async def start_node( self, - request: Union[cloud_tpu.StartNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StartNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Starts a node. @@ -801,7 +811,7 @@ async def sample_start_node(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.StartNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.StartNodeRequest, dict]]): The request object. Request for [StartNode][google.cloud.tpu.v2alpha1.Tpu.StartNode]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -857,12 +867,12 @@ async def sample_start_node(): async def update_node( self, - request: Union[cloud_tpu.UpdateNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.UpdateNodeRequest, dict]] = None, *, - node: cloud_tpu.Node = None, - update_mask: field_mask_pb2.FieldMask = None, + node: Optional[cloud_tpu.Node] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates the configurations of a node. @@ -902,7 +912,7 @@ async def sample_update_node(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.UpdateNodeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.UpdateNodeRequest, dict]]): The request object. Request for [UpdateNode][google.cloud.tpu.v2alpha1.Tpu.UpdateNode]. node (:class:`google.cloud.tpu_v2alpha1.types.Node`): @@ -990,10 +1000,10 @@ async def sample_update_node(): async def generate_service_identity( self, - request: Union[cloud_tpu.GenerateServiceIdentityRequest, dict] = None, + request: Optional[Union[cloud_tpu.GenerateServiceIdentityRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the @@ -1026,7 +1036,7 @@ async def sample_generate_service_identity(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.GenerateServiceIdentityRequest, dict]]): The request object. Request for [GenerateServiceIdentity][google.cloud.tpu.v2alpha1.Tpu.GenerateServiceIdentity]. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -1071,11 +1081,11 @@ async def sample_generate_service_identity(): async def list_accelerator_types( self, - request: Union[cloud_tpu.ListAcceleratorTypesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListAcceleratorTypesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAcceleratorTypesAsyncPager: r"""Lists accelerator types supported by this API. @@ -1108,7 +1118,7 @@ async def sample_list_accelerator_types(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.ListAcceleratorTypesRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.ListAcceleratorTypesRequest, dict]]): The request object. Request for [ListAcceleratorTypes][google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes]. parent (:class:`str`): @@ -1184,11 +1194,11 @@ async def sample_list_accelerator_types(): async def get_accelerator_type( self, - request: Union[cloud_tpu.GetAcceleratorTypeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetAcceleratorTypeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1220,7 +1230,7 @@ async def sample_get_accelerator_type(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.GetAcceleratorTypeRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.GetAcceleratorTypeRequest, dict]]): The request object. Request for [GetAcceleratorType][google.cloud.tpu.v2alpha1.Tpu.GetAcceleratorType]. name (:class:`str`): @@ -1284,11 +1294,11 @@ async def sample_get_accelerator_type(): async def list_runtime_versions( self, - request: Union[cloud_tpu.ListRuntimeVersionsRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListRuntimeVersionsRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRuntimeVersionsAsyncPager: r"""Lists runtime versions supported by this API. @@ -1321,7 +1331,7 @@ async def sample_list_runtime_versions(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.ListRuntimeVersionsRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.ListRuntimeVersionsRequest, dict]]): The request object. Request for [ListRuntimeVersions][google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions]. parent (:class:`str`): @@ -1397,11 +1407,11 @@ async def sample_list_runtime_versions(): async def get_runtime_version( self, - request: Union[cloud_tpu.GetRuntimeVersionRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetRuntimeVersionRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -1433,7 +1443,7 @@ async def sample_get_runtime_version(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.GetRuntimeVersionRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.GetRuntimeVersionRequest, dict]]): The request object. Request for [GetRuntimeVersion][google.cloud.tpu.v2alpha1.Tpu.GetRuntimeVersion]. name (:class:`str`): @@ -1497,10 +1507,10 @@ async def sample_get_runtime_version(): async def get_guest_attributes( self, - request: Union[cloud_tpu.GetGuestAttributesRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetGuestAttributesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. @@ -1532,7 +1542,7 @@ async def sample_get_guest_attributes(): print(response) Args: - request (Union[google.cloud.tpu_v2alpha1.types.GetGuestAttributesRequest, dict]): + request (Optional[Union[google.cloud.tpu_v2alpha1.types.GetGuestAttributesRequest, dict]]): The request object. Request for [GetGuestAttributes][google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes]. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py index bd15139a4375..008b7701f13b 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/client.py @@ -16,7 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union +from typing import ( + Dict, + Mapping, + MutableMapping, + MutableSequence, + Optional, + Sequence, + Tuple, + Type, + Union, + cast, +) from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -61,7 +72,7 @@ class TpuClientMeta(type): def get_transport_class( cls, - label: str = None, + label: Optional[str] = None, ) -> Type[TpuTransport]: """Returns an appropriate transport class. @@ -382,8 +393,8 @@ def __init__( self, *, credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, TpuTransport, None] = None, - client_options: Optional[client_options_lib.ClientOptions] = None, + transport: Optional[Union[str, TpuTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiates the tpu client. @@ -397,7 +408,7 @@ def __init__( transport (Union[str, TpuTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -427,6 +438,7 @@ def __init__( client_options = client_options_lib.from_dict(client_options) if client_options is None: client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( client_options @@ -479,11 +491,11 @@ def __init__( def list_nodes( self, - request: Union[cloud_tpu.ListNodesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListNodesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListNodesPager: r"""Lists nodes. @@ -592,11 +604,11 @@ def sample_list_nodes(): def get_node( self, - request: Union[cloud_tpu.GetNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.Node: r"""Gets the details of a node. @@ -690,13 +702,13 @@ def sample_get_node(): def create_node( self, - request: Union[cloud_tpu.CreateNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.CreateNodeRequest, dict]] = None, *, - parent: str = None, - node: cloud_tpu.Node = None, - node_id: str = None, + parent: Optional[str] = None, + node: Optional[cloud_tpu.Node] = None, + node_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates a node. @@ -826,11 +838,11 @@ def sample_create_node(): def delete_node( self, - request: Union[cloud_tpu.DeleteNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.DeleteNodeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes a node. @@ -941,10 +953,10 @@ def sample_delete_node(): def stop_node( self, - request: Union[cloud_tpu.StopNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StopNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Stops a node. This operation is only available with @@ -1037,10 +1049,10 @@ def sample_stop_node(): def start_node( self, - request: Union[cloud_tpu.StartNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.StartNodeRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Starts a node. @@ -1132,12 +1144,12 @@ def sample_start_node(): def update_node( self, - request: Union[cloud_tpu.UpdateNodeRequest, dict] = None, + request: Optional[Union[cloud_tpu.UpdateNodeRequest, dict]] = None, *, - node: cloud_tpu.Node = None, - update_mask: field_mask_pb2.FieldMask = None, + node: Optional[cloud_tpu.Node] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Updates the configurations of a node. @@ -1265,10 +1277,10 @@ def sample_update_node(): def generate_service_identity( self, - request: Union[cloud_tpu.GenerateServiceIdentityRequest, dict] = None, + request: Optional[Union[cloud_tpu.GenerateServiceIdentityRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.GenerateServiceIdentityResponse: r"""Generates the Cloud TPU service identity for the @@ -1349,11 +1361,11 @@ def sample_generate_service_identity(): def list_accelerator_types( self, - request: Union[cloud_tpu.ListAcceleratorTypesRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListAcceleratorTypesRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAcceleratorTypesPager: r"""Lists accelerator types supported by this API. @@ -1462,11 +1474,11 @@ def sample_list_accelerator_types(): def get_accelerator_type( self, - request: Union[cloud_tpu.GetAcceleratorTypeRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetAcceleratorTypeRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.AcceleratorType: r"""Gets AcceleratorType. @@ -1562,11 +1574,11 @@ def sample_get_accelerator_type(): def list_runtime_versions( self, - request: Union[cloud_tpu.ListRuntimeVersionsRequest, dict] = None, + request: Optional[Union[cloud_tpu.ListRuntimeVersionsRequest, dict]] = None, *, - parent: str = None, + parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListRuntimeVersionsPager: r"""Lists runtime versions supported by this API. @@ -1675,11 +1687,11 @@ def sample_list_runtime_versions(): def get_runtime_version( self, - request: Union[cloud_tpu.GetRuntimeVersionRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetRuntimeVersionRequest, dict]] = None, *, - name: str = None, + name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.RuntimeVersion: r"""Gets a runtime version. @@ -1775,10 +1787,10 @@ def sample_get_runtime_version(): def get_guest_attributes( self, - request: Union[cloud_tpu.GetGuestAttributesRequest, dict] = None, + request: Optional[Union[cloud_tpu.GetGuestAttributesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: float = None, + timeout: Optional[float] = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cloud_tpu.GetGuestAttributesResponse: r"""Retrieves the guest attributes for the node. diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py index 827330e1e1dd..370a034e19cd 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py @@ -49,7 +49,7 @@ def __init__( self, *, host: str = DEFAULT_HOST, - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py index 21ed009c09b4..74a19f646d15 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py @@ -48,14 +48,14 @@ def __init__( self, *, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, - scopes: Sequence[str] = None, - channel: grpc.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, @@ -183,8 +183,8 @@ def __init__( def create_channel( cls, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, - credentials_file: str = None, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, **kwargs, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py index 559f727c5a54..41072e078c62 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py @@ -50,7 +50,7 @@ class TpuGrpcAsyncIOTransport(TpuTransport): def create_channel( cls, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -93,15 +93,15 @@ def __init__( self, *, host: str = "tpu.googleapis.com", - credentials: ga_credentials.Credentials = None, + credentials: Optional[ga_credentials.Credentials] = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, - channel: aio.Channel = None, - api_mtls_endpoint: str = None, - client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, - ssl_channel_credentials: grpc.ChannelCredentials = None, - client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, - quota_project_id=None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, always_use_jwt_access: Optional[bool] = False, api_audience: Optional[str] = None, diff --git a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/types/cloud_tpu.py b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/types/cloud_tpu.py index e85e7336ac37..931695615e89 100644 --- a/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/types/cloud_tpu.py +++ b/packages/google-cloud-tpu/google/cloud/tpu_v2alpha1/types/cloud_tpu.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore import proto # type: ignore @@ -71,11 +73,11 @@ class GuestAttributes(proto.Message): The value of the requested queried path. """ - query_path = proto.Field( + query_path: str = proto.Field( proto.STRING, number=1, ) - query_value = proto.Field( + query_value: "GuestAttributesValue" = proto.Field( proto.MESSAGE, number=2, message="GuestAttributesValue", @@ -86,11 +88,11 @@ class GuestAttributesValue(proto.Message): r"""Array of guest attribute namespace/key/value tuples. Attributes: - items (Sequence[google.cloud.tpu_v2alpha1.types.GuestAttributesEntry]): + items (MutableSequence[google.cloud.tpu_v2alpha1.types.GuestAttributesEntry]): The list of guest attributes entries. """ - items = proto.RepeatedField( + items: MutableSequence["GuestAttributesEntry"] = proto.RepeatedField( proto.MESSAGE, number=1, message="GuestAttributesEntry", @@ -109,15 +111,15 @@ class GuestAttributesEntry(proto.Message): Value for the guest attribute entry. """ - namespace = proto.Field( + namespace: str = proto.Field( proto.STRING, number=1, ) - key = proto.Field( + key: str = proto.Field( proto.STRING, number=2, ) - value = proto.Field( + value: str = proto.Field( proto.STRING, number=3, ) @@ -143,11 +145,11 @@ class DiskMode(proto.Enum): READ_WRITE = 1 READ_ONLY = 2 - source_disk = proto.Field( + source_disk: str = proto.Field( proto.STRING, number=3, ) - mode = proto.Field( + mode: DiskMode = proto.Field( proto.ENUM, number=4, enum=DiskMode, @@ -165,11 +167,11 @@ class SchedulingConfig(proto.Message): reservation. """ - preemptible = proto.Field( + preemptible: bool = proto.Field( proto.BOOL, number=1, ) - reserved = proto.Field( + reserved: bool = proto.Field( proto.BOOL, number=2, ) @@ -188,15 +190,15 @@ class NetworkEndpoint(proto.Message): The access config for the TPU worker. """ - ip_address = proto.Field( + ip_address: str = proto.Field( proto.STRING, number=1, ) - port = proto.Field( + port: int = proto.Field( proto.INT32, number=2, ) - access_config = proto.Field( + access_config: "AccessConfig" = proto.Field( proto.MESSAGE, number=5, message="AccessConfig", @@ -212,7 +214,7 @@ class AccessConfig(proto.Message): associated with the TPU worker. """ - external_ip = proto.Field( + external_ip: str = proto.Field( proto.STRING, number=1, ) @@ -239,15 +241,15 @@ class NetworkConfig(proto.Message): should have Private Google Access enabled. """ - network = proto.Field( + network: str = proto.Field( proto.STRING, number=1, ) - subnetwork = proto.Field( + subnetwork: str = proto.Field( proto.STRING, number=2, ) - enable_external_ips = proto.Field( + enable_external_ips: bool = proto.Field( proto.BOOL, number=3, ) @@ -261,17 +263,17 @@ class ServiceAccount(proto.Message): Email address of the service account. If empty, default Compute service account will be used. - scope (Sequence[str]): + scope (MutableSequence[str]): The list of scopes to be made available for this service account. If empty, access to all Cloud APIs will be allowed. """ - email = proto.Field( + email: str = proto.Field( proto.STRING, number=1, ) - scope = proto.RepeatedField( + scope: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=2, ) @@ -323,32 +325,32 @@ class Node(proto.Message): created. scheduling_config (google.cloud.tpu_v2alpha1.types.SchedulingConfig): The scheduling options for this node. - network_endpoints (Sequence[google.cloud.tpu_v2alpha1.types.NetworkEndpoint]): + network_endpoints (MutableSequence[google.cloud.tpu_v2alpha1.types.NetworkEndpoint]): Output only. The network endpoints where TPU workers can be accessed and sent work. It is recommended that runtime clients of the node reach out to the 0th entry in this map first. health (google.cloud.tpu_v2alpha1.types.Node.Health): The health status of the TPU node. - labels (Mapping[str, str]): + labels (MutableMapping[str, str]): Resource labels to represent user-provided metadata. - metadata (Mapping[str, str]): + metadata (MutableMapping[str, str]): Custom metadata to apply to the TPU Node. Can set startup-script and shutdown-script - tags (Sequence[str]): + tags (MutableSequence[str]): Tags to apply to the TPU Node. Tags are used to identify valid sources or targets for network firewalls. id (int): Output only. The unique identifier for the TPU Node. - data_disks (Sequence[google.cloud.tpu_v2alpha1.types.AttachedDisk]): + data_disks (MutableSequence[google.cloud.tpu_v2alpha1.types.AttachedDisk]): The additional data disks for the Node. api_version (google.cloud.tpu_v2alpha1.types.Node.ApiVersion): Output only. The API version that created this Node. - symptoms (Sequence[google.cloud.tpu_v2alpha1.types.Symptom]): + symptoms (MutableSequence[google.cloud.tpu_v2alpha1.types.Symptom]): Output only. The Symptoms that have occurred to the TPU Node. shielded_instance_config (google.cloud.tpu_v2alpha1.types.ShieldedInstanceConfig): @@ -392,99 +394,99 @@ class ApiVersion(proto.Enum): V1 = 2 V2_ALPHA1 = 3 - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - description = proto.Field( + description: str = proto.Field( proto.STRING, number=3, ) - accelerator_type = proto.Field( + accelerator_type: str = proto.Field( proto.STRING, number=5, ) - state = proto.Field( + state: State = proto.Field( proto.ENUM, number=9, enum=State, ) - health_description = proto.Field( + health_description: str = proto.Field( proto.STRING, number=10, ) - runtime_version = proto.Field( + runtime_version: str = proto.Field( proto.STRING, number=11, ) - network_config = proto.Field( + network_config: "NetworkConfig" = proto.Field( proto.MESSAGE, number=36, message="NetworkConfig", ) - cidr_block = proto.Field( + cidr_block: str = proto.Field( proto.STRING, number=13, ) - service_account = proto.Field( + service_account: "ServiceAccount" = proto.Field( proto.MESSAGE, number=37, message="ServiceAccount", ) - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=16, message=timestamp_pb2.Timestamp, ) - scheduling_config = proto.Field( + scheduling_config: "SchedulingConfig" = proto.Field( proto.MESSAGE, number=17, message="SchedulingConfig", ) - network_endpoints = proto.RepeatedField( + network_endpoints: MutableSequence["NetworkEndpoint"] = proto.RepeatedField( proto.MESSAGE, number=21, message="NetworkEndpoint", ) - health = proto.Field( + health: Health = proto.Field( proto.ENUM, number=22, enum=Health, ) - labels = proto.MapField( + labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=24, ) - metadata = proto.MapField( + metadata: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=34, ) - tags = proto.RepeatedField( + tags: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=40, ) - id = proto.Field( + id: int = proto.Field( proto.INT64, number=33, ) - data_disks = proto.RepeatedField( + data_disks: MutableSequence["AttachedDisk"] = proto.RepeatedField( proto.MESSAGE, number=41, message="AttachedDisk", ) - api_version = proto.Field( + api_version: ApiVersion = proto.Field( proto.ENUM, number=38, enum=ApiVersion, ) - symptoms = proto.RepeatedField( + symptoms: MutableSequence["Symptom"] = proto.RepeatedField( proto.MESSAGE, number=39, message="Symptom", ) - shielded_instance_config = proto.Field( + shielded_instance_config: "ShieldedInstanceConfig" = proto.Field( proto.MESSAGE, number=45, message="ShieldedInstanceConfig", @@ -504,15 +506,15 @@ class ListNodesRequest(proto.Message): request, if any. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) @@ -522,11 +524,11 @@ class ListNodesResponse(proto.Message): r"""Response for [ListNodes][google.cloud.tpu.v2alpha1.Tpu.ListNodes]. Attributes: - nodes (Sequence[google.cloud.tpu_v2alpha1.types.Node]): + nodes (MutableSequence[google.cloud.tpu_v2alpha1.types.Node]): The listed nodes. next_page_token (str): The next page token or empty if none. - unreachable (Sequence[str]): + unreachable (MutableSequence[str]): Locations that could not be reached. """ @@ -534,16 +536,16 @@ class ListNodesResponse(proto.Message): def raw_page(self): return self - nodes = proto.RepeatedField( + nodes: MutableSequence["Node"] = proto.RepeatedField( proto.MESSAGE, number=1, message="Node", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - unreachable = proto.RepeatedField( + unreachable: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) @@ -557,7 +559,7 @@ class GetNodeRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -575,15 +577,15 @@ class CreateNodeRequest(proto.Message): Required. The node. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - node_id = proto.Field( + node_id: str = proto.Field( proto.STRING, number=2, ) - node = proto.Field( + node: "Node" = proto.Field( proto.MESSAGE, number=3, message="Node", @@ -598,7 +600,7 @@ class DeleteNodeRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -612,7 +614,7 @@ class StopNodeRequest(proto.Message): The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -626,7 +628,7 @@ class StartNodeRequest(proto.Message): The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -644,12 +646,12 @@ class UpdateNodeRequest(proto.Message): updated. """ - update_mask = proto.Field( + update_mask: field_mask_pb2.FieldMask = proto.Field( proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, ) - node = proto.Field( + node: "Node" = proto.Field( proto.MESSAGE, number=2, message="Node", @@ -665,7 +667,7 @@ class ServiceIdentity(proto.Message): The email address of the service identity. """ - email = proto.Field( + email: str = proto.Field( proto.STRING, number=1, ) @@ -680,7 +682,7 @@ class GenerateServiceIdentityRequest(proto.Message): Required. The parent resource name. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) @@ -696,7 +698,7 @@ class GenerateServiceIdentityResponse(proto.Message): retrieved. """ - identity = proto.Field( + identity: "ServiceIdentity" = proto.Field( proto.MESSAGE, number=1, message="ServiceIdentity", @@ -713,11 +715,11 @@ class AcceleratorType(proto.Message): the accelerator type. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - type_ = proto.Field( + type_: str = proto.Field( proto.STRING, number=2, ) @@ -732,7 +734,7 @@ class GetAcceleratorTypeRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -756,23 +758,23 @@ class ListAcceleratorTypesRequest(proto.Message): Sort results. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=5, ) - order_by = proto.Field( + order_by: str = proto.Field( proto.STRING, number=6, ) @@ -783,11 +785,11 @@ class ListAcceleratorTypesResponse(proto.Message): [ListAcceleratorTypes][google.cloud.tpu.v2alpha1.Tpu.ListAcceleratorTypes]. Attributes: - accelerator_types (Sequence[google.cloud.tpu_v2alpha1.types.AcceleratorType]): + accelerator_types (MutableSequence[google.cloud.tpu_v2alpha1.types.AcceleratorType]): The listed nodes. next_page_token (str): The next page token or empty if none. - unreachable (Sequence[str]): + unreachable (MutableSequence[str]): Locations that could not be reached. """ @@ -795,16 +797,16 @@ class ListAcceleratorTypesResponse(proto.Message): def raw_page(self): return self - accelerator_types = proto.RepeatedField( + accelerator_types: MutableSequence["AcceleratorType"] = proto.RepeatedField( proto.MESSAGE, number=1, message="AcceleratorType", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - unreachable = proto.RepeatedField( + unreachable: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) @@ -833,33 +835,33 @@ class OperationMetadata(proto.Message): API version. """ - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) - end_time = proto.Field( + end_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, ) - target = proto.Field( + target: str = proto.Field( proto.STRING, number=3, ) - verb = proto.Field( + verb: str = proto.Field( proto.STRING, number=4, ) - status_detail = proto.Field( + status_detail: str = proto.Field( proto.STRING, number=5, ) - cancel_requested = proto.Field( + cancel_requested: bool = proto.Field( proto.BOOL, number=6, ) - api_version = proto.Field( + api_version: str = proto.Field( proto.STRING, number=7, ) @@ -875,11 +877,11 @@ class RuntimeVersion(proto.Message): The runtime version. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - version = proto.Field( + version: str = proto.Field( proto.STRING, number=2, ) @@ -894,7 +896,7 @@ class GetRuntimeVersionRequest(proto.Message): Required. The resource name. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) @@ -918,23 +920,23 @@ class ListRuntimeVersionsRequest(proto.Message): Sort results. """ - parent = proto.Field( + parent: str = proto.Field( proto.STRING, number=1, ) - page_size = proto.Field( + page_size: int = proto.Field( proto.INT32, number=2, ) - page_token = proto.Field( + page_token: str = proto.Field( proto.STRING, number=3, ) - filter = proto.Field( + filter: str = proto.Field( proto.STRING, number=5, ) - order_by = proto.Field( + order_by: str = proto.Field( proto.STRING, number=6, ) @@ -945,11 +947,11 @@ class ListRuntimeVersionsResponse(proto.Message): [ListRuntimeVersions][google.cloud.tpu.v2alpha1.Tpu.ListRuntimeVersions]. Attributes: - runtime_versions (Sequence[google.cloud.tpu_v2alpha1.types.RuntimeVersion]): + runtime_versions (MutableSequence[google.cloud.tpu_v2alpha1.types.RuntimeVersion]): The listed nodes. next_page_token (str): The next page token or empty if none. - unreachable (Sequence[str]): + unreachable (MutableSequence[str]): Locations that could not be reached. """ @@ -957,16 +959,16 @@ class ListRuntimeVersionsResponse(proto.Message): def raw_page(self): return self - runtime_versions = proto.RepeatedField( + runtime_versions: MutableSequence["RuntimeVersion"] = proto.RepeatedField( proto.MESSAGE, number=1, message="RuntimeVersion", ) - next_page_token = proto.Field( + next_page_token: str = proto.Field( proto.STRING, number=2, ) - unreachable = proto.RepeatedField( + unreachable: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) @@ -999,21 +1001,21 @@ class SymptomType(proto.Enum): HBM_OUT_OF_MEMORY = 5 PROJECT_ABUSE = 6 - create_time = proto.Field( + create_time: timestamp_pb2.Timestamp = proto.Field( proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, ) - symptom_type = proto.Field( + symptom_type: SymptomType = proto.Field( proto.ENUM, number=2, enum=SymptomType, ) - details = proto.Field( + details: str = proto.Field( proto.STRING, number=3, ) - worker_id = proto.Field( + worker_id: str = proto.Field( proto.STRING, number=4, ) @@ -1028,20 +1030,20 @@ class GetGuestAttributesRequest(proto.Message): Required. The resource name. query_path (str): The guest attributes path to be queried. - worker_ids (Sequence[str]): + worker_ids (MutableSequence[str]): The 0-based worker ID. If it is empty, all workers' GuestAttributes will be returned. """ - name = proto.Field( + name: str = proto.Field( proto.STRING, number=1, ) - query_path = proto.Field( + query_path: str = proto.Field( proto.STRING, number=2, ) - worker_ids = proto.RepeatedField( + worker_ids: MutableSequence[str] = proto.RepeatedField( proto.STRING, number=3, ) @@ -1052,11 +1054,11 @@ class GetGuestAttributesResponse(proto.Message): [GetGuestAttributes][google.cloud.tpu.v2alpha1.Tpu.GetGuestAttributes]. Attributes: - guest_attributes (Sequence[google.cloud.tpu_v2alpha1.types.GuestAttributes]): + guest_attributes (MutableSequence[google.cloud.tpu_v2alpha1.types.GuestAttributes]): The guest attributes for the TPU workers. """ - guest_attributes = proto.RepeatedField( + guest_attributes: MutableSequence["GuestAttributes"] = proto.RepeatedField( proto.MESSAGE, number=1, message="GuestAttributes", @@ -1072,7 +1074,7 @@ class ShieldedInstanceConfig(proto.Message): enabled. """ - enable_secure_boot = proto.Field( + enable_secure_boot: bool = proto.Field( proto.BOOL, number=1, ) diff --git a/packages/google-cloud-tpu/owlbot.py b/packages/google-cloud-tpu/owlbot.py new file mode 100644 index 000000000000..ce738f01d012 --- /dev/null +++ b/packages/google-cloud-tpu/owlbot.py @@ -0,0 +1,56 @@ +# Copyright 2022 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 json +from pathlib import Path +import shutil + +import synthtool as s +import synthtool.gcp as gcp +from synthtool.languages import python + +# ---------------------------------------------------------------------------- +# Copy the generated client from the owl-bot staging directory +# ---------------------------------------------------------------------------- + +clean_up_generated_samples = True + +# Load the default version defined in .repo-metadata.json. +default_version = json.load(open(".repo-metadata.json", "rt")).get( + "default_version" +) + +for library in s.get_staging_dirs(default_version): + if clean_up_generated_samples: + shutil.rmtree("samples/generated_samples", ignore_errors=True) + clean_up_generated_samples = False + s.move([library], excludes=["**/gapic_version.py"]) +s.remove_staging_dirs() + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- + +templated_files = gcp.CommonTemplates().py_library( + cov_level=100, + microgenerator=True, + versions=gcp.common.detect_versions(path="./google", default_first=True), +) +s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"]) + +python.py_samples(skip_readmes=True) + +# run format session for all directories which have a noxfile +for noxfile in Path(".").glob("**/noxfile.py"): + s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False) diff --git a/packages/google-cloud-tpu/release-please-config.json b/packages/google-cloud-tpu/release-please-config.json new file mode 100644 index 000000000000..9aa8dfd78fb0 --- /dev/null +++ b/packages/google-cloud-tpu/release-please-config.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "python", + "extra-files": [ + "google/cloud/tpu/gapic_version.py", + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json", + "jsonpath": "$.clientLibrary.version" + }, + { + "type": "json", + "path": "samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json", + "jsonpath": "$.clientLibrary.version" + } + ] + } + }, + "release-type": "python", + "plugins": [ + { + "type": "sentence-case" + } + ], + "initial-version": "0.1.0" +} diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_tpu_v1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json similarity index 99% rename from packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_tpu_v1.json rename to packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json index 14bc4cc95639..0a659a05f598 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_tpu_v1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json @@ -7,7 +7,8 @@ } ], "language": "PYTHON", - "name": "google-cloud-tpu" + "name": "google-cloud-tpu", + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_tpu_v2alpha1.json b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json similarity index 99% rename from packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_tpu_v2alpha1.json rename to packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json index 1b4d1f6f379b..2e8d3cfeab8c 100644 --- a/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_tpu_v2alpha1.json +++ b/packages/google-cloud-tpu/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json @@ -7,7 +7,8 @@ } ], "language": "PYTHON", - "name": "google-cloud-tpu" + "name": "google-cloud-tpu", + "version": "0.1.0" }, "snippets": [ { diff --git a/packages/google-cloud-tpu/setup.py b/packages/google-cloud-tpu/setup.py index b935fc406f76..470abc84286a 100644 --- a/packages/google-cloud-tpu/setup.py +++ b/packages/google-cloud-tpu/setup.py @@ -1,34 +1,46 @@ # -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC +# Copyright 2022 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 # -# https://www.apache.org/licenses/LICENSE-2.0 +# 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 io import os -import setuptools +import setuptools # type: ignore + +package_root = os.path.abspath(os.path.dirname(__file__)) name = "google-cloud-tpu" -description = "Cloud TPU API client library" -version = "1.5.2" -release_status = "Development Status :: 5 - Production/Stable" -url = "https://github.com/googleapis/python-tpu" + + +description = "Google Cloud Tpu API client library" + +version = {} +with open(os.path.join(package_root, "google/cloud/tpu/gapic_version.py")) as fp: + exec(fp.read(), version) +version = version["__version__"] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + dependencies = [ - "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", + "google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", "proto-plus >= 1.22.0, <2.0.0dev", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] +url = "https://github.com/googleapis/python-tpu" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -46,7 +58,6 @@ if "google.cloud" in packages: namespaces.append("google.cloud") - setuptools.setup( name=name, version=version, diff --git a/packages/google-cloud-tpu/testing/constraints-3.10.txt b/packages/google-cloud-tpu/testing/constraints-3.10.txt index e69de29bb2d1..ed7f9aed2559 100644 --- a/packages/google-cloud-tpu/testing/constraints-3.10.txt +++ b/packages/google-cloud-tpu/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/packages/google-cloud-tpu/testing/constraints-3.11.txt b/packages/google-cloud-tpu/testing/constraints-3.11.txt index e69de29bb2d1..ed7f9aed2559 100644 --- a/packages/google-cloud-tpu/testing/constraints-3.11.txt +++ b/packages/google-cloud-tpu/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/packages/google-cloud-tpu/testing/constraints-3.7.txt b/packages/google-cloud-tpu/testing/constraints-3.7.txt index 4005dc5bf25e..6f3158cc2034 100644 --- a/packages/google-cloud-tpu/testing/constraints-3.7.txt +++ b/packages/google-cloud-tpu/testing/constraints-3.7.txt @@ -4,6 +4,6 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.32.0 +google-api-core==1.33.2 proto-plus==1.22.0 protobuf==3.19.5 diff --git a/packages/google-cloud-tpu/testing/constraints-3.8.txt b/packages/google-cloud-tpu/testing/constraints-3.8.txt index e69de29bb2d1..ed7f9aed2559 100644 --- a/packages/google-cloud-tpu/testing/constraints-3.8.txt +++ b/packages/google-cloud-tpu/testing/constraints-3.8.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/packages/google-cloud-tpu/testing/constraints-3.9.txt b/packages/google-cloud-tpu/testing/constraints-3.9.txt index e69de29bb2d1..ed7f9aed2559 100644 --- a/packages/google-cloud-tpu/testing/constraints-3.9.txt +++ b/packages/google-cloud-tpu/testing/constraints-3.9.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf