Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate GA #3650

Merged
merged 5 commits into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following client libraries have **GA** support:
- `Google Cloud Datastore`_ (`Datastore README`_)
- `Stackdriver Logging`_ (`Logging README`_)
- `Google Cloud Storage`_ (`Storage README`_)
- `Google Cloud Translation`_ (`Translation README`_)

**GA** (general availability) indicates that the client library for a
particular service is stable, and that the code surface will not change in
Expand All @@ -33,7 +34,6 @@ The following client libraries have **beta** support:
- `Google BigQuery`_ (`BigQuery README`_)
- `Google Cloud Vision`_ (`Vision README`_)
- `Google Cloud Natural Language`_ (`Natural Language README`_)
- `Google Cloud Translation`_ (`Translation README`_)
- `Google Cloud Video Intelligence`_ (`Video Intelligence README`_)

**Beta** indicates that the client library for a particular service is
Expand Down
32 changes: 32 additions & 0 deletions translate/google/cloud/translate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2017 Google Inc.
#
# 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.

"""Google Cloud Translation API wrapper."""


from google.cloud.translate_v2 import __version__
from google.cloud.translate_v2.client import Client

# 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


__all__ = (
'__version__',
'BASE',
'Client',
'NMT',
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
from pkg_resources import get_distribution
__version__ = get_distribution('google-cloud-translate').version

from google.cloud.translate.client import BASE
from google.cloud.translate.client import Client
from google.cloud.translate.client import NMT
from google.cloud.translate_v2.client import Client


__all__ = ['__version__', 'BASE', 'Client', 'NMT']
__all__ = (
'__version__',
'Client',
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from google.cloud import _http

from google.cloud.translate import __version__
from google.cloud.translate_v2 import __version__


_CLIENT_INFO = _http.CLIENT_INFO_TEMPLATE.format(__version__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from google.cloud._helpers import _to_bytes
from google.cloud.client import Client as BaseClient

from google.cloud.translate._http import Connection
from google.cloud.translate_v2._http import Connection


ENGLISH_ISO_639 = 'en'
Expand Down Expand Up @@ -189,8 +189,8 @@ def translate(self, values, target_language=None, format_=None,
in the query.

:type model: str
:param model: (Optional) The model used to translate the text. The
only accepted values are :attr:`BASE` and :attr:`NMT`.
:param model: (Optional) The model used to translate the text, such
as ``'base'`` or ``'nmt'``.

This comment was marked as spam.

This comment was marked as spam.


:rtype: str or list
:returns: A list of dictionaries for each queried value. Each
Expand Down
4 changes: 2 additions & 2 deletions translate/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'include_package_data': True,
'zip_safe': False,
'classifiers': [
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
Expand All @@ -56,7 +56,7 @@

setup(
name='google-cloud-translate',
version='0.25.0',
version='1.0.0',

This comment was marked as spam.

This comment was marked as spam.

description='Python Client for Google Cloud Translation API',
long_description=README,
namespace_packages=[
Expand Down
2 changes: 1 addition & 1 deletion translate/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_translate(self):
values = ['hvala ti', 'dankon',
'Me llamo Jeff', 'My name is Jeff']
translations = Config.CLIENT.translate(
values, target_language='de', model=translate.NMT)
values, target_language='de', model='nmt')

This comment was marked as spam.

This comment was marked as spam.

self.assertEqual(len(values), len(translations))

self.assertEqual(
Expand Down
4 changes: 2 additions & 2 deletions translate/tests/unit/test__http.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestConnection(unittest.TestCase):

@staticmethod
def _get_target_class():
from google.cloud.translate._http import Connection
from google.cloud.translate_v2._http import Connection

return Connection

Expand Down Expand Up @@ -57,7 +57,7 @@ def test_build_api_url_w_extra_query_params(self):

def test_extra_headers(self):
from google.cloud import _http as base_http
from google.cloud.translate import _http as MUT
from google.cloud.translate_v2 import _http as MUT

http = mock.Mock(spec=['request'])
response = mock.Mock(status=200, spec=['status'])
Expand Down
11 changes: 5 additions & 6 deletions translate/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ class TestClient(unittest.TestCase):

@staticmethod
def _get_target_class():
from google.cloud.translate.client import Client

from google.cloud.translate import Client
return Client

def _make_one(self, *args, **kw):
return self._get_target_class()(*args, **kw)

def test_constructor(self):
from google.cloud.translate._http import Connection
from google.cloud.translate.client import ENGLISH_ISO_639
from google.cloud.translate_v2._http import Connection
from google.cloud.translate_v2.client import ENGLISH_ISO_639

http = object()
client = self._make_one(_http=http)
Expand All @@ -38,7 +37,7 @@ def test_constructor(self):
self.assertEqual(client.target_language, ENGLISH_ISO_639)

def test_constructor_non_default(self):
from google.cloud.translate._http import Connection
from google.cloud.translate_v2._http import Connection

http = object()
target = 'es'
Expand All @@ -49,7 +48,7 @@ def test_constructor_non_default(self):
self.assertEqual(client.target_language, target)

def test_get_languages(self):
from google.cloud.translate.client import ENGLISH_ISO_639
from google.cloud.translate_v2.client import ENGLISH_ISO_639

client = self._make_one(_http=object())
supported = [
Expand Down