From 38db3433b4c1f3382d28744af170f81534d693ad Mon Sep 17 00:00:00 2001 From: Noah Negrey Date: Thu, 18 Jul 2019 08:04:59 -0600 Subject: [PATCH 1/4] Revert "Update detect.py (#2174)" This reverts commit 0c0c1ed4a13fe5cc0db7930313f93e9f3608e124. --- vision/cloud-client/detect/detect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vision/cloud-client/detect/detect.py b/vision/cloud-client/detect/detect.py index 616fdec3ee1..8a285b78558 100644 --- a/vision/cloud-client/detect/detect.py +++ b/vision/cloud-client/detect/detect.py @@ -704,7 +704,7 @@ def async_detect_document(gcs_source_uri, gcs_destination_uri): bucket_name = match.group(1) prefix = match.group(2) - bucket = storage_client.get_bucket(bucket_name) + bucket = storage_client.get_bucket(bucket_name=bucket_name) # List objects with the given prefix. blob_list = list(bucket.list_blobs(prefix=prefix)) @@ -715,7 +715,7 @@ def async_detect_document(gcs_source_uri, gcs_destination_uri): # Process the first output file from GCS. # Since we specified batch_size=2, the first response contains # the first two pages of the input file. - output = blob_list[1] + output = blob_list[0] json_string = output.download_as_string() response = json_format.Parse( From 9519c6973e8c1c0fa11f9049de854ab3fcf35ccc Mon Sep 17 00:00:00 2001 From: Noah Negrey Date: Thu, 18 Jul 2019 08:32:54 -0600 Subject: [PATCH 2/4] Update beta_snippets_test.py --- vision/cloud-client/detect/beta_snippets_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vision/cloud-client/detect/beta_snippets_test.py b/vision/cloud-client/detect/beta_snippets_test.py index acbb5b7015e..57f7c375ba7 100644 --- a/vision/cloud-client/detect/beta_snippets_test.py +++ b/vision/cloud-client/detect/beta_snippets_test.py @@ -79,5 +79,11 @@ def test_async_batch_annotate_images(capsys): gcs_uri = GCS_ROOT + 'landmark/eiffel_tower.jpg' beta_snippets.async_batch_annotate_images_uri(gcs_uri, GCS_DESTINATION_URI) out, _ = capsys.readouterr() - assert 'language_code: "en"' in out assert 'description: "Tower"' in out + + from google.cloud import storage + storage_client = storage.Client() + bucket = storage_client.get_bucket(BUCKET) + if len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) > 0: + for blob in bucket.list_blobs(prefix=OUTPUT_PREFIX): + blob.delete() From 895aa8a1cc92883f0f64f0f925640e9684a8cfa3 Mon Sep 17 00:00:00 2001 From: Noah Negrey Date: Thu, 18 Jul 2019 08:33:28 -0600 Subject: [PATCH 3/4] Update beta_snippets.py --- vision/cloud-client/detect/beta_snippets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vision/cloud-client/detect/beta_snippets.py b/vision/cloud-client/detect/beta_snippets.py index 5d792b9138b..52dd00116c3 100644 --- a/vision/cloud-client/detect/beta_snippets.py +++ b/vision/cloud-client/detect/beta_snippets.py @@ -388,9 +388,9 @@ def async_batch_annotate_images_uri(input_image_uri, output_uri): localize_objects_uri(args.uri) elif 'handwritten-ocr-uri' in args.command: detect_handwritten_ocr_uri(args.uri) - elif 'batch-annotate-files' in args.command: + elif 'batch-annotate-files-uri' in args.command: detect_batch_annotate_files_uri(args.uri) - elif 'batch-annotate-images' in args.command: + elif 'batch-annotate-images-uri' in args.command: async_batch_annotate_images_uri(args.uri, args.output) else: if 'object-localization' in args.command: From 7ce49256922346a494dedb2dd3f02e4d6c683ab7 Mon Sep 17 00:00:00 2001 From: Noah Negrey Date: Thu, 18 Jul 2019 08:36:48 -0600 Subject: [PATCH 4/4] Update detect.py --- vision/cloud-client/detect/detect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vision/cloud-client/detect/detect.py b/vision/cloud-client/detect/detect.py index 8a285b78558..83974d15d20 100644 --- a/vision/cloud-client/detect/detect.py +++ b/vision/cloud-client/detect/detect.py @@ -704,7 +704,7 @@ def async_detect_document(gcs_source_uri, gcs_destination_uri): bucket_name = match.group(1) prefix = match.group(2) - bucket = storage_client.get_bucket(bucket_name=bucket_name) + bucket = storage_client.get_bucket(bucket_name) # List objects with the given prefix. blob_list = list(bucket.list_blobs(prefix=prefix))