From edd5830d9d6cfad64c4ce6a1c0fa75dd3b263a6f Mon Sep 17 00:00:00 2001 From: Neenu Shaji Date: Thu, 10 Jun 2021 14:48:07 -0400 Subject: [PATCH] chore: migrate to owlbot (#738) --- .../main/java/beta/automl/ImportDataset.java | 4 ++-- .../main/java/beta/automl/ListDatasets.java | 2 -- .../src/main/java/beta/automl/ListModels.java | 2 -- .../LanguageEntityExtractionPredict.java | 6 +++--- .../java/com/example/automl/ListModels.java | 2 -- .../cloud/translate/automl/DatasetApi.java | 1 - .../cloud/translate/automl/ModelApi.java | 1 - .../google/cloud/vision/PredictionApi.java | 3 ++- .../cloud/vision/samples/automl/ModelApi.java | 10 --------- .../java/beta/automl/CancelOperationTest.java | 3 +-- .../java/beta/automl/ImportDatasetTest.java | 3 +-- .../test/java/beta/automl/SetEndpointIT.java | 4 +--- .../TablesBatchPredictBigQueryTest.java | 3 +-- .../beta/automl/TablesCreateModelTest.java | 7 +++---- .../VideoClassificationCreateModelTest.java | 3 +-- .../VideoObjectTrackingCreateModelTest.java | 3 +-- .../com/example/automl/ListModelsTest.java | 1 - .../automl/ListOperationStatusTest.java | 21 ++++++++++--------- .../cloud/translate/automl/DatasetApiIT.java | 5 ++--- 19 files changed, 29 insertions(+), 55 deletions(-) diff --git a/automl/snippets/src/main/java/beta/automl/ImportDataset.java b/automl/snippets/src/main/java/beta/automl/ImportDataset.java index 9d21ecc62ad..72f19b19233 100644 --- a/automl/snippets/src/main/java/beta/automl/ImportDataset.java +++ b/automl/snippets/src/main/java/beta/automl/ImportDataset.java @@ -69,8 +69,8 @@ static void importDataset(String projectId, String datasetId, String path) System.out.println("Processing import..."); // Start the import job - OperationFuture operation = client - .importDataAsync(datasetFullId, inputConfig); + OperationFuture operation = + client.importDataAsync(datasetFullId, inputConfig); System.out.format("Operation name: %s%n", operation.getName()); diff --git a/automl/snippets/src/main/java/beta/automl/ListDatasets.java b/automl/snippets/src/main/java/beta/automl/ListDatasets.java index e3a05e0ed17..7e624aa6fef 100644 --- a/automl/snippets/src/main/java/beta/automl/ListDatasets.java +++ b/automl/snippets/src/main/java/beta/automl/ListDatasets.java @@ -20,12 +20,10 @@ // [START automl_video_object_tracking_list_datasets_beta] // [START automl_tables_list_datasets] import com.google.cloud.automl.v1beta1.AutoMlClient; -import com.google.cloud.automl.v1beta1.AutoMlSettings; import com.google.cloud.automl.v1beta1.Dataset; import com.google.cloud.automl.v1beta1.ListDatasetsRequest; import com.google.cloud.automl.v1beta1.LocationName; import java.io.IOException; -import org.threeten.bp.Duration; class ListDatasets { diff --git a/automl/snippets/src/main/java/beta/automl/ListModels.java b/automl/snippets/src/main/java/beta/automl/ListModels.java index 8f09dcb9538..87d1b0a7f10 100644 --- a/automl/snippets/src/main/java/beta/automl/ListModels.java +++ b/automl/snippets/src/main/java/beta/automl/ListModels.java @@ -19,12 +19,10 @@ // [START automl_tables_list_models] // [START automl_list_models_beta] import com.google.cloud.automl.v1beta1.AutoMlClient; -import com.google.cloud.automl.v1beta1.AutoMlSettings; import com.google.cloud.automl.v1beta1.ListModelsRequest; import com.google.cloud.automl.v1beta1.LocationName; import com.google.cloud.automl.v1beta1.Model; import java.io.IOException; -import org.threeten.bp.Duration; class ListModels { diff --git a/automl/snippets/src/main/java/com/example/automl/LanguageEntityExtractionPredict.java b/automl/snippets/src/main/java/com/example/automl/LanguageEntityExtractionPredict.java index 4f98f3741aa..065990613b3 100644 --- a/automl/snippets/src/main/java/com/example/automl/LanguageEntityExtractionPredict.java +++ b/automl/snippets/src/main/java/com/example/automl/LanguageEntityExtractionPredict.java @@ -49,9 +49,9 @@ static void predict(String projectId, String modelId, String content) throws IOE // https://cloud.google.com/automl/docs/reference/rest/v1/projects.locations.models/predict#textsnippet TextSnippet textSnippet = TextSnippet.newBuilder() - .setContent(content) - .setMimeType("text/plain") // Types: text/plain, text/html - .build(); + .setContent(content) + .setMimeType("text/plain") // Types: text/plain, text/html + .build(); ExamplePayload payload = ExamplePayload.newBuilder().setTextSnippet(textSnippet).build(); PredictRequest predictRequest = PredictRequest.newBuilder().setName(name.toString()).setPayload(payload).build(); diff --git a/automl/snippets/src/main/java/com/example/automl/ListModels.java b/automl/snippets/src/main/java/com/example/automl/ListModels.java index ffb6ad9d150..c24f09b28ae 100644 --- a/automl/snippets/src/main/java/com/example/automl/ListModels.java +++ b/automl/snippets/src/main/java/com/example/automl/ListModels.java @@ -18,12 +18,10 @@ // [START automl_list_models] import com.google.cloud.automl.v1.AutoMlClient; -import com.google.cloud.automl.v1.AutoMlSettings; import com.google.cloud.automl.v1.ListModelsRequest; import com.google.cloud.automl.v1.LocationName; import com.google.cloud.automl.v1.Model; import java.io.IOException; -import org.threeten.bp.Duration; class ListModels { diff --git a/automl/snippets/src/main/java/com/google/cloud/translate/automl/DatasetApi.java b/automl/snippets/src/main/java/com/google/cloud/translate/automl/DatasetApi.java index 32f0c0641a0..e1c8c4f0579 100644 --- a/automl/snippets/src/main/java/com/google/cloud/translate/automl/DatasetApi.java +++ b/automl/snippets/src/main/java/com/google/cloud/translate/automl/DatasetApi.java @@ -88,7 +88,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception { importDataParser.addArgument("datasetId"); importDataParser.addArgument("path"); - String projectId = System.getenv("PROJECT_ID"); String computeRegion = System.getenv("REGION_NAME"); diff --git a/automl/snippets/src/main/java/com/google/cloud/translate/automl/ModelApi.java b/automl/snippets/src/main/java/com/google/cloud/translate/automl/ModelApi.java index 54f5a337e46..31218067965 100644 --- a/automl/snippets/src/main/java/com/google/cloud/translate/automl/ModelApi.java +++ b/automl/snippets/src/main/java/com/google/cloud/translate/automl/ModelApi.java @@ -21,7 +21,6 @@ import com.google.cloud.automl.v1beta1.ListModelsRequest; import com.google.cloud.automl.v1beta1.LocationName; import com.google.cloud.automl.v1beta1.Model; -import com.google.cloud.automl.v1beta1.ModelName; import com.google.longrunning.Operation; import java.io.IOException; import java.io.PrintStream; diff --git a/automl/snippets/src/main/java/com/google/cloud/vision/PredictionApi.java b/automl/snippets/src/main/java/com/google/cloud/vision/PredictionApi.java index ba52fa81f15..c35d55522b2 100644 --- a/automl/snippets/src/main/java/com/google/cloud/vision/PredictionApi.java +++ b/automl/snippets/src/main/java/com/google/cloud/vision/PredictionApi.java @@ -61,7 +61,8 @@ static void predict( String computeRegion, String modelId, String filePath, - String scoreThreshold) throws IOException { + String scoreThreshold) + throws IOException { // Instantiate client for prediction service. try (PredictionServiceClient predictionClient = PredictionServiceClient.create()) { diff --git a/automl/snippets/src/main/java/com/google/cloud/vision/samples/automl/ModelApi.java b/automl/snippets/src/main/java/com/google/cloud/vision/samples/automl/ModelApi.java index 4b07977df3e..5257e716a52 100644 --- a/automl/snippets/src/main/java/com/google/cloud/vision/samples/automl/ModelApi.java +++ b/automl/snippets/src/main/java/com/google/cloud/vision/samples/automl/ModelApi.java @@ -19,21 +19,11 @@ // Imports the Google Cloud client library import com.google.api.gax.longrunning.OperationFuture; import com.google.cloud.automl.v1beta1.AutoMlClient; -import com.google.cloud.automl.v1beta1.ClassificationProto.ClassificationEvaluationMetrics; -import com.google.cloud.automl.v1beta1.ClassificationProto.ClassificationEvaluationMetrics.ConfidenceMetricsEntry; import com.google.cloud.automl.v1beta1.ImageClassificationModelMetadata; -import com.google.cloud.automl.v1beta1.ListModelEvaluationsRequest; -import com.google.cloud.automl.v1beta1.ListModelsRequest; import com.google.cloud.automl.v1beta1.LocationName; import com.google.cloud.automl.v1beta1.Model; -import com.google.cloud.automl.v1beta1.ModelEvaluation; -import com.google.cloud.automl.v1beta1.ModelEvaluationName; -import com.google.cloud.automl.v1beta1.ModelName; import com.google.cloud.automl.v1beta1.OperationMetadata; -import com.google.longrunning.Operation; -import com.google.protobuf.Empty; import java.io.IOException; -import java.util.List; import java.util.concurrent.ExecutionException; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; diff --git a/automl/snippets/src/test/java/beta/automl/CancelOperationTest.java b/automl/snippets/src/test/java/beta/automl/CancelOperationTest.java index 89487d500ae..2a3d9ab7088 100644 --- a/automl/snippets/src/test/java/beta/automl/CancelOperationTest.java +++ b/automl/snippets/src/test/java/beta/automl/CancelOperationTest.java @@ -73,8 +73,7 @@ public void tearDown() { public void testCancelOperation() throws IOException { String operationFullPathId = String.format( - "projects/%s/locations/%s/operations/%s", PROJECT_ID, "us-central1", - "TCN0000000000"); + "projects/%s/locations/%s/operations/%s", PROJECT_ID, "us-central1", "TCN0000000000"); // Any cancelled operation on models or datasets will be hidden once the operations are flagged // as failed operations // which makes them hard to delete in the teardown. diff --git a/automl/snippets/src/test/java/beta/automl/ImportDatasetTest.java b/automl/snippets/src/test/java/beta/automl/ImportDatasetTest.java index 5a06c43620a..12683878543 100644 --- a/automl/snippets/src/test/java/beta/automl/ImportDatasetTest.java +++ b/automl/snippets/src/test/java/beta/automl/ImportDatasetTest.java @@ -74,8 +74,7 @@ public void tearDown() { } @Test - public void testImportDataset() - throws TimeoutException { + public void testImportDataset() throws TimeoutException { try { ImportDataset.importDataset( PROJECT_ID, "TCN0000000000", BUCKET + "/entity-extraction/dataset.csv"); diff --git a/automl/snippets/src/test/java/beta/automl/SetEndpointIT.java b/automl/snippets/src/test/java/beta/automl/SetEndpointIT.java index 5f0dc551376..b74742e713e 100644 --- a/automl/snippets/src/test/java/beta/automl/SetEndpointIT.java +++ b/automl/snippets/src/test/java/beta/automl/SetEndpointIT.java @@ -29,9 +29,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** - * Tests for Automl Set Endpoint - */ +/** Tests for Automl Set Endpoint */ @RunWith(JUnit4.class) @SuppressWarnings("checkstyle:abbreviationaswordinname") public class SetEndpointIT { diff --git a/automl/snippets/src/test/java/beta/automl/TablesBatchPredictBigQueryTest.java b/automl/snippets/src/test/java/beta/automl/TablesBatchPredictBigQueryTest.java index 630f4379e9c..173564c13b9 100644 --- a/automl/snippets/src/test/java/beta/automl/TablesBatchPredictBigQueryTest.java +++ b/automl/snippets/src/test/java/beta/automl/TablesBatchPredictBigQueryTest.java @@ -38,8 +38,7 @@ public class TablesBatchPredictBigQueryTest { private static final String MODEL_ID = "TBL0000000000000000000"; private static final String INPUT_URI = String.format( - "bq://%s.automl_do_not_delete_predict_test.automl_predict_test_table", - PROJECT_ID); + "bq://%s.automl_do_not_delete_predict_test.automl_predict_test_table", PROJECT_ID); private static final String OUTPUT_URI = "bq://" + PROJECT_ID; private ByteArrayOutputStream bout; private PrintStream out; diff --git a/automl/snippets/src/test/java/beta/automl/TablesCreateModelTest.java b/automl/snippets/src/test/java/beta/automl/TablesCreateModelTest.java index 1f4c57988c5..996daae231f 100644 --- a/automl/snippets/src/test/java/beta/automl/TablesCreateModelTest.java +++ b/automl/snippets/src/test/java/beta/automl/TablesCreateModelTest.java @@ -80,10 +80,9 @@ public void testTablesCreateModel() throws IOException, ExecutionException, Inte // To prevent name collisions when running tests in multiple java versions at once. // AutoML doesn't allow "-", but accepts "_" String modelName = - String.format("test_%s", - UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); - TablesCreateModel - .createModel(PROJECT_ID, DATASET_ID, TABLE_SPEC_ID, COLUMN_SPEC_ID, modelName); + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + TablesCreateModel.createModel( + PROJECT_ID, DATASET_ID, TABLE_SPEC_ID, COLUMN_SPEC_ID, modelName); String got = bout.toString(); assertThat(got).contains("Dataset does not exist"); } catch (IOException | ExecutionException | InterruptedException e) { diff --git a/automl/snippets/src/test/java/beta/automl/VideoClassificationCreateModelTest.java b/automl/snippets/src/test/java/beta/automl/VideoClassificationCreateModelTest.java index 50c6eb2d3ce..233a6af230c 100644 --- a/automl/snippets/src/test/java/beta/automl/VideoClassificationCreateModelTest.java +++ b/automl/snippets/src/test/java/beta/automl/VideoClassificationCreateModelTest.java @@ -79,8 +79,7 @@ public void testVisionClassificationCreateModel() // To prevent name collisions when running tests in multiple java versions at once. // AutoML doesn't allow "-", but accepts "_" String modelName = - String.format("test_%s", - UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); VideoClassificationCreateModel.createModel(PROJECT_ID, DATASET_ID, modelName); String got = bout.toString(); assertThat(got).contains("Dataset does not exist"); diff --git a/automl/snippets/src/test/java/beta/automl/VideoObjectTrackingCreateModelTest.java b/automl/snippets/src/test/java/beta/automl/VideoObjectTrackingCreateModelTest.java index 2795748698f..04df91b367d 100644 --- a/automl/snippets/src/test/java/beta/automl/VideoObjectTrackingCreateModelTest.java +++ b/automl/snippets/src/test/java/beta/automl/VideoObjectTrackingCreateModelTest.java @@ -80,8 +80,7 @@ public void testVisionClassificationCreateModel() // To prevent name collisions when running tests in multiple java versions at once. // AutoML doesn't allow "-", but accepts "_" String modelName = - String.format("test_%s", - UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); + String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26)); VideoObjectTrackingCreateModel.createModel(PROJECT_ID, DATASET_ID, modelName); String got = bout.toString(); diff --git a/automl/snippets/src/test/java/com/example/automl/ListModelsTest.java b/automl/snippets/src/test/java/com/example/automl/ListModelsTest.java index 98bed456072..df6c986bf2c 100644 --- a/automl/snippets/src/test/java/com/example/automl/ListModelsTest.java +++ b/automl/snippets/src/test/java/com/example/automl/ListModelsTest.java @@ -25,7 +25,6 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/automl/snippets/src/test/java/com/example/automl/ListOperationStatusTest.java b/automl/snippets/src/test/java/com/example/automl/ListOperationStatusTest.java index 6f74b4068ab..5a4779a42f8 100644 --- a/automl/snippets/src/test/java/com/example/automl/ListOperationStatusTest.java +++ b/automl/snippets/src/test/java/com/example/automl/ListOperationStatusTest.java @@ -83,17 +83,17 @@ public void setUp() throws IOException, InterruptedException { if (operationFullPathsToBeDeleted.size() > 300) { System.out.println("Cleaning up..."); - for (String operationFullPath : operationFullPathsToBeDeleted.subList(0, operationFullPathsToBeDeleted.size() / 2)) { // retry_interval * (random value in range [1 - rand_factor, 1 + rand_factor]) - ExponentialBackOff exponentialBackOff = new ExponentialBackOff.Builder() - .setInitialIntervalMillis(60000) - .setMaxElapsedTimeMillis(300000) - .setRandomizationFactor(0.5) - .setMultiplier(1.1) - .setMaxIntervalMillis(80000) - .build(); + ExponentialBackOff exponentialBackOff = + new ExponentialBackOff.Builder() + .setInitialIntervalMillis(60000) + .setMaxElapsedTimeMillis(300000) + .setRandomizationFactor(0.5) + .setMultiplier(1.1) + .setMaxIntervalMillis(80000) + .build(); // delete unused operations. try { @@ -101,8 +101,9 @@ public void setUp() throws IOException, InterruptedException { } catch (ResourceExhaustedException ex) { // exponential back off and retry. long backOffInMillis = exponentialBackOff.nextBackOffMillis(); - System.out.printf("Backing off for %d milliseconds " - + "due to Resource exhaustion.\n", backOffInMillis); + System.out.printf( + "Backing off for %d milliseconds " + "due to Resource exhaustion.\n", + backOffInMillis); if (backOffInMillis < 0) { break; } diff --git a/automl/snippets/src/test/java/com/google/cloud/translate/automl/DatasetApiIT.java b/automl/snippets/src/test/java/com/google/cloud/translate/automl/DatasetApiIT.java index 4dd9dc7fb43..4b8f1428859 100644 --- a/automl/snippets/src/test/java/com/google/cloud/translate/automl/DatasetApiIT.java +++ b/automl/snippets/src/test/java/com/google/cloud/translate/automl/DatasetApiIT.java @@ -59,11 +59,10 @@ public void tearDown() { } @Test - public void testCreateImportDeleteDataset() - throws IOException, InterruptedException { + public void testCreateImportDeleteDataset() throws IOException, InterruptedException { try { DatasetApi.importData( - PROJECT_ID, COMPUTE_REGION, datasetId, "gs://" + BUCKET + "/en-ja-short.csv"); + PROJECT_ID, COMPUTE_REGION, datasetId, "gs://" + BUCKET + "/en-ja-short.csv"); String got = bout.toString(); assertThat(got).contains("The Dataset doesn't exist "); } catch (NotFoundException | ExecutionException | StatusRuntimeException ex) {