Skip to content

Commit 193f57b

Browse files
feat: publishing TPU v2 API (#202)
* 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 <[email protected]>
1 parent 3a2ec53 commit 193f57b

File tree

96 files changed

+29723
-527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+29723
-527
lines changed

packages/google-cloud-tpu/.coveragerc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@ exclude_lines =
1010
pragma: NO COVER
1111
# Ignore debug-only repr
1212
def __repr__
13-
# Ignore pkg_resources exceptions.
14-
# This is added at the module level as a safeguard for if someone
15-
# generates the code and tries to run it without pip installing. This
16-
# makes it virtually impossible to test properly.
17-
except pkg_resources.DistributionNotFound

packages/google-cloud-tpu/docs/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ API Reference
1414
tpu_v1/services
1515
tpu_v1/types
1616

17+
API Reference
18+
-------------
19+
.. toctree::
20+
:maxdepth: 2
21+
22+
tpu_v2/services
23+
tpu_v2/types
24+
1725
API Reference
1826
-------------
1927
.. toctree::
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Tpu v2 API
2+
====================================
3+
.. toctree::
4+
:maxdepth: 2
5+
6+
tpu
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Tpu
2+
---------------------
3+
4+
.. automodule:: google.cloud.tpu_v2.services.tpu
5+
:members:
6+
:inherited-members:
7+
8+
.. automodule:: google.cloud.tpu_v2.services.tpu.pagers
9+
:members:
10+
:inherited-members:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Types for Google Cloud Tpu v2 API
2+
=================================
3+
4+
.. automodule:: google.cloud.tpu_v2.types
5+
:members:
6+
:show-inheritance:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
__version__ = "1.5.2" # {x-release-please-version}

packages/google-cloud-tpu/google/cloud/tpu_v1/services/tpu/async_client.py

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
from google.api_core.client_options import ClientOptions
3535
from google.auth import credentials as ga_credentials # type: ignore
3636
from google.oauth2 import service_account # type: ignore
37-
import pkg_resources
37+
38+
from google.cloud.tpu_v1 import gapic_version as package_version
3839

3940
try:
4041
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault]
@@ -223,7 +224,7 @@ async def list_nodes(
223224
*,
224225
parent: Optional[str] = None,
225226
retry: OptionalRetry = gapic_v1.method.DEFAULT,
226-
timeout: Optional[float] = None,
227+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
227228
metadata: Sequence[Tuple[str, str]] = (),
228229
) -> pagers.ListNodesAsyncPager:
229230
r"""Lists nodes.
@@ -336,7 +337,7 @@ async def get_node(
336337
*,
337338
name: Optional[str] = None,
338339
retry: OptionalRetry = gapic_v1.method.DEFAULT,
339-
timeout: Optional[float] = None,
340+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
340341
metadata: Sequence[Tuple[str, str]] = (),
341342
) -> cloud_tpu.Node:
342343
r"""Gets the details of a node.
@@ -436,7 +437,7 @@ async def create_node(
436437
node: Optional[cloud_tpu.Node] = None,
437438
node_id: Optional[str] = None,
438439
retry: OptionalRetry = gapic_v1.method.DEFAULT,
439-
timeout: Optional[float] = None,
440+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
440441
metadata: Sequence[Tuple[str, str]] = (),
441442
) -> operation_async.AsyncOperation:
442443
r"""Creates a node.
@@ -471,7 +472,7 @@ async def sample_create_node():
471472
472473
print("Waiting for operation to complete...")
473474
474-
response = await operation.result()
475+
response = (await operation).result()
475476
476477
# Handle the response
477478
print(response)
@@ -569,7 +570,7 @@ async def delete_node(
569570
*,
570571
name: Optional[str] = None,
571572
retry: OptionalRetry = gapic_v1.method.DEFAULT,
572-
timeout: Optional[float] = None,
573+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
573574
metadata: Sequence[Tuple[str, str]] = (),
574575
) -> operation_async.AsyncOperation:
575576
r"""Deletes a node.
@@ -599,7 +600,7 @@ async def sample_delete_node():
599600
600601
print("Waiting for operation to complete...")
601602
602-
response = await operation.result()
603+
response = (await operation).result()
603604
604605
# Handle the response
605606
print(response)
@@ -682,7 +683,7 @@ async def reimage_node(
682683
request: Optional[Union[cloud_tpu.ReimageNodeRequest, dict]] = None,
683684
*,
684685
retry: OptionalRetry = gapic_v1.method.DEFAULT,
685-
timeout: Optional[float] = None,
686+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
686687
metadata: Sequence[Tuple[str, str]] = (),
687688
) -> operation_async.AsyncOperation:
688689
r"""Reimages a node's OS.
@@ -711,7 +712,7 @@ async def sample_reimage_node():
711712
712713
print("Waiting for operation to complete...")
713714
714-
response = await operation.result()
715+
response = (await operation).result()
715716
716717
# Handle the response
717718
print(response)
@@ -775,7 +776,7 @@ async def stop_node(
775776
request: Optional[Union[cloud_tpu.StopNodeRequest, dict]] = None,
776777
*,
777778
retry: OptionalRetry = gapic_v1.method.DEFAULT,
778-
timeout: Optional[float] = None,
779+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
779780
metadata: Sequence[Tuple[str, str]] = (),
780781
) -> operation_async.AsyncOperation:
781782
r"""Stops a node, this operation is only available with
@@ -805,7 +806,7 @@ async def sample_stop_node():
805806
806807
print("Waiting for operation to complete...")
807808
808-
response = await operation.result()
809+
response = (await operation).result()
809810
810811
# Handle the response
811812
print(response)
@@ -869,7 +870,7 @@ async def start_node(
869870
request: Optional[Union[cloud_tpu.StartNodeRequest, dict]] = None,
870871
*,
871872
retry: OptionalRetry = gapic_v1.method.DEFAULT,
872-
timeout: Optional[float] = None,
873+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
873874
metadata: Sequence[Tuple[str, str]] = (),
874875
) -> operation_async.AsyncOperation:
875876
r"""Starts a node.
@@ -898,7 +899,7 @@ async def sample_start_node():
898899
899900
print("Waiting for operation to complete...")
900901
901-
response = await operation.result()
902+
response = (await operation).result()
902903
903904
# Handle the response
904905
print(response)
@@ -963,7 +964,7 @@ async def list_tensor_flow_versions(
963964
*,
964965
parent: Optional[str] = None,
965966
retry: OptionalRetry = gapic_v1.method.DEFAULT,
966-
timeout: Optional[float] = None,
967+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
967968
metadata: Sequence[Tuple[str, str]] = (),
968969
) -> pagers.ListTensorFlowVersionsAsyncPager:
969970
r"""List TensorFlow versions supported by this API.
@@ -1076,7 +1077,7 @@ async def get_tensor_flow_version(
10761077
*,
10771078
name: Optional[str] = None,
10781079
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1079-
timeout: Optional[float] = None,
1080+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
10801081
metadata: Sequence[Tuple[str, str]] = (),
10811082
) -> cloud_tpu.TensorFlowVersion:
10821083
r"""Gets TensorFlow Version.
@@ -1176,7 +1177,7 @@ async def list_accelerator_types(
11761177
*,
11771178
parent: Optional[str] = None,
11781179
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1179-
timeout: Optional[float] = None,
1180+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
11801181
metadata: Sequence[Tuple[str, str]] = (),
11811182
) -> pagers.ListAcceleratorTypesAsyncPager:
11821183
r"""Lists accelerator types supported by this API.
@@ -1289,7 +1290,7 @@ async def get_accelerator_type(
12891290
*,
12901291
name: Optional[str] = None,
12911292
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1292-
timeout: Optional[float] = None,
1293+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
12931294
metadata: Sequence[Tuple[str, str]] = (),
12941295
) -> cloud_tpu.AcceleratorType:
12951296
r"""Gets AcceleratorType.
@@ -1388,7 +1389,7 @@ async def list_operations(
13881389
request: Optional[operations_pb2.ListOperationsRequest] = None,
13891390
*,
13901391
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1391-
timeout: Optional[float] = None,
1392+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
13921393
metadata: Sequence[Tuple[str, str]] = (),
13931394
) -> operations_pb2.ListOperationsResponse:
13941395
r"""Lists operations that match the specified filter in the request.
@@ -1442,7 +1443,7 @@ async def get_operation(
14421443
request: Optional[operations_pb2.GetOperationRequest] = None,
14431444
*,
14441445
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1445-
timeout: Optional[float] = None,
1446+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
14461447
metadata: Sequence[Tuple[str, str]] = (),
14471448
) -> operations_pb2.Operation:
14481449
r"""Gets the latest state of a long-running operation.
@@ -1496,7 +1497,7 @@ async def delete_operation(
14961497
request: Optional[operations_pb2.DeleteOperationRequest] = None,
14971498
*,
14981499
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1499-
timeout: Optional[float] = None,
1500+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
15001501
metadata: Sequence[Tuple[str, str]] = (),
15011502
) -> None:
15021503
r"""Deletes a long-running operation.
@@ -1551,7 +1552,7 @@ async def cancel_operation(
15511552
request: Optional[operations_pb2.CancelOperationRequest] = None,
15521553
*,
15531554
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1554-
timeout: Optional[float] = None,
1555+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
15551556
metadata: Sequence[Tuple[str, str]] = (),
15561557
) -> None:
15571558
r"""Starts asynchronous cancellation on a long-running operation.
@@ -1605,7 +1606,7 @@ async def get_location(
16051606
request: Optional[locations_pb2.GetLocationRequest] = None,
16061607
*,
16071608
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1608-
timeout: Optional[float] = None,
1609+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
16091610
metadata: Sequence[Tuple[str, str]] = (),
16101611
) -> locations_pb2.Location:
16111612
r"""Gets information about a location.
@@ -1659,7 +1660,7 @@ async def list_locations(
16591660
request: Optional[locations_pb2.ListLocationsRequest] = None,
16601661
*,
16611662
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1662-
timeout: Optional[float] = None,
1663+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
16631664
metadata: Sequence[Tuple[str, str]] = (),
16641665
) -> locations_pb2.ListLocationsResponse:
16651666
r"""Lists information about the supported locations for this service.
@@ -1715,14 +1716,9 @@ async def __aexit__(self, exc_type, exc, tb):
17151716
await self.transport.close()
17161717

17171718

1718-
try:
1719-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1720-
gapic_version=pkg_resources.get_distribution(
1721-
"google-cloud-tpu",
1722-
).version,
1723-
)
1724-
except pkg_resources.DistributionNotFound:
1725-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
1719+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
1720+
gapic_version=package_version.__version__
1721+
)
17261722

17271723

17281724
__all__ = ("TpuAsyncClient",)

0 commit comments

Comments
 (0)