1818
1919import create_annotation_spec_set
2020import create_instruction
21+ from google .api_core .client_options import ClientOptions
2122from google .cloud import datalabeling_v1beta1 as datalabeling
2223import import_data
2324import label_image
@@ -52,6 +53,13 @@ def annotation_spec_set():
5253
5354 # tear down
5455 client = datalabeling .DataLabelingServiceClient ()
56+
57+ # If provided, use a provided test endpoint - this will prevent tests on
58+ # this snippet from triggering any action by a real human
59+ if 'DATALABELING_ENDPOINT' in os .environ :
60+ opts = ClientOptions (api_endpoint = os .getenv ('DATALABELING_ENDPOINT' ))
61+ client = datalabeling .DataLabelingServiceClient (client_options = opts )
62+
5563 client .delete_annotation_spec_set (response .name )
5664
5765
@@ -66,6 +74,13 @@ def instruction():
6674
6775 # tear down
6876 client = datalabeling .DataLabelingServiceClient ()
77+
78+ # If provided, use a provided test endpoint - this will prevent tests on
79+ # this snippet from triggering any action by a real human
80+ if 'DATALABELING_ENDPOINT' in os .environ :
81+ opts = ClientOptions (api_endpoint = os .getenv ('DATALABELING_ENDPOINT' ))
82+ client = datalabeling .DataLabelingServiceClient (client_options = opts )
83+
6984 client .delete_instruction (instruction .name )
7085
7186
@@ -89,5 +104,12 @@ def test_label_image(capsys, annotation_spec_set, instruction, dataset):
89104 assert response .cancelled () is True
90105
91106 client = datalabeling .DataLabelingServiceClient ()
107+
108+ # If provided, use a provided test endpoint - this will prevent tests on
109+ # this snippet from triggering any action by a real human
110+ if 'DATALABELING_ENDPOINT' in os .environ :
111+ opts = ClientOptions (api_endpoint = os .getenv ('DATALABELING_ENDPOINT' ))
112+ client = datalabeling .DataLabelingServiceClient (client_options = opts )
113+
92114 client .transport ._operations_client .cancel_operation (
93115 operation_name )
0 commit comments