Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
feat: publishing TPU v2 API (#202)
Browse files Browse the repository at this point in the history
* fix(deps): Require google-api-core >=1.34.0, >=2.11.0

fix: Drop usage of pkg_resources

fix: Fix timeout default values

docs(samples): Snippetgen should call await on the operation coroutine before calling result

PiperOrigin-RevId: 493260409

Source-Link: googleapis/googleapis@fea4387

Source-Link: googleapis/googleapis-gen@387b734
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzg3YjczNDRjNzUyOWVlNDRiZTg0ZTYxM2IxOWE4MjA1MDhjNjEyYiJ9

* add gapic_version.py

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: publishing TPU v2 API
fix!: fix incorrect resource annotations for TPU v2alpha1 API

PiperOrigin-RevId: 493327922

Source-Link: googleapis/googleapis@93c3e0e

Source-Link: googleapis/googleapis-gen@4c01898
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGMwMTg5ODhlMzU3MWRmODBjZGU3OTIzYTFlNjIwOWZjZjkxOTdjNyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: Update gapic-generator-python to v1.7.1

PiperOrigin-RevId: 495049888

Source-Link: googleapis/googleapis@bf4359c

Source-Link: googleapis/googleapis-gen@5ab9576
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWFiOTU3NmVhZmJkNGRlNDM2ODk2ZjAxYzI3ODc1N2Q4N2EyNGUyNyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* add gapic_version.py

* docs: fix minor docstring formatting

PiperOrigin-RevId: 495593544

Source-Link: googleapis/googleapis@ea52382

Source-Link: googleapis/googleapis-gen@db6462e
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGI2NDYyZWRmZTUwYzBiOTNmNDkxZTA5NGU3NDhmMGRhYTYxZDM5OCJ9

* 🦉 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 <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people committed Dec 15, 2022
1 parent 2668309 commit ac1bc46
Show file tree
Hide file tree
Showing 96 changed files with 29,723 additions and 527 deletions.
5 changes: 0 additions & 5 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
8 changes: 8 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ API Reference
tpu_v1/services
tpu_v1/types

API Reference
-------------
.. toctree::
:maxdepth: 2

tpu_v2/services
tpu_v2/types

API Reference
-------------
.. toctree::
Expand Down
6 changes: 6 additions & 0 deletions docs/tpu_v2/services.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Services for Google Cloud Tpu v2 API
====================================
.. toctree::
:maxdepth: 2

tpu
10 changes: 10 additions & 0 deletions docs/tpu_v2/tpu.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Tpu
---------------------

.. automodule:: google.cloud.tpu_v2.services.tpu
:members:
:inherited-members:

.. automodule:: google.cloud.tpu_v2.services.tpu.pagers
:members:
:inherited-members:
6 changes: 6 additions & 0 deletions docs/tpu_v2/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Types for Google Cloud Tpu v2 API
=================================

.. automodule:: google.cloud.tpu_v2.types
:members:
:show-inheritance:
16 changes: 16 additions & 0 deletions google/cloud/tpu_v1/gapic_version.py
Original file line number Diff line number Diff line change
@@ -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}
58 changes: 27 additions & 31 deletions google/cloud/tpu_v1/services/tpu/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from google.api_core.client_options import ClientOptions
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
import pkg_resources

from google.cloud.tpu_v1 import gapic_version as package_version

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
Expand Down Expand Up @@ -223,7 +224,7 @@ async def list_nodes(
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListNodesAsyncPager:
r"""Lists nodes.
Expand Down Expand Up @@ -336,7 +337,7 @@ async def get_node(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tpu.Node:
r"""Gets the details of a node.
Expand Down Expand Up @@ -436,7 +437,7 @@ async def create_node(
node: Optional[cloud_tpu.Node] = None,
node_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a node.
Expand Down Expand Up @@ -471,7 +472,7 @@ async def sample_create_node():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -569,7 +570,7 @@ async def delete_node(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Deletes a node.
Expand Down Expand Up @@ -599,7 +600,7 @@ async def sample_delete_node():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -682,7 +683,7 @@ async def reimage_node(
request: Optional[Union[cloud_tpu.ReimageNodeRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Reimages a node's OS.
Expand Down Expand Up @@ -711,7 +712,7 @@ async def sample_reimage_node():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -775,7 +776,7 @@ async def stop_node(
request: Optional[Union[cloud_tpu.StopNodeRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Stops a node, this operation is only available with
Expand Down Expand Up @@ -805,7 +806,7 @@ async def sample_stop_node():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -869,7 +870,7 @@ async def start_node(
request: Optional[Union[cloud_tpu.StartNodeRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Starts a node.
Expand Down Expand Up @@ -898,7 +899,7 @@ async def sample_start_node():
print("Waiting for operation to complete...")
response = await operation.result()
response = (await operation).result()
# Handle the response
print(response)
Expand Down Expand Up @@ -963,7 +964,7 @@ async def list_tensor_flow_versions(
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListTensorFlowVersionsAsyncPager:
r"""List TensorFlow versions supported by this API.
Expand Down Expand Up @@ -1076,7 +1077,7 @@ async def get_tensor_flow_version(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tpu.TensorFlowVersion:
r"""Gets TensorFlow Version.
Expand Down Expand Up @@ -1176,7 +1177,7 @@ async def list_accelerator_types(
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListAcceleratorTypesAsyncPager:
r"""Lists accelerator types supported by this API.
Expand Down Expand Up @@ -1289,7 +1290,7 @@ async def get_accelerator_type(
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> cloud_tpu.AcceleratorType:
r"""Gets AcceleratorType.
Expand Down Expand Up @@ -1388,7 +1389,7 @@ async def list_operations(
request: Optional[operations_pb2.ListOperationsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.ListOperationsResponse:
r"""Lists operations that match the specified filter in the request.
Expand Down Expand Up @@ -1442,7 +1443,7 @@ async def get_operation(
request: Optional[operations_pb2.GetOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.
Expand Down Expand Up @@ -1496,7 +1497,7 @@ async def delete_operation(
request: Optional[operations_pb2.DeleteOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes a long-running operation.
Expand Down Expand Up @@ -1551,7 +1552,7 @@ async def cancel_operation(
request: Optional[operations_pb2.CancelOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Starts asynchronous cancellation on a long-running operation.
Expand Down Expand Up @@ -1605,7 +1606,7 @@ async def get_location(
request: Optional[locations_pb2.GetLocationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> locations_pb2.Location:
r"""Gets information about a location.
Expand Down Expand Up @@ -1659,7 +1660,7 @@ async def list_locations(
request: Optional[locations_pb2.ListLocationsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Optional[float] = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> locations_pb2.ListLocationsResponse:
r"""Lists information about the supported locations for this service.
Expand Down Expand Up @@ -1715,14 +1716,9 @@ async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-tpu",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("TpuAsyncClient",)
Loading

0 comments on commit ac1bc46

Please sign in to comment.