diff --git a/samples/snippets/translate_v3_batch_translate_text.py b/samples/snippets/translate_v3_batch_translate_text.py index 6c67d2c2..4454afb4 100644 --- a/samples/snippets/translate_v3_batch_translate_text.py +++ b/samples/snippets/translate_v3_batch_translate_text.py @@ -17,9 +17,10 @@ def batch_translate_text( - input_uri="gs://YOUR_BUCKET_ID/path/to/your/file.txt", - output_uri="gs://YOUR_BUCKET_ID/path/to/save/results/", - project_id="YOUR_PROJECT_ID" + input_uri="gs://YOUR_BUCKET_ID/path/to/your/file.txt", + output_uri="gs://YOUR_BUCKET_ID/path/to/save/results/", + project_id="YOUR_PROJECT_ID", + timeout=180, ): """Translates a batch of texts on GCS and stores the result in a GCS location.""" @@ -46,7 +47,7 @@ def batch_translate_text( output_config=output_config) print(u"Waiting for operation to complete...") - response = operation.result(180) + response = operation.result(timeout) print(u"Total Characters: {}".format(response.total_characters)) print(u"Translated Characters: {}".format(response.translated_characters)) diff --git a/samples/snippets/translate_v3_batch_translate_text_with_glossary.py b/samples/snippets/translate_v3_batch_translate_text_with_glossary.py index d72c3186..97845e2a 100644 --- a/samples/snippets/translate_v3_batch_translate_text_with_glossary.py +++ b/samples/snippets/translate_v3_batch_translate_text_with_glossary.py @@ -18,10 +18,11 @@ def batch_translate_text_with_glossary( - input_uri="gs://YOUR_BUCKET_ID/path/to/your/file.txt", - output_uri="gs://YOUR_BUCKET_ID/path/to/save/results/", - project_id="YOUR_PROJECT_ID", - glossary_id="YOUR_GLOSSARY_ID", + input_uri="gs://YOUR_BUCKET_ID/path/to/your/file.txt", + output_uri="gs://YOUR_BUCKET_ID/path/to/save/results/", + project_id="YOUR_PROJECT_ID", + glossary_id="YOUR_GLOSSARY_ID", + timeout=180, ): """Translates a batch of texts on GCS and stores the result in a GCS location. Glossary is applied for translation.""" @@ -65,7 +66,7 @@ def batch_translate_text_with_glossary( ) print(u"Waiting for operation to complete...") - response = operation.result(180) + response = operation.result(timeout) print(u"Total Characters: {}".format(response.total_characters)) print(u"Translated Characters: {}".format(response.translated_characters)) diff --git a/samples/snippets/translate_v3_batch_translate_text_with_glossary_test.py b/samples/snippets/translate_v3_batch_translate_text_with_glossary_test.py index 1a1850ac..23aa6691 100644 --- a/samples/snippets/translate_v3_batch_translate_text_with_glossary_test.py +++ b/samples/snippets/translate_v3_batch_translate_text_with_glossary_test.py @@ -73,6 +73,7 @@ def test_batch_translate_text_with_glossary(capsys, bucket, glossary): "gs://{}/translation/BATCH_TRANSLATION_OUTPUT/".format(bucket.name), PROJECT_ID, glossary, + 240 ) out, _ = capsys.readouterr() diff --git a/samples/snippets/translate_v3_create_glossary.py b/samples/snippets/translate_v3_create_glossary.py index a94e488e..603cb4cc 100644 --- a/samples/snippets/translate_v3_create_glossary.py +++ b/samples/snippets/translate_v3_create_glossary.py @@ -17,9 +17,10 @@ def create_glossary( - project_id="YOUR_PROJECT_ID", - input_uri="YOUR_INPUT_URI", - glossary_id="YOUR_GLOSSARY_ID", + project_id="YOUR_PROJECT_ID", + input_uri="YOUR_INPUT_URI", + glossary_id="YOUR_GLOSSARY_ID", + timeout=180, ): """ Create a equivalent term sets glossary. Glossary can be words or @@ -51,7 +52,7 @@ def create_glossary( # to translate the domain-specific terminology. operation = client.create_glossary(parent=parent, glossary=glossary) - result = operation.result(timeout=180) + result = operation.result(timeout) print("Created: {}".format(result.name)) print("Input Uri: {}".format(result.input_config.gcs_source.input_uri)) diff --git a/samples/snippets/translate_v3_delete_glossary.py b/samples/snippets/translate_v3_delete_glossary.py index f3f89753..e8acf76c 100644 --- a/samples/snippets/translate_v3_delete_glossary.py +++ b/samples/snippets/translate_v3_delete_glossary.py @@ -17,7 +17,9 @@ def delete_glossary( - project_id="YOUR_PROJECT_ID", glossary_id="YOUR_GLOSSARY_ID" + project_id="YOUR_PROJECT_ID", + glossary_id="YOUR_GLOSSARY_ID", + timeout=180, ): """Delete a specific glossary based on the glossary ID.""" client = translate.TranslationServiceClient() @@ -25,7 +27,7 @@ def delete_glossary( parent = client.glossary_path(project_id, "us-central1", glossary_id) operation = client.delete_glossary(parent) - result = operation.result(timeout=180) + result = operation.result(timeout) print("Deleted: {}".format(result.name))