-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* 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>
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
# 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_dataset(project_id, dataset_id): | ||
"""Delete a dataset.""" | ||
# [START automl_delete_dataset_beta] | ||
from google.cloud import automl_v1beta1 as automl | ||
|
||
# TODO(developer): Uncomment and set the following variables | ||
# project_id = "YOUR_PROJECT_ID" | ||
# dataset_id = "YOUR_DATASET_ID" | ||
|
||
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(dataset_full_id) | ||
|
||
print("Dataset deleted. {}".format(response.result())) | ||
# [END automl_delete_dataset_beta] |
This file contains 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,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 datetime | ||
import os | ||
|
||
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 = client.location_path(PROJECT_ID, "us-central1") | ||
display_name = "test_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S") | ||
metadata = automl.types.TextExtractionDatasetMetadata() | ||
dataset = automl.types.Dataset( | ||
display_name=display_name, text_extraction_dataset_metadata=metadata | ||
) | ||
dataset = client.create_dataset(project_location, dataset) | ||
dataset_id = dataset.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 |
This file contains 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 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