From 369bb871e96408b0cdda3f6810b400cf3ecefbfb Mon Sep 17 00:00:00 2001 From: kurtisvg <31518063+kurtisvg@users.noreply.github.com> Date: Fri, 20 Dec 2019 17:49:32 -0800 Subject: [PATCH] Update datalabeling to match lint. --- datalabeling/export_data.py | 1 + datalabeling/import_data.py | 1 + datalabeling/label_image.py | 1 + datalabeling/label_text.py | 6 ++++-- datalabeling/label_video.py | 6 ++++-- datalabeling/manage_dataset.py | 1 + 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/datalabeling/export_data.py b/datalabeling/export_data.py index 35418a4839f..3ffa2abd3b2 100644 --- a/datalabeling/export_data.py +++ b/datalabeling/export_data.py @@ -30,6 +30,7 @@ def export_data(dataset_resource_name, annotated_dataset_resource_name, # this snippet from triggering any action by a real human if 'DATALABELING_ENDPOINT' in os.environ: opts = ClientOptions(api_endpoint=os.getenv('DATALABELING_ENDPOINT')) + client = datalabeling.DataLabelingServiceClient(client_options=opts) # [START datalabeling_export_data_beta] gcs_destination = datalabeling.types.GcsDestination( diff --git a/datalabeling/import_data.py b/datalabeling/import_data.py index c38a81c596d..3ef4331f797 100644 --- a/datalabeling/import_data.py +++ b/datalabeling/import_data.py @@ -29,6 +29,7 @@ def import_data(dataset_resource_name, data_type, input_gcs_uri): # this snippet from triggering any action by a real human if 'DATALABELING_ENDPOINT' in os.environ: opts = ClientOptions(api_endpoint=os.getenv('DATALABELING_ENDPOINT')) + client = datalabeling.DataLabelingServiceClient(client_options=opts) # [START datalabeling_import_data_beta] gcs_source = datalabeling.types.GcsSource( diff --git a/datalabeling/label_image.py b/datalabeling/label_image.py index 3b2405d8f85..bbd92dde4b7 100644 --- a/datalabeling/label_image.py +++ b/datalabeling/label_image.py @@ -30,6 +30,7 @@ def label_image(dataset_resource_name, instruction_resource_name, # this snippet from triggering any action by a real human if 'DATALABELING_ENDPOINT' in os.environ: opts = ClientOptions(api_endpoint=os.getenv('DATALABELING_ENDPOINT')) + client = datalabeling.DataLabelingServiceClient(client_options=opts) # [START datalabeling_label_image_beta] basic_config = datalabeling.types.HumanAnnotationConfig( diff --git a/datalabeling/label_text.py b/datalabeling/label_text.py index 91db90f81a9..e6056ef19c0 100644 --- a/datalabeling/label_text.py +++ b/datalabeling/label_text.py @@ -18,18 +18,20 @@ import os from google.api_core.client_options import ClientOptions + # [START datalabeling_label_text_beta] def label_text(dataset_resource_name, instruction_resource_name, annotation_spec_set_resource_name): """Labels a text dataset.""" from google.cloud import datalabeling_v1beta1 as datalabeling client = datalabeling.DataLabelingServiceClient() - # [END datalabeling_export_data_beta] + # [END datalabeling_label_text_beta] # If provided, use a provided test endpoint - this will prevent tests on # this snippet from triggering any action by a real human if 'DATALABELING_ENDPOINT' in os.environ: opts = ClientOptions(api_endpoint=os.getenv('DATALABELING_ENDPOINT')) - # [START datalabeling_export_data_beta] + client = datalabeling.DataLabelingServiceClient(client_options=opts) + # [START datalabeling_label_text_beta] basic_config = datalabeling.types.HumanAnnotationConfig( instruction=instruction_resource_name, diff --git a/datalabeling/label_video.py b/datalabeling/label_video.py index 0ce1f29768b..5ae317e82e5 100644 --- a/datalabeling/label_video.py +++ b/datalabeling/label_video.py @@ -18,18 +18,20 @@ import os from google.api_core.client_options import ClientOptions + # [START datalabeling_label_video_beta] def label_video(dataset_resource_name, instruction_resource_name, annotation_spec_set_resource_name): """Labels a video dataset.""" from google.cloud import datalabeling_v1beta1 as datalabeling client = datalabeling.DataLabelingServiceClient() - # [END datalabeling_export_data_beta] + # [END datalabeling_label_video_beta] # If provided, use a provided test endpoint - this will prevent tests on # this snippet from triggering any action by a real human if 'DATALABELING_ENDPOINT' in os.environ: opts = ClientOptions(api_endpoint=os.getenv('DATALABELING_ENDPOINT')) - # [START datalabeling_export_data_beta] + client = datalabeling.DataLabelingServiceClient(client_options=opts) + # [START datalabeling_label_video_beta] basic_config = datalabeling.types.HumanAnnotationConfig( instruction=instruction_resource_name, diff --git a/datalabeling/manage_dataset.py b/datalabeling/manage_dataset.py index d73d4710f86..a6318bfb338 100644 --- a/datalabeling/manage_dataset.py +++ b/datalabeling/manage_dataset.py @@ -29,6 +29,7 @@ def create_dataset(project_id): # this snippet from triggering any action by a real human if 'DATALABELING_ENDPOINT' in os.environ: opts = ClientOptions(api_endpoint=os.getenv('DATALABELING_ENDPOINT')) + client = datalabeling.DataLabelingServiceClient(client_options=opts) # [START datalabeling_create_dataset_beta] formatted_project_name = client.project_path(project_id)