|
| 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 | +# [START automl_video_classification_list_datasets_beta] |
| 16 | +# [START automl_video_object_tracking_list_datasets_beta] |
| 17 | +from google.cloud import automl_v1beta1 as automl |
| 18 | + |
| 19 | + |
| 20 | +def list_datasets(project_id="YOUR_PROJECT_ID"): |
| 21 | + """List datasets.""" |
| 22 | + client = automl.AutoMlClient() |
| 23 | + # A resource that represents Google Cloud Platform location. |
| 24 | + project_location = client.location_path(project_id, "us-central1") |
| 25 | + |
| 26 | + # List all the datasets available in the region. |
| 27 | + response = client.list_datasets(project_location, "") |
| 28 | + |
| 29 | + print("List of datasets:") |
| 30 | + for dataset in response: |
| 31 | + print("Dataset name: {}".format(dataset.name)) |
| 32 | + print("Dataset id: {}".format(dataset.name.split("/")[-1])) |
| 33 | + print("Dataset display name: {}".format(dataset.display_name)) |
| 34 | + print("Dataset create time:") |
| 35 | + print("\tseconds: {}".format(dataset.create_time.seconds)) |
| 36 | + print("\tnanos: {}".format(dataset.create_time.nanos)) |
| 37 | + # [END automl_video_object_tracking_list_datasets_beta] |
| 38 | + |
| 39 | + print( |
| 40 | + "Video classification dataset metadata: {}".format( |
| 41 | + dataset.video_classification_dataset_metadata |
| 42 | + ) |
| 43 | + ) |
| 44 | + # [END automl_video_classification_list_datasets_beta] |
| 45 | + |
| 46 | + # [START automl_video_object_tracking_list_datasets_beta] |
| 47 | + print( |
| 48 | + "Video object tracking dataset metadata: {}".format( |
| 49 | + dataset.video_object_tracking_dataset_metadata |
| 50 | + ) |
| 51 | + ) |
| 52 | + # [END automl_video_object_tracking_list_datasets_beta] |
0 commit comments