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

feat!: migrate API to microgenerator #31

Merged
merged 104 commits into from Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from 99 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
37a89ce
Add new "quickstart" samples [(#547)](https://github.com/GoogleCloudP…
jmdobry Oct 5, 2016
e3ef3df
Quickstart tests [(#569)](https://github.com/GoogleCloudPlatform/pyth…
Oct 12, 2016
73e12f0
Add translate samples [(#574)](https://github.com/GoogleCloudPlatform…
Oct 12, 2016
64a0a04
Generate most non-appengine readmes
Oct 25, 2016
52b7975
Update requirements.txt
puneith Nov 15, 2016
bcc3886
Merge pull request #653 from GoogleCloudPlatform/google-translate-ver…
Nov 15, 2016
9d6a764
added model in the sample [(#650)](https://github.com/GoogleCloudPlat…
puneith Nov 15, 2016
51c5769
added with and without model separately [(#657)](https://github.com/G…
puneith Nov 15, 2016
b5ddbe3
Translate API no longer requires an API key. [(#659)](https://github.…
jmdobry Nov 17, 2016
a743ae0
Auto-update dependencies. [(#715)](https://github.com/GoogleCloudPlat…
dpebot Dec 13, 2016
a2cf9fb
Changes default model to premium [(#749)](https://github.com/GoogleCl…
gguuss Jan 6, 2017
76c019a
Updates readme template to show credential auth instead of api key. […
gguuss Feb 14, 2017
f4502c0
Updates translate version to match speech and language. [(#843)](http…
gguuss Mar 7, 2017
ba65bb2
Translate update [(#886)](https://github.com/GoogleCloudPlatform/pyth…
gguuss Apr 4, 2017
4de3659
Remove cloud config fixture [(#887)](https://github.com/GoogleCloudPl…
Apr 4, 2017
9fcaaf4
Unicode for translation
gguuss Apr 14, 2017
c38796e
Adds check for translated text
gguuss Apr 14, 2017
f8932fa
Unicode for translation
gguuss Apr 14, 2017
a948f73
Unicode for translation
gguuss Apr 14, 2017
4de577b
Unicode for translation
gguuss Apr 14, 2017
2c1a51f
missing newline
gguuss Apr 14, 2017
b8b38d4
Adds six for 2/3 compatibility
gguuss Apr 17, 2017
2f5cb80
Changes encoding style.
gguuss Apr 17, 2017
8d85abc
Fix unicode
Apr 18, 2017
52f0cba
renaming of the product to Google Translation API [(#910)](https://gi…
merla18 Apr 20, 2017
a697eb1
Update translate readme
Apr 20, 2017
108abe5
Re-generate all readmes
Apr 27, 2017
16186f4
Fix README rst links [(#962)](https://github.com/GoogleCloudPlatform/…
waprin May 24, 2017
de3d7f3
Auto-update dependencies. [(#1004)](https://github.com/GoogleCloudPla…
dpebot Jun 27, 2017
22402fe
Auto-update dependencies. [(#1055)](https://github.com/GoogleCloudPla…
dpebot Aug 7, 2017
0e7e947
Auto-update dependencies. [(#1093)](https://github.com/GoogleCloudPla…
dpebot Aug 29, 2017
20d7d84
Update all generated readme auth instructions [(#1121)](https://githu…
Sep 18, 2017
0cbb423
Added Link to Python Setup Guide [(#1158)](https://github.com/GoogleC…
Oct 12, 2017
cac8c70
Auto-update dependencies. [(#1186)](https://github.com/GoogleCloudPla…
dpebot Nov 1, 2017
434eba0
Fixed failed tests on Kokoro (Spanner + Translate) [(#1192)](https://…
Nov 3, 2017
0d514cc
Added "Open in Cloud Shell" buttons to README files [(#1254)](https:/…
Dec 7, 2017
61265f2
Auto-update dependencies. [(#1377)](https://github.com/GoogleCloudPla…
dpebot Mar 5, 2018
541a3a5
Regenerate the README files and fix the Open in Cloud Shell link for …
Apr 7, 2018
69abd4f
Update READMEs to fix numbering and add git clone [(#1464)](https://g…
frankyn Apr 26, 2018
ef12fcb
Add translate region tags [(#1488)](https://github.com/GoogleCloudPla…
averikitsch May 21, 2018
294fe72
Include the comma in the translation [(#1787)](https://github.com/Goo…
engelke Oct 22, 2018
d2c3149
Auto-update dependencies. [(#1980)](https://github.com/GoogleCloudPla…
dpebot Feb 6, 2019
7cba151
Translation v3beta1 samples [(#2084)](https://github.com/GoogleCloudP…
beccasaurus Apr 6, 2019
458c33a
fixing translate-with-glossary bug [(#2323)](https://github.com/Googl…
crowdus Aug 8, 2019
59fbf25
Translate beta samples fix [(#2327)](https://github.com/GoogleCloudPl…
crowdus Aug 12, 2019
59be81d
Using glossaries with tts and vision tutorial sample code [(#2325)](h…
crowdus Aug 19, 2019
2bd4ab3
fix: refactored MP3 file creation test for Hybrid glossaries samples …
crowdus Sep 4, 2019
0443253
Fix variable names in comments [(#2400)](https://github.com/GoogleClo…
nnegrey Sep 16, 2019
4ba3a44
Adds updates for samples profiler ... vision [(#2439)](https://github…
gguuss Oct 7, 2019
9832634
Update v2 samples to explicitly use v2 library [(#2498)](https://gith…
nnegrey Oct 28, 2019
b400096
fix: translate test [(#2671)](https://github.com/GoogleCloudPlatform/…
leahecole Jan 6, 2020
0666215
automl: add natural language sentiment analysis ga samples [(#2677)](…
nnegrey Jan 7, 2020
42afcb4
fix region tag typo [(#2731)](https://github.com/GoogleCloudPlatform/…
leahecole Jan 21, 2020
a80d5f4
Migrate published samples [(#2759)](https://github.com/GoogleCloudPla…
texasmichelle Jan 31, 2020
d5f78a9
translate v3 snippets [(#2745)](https://github.com/GoogleCloudPlatfor…
munkhuushmgl Feb 4, 2020
33f7ce0
Translate: migrate published samples [(#2768)](https://github.com/Goo…
texasmichelle Feb 4, 2020
48850ab
Translate: migrate published glossaries samples [(#2769)](https://git…
texasmichelle Feb 4, 2020
aa59393
translate: increase timeout [(#2937)](https://github.com/GoogleCloudP…
nnegrey Feb 20, 2020
cc5c848
Translate: migrate published v3 translate batch samples [(#2914)](ht…
munkhuushmgl Mar 2, 2020
3fa87ea
chore(deps): update dependency google-cloud-storage to v1.26.0 [(#304…
renovate-bot Mar 9, 2020
d02a0ae
chore(deps): update dependency google-cloud-translate to v1.7.0 [(#30…
renovate-bot Mar 11, 2020
6809f72
translate: fix tests [(#3087)](https://github.com/GoogleCloudPlatform…
nnegrey Mar 12, 2020
089c5d5
translate-v3: samples [(#3034)](https://github.com/GoogleCloudPlatfo…
munkhuushmgl Mar 16, 2020
84e3684
chore(deps): update dependency google-cloud-vision to v0.42.0 [(#3170…
renovate-bot Mar 27, 2020
8e6f3d8
chore(deps): update dependency google-cloud-texttospeech to v1 [(#321…
renovate-bot Mar 29, 2020
fb7dd90
chore(deps): update dependency google-cloud-translate to v2 [(#3211)]…
renovate-bot Mar 30, 2020
723d450
Simplify noxfile setup. [(#2806)](https://github.com/GoogleCloudPlatf…
kurtisvg Apr 2, 2020
296f00e
Update dependency google-cloud-vision to v1 [(#3227)](https://github.…
renovate-bot Apr 2, 2020
3aef3b1
translate: make test generic [(#3386)](https://github.com/GoogleCloud…
nnegrey Apr 14, 2020
1b38db5
[translate] fix: mark some tests as flaky [(#3495)](https://github.co…
Apr 24, 2020
9acae80
testing: replace @flaky with @pytest.mark.flaky [(#3496)](https://git…
Apr 25, 2020
6ed8d4e
chore(deps): update dependency google-cloud-storage to v1.28.0 [(#326…
renovate-bot Apr 29, 2020
eb357b1
translate: fix glossary leak issue [(#3572)](https://github.com/Googl…
munkhuushmgl May 1, 2020
dcacff2
chore: some lint fixes [(#3751)](https://github.com/GoogleCloudPlatfo…
May 13, 2020
9556441
chore(deps): update dependency google-cloud-storage to v1.28.1 [(#378…
renovate-bot May 19, 2020
7c4f9bf
[translate] fix hybrid glossaries tests [(#3936)](https://github.com/…
busunkim96 Jun 3, 2020
6f32e31
testing: start using btlr [(#3959)](https://github.com/GoogleCloudPla…
Jun 9, 2020
8ca332b
Replace GCLOUD_PROJECT with GOOGLE_CLOUD_PROJECT. [(#4022)](https://g…
kurtisvg Jun 9, 2020
79a6298
remove whitelist replace with allowlist [(#4050)](https://github.com/…
leahecole Jun 10, 2020
cb499dc
chore(deps): update dependency google-cloud-storage to v1.29.0 [(#404…
renovate-bot Jun 19, 2020
58b3d2e
chore(deps): update dependency google-cloud-texttospeech to v2.1.0 [(…
renovate-bot Jun 24, 2020
3bc8506
testing(translate): parameterize the timeout [(#4247)](https://github…
Jul 6, 2020
de0ee32
chore(deps): update dependency pytest to v5.4.3 [(#4279)](https://git…
renovate-bot Jul 12, 2020
135b228
Update dependency flaky to v3.7.0 [(#4300)](https://github.com/Google…
renovate-bot Jul 16, 2020
6573d95
testing(translate): bump the timeout for operations [(#4258)](https:/…
Jul 16, 2020
0f9c755
Merge branch 'snippets-samples' into add-snippets-samples
danoscarmike Jul 21, 2020
0081e92
chore: update templates
danoscarmike Jul 24, 2020
0714f6d
chore: narrows samples CODEOWNERS to .py only
danoscarmike Jul 24, 2020
3e7b19c
chore: wip migration to microgenerator
danoscarmike Jul 28, 2020
5217b38
feat!: move API to python microgenerator
danoscarmike Jul 31, 2020
67f317e
docs: readmegen updates
danoscarmike Jul 31, 2020
0633064
chore: add build config for docs-presubmit
danoscarmike Jul 31, 2020
753286b
Merge remote-tracking branch 'upstream/master' into master
danoscarmike Jul 31, 2020
fd045e3
chore: merge master
danoscarmike Aug 3, 2020
e1e1919
Merge branch 'master' into microgen
danoscarmike Aug 3, 2020
f2d4b18
Merge upstream into master
danoscarmike Aug 3, 2020
d3f4bfd
chore: rm protos
danoscarmike Aug 3, 2020
eebadb4
Merge branch 'master' into microgen
danoscarmike Aug 3, 2020
6378cea
chore: uses PROJECT_ID env var in system test
danoscarmike Aug 3, 2020
d830f91
Merge branch 'microgen' of github.com:danoscarmike/python-translate i…
danoscarmike Aug 3, 2020
fbaa3ee
Merge remote-tracking branch 'upstream/master' into master
danoscarmike Aug 4, 2020
7adc9fc
Merge branch 'master' into microgen
danoscarmike Aug 4, 2020
ec4ec30
chore: clarifies examples in migration guide
danoscarmike Aug 4, 2020
688987e
chore: adds explicit variable
danoscarmike Aug 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .coveragerc
Expand Up @@ -32,4 +32,8 @@ omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
*/site-packages/*.py
google/cloud/__init__.py
google/cloud/translate.py
google/cloud/translate/__init__.py
google/cloud/translation*/*.py
5 changes: 3 additions & 2 deletions README.rst
Expand Up @@ -55,11 +55,12 @@ dependencies.

Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.5
Python >= 3.6

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
Python == 2.7.
The last version of this library compatible with Python 2.7 is google-cloud-translate==2.0.1.


Mac/Linux
Expand Down
182 changes: 182 additions & 0 deletions UPGRADING.md
@@ -0,0 +1,182 @@
# 3.0.0 Migration Guide

The 3.0 release of the `google-cloud-translate` client is a significant upgrade based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-python), and includes substantial interface changes. Existing code written for earlier versions of this library will likely require updates to use this version. This document describes the changes that have been made, and what you need to do to update your usage.

If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-translate/issues).

## Supported Python Versions

> **WARNING**: Breaking change

The 3.0.0 release requires Python 3.6+.


## Method Calls

> **WARNING**: Breaking change

Methods expect request objects. We provide a script that will convert most common use cases.

* Install the library

```py
python3 -m pip install google-cloud-translate
```

* The script `fixup_translation_{version}_keywords.py` is shipped with the library. It expects
an input directory (with the code to convert) and an empty destination directory.

```sh
$ fixup_translation_v3_keywords.py --input-directory .samples/ --output-directory samples/
```

**Before:**
```py
from google.cloud import translate

client = translate.TranslationServiceClient()
parent = client.location_path(<PROJECT_ID>, <LOCATION>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parent = client.location_path(<PROJECT_ID>, <LOCATION>)
parent = client.location_path("<PROJECT_ID>", "<LOCATION>")


response = client.translate_text(
parent=parent,
contents=[text],
danoscarmike marked this conversation as resolved.
Show resolved Hide resolved
mime_type="text/plain",
source_language_code="en-US",
target_language_code="fr",
)
```


**After:**
```py
from google.cloud import translate

client = translate.TranslationServiceClient()
parent = "projects/<PROJECT_ID>/locations/<LOCATION>"

response = client.translate_text(
request={
"parent": parent,
"contents": [text],
"mime_type": "text/plain",
"source_language_code": "en-US",
"target_language_code": "fr"
}
)
```

### More Details

In `google-cloud-translate<3.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.

**Before:**
```py
def translate_text(
self,
contents,
target_language_code,
parent,
mime_type=None,
source_language_code=None,
model=None,
glossary_config=None,
labels=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
```

In the 3.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.

Some methods have additional keyword only parameters. The available parameters depend on the [`google.api.method_signature` annotation](https://github.com/googleapis/googleapis/blob/master/google/cloud/translate/v3/translation_service.proto#L55) specified by the API producer.


**After:**
```py
def translate_text(
self,
request: translation_service.TranslateTextRequest = None,
*,
parent: str = None,
target_language_code: str = None,
contents: Sequence[str] = None,
model: str = None,
mime_type: str = None,
source_language_code: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> translation_service.TranslateTextResponse:
```

> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
> Passing both will result in an error.


Both of these calls are valid:

```py
response = client.translate_text(
request={
"parent": parent,
"target_language_code": target_language_code,
"contents": contents
}
)
```

```py
response = client.translate_text(
parent=parent,
target_language_code=target_language_code,
contents=contents
)
```

This call is invalid because it mixes `request` with a keyword argument `target_language_code`. Executing this code
will result in an error.

```py
response = client.translate_text(
request={
"parent": parent,
"contents": contents,
},
target_language_code=target_language_code
)
```



## Enums and types


> **WARNING**: Breaking change

The submodule `enums` (containing enum classes for long running operation State) has been removed.

The submodule `types` is still present. When using the primary version module alias (`translate`)
it is possible to access the types classes directly.

```py
from google.cloud import translate # the primary version is imported by default

client = translate.TranslationServiceClient()

glossary_config = client.TranslateTextGlossaryConfig(
glossary=glossary_path
)
```

When a specific version is imported, the full module name must be specified to access types classes.

```py
from google.cloud import translate_v3beta1 as translate

client = translate.TranslationServiceClient()

glossary_config = client.types.TranslateTextGlossaryConfig(
glossary=glossary_path
)
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
6 changes: 0 additions & 6 deletions docs/gapic/v3/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v3/types.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/gapic/v3beta1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v3beta1/types.rst

This file was deleted.

32 changes: 29 additions & 3 deletions docs/index.rst
Expand Up @@ -13,15 +13,41 @@ want to import from ``google.cloud.translate_v3beta1`` in lieu of
``google.cloud.translate``. The previous release ``v2`` is also available.
Import from ``google.cloud.translate_v2`` to use this release.


v3 API Reference
----------------
.. toctree::
:maxdepth: 2

v3
v3beta1
Client (v3) <translate_v3/services>
Types (v3) <translate_v3/types>

v3beta1 API Reference
---------------------
.. toctree::
:maxdepth: 2

Client (v3beta1) <translate_v3beta1/services>
Types (v3beta1) <translate_v3beta1/types>

v2 API Reference
----------------
.. toctree::
:maxdepth: 2

v2


Migration Guide
---------------

See the guide below for instructions on migrating to the 3.x release of this library.

.. toctree::
:maxdepth: 2

UPGRADING


Changelog
---------

Expand Down
6 changes: 6 additions & 0 deletions docs/translate_v3/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Translation v3 API
============================================

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

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

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

.. automodule:: google.cloud.translate_v3beta1.types
:members:
8 changes: 0 additions & 8 deletions docs/v3.rst

This file was deleted.

8 changes: 0 additions & 8 deletions docs/v3beta1.rst

This file was deleted.