Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f4ff21a

Browse filesBrowse files
nnegreyleahecolebusunkim96gcf-merge-on-green[bot]
authored
automl: video beta samples move from branch to master (GoogleCloudPlatform#2753)
* automl: video beta samples move from branch to master * fix test for when create dataset doesn't return an LRO Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com> Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com>
1 parent 89f7747 commit f4ff21a
Copy full SHA for f4ff21a

File tree

Expand file treeCollapse file tree

4 files changed

+81
-0
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+81
-0
lines changed

‎automl/beta/delete_dataset.py

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
def delete_dataset(project_id, dataset_id):
17+
"""Delete a dataset."""
18+
# [START automl_delete_dataset_beta]
19+
from google.cloud import automl_v1beta1 as automl
20+
21+
# TODO(developer): Uncomment and set the following variables
22+
# project_id = "YOUR_PROJECT_ID"
23+
# dataset_id = "YOUR_DATASET_ID"
24+
25+
client = automl.AutoMlClient()
26+
# Get the full path of the dataset
27+
dataset_full_id = client.dataset_path(
28+
project_id, "us-central1", dataset_id
29+
)
30+
response = client.delete_dataset(dataset_full_id)
31+
32+
print("Dataset deleted. {}".format(response.result()))
33+
# [END automl_delete_dataset_beta]

‎automl/beta/delete_dataset_test.py

Copy file name to clipboard
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import datetime
16+
import os
17+
18+
from google.cloud import automl_v1beta1 as automl
19+
import pytest
20+
21+
import delete_dataset
22+
23+
PROJECT_ID = os.environ["AUTOML_PROJECT_ID"]
24+
BUCKET_ID = "{}-lcm".format(PROJECT_ID)
25+
26+
27+
@pytest.fixture(scope="function")
28+
def dataset_id():
29+
client = automl.AutoMlClient()
30+
project_location = client.location_path(PROJECT_ID, "us-central1")
31+
display_name = "test_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
32+
metadata = automl.types.TextExtractionDatasetMetadata()
33+
dataset = automl.types.Dataset(
34+
display_name=display_name, text_extraction_dataset_metadata=metadata
35+
)
36+
dataset = client.create_dataset(project_location, dataset)
37+
dataset_id = dataset.name.split("/")[-1]
38+
39+
yield dataset_id
40+
41+
42+
def test_delete_dataset(capsys, dataset_id):
43+
# delete dataset
44+
delete_dataset.delete_dataset(PROJECT_ID, dataset_id)
45+
out, _ = capsys.readouterr()
46+
assert "Dataset deleted." in out

‎automl/beta/import_dataset.py

Copy file name to clipboardExpand all lines: automl/beta/import_dataset.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
1516
# [START automl_import_data_beta]
1617
from google.cloud import automl_v1beta1 as automl
1718

‎automl/beta/list_datasets.py

Copy file name to clipboardExpand all lines: automl/beta/list_datasets.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
1516
# [START automl_video_classification_list_datasets_beta]
1617
# [START automl_video_object_tracking_list_datasets_beta]
1718
from google.cloud import automl_v1beta1 as automl

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.