From 29d10b977f4e03ba8cc5e16e545e337f6b7b0c29 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 7 Aug 2020 15:30:23 -0700 Subject: [PATCH 1/4] chore: applies new samples README template --- samples/snippets/hybrid_glossaries/README.rst | 23 +++++++++++++++---- synth.metadata | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/samples/snippets/hybrid_glossaries/README.rst b/samples/snippets/hybrid_glossaries/README.rst index 61fdc27f..e68b8114 100644 --- a/samples/snippets/hybrid_glossaries/README.rst +++ b/samples/snippets/hybrid_glossaries/README.rst @@ -1,3 +1,4 @@ + .. This file is automatically generated. Do not edit this file directly. Google Translation API Python Samples @@ -15,13 +16,11 @@ This directory contains samples for Google Translation API. With `Google Transla .. _Google Translation API: https://cloud.google.com/translate/docs - - - Setup ------------------------------------------------------------------------------- + Authentication ++++++++++++++ @@ -32,6 +31,9 @@ credentials for applications. .. _Authentication Getting Started Guide: https://cloud.google.com/docs/authentication/getting-started + + + Install Dependencies ++++++++++++++++++++ @@ -46,7 +48,7 @@ Install Dependencies .. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. +#. Create a virtualenv. Samples are compatible with Python 3.6+. .. code-block:: bash @@ -62,9 +64,15 @@ Install Dependencies .. _pip: https://pip.pypa.io/ .. _virtualenv: https://virtualenv.pypa.io/ + + + + + Samples ------------------------------------------------------------------------------- + Using glossaries with vision and text-to-speech +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -83,6 +91,10 @@ To run this sample: + + + + The client library ------------------------------------------------------------------------------- @@ -98,4 +110,5 @@ to `browse the source`_ and `report issues`_. https://github.com/GoogleCloudPlatform/google-cloud-python/issues -.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file + +.. _Google Cloud SDK: https://cloud.google.com/sdk/ diff --git a/synth.metadata b/synth.metadata index 9674f5cc..21dd9dcf 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-translate.git", - "sha": "e5182377b07c376a78b9e6c9ca71fa64dc82bd3e" + "sha": "3758c8fc27e7ef052e215c720c5d64a8cb349bf1" } }, { From 2a80f87c6ff441fb81161db8cda1049aa6851cc4 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 8 Aug 2020 00:38:03 +0200 Subject: [PATCH 2/4] chore(deps): update dependency google-cloud-translate to v3 (#37) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Update | Change | |---|---|---| | [google-cloud-translate](https://togithub.com/googleapis/python-translate) | major | `==2.0.1` -> `==3.0.0` | --- ### Release Notes
googleapis/python-translate ### [`v3.0.0`](https://togithub.com/googleapis/python-translate/blob/master/CHANGELOG.md#​300-httpswwwgithubcomgoogleapispython-translatecomparev202v300-2020-08-05) [Compare Source](https://togithub.com/googleapis/python-translate/compare/v2.0.2...v3.0.0) ##### ⚠ BREAKING CHANGES - migrate API to microgenerator ([#​31](https://togithub.com/googleapis/python-translate/issues/31)) ##### Features - migrate API to microgenerator ([#​31](https://www.github.com/googleapis/python-translate/issues/31)) ([1c5b6e8](https://www.github.com/googleapis/python-translate/commit/1c5b6e89a0a3b55c41c909e4ee27e0bd23e4b579)) ##### [2.0.2](https://www.github.com/googleapis/python-translate/compare/v2.0.1...v2.0.2) (2020-08-03) ##### Bug Fixes - refactored MP3 file creation test for Hybrid glossaries samples [(\[#​2379\](https://www.github.com/googleapis/python-translate/issues/2379))](https://togithub.com/GoogleCloudPlatform/python-docs-samples/issues/2379) ([b8b5101](https://www.github.com/googleapis/python-translate/commit/b8b5101be28d0d0d17a4d688eea81af6754a394c)) - translate test [(\[#​2671\](https://www.github.com/googleapis/python-translate/issues/2671))](https://togithub.com/GoogleCloudPlatform/python-docs-samples/issues/2671) ([a3d9f80](https://www.github.com/googleapis/python-translate/commit/a3d9f804576caeb4fdcdbbd4479caeb926efd8d0)) - update default retry config ([#​15](https://www.github.com/googleapis/python-translate/issues/15)) ([dddf0bf](https://www.github.com/googleapis/python-translate/commit/dddf0bf33463968932031cc0be5bc8a0d4a96455)) ##### [2.0.1](https://www.github.com/googleapis/python-translate/compare/v2.0.0...v2.0.1) (2020-01-31) ##### Bug Fixes - **translate:** add py2 deprecation warning; bump copyright year to 2020; add 3.8 unit tests (via synth) ([#​9943](https://www.github.com/googleapis/python-translate/issues/9943)) ([b57f09a](https://www.github.com/googleapis/python-translate/commit/b57f09a5f804daca1a96918a29746f24ae7bc4a5)) - **translate:** update test assertion and core version pins ([#​10098](https://www.github.com/googleapis/python-translate/issues/10098)) ([74b7757](https://www.github.com/googleapis/python-translate/commit/74b77579a1770c743353bdafde3e1744cbbe7842)) ### [`v2.0.2`](https://togithub.com/googleapis/python-translate/blob/master/CHANGELOG.md#​202-httpswwwgithubcomgoogleapispython-translatecomparev201v202-2020-08-03) [Compare Source](https://togithub.com/googleapis/python-translate/compare/v2.0.1...v2.0.2)
--- ### Renovate configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#googleapis/python-translate). --- samples/snippets/hybrid_glossaries/requirements.txt | 2 +- samples/snippets/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/snippets/hybrid_glossaries/requirements.txt b/samples/snippets/hybrid_glossaries/requirements.txt index cc7f4187..af2fa067 100644 --- a/samples/snippets/hybrid_glossaries/requirements.txt +++ b/samples/snippets/hybrid_glossaries/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-translate==2.0.1 +google-cloud-translate==3.0.0 google-cloud-vision==1.0.0 google-cloud-texttospeech==2.1.0 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 1a58bd9b..4c26010b 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-translate==2.0.1 +google-cloud-translate==3.0.0 google-cloud-storage==1.30.0 From a334317bc34b8927adfbc4a2559dbb71ee22c78d Mon Sep 17 00:00:00 2001 From: Dan O'Meara Date: Fri, 7 Aug 2020 19:25:39 -0700 Subject: [PATCH 3/4] 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 --- .coveragerc | 5 ++ docs/translate_v3/services.rst | 4 +- docs/translate_v3/types.rst | 4 +- docs/translate_v3beta1/services.rst | 4 +- docs/translate_v3beta1/types.rst | 4 +- google/cloud/translate/py.typed | 2 +- google/cloud/translate_v3/py.typed | 2 +- .../translation_service/async_client.py | 52 +++++++++++++---- .../services/translation_service/client.py | 4 +- .../translation_service/transports/base.py | 58 +++++++++++++++---- google/cloud/translate_v3beta1/py.typed | 2 +- .../translation_service/async_client.py | 52 +++++++++++++---- .../services/translation_service/client.py | 4 +- .../translation_service/transports/base.py | 58 +++++++++++++++---- ...ords.py => fixup_translate_v3_keywords.py} | 6 +- ...py => fixup_translate_v3beta1_keywords.py} | 6 +- setup.py | 4 +- synth.metadata | 20 ++----- synth.py | 25 +------- 19 files changed, 211 insertions(+), 105 deletions(-) rename scripts/{fixup_translation_v3_keywords.py => fixup_translate_v3_keywords.py} (97%) rename scripts/{fixup_translation_v3beta1_keywords.py => fixup_translate_v3beta1_keywords.py} (97%) diff --git a/.coveragerc b/.coveragerc index b6b6f7b3..d9205f04 100644 --- a/.coveragerc +++ b/.coveragerc @@ -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 diff --git a/docs/translate_v3/services.rst b/docs/translate_v3/services.rst index 8400587e..ce46a05d 100644 --- a/docs/translate_v3/services.rst +++ b/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: diff --git a/docs/translate_v3/types.rst b/docs/translate_v3/types.rst index a126067f..f84d4f23 100644 --- a/docs/translate_v3/types.rst +++ b/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: diff --git a/docs/translate_v3beta1/services.rst b/docs/translate_v3beta1/services.rst index eb522c99..4fc95083 100644 --- a/docs/translate_v3beta1/services.rst +++ b/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: diff --git a/docs/translate_v3beta1/types.rst b/docs/translate_v3beta1/types.rst index aaf04973..32f1a720 100644 --- a/docs/translate_v3beta1/types.rst +++ b/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: diff --git a/google/cloud/translate/py.typed b/google/cloud/translate/py.typed index dd819a47..39eb1d6c 100644 --- a/google/cloud/translate/py.typed +++ b/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. diff --git a/google/cloud/translate_v3/py.typed b/google/cloud/translate_v3/py.typed index dd819a47..39eb1d6c 100644 --- a/google/cloud/translate_v3/py.typed +++ b/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. diff --git a/google/cloud/translate_v3/services/translation_service/async_client.py b/google/cloud/translate_v3/services/translation_service/async_client.py index 66552ce7..9cb9b9d8 100644 --- a/google/cloud/translate_v3/services/translation_service/async_client.py +++ b/google/cloud/translate_v3/services/translation_service/async_client.py @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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() diff --git a/google/cloud/translate_v3/services/translation_service/client.py b/google/cloud/translate_v3/services/translation_service/client.py index 097743cb..d00cd12d 100644 --- a/google/cloud/translate_v3/services/translation_service/client.py +++ b/google/cloud/translate_v3/services/translation_service/client.py @@ -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() diff --git a/google/cloud/translate_v3/services/translation_service/transports/base.py b/google/cloud/translate_v3/services/translation_service/transports/base.py index d32c016c..ad022171 100644 --- a/google/cloud/translate_v3/services/translation_service/transports/base.py +++ b/google/cloud/translate_v3/services/translation_service/transports/base.py @@ -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() @@ -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, ), } diff --git a/google/cloud/translate_v3beta1/py.typed b/google/cloud/translate_v3beta1/py.typed index dd819a47..39eb1d6c 100644 --- a/google/cloud/translate_v3beta1/py.typed +++ b/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. diff --git a/google/cloud/translate_v3beta1/services/translation_service/async_client.py b/google/cloud/translate_v3beta1/services/translation_service/async_client.py index c7908f2b..fe0e508b 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/async_client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/async_client.py @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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, ) @@ -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() diff --git a/google/cloud/translate_v3beta1/services/translation_service/client.py b/google/cloud/translate_v3beta1/services/translation_service/client.py index b4efa659..6d991415 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/client.py +++ b/google/cloud/translate_v3beta1/services/translation_service/client.py @@ -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() diff --git a/google/cloud/translate_v3beta1/services/translation_service/transports/base.py b/google/cloud/translate_v3beta1/services/translation_service/transports/base.py index 35c84f1c..b532a056 100644 --- a/google/cloud/translate_v3beta1/services/translation_service/transports/base.py +++ b/google/cloud/translate_v3beta1/services/translation_service/transports/base.py @@ -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() @@ -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, ), } diff --git a/scripts/fixup_translation_v3_keywords.py b/scripts/fixup_translate_v3_keywords.py similarity index 97% rename from scripts/fixup_translation_v3_keywords.py rename to scripts/fixup_translate_v3_keywords.py index 60b6c6d3..0f8aaa48 100644 --- a/scripts/fixup_translation_v3_keywords.py +++ b/scripts/fixup_translate_v3_keywords.py @@ -37,7 +37,7 @@ def partition( return results[1], results[0] -class translationCallTransformer(cst.CSTTransformer): +class translateCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'batch_translate_text': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'labels', ), @@ -97,7 +97,7 @@ def fix_files( in_dir: pathlib.Path, out_dir: pathlib.Path, *, - transformer=translationCallTransformer(), + transformer=translateCallTransformer(), ): """Duplicate the input dir to the output dir, fixing file method calls. @@ -130,7 +130,7 @@ def fix_files( if __name__ == '__main__': parser = argparse.ArgumentParser( - description="""Fix up source that uses the translation client library. + description="""Fix up source that uses the translate client library. The existing sources are NOT overwritten but are copied to output_dir with changes made. diff --git a/scripts/fixup_translation_v3beta1_keywords.py b/scripts/fixup_translate_v3beta1_keywords.py similarity index 97% rename from scripts/fixup_translation_v3beta1_keywords.py rename to scripts/fixup_translate_v3beta1_keywords.py index 60b6c6d3..0f8aaa48 100644 --- a/scripts/fixup_translation_v3beta1_keywords.py +++ b/scripts/fixup_translate_v3beta1_keywords.py @@ -37,7 +37,7 @@ def partition( return results[1], results[0] -class translationCallTransformer(cst.CSTTransformer): +class translateCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'batch_translate_text': ('parent', 'source_language_code', 'target_language_codes', 'input_configs', 'output_config', 'models', 'glossaries', 'labels', ), @@ -97,7 +97,7 @@ def fix_files( in_dir: pathlib.Path, out_dir: pathlib.Path, *, - transformer=translationCallTransformer(), + transformer=translateCallTransformer(), ): """Duplicate the input dir to the output dir, fixing file method calls. @@ -130,7 +130,7 @@ def fix_files( if __name__ == '__main__': parser = argparse.ArgumentParser( - description="""Fix up source that uses the translation client library. + description="""Fix up source that uses the translate client library. The existing sources are NOT overwritten but are copied to output_dir with changes made. diff --git a/setup.py b/setup.py index 59edcb15..1df70c1a 100644 --- a/setup.py +++ b/setup.py @@ -83,8 +83,8 @@ platforms="Posix; MacOS X; Windows", packages=packages, scripts=[ - "scripts/fixup_translation_v3_keywords.py", - "scripts/fixup_translation_v3beta1_keywords.py", + "scripts/fixup_translate_v3_keywords.py", + "scripts/fixup_translate_v3beta1_keywords.py", ], namespace_packages=namespaces, install_requires=dependencies, diff --git a/synth.metadata b/synth.metadata index 21dd9dcf..32b3b56a 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,30 +3,22 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/python-translate.git", - "sha": "3758c8fc27e7ef052e215c720c5d64a8cb349bf1" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "868615a5c1c1059c636bb3d82a555edb1d5a251e", - "internalRef": "324294521" + "remote": "git@github.com:danoscarmike/python-translate", + "sha": "2a80f87c6ff441fb81161db8cda1049aa6851cc4" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "4f8f5dc24af79694887385015294e4dbb214c352" + "sha": "5f2f711c91199ba2f609d3f06a2fe22aee4e5be3" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "4f8f5dc24af79694887385015294e4dbb214c352" + "sha": "5f2f711c91199ba2f609d3f06a2fe22aee4e5be3" } } ], @@ -37,7 +29,7 @@ "apiName": "translate", "apiVersion": "v3beta1", "language": "python", - "generator": "gapic-generator-python" + "generator": "bazel" } }, { @@ -46,7 +38,7 @@ "apiName": "translate", "apiVersion": "v3", "language": "python", - "generator": "gapic-generator-python" + "generator": "bazel" } } ] diff --git a/synth.py b/synth.py index df2a8a73..8ca9bf33 100644 --- a/synth.py +++ b/synth.py @@ -18,7 +18,7 @@ from synthtool import gcp from synthtool.languages import python -gapic = gcp.GAPICMicrogenerator() +gapic = gcp.GAPICBazel() common = gcp.CommonTemplates() versions = ["v3beta1", "v3"] @@ -38,22 +38,9 @@ library = gapic.py_library( service="translate", version=version, - proto_path=f"google/cloud/translate/{version}" + bazel_target=f"//google/cloud/translate/{version}:translation-{version}-py", ) - - s.move(library / "google/cloud/translation", "google/cloud/translate") - s.move(library / f"google/cloud/translation_{version}", f"google/cloud/translate_{version}") - s.move(library / f"docs/translation_{version}", f"docs/translate_{version}") - s.move(library / f"tests/unit/gapic/translation_{version}", f"tests/unit/gapic/translate_{version}") - s.move(library / "scripts") - -# google.cloud.translation -> google.cloud.translate -s.replace( - ["google/cloud/translate*/**/*.py", "docs/translate_v*/*"], - " google.cloud.translation", - " google.cloud.translate" -) -s.replace("tests/**/*.py", "google.cloud.translation", "google.cloud.translate") + s.move(library, excludes=excludes) # TODO(danoscarmike): remove once upstream protos have been fixed # Escape underscores in gs:\\ URLs @@ -81,10 +68,4 @@ python.py_samples() -# ---------------------------------------------------------------------------- -# Samples templates -# ---------------------------------------------------------------------------- - -python.py_samples() - s.shell.run(["nox", "-s", "blacken"], hide_output=False) From bb3720baab0df993409198bb263747d891cf6b33 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2020 09:19:49 -0700 Subject: [PATCH 4/4] chore: release 3.0.1 (#41) * chore: updated CHANGELOG.md [ci skip] * chore: updated setup.cfg [ci skip] * chore: updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ setup.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e29a3056..11aa7cfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-translate/#history +### [3.0.1](https://www.github.com/googleapis/python-translate/compare/v3.0.0...v3.0.1) (2020-08-08) + + +### Bug Fixes + +* update retry and timeout config ([#39](https://www.github.com/googleapis/python-translate/issues/39)) ([a334317](https://www.github.com/googleapis/python-translate/commit/a334317bc34b8927adfbc4a2559dbb71ee22c78d)) + ## [3.0.0](https://www.github.com/googleapis/python-translate/compare/v2.0.2...v3.0.0) (2020-08-05) diff --git a/setup.py b/setup.py index 1df70c1a..047a6707 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-translate" description = "Google Cloud Translation API client library" -version = "3.0.0" +version = "3.0.1" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'