Skip to content

migrate code from googleapis/python-automl #8528

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

Merged
merged 158 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
45567b6
automl: add base model samples for automl ga [(#2609)](https://github…
nnegrey Dec 20, 2019
9b5f526
Automl ga vision classification [(#2612)](https://github.com/GoogleCl…
nnegrey Jan 2, 2020
d1510d6
automl: add translate ga samples [(#2679)](https://github.com/GoogleC…
nnegrey Jan 3, 2020
a2bc66e
automl: add natural language sentiment analysis ga samples [(#2677)](…
nnegrey Jan 7, 2020
faaa7d1
automl: add base dataset samples for automl ga [(#2608)](https://gith…
nnegrey Jan 9, 2020
d8bcad2
automl: add natural language text classification ga samples [(#2678)]…
nnegrey Jan 14, 2020
72870c5
automl: add natural language entity extraction ga samples [(#2676)](h…
nnegrey Jan 14, 2020
1b5aa13
automl: add vision object detection samples for atuoml ga [(#2614)](h…
nnegrey Jan 14, 2020
0aa89b5
Automl ga base samples [(#2613)](https://github.com/GoogleCloudPlatfo…
nnegrey Jan 28, 2020
5164726
Update dependency google-cloud-automl to v0.10.0 [(#3033)](https://gi…
renovate-bot Mar 6, 2020
d78d643
automl: fix batch test due to error message change [(#3057)](https://…
nnegrey Mar 6, 2020
daf966f
chore(deps): update dependency google-cloud-storage to v1.26.0 [(#304…
renovate-bot Mar 9, 2020
4b16d18
Simplify noxfile setup. [(#2806)](https://github.com/GoogleCloudPlatf…
kurtisvg Apr 2, 2020
0f8a98b
[automl] fix: retry vision_object_detection_predict.predict [(#3492)]…
Apr 24, 2020
b7bf78e
chore(deps): update dependency google-cloud-storage to v1.28.0 [(#326…
renovate-bot Apr 29, 2020
a06af9f
chore(deps): update dependency google-cloud-storage to v1.28.1 [(#378…
renovate-bot May 19, 2020
667a1a0
chore(deps): update dependency google-cloud-storage to v1.29.0 [(#404…
renovate-bot Jun 19, 2020
e6e09fa
chore(deps): update dependency google-cloud-automl to v1 [(#4127)](ht…
renovate-bot Jun 19, 2020
8e56119
chore(deps): update dependency pytest to v5.4.3 [(#4279)](https://git…
renovate-bot Jul 12, 2020
e84bf0c
testing(automl): retry upon InternalServerError [(#4350)](https://git…
Jul 22, 2020
a163127
Update dependency pytest to v6 [(#4390)](https://github.com/GoogleClo…
renovate-bot Aug 1, 2020
c9cd8ed
chore: update templates
busunkim96 Aug 7, 2020
2f16326
Add Set Endpoint Samples [(#2497)](https://github.com/GoogleCloudPlat…
nnegrey Nov 15, 2019
7194a35
Auto-update dependencies. [(#2005)](https://github.com/GoogleCloudPla…
dpebot Dec 21, 2019
67e0111
automl: video beta move model samples from branch to master [(#2754)]…
nnegrey Jan 31, 2020
71de978
Update dependency google-cloud-automl to v0.10.0 [(#3033)](https://gi…
renovate-bot Mar 6, 2020
aca8456
automl: move video object tracking samples out of branch [(#3043)](ht…
nnegrey Mar 10, 2020
b492088
automl: video beta - move beta samples out of branch and into master …
nnegrey Mar 12, 2020
b61d731
automl: move samples to beta set [(#3045)](https://github.com/GoogleC…
nnegrey Mar 12, 2020
e93317c
automl: video beta samples move from branch to master [(#2753)](https…
nnegrey Mar 17, 2020
c83e0a8
automl: move samples into beta set [(#3044)](https://github.com/Googl…
nnegrey Mar 19, 2020
70bd0dd
Simplify noxfile setup. [(#2806)](https://github.com/GoogleCloudPlatf…
kurtisvg Apr 2, 2020
43b5c0e
automl: move video classification samples out of branch [(#3042)](htt…
nnegrey Apr 2, 2020
8ad4771
chore: some lint fixes [(#3737)](https://github.com/GoogleCloudPlatfo…
May 12, 2020
1ee4917
Replace GCLOUD_PROJECT with GOOGLE_CLOUD_PROJECT. [(#4022)](https://g…
kurtisvg Jun 9, 2020
29b2ff3
chore(deps): update dependency google-cloud-automl to v1 [(#4127)](ht…
renovate-bot Jun 19, 2020
2809161
chore(deps): update dependency pytest to v5.4.3 [(#4279)](https://git…
renovate-bot Jul 12, 2020
6754805
Update dependency pytest to v6 [(#4390)](https://github.com/GoogleClo…
renovate-bot Aug 1, 2020
2b6c25b
chore: update templates
busunkim96 Aug 7, 2020
963dfb0
chore: fix batch predict test
busunkim96 Aug 13, 2020
96a73f9
docs: add samples from tables/automl (#54)
busunkim96 Aug 13, 2020
237d97a
automl beta [(#1575)](https://github.com/GoogleCloudPlatform/python-d…
sirtorry Jul 20, 2018
e3c9dc8
remove translate prediction fallback [(#1598)](https://github.com/Goo…
sirtorry Jul 24, 2018
72fe254
skip automl model create/delete test [(#1608)](https://github.com/Goo…
sirtorry Aug 3, 2018
82ac276
Auto-update dependencies. [(#1658)](https://github.com/GoogleCloudPla…
dpebot Aug 28, 2018
2e80f45
Update AutoML region tags to use standard product prefixes [(#1669)](…
alixhami Aug 29, 2018
6d5fb26
Fix AutoML region tag typos [(#1687)](https://github.com/GoogleCloudP…
alixhami Sep 6, 2018
f2217bb
Fixed name of model [(#1779)](https://github.com/GoogleCloudPlatform/…
engelke Oct 19, 2018
c0425dd
Auto-update dependencies. [(#1980)](https://github.com/GoogleCloudPla…
dpebot Feb 6, 2019
fae4b44
Updated beta version of automl [(#2124)](https://github.com/GoogleClo…
engelke Apr 26, 2019
2c4f530
Translate: migrate published v3 translate batch samples [(#2914)](ht…
munkhuushmgl Mar 2, 2020
808c225
chore(deps): update dependency google-cloud-storage to v1.28.1 [(#378…
renovate-bot May 19, 2020
9775c7e
Replace GCLOUD_PROJECT with GOOGLE_CLOUD_PROJECT. [(#4022)](https://g…
kurtisvg Jun 9, 2020
44766bb
fix(translate): fix a broken test [(#4360)](https://github.com/Google…
Jul 23, 2020
e28ebcb
chore(deps): update dependency google-cloud-translate to v2.0.2 [(#44…
renovate-bot Aug 4, 2020
0c2985f
Update dependency google-cloud-storage to v1.30.0
renovate-bot Jul 29, 2020
87f3105
docs: add cancel operation sample
busunkim96 Aug 18, 2020
b2209c9
chore: lint
busunkim96 Aug 18, 2020
d7d5fdd
feat!: move to microgen (#61)
busunkim96 Sep 16, 2020
eacc07f
samples: migrate vision automl samples (#71)
munkhuushmgl Sep 21, 2020
411d98f
chore(deps): update dependency google-cloud-storage to v1.31.2 (#57)
renovate-bot Sep 23, 2020
c6b4576
samples: tests refactored due to overwhelmed resources (#79)
munkhuushmgl Sep 25, 2020
9b467fd
samples: version update on automl tables (#84)
munkhuushmgl Oct 20, 2020
ad935e2
chore(deps): update dependency google-cloud-storage to v1.32.0 (#83)
renovate-bot Oct 23, 2020
d49a2e1
feat: add support for common resource paths and expose the client tra…
yoshi-automation Dec 1, 2020
0021cc6
chore(deps): update dependency google-cloud-storage to v1.33.0 (#96)
renovate-bot Dec 8, 2020
d98a59a
chore(deps): update dependency google-cloud-translate to v3.0.2 (#105)
renovate-bot Dec 14, 2020
660077a
chore: refactor translation automl test (#113)
munkhuushmgl Dec 22, 2020
2389d5c
chore: update templates (#115)
yoshi-automation Dec 29, 2020
a140943
chore: removed unused and duplicate samples (#127)
munkhuushmgl Feb 16, 2021
c65b7b9
bug: missing preprocessing examples for automl edge models (#131)
genquan9 Mar 2, 2021
066bac1
chore: remove unneeded Translation and NL references (#129)
telpirion Mar 2, 2021
d9f1961
chore(deps): update dependency google-cloud-automl to v2.2.0 (#133)
renovate-bot Mar 5, 2021
c98aee6
chore(deps): update dependency google-cloud-storage to v1.36.1 (#106)
renovate-bot Mar 5, 2021
828f718
chore(deps): update dependency google-cloud-storage to v1.36.2 (#135)
renovate-bot Mar 11, 2021
7e625f0
chore(deps): update dependency google-cloud-storage to v1.37.0 (#138)
renovate-bot Mar 25, 2021
fd2fe6b
chore(deps): update dependency google-cloud-translate to v3.1.0 (#139)
renovate-bot Apr 1, 2021
c6728d0
fix: use correct retry deadlines (#119)
yoshi-automation Apr 2, 2021
b093c99
chore(deps): update dependency google-cloud-storage to v1.37.1 (#142)
renovate-bot Apr 8, 2021
248ad6b
chore(deps): update dependency google-cloud-automl to v2.3.0 (#147)
renovate-bot Apr 28, 2021
e5fe822
chore: migrate to owl bot (#156)
parthea May 13, 2021
32596e9
chore(deps): update dependency pytest to v6.2.4 (#157)
renovate-bot May 14, 2021
627fbab
chore: new owl bot post processor docker image (#164)
gcf-owl-bot[bot] May 28, 2021
ae5fa4c
chore(deps): update dependency google-cloud-translate to v3.2.0 (#169)
renovate-bot Jun 4, 2021
0b50aae
chore(deps): update dependency google-cloud-storage to v1.38.0 (#152)
renovate-bot Jun 16, 2021
a30720e
chore(deps): update dependency google-cloud-storage to v1.39.0 (#177)
renovate-bot Jun 23, 2021
7bed4a7
chore(deps): update dependency google-cloud-translate to v3.2.1 (#176)
renovate-bot Jun 24, 2021
2bb3697
chore(deps): update dependency google-cloud-storage to v1.40.0 (#182)
renovate-bot Jul 1, 2021
f54976c
chore(deps): update dependency backoff to v1.11.0 (#184)
renovate-bot Jul 12, 2021
ec1a3f1
chore(deps): update dependency google-cloud-automl to v2.4.0 (#185)
renovate-bot Jul 13, 2021
56b0cbb
chore(deps): update dependency backoff to v1.11.1 (#206)
renovate-bot Jul 16, 2021
04e94ab
chore(deps): update dependency google-cloud-storage to v1.41.0 (#205)
renovate-bot Jul 16, 2021
206705c
chore(deps): update dependency google-cloud-storage to v1.41.1 (#212)
renovate-bot Jul 21, 2021
c46e046
feat: add Samples section to CONTRIBUTING.rst (#210)
gcf-owl-bot[bot] Jul 22, 2021
5ad4229
chore(deps): update dependency google-cloud-automl to v2.4.1 (#213)
renovate-bot Jul 22, 2021
366e9ce
chore(deps): update dependency google-cloud-translate to v3.3.1 (#214)
renovate-bot Jul 22, 2021
780f3fd
chore(deps): update dependency google-cloud-automl to v2.4.2 (#220)
renovate-bot Jul 28, 2021
e97fa1c
chore(deps): update dependency google-cloud-translate to v3.3.2 (#221)
renovate-bot Jul 29, 2021
c90f579
chore: fix INSTALL_LIBRARY_FROM_SOURCE in noxfile.py (#224)
gcf-owl-bot[bot] Aug 11, 2021
4425e07
chore(deps): update dependency google-cloud-storage to v1.42.0 (#226)
renovate-bot Aug 12, 2021
63fb4c3
chore: drop mention of Python 2.7 from templates (#228)
gcf-owl-bot[bot] Aug 13, 2021
3fce81e
samples: switch to next() function rather than next() method (#242)
telpirion Sep 2, 2021
8d52bb3
fix: flaky test, issue 223 (#250)
andrewferlitsch Sep 10, 2021
03407e0
chore: blacken samples noxfile template (#252)
gcf-owl-bot[bot] Sep 17, 2021
72734c5
chore: fail samples nox session if python version is missing (#259)
gcf-owl-bot[bot] Sep 30, 2021
f7994ec
chore(python): Add kokoro configs for python 3.10 samples testing (#265)
gcf-owl-bot[bot] Oct 8, 2021
44143e7
chore(deps): update all dependencies (#240)
renovate-bot Oct 15, 2021
b889563
chore(deps): update all dependencies (#269)
renovate-bot Oct 18, 2021
a027d45
chore(deps): update dependency google-cloud-translate to v3.6.0 (#272)
renovate-bot Oct 20, 2021
c517dbc
chore(deps): update dependency google-cloud-automl to v2.5.1 (#275)
renovate-bot Oct 21, 2021
dc7302b
chore(deps): update dependency google-cloud-automl to v2.5.2 (#280)
renovate-bot Nov 4, 2021
73fa3fe
chore(deps): update dependency google-cloud-translate to v3.6.1 (#281)
renovate-bot Nov 4, 2021
0b5ba42
chore(deps): update dependency google-cloud-storage to v1.43.0 (#291)
renovate-bot Nov 18, 2021
025b915
test: Backoff on predict_test.py (#302)
nayaknishant Dec 12, 2021
ac88dfe
chore: update python-docs-samples link to main branch (#297)
gcf-owl-bot[bot] Dec 13, 2021
3251ae6
chore(deps): update dependency google-cloud-storage to v1.44.0 (#308)
renovate-bot Jan 11, 2022
6bb987e
chore(samples): Add check for tests in directory (#313)
gcf-owl-bot[bot] Jan 11, 2022
25a6565
fix(deps): allow google-cloud-storage < 3.0.0dev (#316)
renovate-bot Jan 15, 2022
7b57c83
chore(deps): update dependency google-cloud-automl to v2.6.0 (#321)
renovate-bot Jan 18, 2022
37c971b
chore(python): Noxfile recognizes that tests can live in a folder (#322)
gcf-owl-bot[bot] Jan 19, 2022
a6c64c1
chore(deps): update dependency google-cloud-storage to v2.1.0 (#323)
renovate-bot Jan 22, 2022
fface3e
chore(deps): update all dependencies (#332)
renovate-bot Feb 6, 2022
64b9e81
chore(deps): update all dependencies (#334)
renovate-bot Feb 25, 2022
6e9c7f7
chore(deps): update all dependencies (#343)
renovate-bot Mar 1, 2022
f5d0e1e
chore: Adding support for pytest-xdist and pytest-parallel (#349)
gcf-owl-bot[bot] Mar 4, 2022
e2cfc25
chore(deps): update all dependencies (#345)
renovate-bot Mar 6, 2022
f490444
chore(deps): update all dependencies (#353)
renovate-bot Mar 7, 2022
185220e
chore(deps): update dependency pytest to v7.1.0 (#356)
renovate-bot Mar 13, 2022
889a3ba
chore(deps): update dependency google-cloud-storage to v2.2.0 (#357)
renovate-bot Mar 14, 2022
de818bb
chore(deps): update dependency google-cloud-storage to v2.2.1 (#358)
renovate-bot Mar 15, 2022
138c42a
chore(deps): update dependency pytest to v7.1.1 (#360)
renovate-bot Mar 21, 2022
a0e7f43
chore(python): use black==22.3.0 (#362)
gcf-owl-bot[bot] Mar 30, 2022
ad11401
chore(deps): update dependency google-cloud-storage to v2.3.0 (#376)
renovate-bot Apr 13, 2022
9c3cff5
chore(python): add nox session to sort python imports (#378)
gcf-owl-bot[bot] Apr 21, 2022
683d2de
chore(deps): update dependency pytest to v7.1.2 (#381)
renovate-bot Apr 25, 2022
ab40e26
chore(deps): update dependency backoff to v2 (#383)
renovate-bot Apr 26, 2022
00e91fe
chore(deps): update dependency backoff to v2.0.1 (#385)
renovate-bot Apr 27, 2022
88bbdcf
chore(deps): update dependency google-cloud-translate to v3.7.3 (#389)
renovate-bot May 19, 2022
03ad810
chore(deps): update all dependencies (#396)
renovate-bot Jun 7, 2022
c2456b5
fix: require python 3.7+ (#405)
gcf-owl-bot[bot] Jul 17, 2022
8405349
chore(deps): update all dependencies (#398)
renovate-bot Jul 19, 2022
2c699dc
chore(deps): update all dependencies (#413)
renovate-bot Aug 2, 2022
b2044a8
chore(deps): update all dependencies (#415)
renovate-bot Aug 6, 2022
403e850
chore(deps): update all dependencies (#420)
renovate-bot Aug 16, 2022
90ad2c7
chore(deps): update dependency pytest to v7.1.3 (#431)
renovate-bot Sep 6, 2022
3f1bd22
chore(deps): update dependency google-cloud-translate to v3.8.2 (#432)
renovate-bot Sep 7, 2022
9bc963c
chore: detect samples tests in nested directories (#436)
gcf-owl-bot[bot] Sep 13, 2022
a9b9a61
chore(deps): update all dependencies (#441)
renovate-bot Oct 4, 2022
0f2071e
chore(deps): update dependency backoff to v2.2.1 (#442)
renovate-bot Oct 6, 2022
f1eeacb
chore(deps): update all dependencies (#446)
renovate-bot Oct 18, 2022
1c943d6
chore(deps): update dependency pytest to v7.2.0 (#447)
renovate-bot Oct 26, 2022
5979c87
Merge remote-tracking branch 'migration/main' into python-automl-migr…
arbrown Nov 17, 2022
e723414
Add blunderbuss and codeowners
arbrown Nov 17, 2022
f55d5af
Ignore input.txt from header check
arbrown Nov 17, 2022
687131b
Remove noxfiles
arbrown Nov 17, 2022
91ab689
Update .github/blunderbuss.yml
arbrown Nov 17, 2022
fbfc744
Add copyright header to sample text file
arbrown Nov 17, 2022
ef2735c
Update automl/snippets/resources/input.txt
dandhlee Nov 17, 2022
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/appengine/flexible/django_cloudsql/**/* @glasnt @GoogleCloudPlatform/aap-dpes @GoogleCloudPlatform/python-samples-reviewers
/appengine/standard_python3/spanner/* @GoogleCloudPlatform/api-spanner-python @GoogleCloudPlatform/python-samples-reviewers
/auth/**/* @arithmetic1728 @GoogleCloudPlatform/python-samples-reviewers
/automl/**/* @GoogleCloudPlatform/ml-apis @GoogleCloudPlatform/python-samples-reviewers
/batch/**/* @m-strzelczyk @GoogleCloudPlatform/dee-infra @GoogleCloudPlatform/python-samples-reviewers
/bigquery/**/* @chalmerlowe @GoogleCloudPlatform/python-samples-reviewers
/bigquery/remote_function/**/* @autoerr @GoogleCloudPlatform/python-samples-reviewers
Expand Down
4 changes: 4 additions & 0 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ assign_issues_by:
- 'api: vision'
to:
- GoogleCloudPlatform/python-samples-reviewers
- labels:
- 'api: vision'
to:
- GoogleCloudPlatform/ml-apis

assign_prs_by:
- labels:
Expand Down
1 change: 0 additions & 1 deletion .github/header-checker-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ignoreFiles:
- "texttospeech/snippets/resources/example.txt"
- "texttospeech/snippets/resources/hello.txt"


ignoreLicenseYear: true

sourceFileExtensions:
Expand Down
1 change: 1 addition & 0 deletions automl/AUTHORING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md
1 change: 1 addition & 0 deletions automl/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/CONTRIBUTING.md
59 changes: 59 additions & 0 deletions automl/beta/batch_predict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2020 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.


# [START automl_batch_predict_beta]
from google.cloud import automl_v1beta1 as automl


def batch_predict(
project_id="YOUR_PROJECT_ID",
model_id="YOUR_MODEL_ID",
input_uri="gs://YOUR_BUCKET_ID/path/to/your/input/csv_or_jsonl",
output_uri="gs://YOUR_BUCKET_ID/path/to/save/results/",
):
"""Batch predict"""
prediction_client = automl.PredictionServiceClient()

# Get the full path of the model.
model_full_id = automl.AutoMlClient.model_path(
project_id, "us-central1", model_id
)

gcs_source = automl.GcsSource(input_uris=[input_uri])

input_config = automl.BatchPredictInputConfig(gcs_source=gcs_source)
gcs_destination = automl.GcsDestination(output_uri_prefix=output_uri)
output_config = automl.BatchPredictOutputConfig(
gcs_destination=gcs_destination
)
params = {}

request = automl.BatchPredictRequest(
name=model_full_id,
input_config=input_config,
output_config=output_config,
params=params
)
response = prediction_client.batch_predict(
request=request
)

print("Waiting for operation to complete...")
print(
"Batch Prediction results saved to Cloud Storage bucket. {}".format(
response.result()
)
)
# [END automl_batch_predict_beta]
47 changes: 47 additions & 0 deletions automl/beta/batch_predict_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2020 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 ladnguage governing permissions and
# limitations under the License.

import datetime
import os

import batch_predict

PROJECT_ID = os.environ["AUTOML_PROJECT_ID"]
BUCKET_ID = "{}-lcm".format(PROJECT_ID)
MODEL_ID = "TEN0000000000000000000"
PREFIX = "TEST_EXPORT_OUTPUT_" + datetime.datetime.now().strftime(
"%Y%m%d%H%M%S"
)


def test_batch_predict(capsys):
# As batch prediction can take a long time. Try to batch predict on a model
# and confirm that the model was not found, but other elements of the
# request were valid.
try:
input_uri = "gs://{}/entity-extraction/input.jsonl".format(BUCKET_ID)
output_uri = "gs://{}/{}/".format(BUCKET_ID, PREFIX)
batch_predict.batch_predict(
PROJECT_ID, MODEL_ID, input_uri, output_uri
)
out, _ = capsys.readouterr()
assert (
"does not exist"
in out
)
except Exception as e:
assert (
"does not exist"
in e.message
)
62 changes: 62 additions & 0 deletions automl/beta/cancel_operation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -*- 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
#
# 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,
# 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.


# [START automl_cancel_operation]

from google.cloud import automl_v1beta1


def sample_cancel_operation(project, operation_id):
"""
Cancel Long-Running Operation

Args:
project Required. Your Google Cloud Project ID.
operation_id Required. The ID of the Operation.
"""

client = automl_v1beta1.AutoMlClient()

operations_client = client._transport.operations_client

# project = '[Google Cloud Project ID]'
# operation_id = '[Operation ID]'
name = "projects/{}/locations/us-central1/operations/{}".format(
project, operation_id
)

operations_client.cancel_operation(name)

print(u"Cancelled operation: {}".format(name))


# [END automl_cancel_operation]


def main():
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--project", type=str, default="[Google Cloud Project ID]")
parser.add_argument("--operation_id", type=str, default="[Operation ID]")
args = parser.parse_args()

sample_cancel_operation(args.project, args.operation_id)


if __name__ == "__main__":
main()
30 changes: 30 additions & 0 deletions automl/beta/delete_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2020 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.


# [START automl_delete_dataset_beta]
from google.cloud import automl_v1beta1 as automl


def delete_dataset(project_id="YOUR_PROJECT_ID", dataset_id="YOUR_DATASET_ID"):
"""Delete a dataset."""
client = automl.AutoMlClient()
# Get the full path of the dataset
dataset_full_id = client.dataset_path(
project_id, "us-central1", dataset_id
)
response = client.delete_dataset(name=dataset_full_id)

print("Dataset deleted. {}".format(response.result()))
# [END automl_delete_dataset_beta]
46 changes: 46 additions & 0 deletions automl/beta/delete_dataset_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 2020 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.

import os
import uuid

from google.cloud import automl_v1beta1 as automl
import pytest

import delete_dataset

PROJECT_ID = os.environ["AUTOML_PROJECT_ID"]
BUCKET_ID = "{}-lcm".format(PROJECT_ID)


@pytest.fixture(scope="function")
def dataset_id():
client = automl.AutoMlClient()
project_location = f"projects/{PROJECT_ID}/locations/us-central1"
display_name = "test_{}".format(uuid.uuid4()).replace("-", "")[:32]
metadata = automl.VideoClassificationDatasetMetadata()
dataset = automl.Dataset(
display_name=display_name, video_classification_dataset_metadata=metadata
)
response = client.create_dataset(parent=project_location, dataset=dataset)
dataset_id = response.name.split("/")[-1]

yield dataset_id


def test_delete_dataset(capsys, dataset_id):
# delete dataset
delete_dataset.delete_dataset(PROJECT_ID, dataset_id)
out, _ = capsys.readouterr()
assert "Dataset deleted." in out
31 changes: 31 additions & 0 deletions automl/beta/delete_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2020 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.


def delete_model(project_id, model_id):
"""Delete a model."""
# [START automl_delete_model_beta]
from google.cloud import automl_v1beta1 as automl

# TODO(developer): Uncomment and set the following variables
# 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.delete_model(name=model_full_id)

print("Model deleted. {}".format(response.result()))
# [END automl_delete_model_beta]
31 changes: 31 additions & 0 deletions automl/beta/delete_model_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2020 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.

import os

import delete_model

PROJECT_ID = os.environ["AUTOML_PROJECT_ID"]


def test_delete_model(capsys):
# As model creation can take many hours, instead try to delete a
# nonexistent model and confirm that the model was not found, but other
# elements of the request were valid.
try:
delete_model.delete_model(PROJECT_ID, "VCN0000000000000000000")
out, _ = capsys.readouterr()
assert "The model does not exist" in out
except Exception as e:
assert "The model does not exist" in e.message
42 changes: 42 additions & 0 deletions automl/beta/get_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2020 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.


def get_model(project_id, model_id):
"""Get a model."""
# [START automl_get_model_beta]
from google.cloud import automl_v1beta1 as automl

# TODO(developer): Uncomment and set the following variables
# 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)
model = client.get_model(name=model_full_id)

# Retrieve deployment state.
if model.deployment_state == automl.Model.DeploymentState.DEPLOYED:
deployment_state = "deployed"
else:
deployment_state = "undeployed"

# Display the model information.
print("Model name: {}".format(model.name))
print("Model id: {}".format(model.name.split("/")[-1]))
print("Model display name: {}".format(model.display_name))
print("Model create time: {}".format(model.create_time))
print("Model deployment state: {}".format(deployment_state))
# [END automl_get_model_beta]
Loading