@@ -35,20 +35,20 @@ def create_dataset(project_id):
35
35
formatted_project_name = client .project_path (project_id )
36
36
37
37
dataset = datalabeling .types .Dataset (
38
- display_name = 'YOUR_ANNOTATION_SPEC_SET_DISPLAY_NAME ' ,
38
+ display_name = 'YOUR_DATASET_SET_DISPLAY_NAME ' ,
39
39
description = 'YOUR_DESCRIPTION'
40
40
)
41
41
42
42
response = client .create_dataset (formatted_project_name , dataset )
43
43
44
44
# The format of resource name:
45
45
# project_id/{project_id}/datasets/{dataset_id}
46
- print ('The dataset resource name: {}\n ' .format (response .name ))
46
+ print ('The dataset resource name: {}' .format (response .name ))
47
47
print ('Display name: {}' .format (response .display_name ))
48
48
print ('Description: {}' .format (response .description ))
49
49
print ('Create time:' )
50
50
print ('\t seconds: {}' .format (response .create_time .seconds ))
51
- print ('\t nanos: {}' .format (response .create_time .nanos ))
51
+ print ('\t nanos: {}\n ' .format (response .create_time .nanos ))
52
52
53
53
return response
54
54
# [END datalabeling_create_dataset_beta]
@@ -59,6 +59,13 @@ def list_datasets(project_id):
59
59
"""Lists datasets for the given Google Cloud project."""
60
60
from google .cloud import datalabeling_v1beta1 as datalabeling
61
61
client = datalabeling .DataLabelingServiceClient ()
62
+ # [END datalabeling_list_datasets_beta]
63
+ # If provided, use a provided test endpoint - this will prevent tests on
64
+ # this snippet from triggering any action by a real human
65
+ if 'DATALABELING_ENDPOINT' in os .environ :
66
+ opts = ClientOptions (api_endpoint = os .getenv ('DATALABELING_ENDPOINT' ))
67
+ client = datalabeling .DataLabelingServiceClient (client_options = opts )
68
+ # [START datalabeling_list_datasets_beta]
62
69
63
70
formatted_project_name = client .project_path (project_id )
64
71
@@ -80,6 +87,13 @@ def get_dataset(dataset_resource_name):
80
87
"""Gets a dataset for the given Google Cloud project."""
81
88
from google .cloud import datalabeling_v1beta1 as datalabeling
82
89
client = datalabeling .DataLabelingServiceClient ()
90
+ # [END datalabeling_get_dataset_beta]
91
+ # If provided, use a provided test endpoint - this will prevent tests on
92
+ # this snippet from triggering any action by a real human
93
+ if 'DATALABELING_ENDPOINT' in os .environ :
94
+ opts = ClientOptions (api_endpoint = os .getenv ('DATALABELING_ENDPOINT' ))
95
+ client = datalabeling .DataLabelingServiceClient (client_options = opts )
96
+ # [START datalabeling_get_dataset_beta]
83
97
84
98
response = client .get_dataset (dataset_resource_name )
85
99
@@ -97,6 +111,13 @@ def delete_dataset(dataset_resource_name):
97
111
"""Deletes a dataset for the given Google Cloud project."""
98
112
from google .cloud import datalabeling_v1beta1 as datalabeling
99
113
client = datalabeling .DataLabelingServiceClient ()
114
+ # [END datalabeling_delete_dataset_beta]
115
+ # If provided, use a provided test endpoint - this will prevent tests on
116
+ # this snippet from triggering any action by a real human
117
+ if 'DATALABELING_ENDPOINT' in os .environ :
118
+ opts = ClientOptions (api_endpoint = os .getenv ('DATALABELING_ENDPOINT' ))
119
+ client = datalabeling .DataLabelingServiceClient (client_options = opts )
120
+ # [START datalabeling_delete_dataset_beta]
100
121
101
122
response = client .delete_dataset (dataset_resource_name )
102
123
0 commit comments