This repository was archived by the owner on Dec 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
feat!: move to microgen #61
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2bf57f0
feat!: move to microgen
busunkim96 02b8d45
test: fix unit tests
busunkim96 027c649
test: update snipets dir
busunkim96 ddac911
test: adjust path helper usage
busunkim96 814da11
fix: fix more tests
busunkim96 1f7fb0b
test: fix more test
busunkim96 683e6c6
test: fix tables tests
busunkim96 a80ac60
test: tables unit tests
busunkim96 1d474ff
docs: update docs
busunkim96 75a272b
docs: mention filter_ -> filter rename
busunkim96 abe263a
fix: make **kwarg passing consistent
busunkim96 af21576
chore: update translation samples
busunkim96 7e71818
test: fix model_list_get_evaluate
busunkim96 f8730cb
test: fix model_list_get_evaluate
busunkim96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,269 @@ | ||
# 3.0.0 Migration Guide | ||
|
||
The 2.0 release of the `google-cloud-automl` 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-automl/issues). | ||
|
||
## Supported Python Versions | ||
|
||
> **WARNING**: Breaking change | ||
|
||
The 2.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-automl | ||
``` | ||
|
||
* The script `fixup_automl_{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_automl_v1_keywords.py --input-directory .samples/ --output-directory samples/ | ||
``` | ||
|
||
**Before:** | ||
```py | ||
from google.cloud import automl | ||
|
||
project_id = "YOUR_PROJECT_ID" | ||
model_id = "YOUR_MODEL_ID" | ||
|
||
client = automl.AutoMlClient() | ||
# Get the full path of the model. | ||
model_full_id = client.model_path(project_id, "us-central1", model_id) | ||
response = client.deploy_model(model_full_id) | ||
``` | ||
|
||
|
||
**After:** | ||
```py | ||
from google.cloud import automl | ||
|
||
project_id = "YOUR_PROJECT_ID" | ||
model_id = "YOUR_MODEL_ID" | ||
|
||
client = automl.AutoMlClient() | ||
# Get the full path of the model. | ||
model_full_id = client.model_path(project_id, "us-central1", model_id) | ||
response = client.deploy_model(name=model_full_id) | ||
``` | ||
|
||
### More Details | ||
|
||
In `google-cloud-automl<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters. | ||
|
||
**Before:** | ||
```py | ||
def batch_predict( | ||
self, | ||
name, | ||
input_config, | ||
output_config, | ||
params=None, | ||
retry=google.api_core.gapic_v1.method.DEFAULT, | ||
timeout=google.api_core.gapic_v1.method.DEFAULT, | ||
metadata=None, | ||
): | ||
``` | ||
|
||
In the 2.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/2db5725bf898b544a0cf951e1694d3b0fce5eda3/google/cloud/automl/v1/prediction_service.proto#L86) specified by the API producer. | ||
|
||
|
||
**After:** | ||
```py | ||
def batch_predict( | ||
self, | ||
request: prediction_service.BatchPredictRequest = None, | ||
*, | ||
name: str = None, | ||
input_config: io.BatchPredictInputConfig = None, | ||
output_config: io.BatchPredictOutputConfig = None, | ||
params: Sequence[prediction_service.BatchPredictRequest.ParamsEntry] = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> operation.Operation: | ||
``` | ||
|
||
> **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.batch_predict( | ||
request={ | ||
"name": name, | ||
"input_config": input_config, | ||
"output_config": output_config, | ||
"params": params, | ||
} | ||
) | ||
``` | ||
|
||
```py | ||
response = client.batch_predict( | ||
name=name, | ||
input_config=input_config, | ||
output_config=output_config, | ||
params=params, | ||
) | ||
``` | ||
|
||
This call is invalid because it mixes `request` with a keyword argument `params`. Executing this code | ||
will result in an error. | ||
|
||
```py | ||
response = client.batch_predict( | ||
request={ | ||
"name": name, | ||
"input_config": input_config, | ||
"output_config": output_config, | ||
}, | ||
params=params, | ||
) | ||
``` | ||
|
||
|
||
The method `list_datasets` takes an argument `filter` instead of `filter_`. | ||
|
||
**Before** | ||
```py | ||
from google.cloud import automl | ||
|
||
project_id = "PROJECT_ID" | ||
|
||
client = automl.AutoMlClient() | ||
project_location = client.location_path(project_id, "us-central1") | ||
|
||
# List all the datasets available in the region. | ||
response = client.list_datasets(project_location, filter_="") | ||
``` | ||
|
||
**After** | ||
```py | ||
from google.cloud import automl | ||
|
||
project_id = "PROJECT_ID" | ||
client = automl.AutoMlClient() | ||
# A resource that represents Google Cloud Platform location. | ||
project_location = f"projects/{project_id}/locations/us-central1" | ||
|
||
# List all the datasets available in the region. | ||
response = client.list_datasets(parent=project_location, filter="") | ||
``` | ||
|
||
### Changes to v1beta1 Tables Client | ||
|
||
Optional arguments are now keyword-only arguments and *must* be passed by name. | ||
See [PEP 3102](https://www.python.org/dev/peps/pep-3102/). | ||
|
||
***Before** | ||
```py | ||
def predict( | ||
self, | ||
inputs, | ||
model=None, | ||
model_name=None, | ||
model_display_name=None, | ||
feature_importance=False, | ||
project=None, | ||
region=None, | ||
**kwargs | ||
): | ||
``` | ||
|
||
**After** | ||
```py | ||
def predict( | ||
self, | ||
inputs, | ||
*, | ||
model=None, | ||
model_name=None, | ||
model_display_name=None, | ||
feature_importance=False, | ||
project=None, | ||
region=None, | ||
**kwargs, | ||
): | ||
``` | ||
|
||
**kwargs passed to methods must be either (1) kwargs on the underlying method (`retry`, `timeout`, or `metadata`) or (2) attributes of the request object. | ||
|
||
The following call is valid because `filter` is an attribute of `automl_v1beta1.ListDatasetsRequest`. | ||
|
||
```py | ||
from google.cloud import automl_v1beta1 as automl | ||
|
||
client = automl.TablesClient(project=project_id, region=compute_region) | ||
|
||
# List all the datasets available in the region by applying filter. | ||
response = client.list_datasets(filter=filter) | ||
``` | ||
|
||
|
||
|
||
## Enums and types | ||
6D4E
|
||
|
||
> **WARNING**: Breaking change | ||
|
||
The submodule `enums` and `types` have been removed. | ||
|
||
**Before:** | ||
```py | ||
|
||
from google.cloud import automl | ||
|
||
gcs_source = automl.types.GcsSource(input_uris=["gs://YOUR_BUCKET_ID/path/to/your/input/csv_or_jsonl"]) | ||
deployment_state = automl.enums.Model.DeploymentState.DEPLOYED | ||
``` | ||
|
||
|
||
**After:** | ||
```py | ||
from google.cloud import automl | ||
|
||
gcs_source = automl.GcsSource(input_uris=["gs://YOUR_BUCKET_ID/path/to/your/input/csv_or_jsonl"]) | ||
deployment_state = automl.Model.DeploymentState.DEPLOYED | ||
``` | ||
|
||
|
||
## Resource Path Helper Methods | ||
|
||
The following resource name helpers have been removed. Please construct the strings manually. | ||
|
||
```py | ||
from google.cloud import automl | ||
|
||
project = "my-project" | ||
location = "us-central1" | ||
dataset = "my-dataset" | ||
model = "my-model" | ||
annotation_spec = "test-annotation" | ||
model_evaluation = "test-evaluation" | ||
|
||
# AutoMlClient | ||
annotation_spec_path = f"projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}" | ||
location_path = f"projects/{project}/locations/{location}" | ||
model_evaluation_path = f"projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation}", | ||
|
||
# PredictionServiceClient | ||
model_path = f"projects/{project}/locations/{location}/models/{model}" | ||
# alternatively you can use `model_path` from AutoMlClient | ||
model_path = automl.AutoMlClient.model_path(project_id, location, model_id) | ||
|
||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../UPGRADING.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Services for Google Cloud Automl v1 API | ||
======================================= | ||
|
||
.. automodule:: google.cloud.automl_v1.services.auto_ml | ||
:members: | ||
:inherited-members: | ||
.. automodule:: google.cloud.automl_v1.services.prediction_service | ||
:members: | ||
:inherited-members: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Types for Google Cloud Automl v1 API | ||
==================================== | ||
|
||
.. automodule:: google.cloud.automl_v1.types | ||
:members: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Services for Google Cloud Automl v1beta1 API | ||
============================================ | ||
|
||
.. automodule:: google.cloud.automl_v1beta1.services.auto_ml | ||
:members: | ||
:inherited-members: | ||
.. automodule:: google.cloud.automl_v1beta1.services.prediction_service | ||
:members: | ||
:inherited-members: | ||
.. automodule:: google.cloud.automl_v1beta1.services.tables | ||
:members: | ||
:inherited-members: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Types for Google Cloud Automl v1beta1 API | ||
========================================= | ||
|
||
.. automodule:: google.cloud.automl_v1beta1.types | ||
:members: |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.