Skip to content

Commit 4f34901

Browse files
authored
feat!: move to microgen (#61)
See UPGRADING.md
1 parent f6ca5d0 commit 4f34901

File tree

354 files changed

+45761
-48392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

354 files changed

+45761
-48392
lines changed

packages/google-cloud-automl/README.rst

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Python >= 3.5
5656

5757
Deprecated Python Versions
5858
^^^^^^^^^^^^^^^^^^^^^^^^^^
59-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
59+
Python == 2.7.
60+
61+
The last version of this library compatible with Python 2.7 is google-cloud-automl==1.0.1.
6062

6163

6264
Mac/Linux
@@ -80,18 +82,6 @@ Windows
8082
<your-env>\Scripts\activate
8183
<your-env>\Scripts\pip.exe install google-cloud-automl
8284
83-
Example Usage
84-
~~~~~~~~~~~~~
85-
86-
.. code-block:: python
87-
88-
from google.cloud.automl_v1beta1 import PredictionServiceClient
89-
90-
client = PredictionServiceClient()
91-
model_path = client.model_path('my-project-123', 'us-central', 'model-name')
92-
payload = {...}
93-
params = {'foo': 1}
94-
response = client.predict(model_path, payload, params=params)
9585
9686
Next Steps
9787
~~~~~~~~~~
@@ -100,32 +90,3 @@ Next Steps
10090
API to see other available methods on the client.
10191
- Read the `Product documentation`_ to learn
10292
more about the product and see How-to Guides.
103-
104-
Making & Testing Local Changes
105-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106-
107-
If you want to make changes to this library, here is how to set up your
108-
development environment:
109-
110-
1. Make sure you have `virtualenv`_ installed and activated as shown above.
111-
2. Run the following one-time setup (it will be persisted in your virtualenv):
112-
113-
.. code-block:: console
114-
115-
pip install -r ../docs/requirements.txt
116-
pip install -U nox mock pytest
117-
118-
3. If you want to run all tests, you will need a billing-enabled
119-
`GCP project`_, and a `service account`_ with access to the AutoML APIs.
120-
Note: the first time the tests run in a new project it will take a _long_
121-
time, on the order of 2-3 hours. This is one-time setup that will be skipped
122-
in future runs.
123-
124-
.. _service account: https://cloud.google.com/iam/docs/creating-managing-service-accounts
125-
.. _GCP project: https://cloud.google.com/resource-manager/docs/creating-managing-projects
126-
127-
.. code-block:: console
128-
129-
export PROJECT_ID=<project-id> GOOGLE_APPLICATION_CREDENTIALS=</path/to/creds.json>
130-
nox
131-
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# 3.0.0 Migration Guide
2+
3+
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.
4+
5+
If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-automl/issues).
6+
7+
## Supported Python Versions
8+
9+
> **WARNING**: Breaking change
10+
11+
The 2.0.0 release requires Python 3.6+.
12+
13+
14+
## Method Calls
15+
16+
> **WARNING**: Breaking change
17+
18+
Methods expect request objects. We provide a script that will convert most common use cases.
19+
20+
* Install the library
21+
22+
```py
23+
python3 -m pip install google-cloud-automl
24+
```
25+
26+
* The script `fixup_automl_{version}_keywords.py` is shipped with the library. It expects
27+
an input directory (with the code to convert) and an empty destination directory.
28+
29+
```sh
30+
$ fixup_automl_v1_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud import automl
36+
37+
project_id = "YOUR_PROJECT_ID"
38+
model_id = "YOUR_MODEL_ID"
39+
40+
client = automl.AutoMlClient()
41+
# Get the full path of the model.
42+
model_full_id = client.model_path(project_id, "us-central1", model_id)
43+
response = client.deploy_model(model_full_id)
44+
```
45+
46+
47+
**After:**
48+
```py
49+
from google.cloud import automl
50+
51+
project_id = "YOUR_PROJECT_ID"
52+
model_id = "YOUR_MODEL_ID"
53+
54+
client = automl.AutoMlClient()
55+
# Get the full path of the model.
56+
model_full_id = client.model_path(project_id, "us-central1", model_id)
57+
response = client.deploy_model(name=model_full_id)
58+
```
59+
60+
### More Details
61+
62+
In `google-cloud-automl<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
63+
64+
**Before:**
65+
```py
66+
def batch_predict(
67+
self,
68+
name,
69+
input_config,
70+
output_config,
71+
params=None,
72+
retry=google.api_core.gapic_v1.method.DEFAULT,
73+
timeout=google.api_core.gapic_v1.method.DEFAULT,
74+
metadata=None,
75+
):
76+
```
77+
78+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
79+
80+
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.
81+
82+
83+
**After:**
84+
```py
85+
def batch_predict(
86+
self,
87+
request: prediction_service.BatchPredictRequest = None,
88+
*,
89+
name: str = None,
90+
input_config: io.BatchPredictInputConfig = None,
91+
output_config: io.BatchPredictOutputConfig = None,
92+
params: Sequence[prediction_service.BatchPredictRequest.ParamsEntry] = None,
93+
retry: retries.Retry = gapic_v1.method.DEFAULT,
94+
timeout: float = None,
95+
metadata: Sequence[Tuple[str, str]] = (),
96+
) -> operation.Operation:
97+
```
98+
99+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
100+
> Passing both will result in an error.
101+
102+
103+
Both of these calls are valid:
104+
105+
```py
106+
response = client.batch_predict(
107+
request={
108+
"name": name,
109+
"input_config": input_config,
110+
"output_config": output_config,
111+
"params": params,
112+
}
113+
)
114+
```
115+
116+
```py
117+
response = client.batch_predict(
118+
name=name,
119+
input_config=input_config,
120+
output_config=output_config,
121+
params=params,
122+
)
123+
```
124+
125+
This call is invalid because it mixes `request` with a keyword argument `params`. Executing this code
126+
will result in an error.
127+
128+
```py
129+
response = client.batch_predict(
130+
request={
131+
"name": name,
132+
"input_config": input_config,
133+
"output_config": output_config,
134+
},
135+
params=params,
136+
)
137+
```
138+
139+
140+
The method `list_datasets` takes an argument `filter` instead of `filter_`.
141+
142+
**Before**
143+
```py
144+
from google.cloud import automl
145+
146+
project_id = "PROJECT_ID"
147+
148+
client = automl.AutoMlClient()
149+
project_location = client.location_path(project_id, "us-central1")
150+
151+
# List all the datasets available in the region.
152+
response = client.list_datasets(project_location, filter_="")
153+
```
154+
155+
**After**
156+
```py
157+
from google.cloud import automl
158+
159+
project_id = "PROJECT_ID"
160+
client = automl.AutoMlClient()
161+
# A resource that represents Google Cloud Platform location.
162+
project_location = f"projects/{project_id}/locations/us-central1"
163+
164+
# List all the datasets available in the region.
165+
response = client.list_datasets(parent=project_location, filter="")
166+
```
167+
168+
### Changes to v1beta1 Tables Client
169+
170+
Optional arguments are now keyword-only arguments and *must* be passed by name.
171+
See [PEP 3102](https://www.python.org/dev/peps/pep-3102/).
172+
173+
***Before**
174+
```py
175+
def predict(
176+
self,
177+
inputs,
178+
model=None,
179+
model_name=None,
180+
model_display_name=None,
181+
feature_importance=False,
182+
project=None,
183+
region=None,
184+
**kwargs
185+
):
186+
```
187+
188+
**After**
189+
```py
190+
def predict(
191+
self,
192+
inputs,
193+
*,
194+
model=None,
195+
model_name=None,
196+
model_display_name=None,
197+
feature_importance=False,
198+
project=None,
199+
region=None,
200+
**kwargs,
201+
):
202+
```
203+
204+
**kwargs passed to methods must be either (1) kwargs on the underlying method (`retry`, `timeout`, or `metadata`) or (2) attributes of the request object.
205+
206+
The following call is valid because `filter` is an attribute of `automl_v1beta1.ListDatasetsRequest`.
207+
208+
```py
209+
from google.cloud import automl_v1beta1 as automl
210+
211+
client = automl.TablesClient(project=project_id, region=compute_region)
212+
213+
# List all the datasets available in the region by applying filter.
214+
response = client.list_datasets(filter=filter)
215+
```
216+
217+
218+
219+
## Enums and types
220+
221+
222+
> **WARNING**: Breaking change
223+
224+
The submodule `enums` and `types` have been removed.
225+
226+
**Before:**
227+
```py
228+
229+
from google.cloud import automl
230+
231+
gcs_source = automl.types.GcsSource(input_uris=["gs://YOUR_BUCKET_ID/path/to/your/input/csv_or_jsonl"])
232+
deployment_state = automl.enums.Model.DeploymentState.DEPLOYED
233+
```
234+
235+
236+
**After:**
237+
```py
238+
from google.cloud import automl
239+
240+
gcs_source = automl.GcsSource(input_uris=["gs://YOUR_BUCKET_ID/path/to/your/input/csv_or_jsonl"])
241+
deployment_state = automl.Model.DeploymentState.DEPLOYED
242+
```
243+
244+
245+
## Resource Path Helper Methods
246+
247+
The following resource name helpers have been removed. Please construct the strings manually.
248+
249+
```py
250+
from google.cloud import automl
251+
252+
project = "my-project"
253+
location = "us-central1"
254+
dataset = "my-dataset"
255+
model = "my-model"
256+
annotation_spec = "test-annotation"
257+
model_evaluation = "test-evaluation"
258+
259+
# AutoMlClient
260+
annotation_spec_path = f"projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}"
261+
location_path = f"projects/{project}/locations/{location}"
262+
model_evaluation_path = f"projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation}",
263+
264+
# PredictionServiceClient
265+
model_path = f"projects/{project}/locations/{location}/models/{model}"
266+
# alternatively you can use `model_path` from AutoMlClient
267+
model_path = automl.AutoMlClient.model_path(project_id, location, model_id)
268+
269+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Services for Google Cloud Automl v1 API
2+
=======================================
3+
4+
.. automodule:: google.cloud.automl_v1.services.auto_ml
5+
:members:
6+
:inherited-members:
7+
.. automodule:: google.cloud.automl_v1.services.prediction_service
8+
:members:
9+
:inherited-members:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Cloud Automl v1 API
2+
====================================
3+
4+
.. automodule:: google.cloud.automl_v1.types
5+
:members:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Services for Google Cloud Automl v1beta1 API
2+
============================================
3+
4+
.. automodule:: google.cloud.automl_v1beta1.services.auto_ml
5+
:members:
6+
:inherited-members:
7+
.. automodule:: google.cloud.automl_v1beta1.services.prediction_service
8+
:members:
9+
:inherited-members:
10+
.. automodule:: google.cloud.automl_v1beta1.services.tables
11+
:members:
12+
:inherited-members:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Cloud Automl v1beta1 API
2+
=========================================
3+
4+
.. automodule:: google.cloud.automl_v1beta1.types
5+
:members:

packages/google-cloud-automl/docs/gapic/v1/api.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/google-cloud-automl/docs/gapic/v1/types.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/google-cloud-automl/docs/gapic/v1beta1/api.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)