Skip to content

Commit

Permalink
Update datalabeling to match lint. (#2642)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisvg authored Dec 21, 2019
1 parent 6e9ab2e commit 32403eb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions datalabeling/export_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions datalabeling/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions datalabeling/label_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions datalabeling/label_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions datalabeling/label_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions datalabeling/manage_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 32403eb

Please sign in to comment.