Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translate: bump batch request timeouts #1951

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class BatchTranslateTextWithGlossary {

public static void batchTranslateTextWithGlossary()
throws InterruptedException, ExecutionException, IOException {
throws InterruptedException, ExecutionException, IOException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "YOUR-PROJECT-ID";
// Supported Languages: https://cloud.google.com/translate/docs/languages
Expand All @@ -57,7 +59,7 @@ public static void batchTranslateTextWithGlossary(
String inputUri,
String outputUri,
String glossaryId)
throws IOException, ExecutionException, InterruptedException {
throws IOException, ExecutionException, InterruptedException, TimeoutException {

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
Expand Down Expand Up @@ -102,7 +104,7 @@ public static void batchTranslateTextWithGlossary(
client.batchTranslateTextAsync(request);

System.out.println("Waiting for operation to complete...");
BatchTranslateResponse response = future.get();
BatchTranslateResponse response = future.get(120, TimeUnit.SECONDS);
// Display the translation for each input text provided
System.out.printf("Total Characters: %s\n", response.getTotalCharacters());
System.out.printf("Translated Characters: %s\n", response.getTranslatedCharacters());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class BatchTranslateTextWithGlossaryAndModel {

public static void batchTranslateTextWithGlossaryAndModel()
throws InterruptedException, ExecutionException, IOException {
throws InterruptedException, ExecutionException, IOException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "YOUR-PROJECT-ID";
// Supported Languages: https://cloud.google.com/translate/docs/languages
Expand All @@ -59,7 +61,7 @@ public static void batchTranslateTextWithGlossaryAndModel(
String outputUri,
String glossaryId,
String modelId)
throws IOException, ExecutionException, InterruptedException {
throws IOException, ExecutionException, InterruptedException, TimeoutException {

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
Expand Down Expand Up @@ -109,7 +111,7 @@ public static void batchTranslateTextWithGlossaryAndModel(
client.batchTranslateTextAsync(request);

System.out.println("Waiting for operation to complete...");
BatchTranslateResponse response = future.get();
BatchTranslateResponse response = future.get(120, TimeUnit.SECONDS);
// Display the translation for each input text provided
System.out.printf("Total Characters: %s\n", response.getTotalCharacters());
System.out.printf("Translated Characters: %s\n", response.getTranslatedCharacters());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class BatchTranslateTextWithModel {

public static void batchTranslateTextWithModel()
throws InterruptedException, ExecutionException, IOException {
throws InterruptedException, ExecutionException, IOException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "YOUR-PROJECT-ID";
// Supported Languages: https://cloud.google.com/translate/docs/languages
Expand All @@ -55,7 +57,7 @@ public static void batchTranslateTextWithModel(
String inputUri,
String outputUri,
String modelId)
throws IOException, ExecutionException, InterruptedException {
throws IOException, ExecutionException, InterruptedException, TimeoutException {

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
Expand Down Expand Up @@ -99,7 +101,7 @@ public static void batchTranslateTextWithModel(
client.batchTranslateTextAsync(request);

System.out.println("Waiting for operation to complete...");
BatchTranslateResponse response = future.get();
BatchTranslateResponse response = future.get(120, TimeUnit.SECONDS);
// Display the translation for each input text provided
System.out.printf("Total Characters: %s\n", response.getTotalCharacters());
System.out.printf("Translated Characters: %s\n", response.getTranslatedCharacters());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -130,7 +131,7 @@ public void tearDown() throws InterruptedException, ExecutionException, IOExcept

@Test
public void testBatchTranslateTextWithGlossaryAndModel()
throws InterruptedException, ExecutionException, IOException {
throws InterruptedException, ExecutionException, IOException, TimeoutException {
BatchTranslateTextWithGlossaryAndModel.batchTranslateTextWithGlossaryAndModel(
PROJECT_ID,
"en",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -130,7 +131,7 @@ public void tearDown() throws InterruptedException, ExecutionException, IOExcept

@Test
public void testBatchTranslateTextWithGlossary()
throws InterruptedException, ExecutionException, IOException {
throws InterruptedException, ExecutionException, IOException, TimeoutException {
BatchTranslateTextWithGlossary.batchTranslateTextWithGlossary(
PROJECT_ID,
"en",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -101,7 +102,7 @@ public void tearDown() {

@Test
public void testBatchTranslateTextWithModel()
throws InterruptedException, ExecutionException, IOException {
throws InterruptedException, ExecutionException, IOException, TimeoutException {
BatchTranslateTextWithModel.batchTranslateTextWithModel(
PROJECT_ID,
"en",
Expand Down