From f1d08c57fc17d0bd0015eb7a8dfd96ee8352d35a Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 18 Oct 2019 15:55:06 -0700 Subject: [PATCH 1/2] feat(translate)!: make translate_v3 the default client --- translate/google/cloud/translate.py | 19 ++++++++----------- translate/synth.metadata | 10 +++++----- translate/synth.py | 3 +++ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/translate/google/cloud/translate.py b/translate/google/cloud/translate.py index 947f8c8ae093..27d23f137628 100644 --- a/translate/google/cloud/translate.py +++ b/translate/google/cloud/translate.py @@ -1,10 +1,12 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2019 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 +# https://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, @@ -12,16 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Google Cloud Translation API wrapper.""" - -from google.cloud.translate_v2 import __version__ -from google.cloud.translate_v2.client import Client +from __future__ import absolute_import -# These constants are essentially deprecated; strings should be used instead. -# They are imported here for backwards compatibility. -from google.cloud.translate_v2.client import BASE -from google.cloud.translate_v2.client import NMT +from google.cloud.translate_v3 import TranslationServiceClient +from google.cloud.translate_v3 import types -__all__ = ("__version__", "BASE", "Client", "NMT") +__all__ = ("types", "TranslationServiceClient") diff --git a/translate/synth.metadata b/translate/synth.metadata index fe995d41d4d1..6c4de912fede 100644 --- a/translate/synth.metadata +++ b/translate/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-10-05T12:42:06.391804Z", + "updateTime": "2019-10-18T22:49:41.466785Z", "sources": [ { "generator": { "name": "artman", - "version": "0.38.0", - "dockerImage": "googleapis/artman@sha256:0d2f8d429110aeb8d82df6550ef4ede59d40df9062d260a1580fce688b0512bf" + "version": "0.40.0", + "dockerImage": "googleapis/artman@sha256:fd2b49cce3d652929cc80157ec2d91bebe993f7cd4e89afaad80f9c785f8bf36" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "ceb8e2fb12f048cc94caae532ef0b4cf026a78f3", - "internalRef": "272971705" + "sha": "0e9a6d15fcb944ed40921ba0aad2082ee1bc7edd", + "internalRef": "275543900" } }, { diff --git a/translate/synth.py b/translate/synth.py index f9f3dbc9ecc7..14a2ad464c37 100644 --- a/translate/synth.py +++ b/translate/synth.py @@ -48,6 +48,9 @@ f"google.cloud.translate_{version}.proto", ) +# Use the highest version library to generate documentation import alias. +s.move(library / "google/cloud/translate.py") + s.replace( "google/cloud/**/translation_service_pb2.py", r"""record delimiters are ':raw-latex:`\\n`' instead of From 12267d5574ad288f320a8c2e29785b58da5067dc Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Mon, 21 Oct 2019 17:35:10 -0700 Subject: [PATCH 2/2] test: update tests to specify v2/v3 --- translate/tests/system.py | 4 ++-- translate/tests/unit/__init__.py | 13 ------------- translate/tests/unit/{ => v2}/test__http.py | 0 translate/tests/unit/{ => v2}/test_client.py | 2 +- 4 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 translate/tests/unit/__init__.py rename translate/tests/unit/{ => v2}/test__http.py (100%) rename translate/tests/unit/{ => v2}/test_client.py (99%) diff --git a/translate/tests/system.py b/translate/tests/system.py index c586411b6111..b92ead125acf 100644 --- a/translate/tests/system.py +++ b/translate/tests/system.py @@ -16,7 +16,7 @@ import unittest -from google.cloud import translate +from google.cloud import translate_v2 class Config(object): @@ -30,7 +30,7 @@ class Config(object): def setUpModule(): - Config.CLIENT = translate.Client() + Config.CLIENT = translate_v2.Client() class TestTranslate(unittest.TestCase): diff --git a/translate/tests/unit/__init__.py b/translate/tests/unit/__init__.py deleted file mode 100644 index df379f1e9d88..000000000000 --- a/translate/tests/unit/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2016 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. diff --git a/translate/tests/unit/test__http.py b/translate/tests/unit/v2/test__http.py similarity index 100% rename from translate/tests/unit/test__http.py rename to translate/tests/unit/v2/test__http.py diff --git a/translate/tests/unit/test_client.py b/translate/tests/unit/v2/test_client.py similarity index 99% rename from translate/tests/unit/test_client.py rename to translate/tests/unit/v2/test_client.py index dfbc5affaa73..2c0f72b1a1e5 100644 --- a/translate/tests/unit/test_client.py +++ b/translate/tests/unit/v2/test_client.py @@ -18,7 +18,7 @@ class TestClient(unittest.TestCase): @staticmethod def _get_target_class(): - from google.cloud.translate import Client + from google.cloud.translate_v2 import Client return Client