Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit a334317

Browse files
authored
fix: update retry and timeout config (#39)
* feat: regenerate library using Bazel adds additional module name overrides sets default timeout and retry config in base * chore: corrects module name in setup.py
1 parent 2a80f87 commit a334317

File tree

19 files changed

+211
-105
lines changed

19 files changed

+211
-105
lines changed

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ exclude_lines =
2828
def __repr__
2929
# Ignore abstract methods
3030
raise NotImplementedError
31+
# Ignore pkg_resources exceptions.
32+
# This is added at the module level as a safeguard for if someone
33+
# generates the code and tries to run it without pip installing. This
34+
# makes it virtually impossible to test properly.
35+
except pkg_resources.DistributionNotFound
3136
omit =
3237
*/gapic/*.py
3338
*/proto/*.py

docs/translate_v3/services.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Services for Google Cloud Translation v3 API
2-
============================================
1+
Services for Google Cloud Translate v3 API
2+
==========================================
33

44
.. automodule:: google.cloud.translate_v3.services.translation_service
55
:members:

docs/translate_v3/types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Types for Google Cloud Translation v3 API
2-
=========================================
1+
Types for Google Cloud Translate v3 API
2+
=======================================
33

44
.. automodule:: google.cloud.translate_v3.types
55
:members:

docs/translate_v3beta1/services.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Services for Google Cloud Translation v3beta1 API
2-
=================================================
1+
Services for Google Cloud Translate v3beta1 API
2+
===============================================
33

44
.. automodule:: google.cloud.translate_v3beta1.services.translation_service
55
:members:

docs/translate_v3beta1/types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Types for Google Cloud Translation v3beta1 API
2-
==============================================
1+
Types for Google Cloud Translate v3beta1 API
2+
============================================
33

44
.. automodule:: google.cloud.translate_v3beta1.types
55
:members:

google/cloud/translate/py.typed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Marker file for PEP 561.
2-
# The google-cloud-translation package uses inline types.
2+
# The google-cloud-translate package uses inline types.

google/cloud/translate_v3/py.typed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Marker file for PEP 561.
2-
# The google-cloud-translation package uses inline types.
2+
# The google-cloud-translate package uses inline types.

google/cloud/translate_v3/services/translation_service/async_client.py

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ async def translate_text(
247247
# and friendly error handling.
248248
rpc = gapic_v1.method_async.wrap_method(
249249
self._client._transport.translate_text,
250-
default_timeout=None,
250+
default_timeout=600.0,
251251
client_info=_client_info,
252252
)
253253

@@ -367,7 +367,7 @@ async def detect_language(
367367
# and friendly error handling.
368368
rpc = gapic_v1.method_async.wrap_method(
369369
self._client._transport.detect_language,
370-
default_timeout=None,
370+
default_timeout=600.0,
371371
client_info=_client_info,
372372
)
373373

@@ -485,7 +485,15 @@ async def get_supported_languages(
485485
# and friendly error handling.
486486
rpc = gapic_v1.method_async.wrap_method(
487487
self._client._transport.get_supported_languages,
488-
default_timeout=None,
488+
default_retry=retries.Retry(
489+
initial=0.1,
490+
maximum=60.0,
491+
multiplier=1.3,
492+
predicate=retries.if_exception_type(
493+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
494+
),
495+
),
496+
default_timeout=600.0,
489497
client_info=_client_info,
490498
)
491499

@@ -549,7 +557,7 @@ async def batch_translate_text(
549557
# and friendly error handling.
550558
rpc = gapic_v1.method_async.wrap_method(
551559
self._client._transport.batch_translate_text,
552-
default_timeout=None,
560+
default_timeout=600.0,
553561
client_info=_client_info,
554562
)
555563

@@ -638,7 +646,7 @@ async def create_glossary(
638646
# and friendly error handling.
639647
rpc = gapic_v1.method_async.wrap_method(
640648
self._client._transport.create_glossary,
641-
default_timeout=None,
649+
default_timeout=600.0,
642650
client_info=_client_info,
643651
)
644652

@@ -720,7 +728,15 @@ async def list_glossaries(
720728
# and friendly error handling.
721729
rpc = gapic_v1.method_async.wrap_method(
722730
self._client._transport.list_glossaries,
723-
default_timeout=None,
731+
default_retry=retries.Retry(
732+
initial=0.1,
733+
maximum=60.0,
734+
multiplier=1.3,
735+
predicate=retries.if_exception_type(
736+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
737+
),
738+
),
739+
default_timeout=600.0,
724740
client_info=_client_info,
725741
)
726742

@@ -797,7 +813,15 @@ async def get_glossary(
797813
# and friendly error handling.
798814
rpc = gapic_v1.method_async.wrap_method(
799815
self._client._transport.get_glossary,
800-
default_timeout=None,
816+
default_retry=retries.Retry(
817+
initial=0.1,
818+
maximum=60.0,
819+
multiplier=1.3,
820+
predicate=retries.if_exception_type(
821+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
822+
),
823+
),
824+
default_timeout=600.0,
801825
client_info=_client_info,
802826
)
803827

@@ -874,7 +898,15 @@ async def delete_glossary(
874898
# and friendly error handling.
875899
rpc = gapic_v1.method_async.wrap_method(
876900
self._client._transport.delete_glossary,
877-
default_timeout=None,
901+
default_retry=retries.Retry(
902+
initial=0.1,
903+
maximum=60.0,
904+
multiplier=1.3,
905+
predicate=retries.if_exception_type(
906+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
907+
),
908+
),
909+
default_timeout=600.0,
878910
client_info=_client_info,
879911
)
880912

@@ -901,9 +933,7 @@ async def delete_glossary(
901933

902934
try:
903935
_client_info = gapic_v1.client_info.ClientInfo(
904-
gapic_version=pkg_resources.get_distribution(
905-
"google-cloud-translation",
906-
).version,
936+
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
907937
)
908938
except pkg_resources.DistributionNotFound:
909939
_client_info = gapic_v1.client_info.ClientInfo()

google/cloud/translate_v3/services/translation_service/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,7 @@ def delete_glossary(
10571057

10581058
try:
10591059
_client_info = gapic_v1.client_info.ClientInfo(
1060-
gapic_version=pkg_resources.get_distribution(
1061-
"google-cloud-translation",
1062-
).version,
1060+
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
10631061
)
10641062
except pkg_resources.DistributionNotFound:
10651063
_client_info = gapic_v1.client_info.ClientInfo()

google/cloud/translate_v3/services/translation_service/transports/base.py

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232

3333
try:
3434
_client_info = gapic_v1.client_info.ClientInfo(
35-
gapic_version=pkg_resources.get_distribution(
36-
"google-cloud-translation",
37-
).version,
35+
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
3836
)
3937
except pkg_resources.DistributionNotFound:
4038
_client_info = gapic_v1.client_info.ClientInfo()
@@ -106,32 +104,70 @@ def _prep_wrapped_messages(self):
106104
# Precompute the wrapped methods.
107105
self._wrapped_methods = {
108106
self.translate_text: gapic_v1.method.wrap_method(
109-
self.translate_text, default_timeout=None, client_info=_client_info,
107+
self.translate_text, default_timeout=600.0, client_info=_client_info,
110108
),
111109
self.detect_language: gapic_v1.method.wrap_method(
112-
self.detect_language, default_timeout=None, client_info=_client_info,
110+
self.detect_language, default_timeout=600.0, client_info=_client_info,
113111
),
114112
self.get_supported_languages: gapic_v1.method.wrap_method(
115113
self.get_supported_languages,
116-
default_timeout=None,
114+
default_retry=retries.Retry(
115+
initial=0.1,
116+
maximum=60.0,
117+
multiplier=1.3,
118+
predicate=retries.if_exception_type(
119+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
120+
),
121+
),
122+
default_timeout=600.0,
117123
client_info=_client_info,
118124
),
119125
self.batch_translate_text: gapic_v1.method.wrap_method(
120126
self.batch_translate_text,
121-
default_timeout=None,
127+
default_timeout=600.0,
122128
client_info=_client_info,
123129
),
124130
self.create_glossary: gapic_v1.method.wrap_method(
125-
self.create_glossary, default_timeout=None, client_info=_client_info,
131+
self.create_glossary, default_timeout=600.0, client_info=_client_info,
126132
),
127133
self.list_glossaries: gapic_v1.method.wrap_method(
128-
self.list_glossaries, default_timeout=None, client_info=_client_info,
134+
self.list_glossaries,
135+
default_retry=retries.Retry(
136+
initial=0.1,
137+
maximum=60.0,
138+
multiplier=1.3,
139+
predicate=retries.if_exception_type(
140+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
141+
),
142+
),
143+
default_timeout=600.0,
144+
client_info=_client_info,
129145
),
130146
self.get_glossary: gapic_v1.method.wrap_method(
131-
self.get_glossary, default_timeout=None, client_info=_client_info,
147+
self.get_glossary,
148+
default_retry=retries.Retry(
149+
initial=0.1,
150+
maximum=60.0,
151+
multiplier=1.3,
152+
predicate=retries.if_exception_type(
153+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
154+
),
155+
),
156+
default_timeout=600.0,
157+
client_info=_client_info,
132158
),
133159
self.delete_glossary: gapic_v1.method.wrap_method(
134-
self.delete_glossary, default_timeout=None, client_info=_client_info,
160+
self.delete_glossary,
161+
default_retry=retries.Retry(
162+
initial=0.1,
163+
maximum=60.0,
164+
multiplier=1.3,
165+
predicate=retries.if_exception_type(
166+
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
167+
),
168+
),
169+
default_timeout=600.0,
170+
client_info=_client_info,
135171
),
136172
}
137173

0 commit comments

Comments
 (0)