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

Commit

Permalink
fix: update retry and timeout config (#39)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
danoscarmike committed Aug 8, 2020
1 parent 2a80f87 commit a334317
Show file tree
Hide file tree
Showing 19 changed files with 211 additions and 105 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Expand Up @@ -28,6 +28,11 @@ exclude_lines =
def __repr__
# Ignore abstract methods
raise NotImplementedError
# 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
omit =
*/gapic/*.py
*/proto/*.py
Expand Down
4 changes: 2 additions & 2 deletions docs/translate_v3/services.rst
@@ -1,5 +1,5 @@
Services for Google Cloud Translation v3 API
============================================
Services for Google Cloud Translate v3 API
==========================================

.. automodule:: google.cloud.translate_v3.services.translation_service
:members:
Expand Down
4 changes: 2 additions & 2 deletions docs/translate_v3/types.rst
@@ -1,5 +1,5 @@
Types for Google Cloud Translation v3 API
=========================================
Types for Google Cloud Translate v3 API
=======================================

.. automodule:: google.cloud.translate_v3.types
:members:
4 changes: 2 additions & 2 deletions docs/translate_v3beta1/services.rst
@@ -1,5 +1,5 @@
Services for Google Cloud Translation v3beta1 API
=================================================
Services for Google Cloud Translate v3beta1 API
===============================================

.. automodule:: google.cloud.translate_v3beta1.services.translation_service
:members:
Expand Down
4 changes: 2 additions & 2 deletions docs/translate_v3beta1/types.rst
@@ -1,5 +1,5 @@
Types for Google Cloud Translation v3beta1 API
==============================================
Types for Google Cloud Translate v3beta1 API
============================================

.. automodule:: google.cloud.translate_v3beta1.types
:members:
2 changes: 1 addition & 1 deletion google/cloud/translate/py.typed
@@ -1,2 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-translation package uses inline types.
# The google-cloud-translate package uses inline types.
2 changes: 1 addition & 1 deletion google/cloud/translate_v3/py.typed
@@ -1,2 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-translation package uses inline types.
# The google-cloud-translate package uses inline types.
Expand Up @@ -247,7 +247,7 @@ async def translate_text(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.translate_text,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -367,7 +367,7 @@ async def detect_language(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.detect_language,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -485,7 +485,15 @@ async def get_supported_languages(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_supported_languages,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -549,7 +557,7 @@ async def batch_translate_text(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.batch_translate_text,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -638,7 +646,7 @@ async def create_glossary(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.create_glossary,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -720,7 +728,15 @@ async def list_glossaries(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_glossaries,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -797,7 +813,15 @@ async def get_glossary(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_glossary,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -874,7 +898,15 @@ async def delete_glossary(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.delete_glossary,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

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

try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-translation",
).version,
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
Expand Down
Expand Up @@ -1057,9 +1057,7 @@ def delete_glossary(

try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-translation",
).version,
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
Expand Down
Expand Up @@ -32,9 +32,7 @@

try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-translation",
).version,
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
Expand Down Expand Up @@ -106,32 +104,70 @@ def _prep_wrapped_messages(self):
# Precompute the wrapped methods.
self._wrapped_methods = {
self.translate_text: gapic_v1.method.wrap_method(
self.translate_text, default_timeout=None, client_info=_client_info,
self.translate_text, default_timeout=600.0, client_info=_client_info,
),
self.detect_language: gapic_v1.method.wrap_method(
self.detect_language, default_timeout=None, client_info=_client_info,
self.detect_language, default_timeout=600.0, client_info=_client_info,
),
self.get_supported_languages: gapic_v1.method.wrap_method(
self.get_supported_languages,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
),
self.batch_translate_text: gapic_v1.method.wrap_method(
self.batch_translate_text,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
),
self.create_glossary: gapic_v1.method.wrap_method(
self.create_glossary, default_timeout=None, client_info=_client_info,
self.create_glossary, default_timeout=600.0, client_info=_client_info,
),
self.list_glossaries: gapic_v1.method.wrap_method(
self.list_glossaries, default_timeout=None, client_info=_client_info,
self.list_glossaries,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
),
self.get_glossary: gapic_v1.method.wrap_method(
self.get_glossary, default_timeout=None, client_info=_client_info,
self.get_glossary,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
),
self.delete_glossary: gapic_v1.method.wrap_method(
self.delete_glossary, default_timeout=None, client_info=_client_info,
self.delete_glossary,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
),
}

Expand Down
2 changes: 1 addition & 1 deletion google/cloud/translate_v3beta1/py.typed
@@ -1,2 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-translation package uses inline types.
# The google-cloud-translate package uses inline types.
Expand Up @@ -131,7 +131,7 @@ async def translate_text(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.translate_text,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -242,7 +242,7 @@ async def detect_language(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.detect_language,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -360,7 +360,15 @@ async def get_supported_languages(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_supported_languages,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -424,7 +432,7 @@ async def batch_translate_text(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.batch_translate_text,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -513,7 +521,7 @@ async def create_glossary(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.create_glossary,
default_timeout=None,
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -607,7 +615,15 @@ async def list_glossaries(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_glossaries,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -684,7 +700,15 @@ async def get_glossary(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_glossary,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

Expand Down Expand Up @@ -761,7 +785,15 @@ async def delete_glossary(
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.delete_glossary,
default_timeout=None,
default_retry=retries.Retry(
initial=0.1,
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
),
),
default_timeout=600.0,
client_info=_client_info,
)

Expand All @@ -788,9 +820,7 @@ async def delete_glossary(

try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-translation",
).version,
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
Expand Down
Expand Up @@ -943,9 +943,7 @@ def delete_glossary(

try:
_client_info = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-translation",
).version,
gapic_version=pkg_resources.get_distribution("google-cloud-translate",).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
Expand Down

0 comments on commit a334317

Please sign in to comment.