diff --git a/automl/beta/pom.xml b/automl/beta/pom.xml
deleted file mode 100644
index 17a1fec5cb3..00000000000
--- a/automl/beta/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
- 4.0.0
- com.example.automl
- automl-google-cloud-samples
- jar
-
-
-
- com.google.cloud.samples
- shared-configuration
- 1.0.17
-
-
-
- 11
- 11
- UTF-8
-
-
-
-
-
-
-
- com.google.cloud
- libraries-bom
- 5.2.0
- pom
- import
-
-
-
-
-
-
- com.google.cloud
- google-cloud-automl
-
-
- com.google.cloud
- google-cloud-bigquery
-
-
-
- com.google.cloud
- google-cloud-storage
-
-
- net.sourceforge.argparse4j
- argparse4j
- 0.8.1
-
-
-
-
- junit
- junit
- 4.13
- test
-
-
- com.google.truth
- truth
- 1.0.1
- test
-
-
-
-
-
diff --git a/automl/beta/src/main/java/com/example/automl/BatchPredict.java b/automl/beta/src/main/java/com/example/automl/BatchPredict.java
deleted file mode 100644
index 3a703d54b77..00000000000
--- a/automl/beta/src/main/java/com/example/automl/BatchPredict.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_batch_predict_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.cloud.automl.v1beta1.BatchPredictInputConfig;
-import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig;
-import com.google.cloud.automl.v1beta1.BatchPredictRequest;
-import com.google.cloud.automl.v1beta1.BatchPredictResult;
-import com.google.cloud.automl.v1beta1.GcsDestination;
-import com.google.cloud.automl.v1beta1.GcsSource;
-import com.google.cloud.automl.v1beta1.ModelName;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.cloud.automl.v1beta1.PredictionServiceClient;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class BatchPredict {
-
- static void batchPredict() throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- String inputUri = "gs://YOUR_BUCKET_ID/path_to_your_input_csv_or_jsonl";
- String outputUri = "gs://YOUR_BUCKET_ID/path_to_save_results/";
- batchPredict(projectId, modelId, inputUri, outputUri);
- }
-
- static void batchPredict(String projectId, String modelId, String inputUri, String outputUri)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (PredictionServiceClient client = PredictionServiceClient.create()) {
- // Get the full path of the model.
- ModelName name = ModelName.of(projectId, "us-central1", modelId);
-
- // Configure the source of the file from a GCS bucket
- GcsSource gcsSource = GcsSource.newBuilder().addInputUris(inputUri).build();
- BatchPredictInputConfig inputConfig =
- BatchPredictInputConfig.newBuilder().setGcsSource(gcsSource).build();
-
- // Configure where to store the output in a GCS bucket
- GcsDestination gcsDestination =
- GcsDestination.newBuilder().setOutputUriPrefix(outputUri).build();
- BatchPredictOutputConfig outputConfig =
- BatchPredictOutputConfig.newBuilder().setGcsDestination(gcsDestination).build();
-
- // Build the request that will be sent to the API
- BatchPredictRequest request =
- BatchPredictRequest.newBuilder()
- .setName(name.toString())
- .setInputConfig(inputConfig)
- .setOutputConfig(outputConfig)
- .build();
-
- // Start an asynchronous request
- OperationFuture future =
- client.batchPredictAsync(request);
-
- System.out.println("Waiting for operation to complete...");
- BatchPredictResult response = future.get();
- System.out.println("Batch Prediction results saved to specified Cloud Storage bucket.");
- }
- }
-}
-// [END automl_batch_predict_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/CancelOperation.java b/automl/beta/src/main/java/com/example/automl/CancelOperation.java
deleted file mode 100644
index 56ab058da39..00000000000
--- a/automl/beta/src/main/java/com/example/automl/CancelOperation.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_cancel_operation_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import java.io.IOException;
-
-class CancelOperation {
-
- static void cancelOperation() throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String location = "us-central1";
- String operationId = "YOUR_OPERATION_ID";
- String operationFullId =
- String.format("projects/%s/locations/%s/operations/%s", projectId, location, operationId);
- cancelOperation(operationFullId);
- }
-
- static void cancelOperation(String operationFullId) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- client.getOperationsClient().cancelOperation(operationFullId);
- System.out.println("Operation cancelled");
- }
- }
-}
-// [END automl_cancel_operation_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/DeleteDataset.java b/automl/beta/src/main/java/com/example/automl/DeleteDataset.java
deleted file mode 100644
index 4e31066991d..00000000000
--- a/automl/beta/src/main/java/com/example/automl/DeleteDataset.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_delete_dataset_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.DatasetName;
-import com.google.protobuf.Empty;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class DeleteDataset {
-
- static void deleteDataset() throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String datasetId = "YOUR_DATASET_ID";
- deleteDataset(projectId, datasetId);
- }
-
- // Delete a dataset
- static void deleteDataset(String projectId, String datasetId)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the dataset.
- DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);
- Empty response = client.deleteDatasetAsync(datasetFullId).get();
- System.out.format("Dataset deleted. %s%n", response);
- }
- }
-}
-// [END automl_delete_dataset_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/DeleteModel.java b/automl/beta/src/main/java/com/example/automl/DeleteModel.java
deleted file mode 100644
index 5c4e063aed3..00000000000
--- a/automl/beta/src/main/java/com/example/automl/DeleteModel.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_delete_model_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.ModelName;
-import com.google.protobuf.Empty;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class DeleteModel {
-
- public static void main(String[] args)
- throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- deleteModel(projectId, modelId);
- }
-
- // Delete a model
- static void deleteModel(String projectId, String modelId)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the model.
- ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
-
- // Delete a model.
- Empty response = client.deleteModelAsync(modelFullId).get();
-
- System.out.println("Model deletion started...");
- System.out.println(String.format("Model deleted. %s", response));
- }
- }
-}
-// [END automl_delete_model_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/DeployModel.java b/automl/beta/src/main/java/com/example/automl/DeployModel.java
deleted file mode 100644
index 14b970a496e..00000000000
--- a/automl/beta/src/main/java/com/example/automl/DeployModel.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_deploy_model_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.DeployModelRequest;
-import com.google.cloud.automl.v1beta1.ModelName;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.protobuf.Empty;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class DeployModel {
-
- public static void main(String[] args)
- throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- deployModel(projectId, modelId);
- }
-
- // Deploy a model for prediction
- static void deployModel(String projectId, String modelId)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the model.
- ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
- DeployModelRequest request =
- DeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
- OperationFuture future = client.deployModelAsync(request);
-
- future.get();
- System.out.println("Model deployment finished");
- }
- }
-}
-// [END automl_deploy_model_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/GetModel.java b/automl/beta/src/main/java/com/example/automl/GetModel.java
deleted file mode 100644
index 453ddf15093..00000000000
--- a/automl/beta/src/main/java/com/example/automl/GetModel.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_get_model_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.Model;
-import com.google.cloud.automl.v1beta1.ModelName;
-import java.io.IOException;
-
-class GetModel {
-
- static void getModel() throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- getModel(projectId, modelId);
- }
-
- // Get a model
- static void getModel(String projectId, String modelId) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the model.
- ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
- Model model = client.getModel(modelFullId);
-
- // Display the model information.
- System.out.format("Model name: %s%n", model.getName());
- // To get the model id, you have to parse it out of the `name` field. As models Ids are
- // required for other methods.
- // Name Format: `projects/{project_id}/locations/{location_id}/models/{model_id}`
- String[] names = model.getName().split("/");
- String retrievedModelId = names[names.length - 1];
- System.out.format("Model id: %s%n", retrievedModelId);
- System.out.format("Model display name: %s%n", model.getDisplayName());
- System.out.println("Model create time:");
- System.out.format("\tseconds: %s%n", model.getCreateTime().getSeconds());
- System.out.format("\tnanos: %s%n", model.getCreateTime().getNanos());
- System.out.format("Model deployment state: %s%n", model.getDeploymentState());
- }
- }
-}
-// [END automl_get_model_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/GetModelEvaluation.java b/automl/beta/src/main/java/com/example/automl/GetModelEvaluation.java
deleted file mode 100644
index 8f81fe545fc..00000000000
--- a/automl/beta/src/main/java/com/example/automl/GetModelEvaluation.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_video_classification_get_model_evaluation_beta]
-// [START automl_video_object_tracking_get_model_evaluation_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.ModelEvaluation;
-import com.google.cloud.automl.v1beta1.ModelEvaluationName;
-import java.io.IOException;
-
-class GetModelEvaluation {
-
- static void getModelEvaluation() throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- String modelEvaluationId = "YOUR_MODEL_EVALUATION_ID";
- getModelEvaluation(projectId, modelId, modelEvaluationId);
- }
-
- // Get a model evaluation
- static void getModelEvaluation(String projectId, String modelId, String modelEvaluationId)
- throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the model evaluation.
- ModelEvaluationName modelEvaluationFullId =
- ModelEvaluationName.of(projectId, "us-central1", modelId, modelEvaluationId);
-
- // Get complete detail of the model evaluation.
- ModelEvaluation modelEvaluation = client.getModelEvaluation(modelEvaluationFullId);
-
- System.out.format("Model Evaluation Name: %s%n", modelEvaluation.getName());
- System.out.format("Model Annotation Spec Id: %s", modelEvaluation.getAnnotationSpecId());
- System.out.println("Create Time:");
- System.out.format("\tseconds: %s%n", modelEvaluation.getCreateTime().getSeconds());
- System.out.format("\tnanos: %s", modelEvaluation.getCreateTime().getNanos() / 1e9);
- System.out.format(
- "Evalution Example Count: %d%n", modelEvaluation.getEvaluatedExampleCount());
-
- // [END automl_video_object_tracking_get_model_evaluation_beta]
- System.out.format(
- "Classification Model Evaluation Metrics: %s%n",
- modelEvaluation.getClassificationEvaluationMetrics());
- // [END automl_video_classification_get_model_evaluation_beta]
-
- // [START automl_video_object_tracking_get_model_evaluation_beta]
- System.out.format(
- "Video Object Tracking Evaluation Metrics: %s%n",
- modelEvaluation.getVideoObjectTrackingEvaluationMetrics());
- // [START automl_video_classification_get_model_evaluation_beta]
- }
- }
-}
-// [END automl_video_classification_get_model_evaluation_beta]
-// [END automl_video_object_tracking_get_model_evaluation_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/GetOperationStatus.java b/automl/beta/src/main/java/com/example/automl/GetOperationStatus.java
deleted file mode 100644
index d5eabe23513..00000000000
--- a/automl/beta/src/main/java/com/example/automl/GetOperationStatus.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_get_operation_status_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.longrunning.Operation;
-import java.io.IOException;
-
-class GetOperationStatus {
-
- static void getOperationStatus() throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String operationFullId = "projects/[projectId]/locations/us-central1/operations/[operationId]";
- getOperationStatus(operationFullId);
- }
-
- // Get the status of an operation
- static void getOperationStatus(String operationFullId) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the latest state of a long-running operation.
- Operation operation = client.getOperationsClient().getOperation(operationFullId);
-
- // Display operation details.
- System.out.println("Operation details:");
- System.out.format("\tName: %s%n", operation.getName());
- System.out.format("\tMetadata Type Url: %s%n", operation.getMetadata().getTypeUrl());
- System.out.format("\tDone: %s%n", operation.getDone());
- if (operation.hasResponse()) {
- System.out.format("\tResponse Type Url: %s%n", operation.getResponse().getTypeUrl());
- }
- if (operation.hasError()) {
- System.out.println("\tResponse:");
- System.out.format("\t\tError code: %s%n", operation.getError().getCode());
- System.out.format("\t\tError message: %s%n", operation.getError().getMessage());
- }
- }
- }
-}
-// [END automl_get_operation_status_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/ImportDataset.java b/automl/beta/src/main/java/com/example/automl/ImportDataset.java
deleted file mode 100644
index 651fd43eaf1..00000000000
--- a/automl/beta/src/main/java/com/example/automl/ImportDataset.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_import_dataset_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.api.gax.retrying.RetrySettings;
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.AutoMlSettings;
-import com.google.cloud.automl.v1beta1.DatasetName;
-import com.google.cloud.automl.v1beta1.GcsSource;
-import com.google.cloud.automl.v1beta1.InputConfig;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.protobuf.Empty;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.threeten.bp.Duration;
-
-class ImportDataset {
-
- public static void main(String[] args)
- throws IOException, ExecutionException, InterruptedException, TimeoutException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String datasetId = "YOUR_DATASET_ID";
- String path = "gs://BUCKET_ID/path_to_training_data.csv";
- importDataset(projectId, datasetId, path);
- }
-
- // Import a dataset
- static void importDataset(String projectId, String datasetId, String path)
- throws IOException, ExecutionException, InterruptedException, TimeoutException {
- Duration totalTimeout = Duration.ofMinutes(45);
- RetrySettings retrySettings = RetrySettings.newBuilder().setTotalTimeout(totalTimeout).build();
- AutoMlSettings.Builder builder = AutoMlSettings.newBuilder();
- builder.importDataSettings().setRetrySettings(retrySettings).build();
- AutoMlSettings settings = builder.build();
-
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create(settings)) {
- // Get the complete path of the dataset.
- DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);
-
- // Get multiple Google Cloud Storage URIs to import data from
- GcsSource gcsSource =
- GcsSource.newBuilder().addAllInputUris(Arrays.asList(path.split(","))).build();
-
- // Import data from the input URI
- InputConfig inputConfig = InputConfig.newBuilder().setGcsSource(gcsSource).build();
- System.out.println("Processing import...");
-
- // Start the import job
- OperationFuture operation = client
- .importDataAsync(datasetFullId, inputConfig);
-
- System.out.format("Operation name: %s%n", operation.getName());
-
- // If you want to wait for the operation to finish, adjust the timeout appropriately. The
- // operation will still run if you choose not to wait for it to complete. You can check the
- // status of your operation using the operation's name.
- Empty response = operation.get(45, TimeUnit.MINUTES);
- System.out.format("Dataset imported. %s%n", response);
- } catch (TimeoutException e) {
- System.out.println("The operation's polling period was not long enough.");
- System.out.println("You can use the Operation's name to get the current status.");
- System.out.println("The import job is still running and will complete as expected.");
- throw e;
- }
- }
-}
-// [END automl_import_dataset_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/ListDatasets.java b/automl/beta/src/main/java/com/example/automl/ListDatasets.java
deleted file mode 100644
index 584db2a43b8..00000000000
--- a/automl/beta/src/main/java/com/example/automl/ListDatasets.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_video_classification_list_datasets_beta]
-// [START automl_video_object_tracking_list_datasets_beta]
-// [START automl_tables_list_datasets_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-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;
-
-class ListDatasets {
-
- static void listDatasets() throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- listDatasets(projectId);
- }
-
- // List the datasets
- static void listDatasets(String projectId) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
- ListDatasetsRequest request =
- ListDatasetsRequest.newBuilder().setParent(projectLocation.toString()).build();
-
- // List all the datasets available in the region by applying filter.
- System.out.println("List of datasets:");
- for (Dataset dataset : client.listDatasets(request).iterateAll()) {
- // Display the dataset information
- System.out.format("%nDataset name: %s%n", dataset.getName());
- // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
- // required for other methods.
- // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
- String[] names = dataset.getName().split("/");
- String retrievedDatasetId = names[names.length - 1];
- System.out.format("Dataset id: %s%n", retrievedDatasetId);
- System.out.format("Dataset display name: %s%n", dataset.getDisplayName());
- System.out.println("Dataset create time:");
- System.out.format("\tseconds: %s%n", dataset.getCreateTime().getSeconds());
- System.out.format("\tnanos: %s%n", dataset.getCreateTime().getNanos());
-
- // [END automl_video_object_tracking_list_datasets_beta]
- // [END automl_tables_list_datasets_beta]
- System.out.format(
- "Video classification dataset metadata: %s%n",
- dataset.getVideoClassificationDatasetMetadata());
- // [END automl_video_classification_list_datasets_beta]
-
- // [START automl_video_object_tracking_list_datasets_beta]
- System.out.format(
- "Video object tracking dataset metadata: %s%n",
- dataset.getVideoObjectTrackingDatasetMetadata());
- // [END automl_video_object_tracking_list_datasets_beta]
-
- // [START automl_tables_list_datasets_beta]
- System.out.format("Tables dataset metadata: %s%n", dataset.getTablesDatasetMetadata());
-
- // [START automl_video_classification_list_datasets_beta]
- // [START automl_video_object_tracking_list_datasets_beta]
- }
- }
- }
-}
-// [END automl_video_classification_list_datasets_beta]
-// [END automl_video_object_tracking_list_datasets_beta]
-// [END automl_tables_list_datasets_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/ListModelEvaluations.java b/automl/beta/src/main/java/com/example/automl/ListModelEvaluations.java
deleted file mode 100644
index 065032cf25b..00000000000
--- a/automl/beta/src/main/java/com/example/automl/ListModelEvaluations.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2019 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_tables_list_model_evaluations_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.ListModelEvaluationsRequest;
-import com.google.cloud.automl.v1beta1.ModelEvaluation;
-import com.google.cloud.automl.v1beta1.ModelName;
-import java.io.IOException;
-
-class ListModelEvaluations {
-
- public static void main(String[] args) throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- listModelEvaluations(projectId, modelId);
- }
-
- // List model evaluations
- static void listModelEvaluations(String projectId, String modelId) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the model.
- ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
- ListModelEvaluationsRequest modelEvaluationsrequest =
- ListModelEvaluationsRequest.newBuilder().setParent(modelFullId.toString()).build();
-
- // List all the model evaluations in the model by applying filter.
- System.out.println("List of model evaluations:");
- for (ModelEvaluation modelEvaluation :
- client.listModelEvaluations(modelEvaluationsrequest).iterateAll()) {
-
- System.out.format("Model Evaluation Name: %s%n", modelEvaluation.getName());
- System.out.format("Model Annotation Spec Id: %s", modelEvaluation.getAnnotationSpecId());
- System.out.println("Create Time:");
- System.out.format("\tseconds: %s%n", modelEvaluation.getCreateTime().getSeconds());
- System.out.format("\tnanos: %s", modelEvaluation.getCreateTime().getNanos() / 1e9);
- System.out.format(
- "Evalution Example Count: %d%n", modelEvaluation.getEvaluatedExampleCount());
-
- System.out.format(
- "Tables Model Evaluation Metrics: %s%n",
- modelEvaluation.getClassificationEvaluationMetrics());
- }
- }
- }
-}
-// [END automl_tables_list_model_evaluations_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/ListModels.java b/automl/beta/src/main/java/com/example/automl/ListModels.java
deleted file mode 100644
index b6678dbf5fe..00000000000
--- a/automl/beta/src/main/java/com/example/automl/ListModels.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_list_models_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-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;
-
-class ListModels {
-
- static void listModels() throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- listModels(projectId);
- }
-
- // List the models available in the specified location
- static void listModels(String projectId) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
-
- // Create list models request.
- ListModelsRequest listModlesRequest =
- ListModelsRequest.newBuilder()
- .setParent(projectLocation.toString())
- .setFilter("")
- .build();
-
- // List all the models available in the region by applying filter.
- System.out.println("List of models:");
- for (Model model : client.listModels(listModlesRequest).iterateAll()) {
- // Display the model information.
- System.out.format("Model name: %s%n", model.getName());
- // To get the model id, you have to parse it out of the `name` field. As models Ids are
- // required for other methods.
- // Name Format: `projects/{project_id}/locations/{location_id}/models/{model_id}`
- String[] names = model.getName().split("/");
- String retrievedModelId = names[names.length - 1];
- System.out.format("Model id: %s%n", retrievedModelId);
- System.out.format("Model display name: %s%n", model.getDisplayName());
- System.out.println("Model create time:");
- System.out.format("\tseconds: %s%n", model.getCreateTime().getSeconds());
- System.out.format("\tnanos: %s%n", model.getCreateTime().getNanos());
- System.out.format("Model deployment state: %s%n", model.getDeploymentState());
- }
- }
- }
-}
-// [END automl_list_models_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/SetEndpoint.java b/automl/beta/src/main/java/com/example/automl/SetEndpoint.java
deleted file mode 100644
index 912590df86f..00000000000
--- a/automl/beta/src/main/java/com/example/automl/SetEndpoint.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2019 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-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;
-
-class SetEndpoint {
-
- // Change your endpoint
- static void setEndpoint(String projectId) throws IOException {
- // [START automl_set_endpoint]
- AutoMlSettings settings =
- AutoMlSettings.newBuilder().setEndpoint("eu-automl.googleapis.com:443").build();
-
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- AutoMlClient client = AutoMlClient.create(settings);
-
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "eu");
- // [END automl_set_endpoint]
-
- ListDatasetsRequest request =
- ListDatasetsRequest.newBuilder()
- .setParent(projectLocation.toString())
- .setFilter("translation_dataset_metadata:*")
- .build();
- // List all the datasets available
- System.out.println("List of datasets:");
- for (Dataset dataset : client.listDatasets(request).iterateAll()) {
- System.out.println(dataset);
- }
- client.close();
- }
-}
diff --git a/automl/beta/src/main/java/com/example/automl/TablesBatchPredictBigQuery.java b/automl/beta/src/main/java/com/example/automl/TablesBatchPredictBigQuery.java
deleted file mode 100644
index 3ee3b2d0ab2..00000000000
--- a/automl/beta/src/main/java/com/example/automl/TablesBatchPredictBigQuery.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_tables_batch_predict_bigquery_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.cloud.automl.v1beta1.BatchPredictInputConfig;
-import com.google.cloud.automl.v1beta1.BatchPredictOutputConfig;
-import com.google.cloud.automl.v1beta1.BatchPredictRequest;
-import com.google.cloud.automl.v1beta1.BatchPredictResult;
-import com.google.cloud.automl.v1beta1.BigQueryDestination;
-import com.google.cloud.automl.v1beta1.BigQuerySource;
-import com.google.cloud.automl.v1beta1.ModelName;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.cloud.automl.v1beta1.PredictionServiceClient;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class TablesBatchPredictBigQuery {
-
- static void batchPredict() throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- String inputUri = "bq://YOUR_PROJECT_ID.bqDatasetID.bqTableId";
- String outputUri = "bq://YOUR_PROJECT_ID";
- batchPredict(projectId, modelId, inputUri, outputUri);
- }
-
- static void batchPredict(String projectId, String modelId, String inputUri, String outputUri)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (PredictionServiceClient client = PredictionServiceClient.create()) {
- // Get the full path of the model.
- ModelName name = ModelName.of(projectId, "us-central1", modelId);
-
- // Configure the source of the file from BigQuery
- BigQuerySource bigQuerySource = BigQuerySource.newBuilder().setInputUri(inputUri).build();
- BatchPredictInputConfig inputConfig =
- BatchPredictInputConfig.newBuilder().setBigquerySource(bigQuerySource).build();
-
- // Configure where to store the output in BigQuery
- BigQueryDestination bigQueryDestination =
- BigQueryDestination.newBuilder().setOutputUri(outputUri).build();
- BatchPredictOutputConfig outputConfig =
- BatchPredictOutputConfig.newBuilder().setBigqueryDestination(bigQueryDestination).build();
-
- // Build the request that will be sent to the API
- BatchPredictRequest request =
- BatchPredictRequest.newBuilder()
- .setName(name.toString())
- .setInputConfig(inputConfig)
- .setOutputConfig(outputConfig)
- .build();
-
- // Start an asynchronous request
- OperationFuture future =
- client.batchPredictAsync(request);
-
- System.out.println("Waiting for operation to complete...");
- BatchPredictResult response = future.get();
- System.out.println("Batch Prediction results saved to BigQuery.");
- }
- }
-}
-// [END automl_tables_batch_predict_bigquery_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/TablesCreateDataset.java b/automl/beta/src/main/java/com/example/automl/TablesCreateDataset.java
deleted file mode 100644
index 8ca97d7b087..00000000000
--- a/automl/beta/src/main/java/com/example/automl/TablesCreateDataset.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_tables_create_dataset_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.Dataset;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.TablesDatasetMetadata;
-import java.io.IOException;
-
-class TablesCreateDataset {
-
- public static void main(String[] args) throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String displayName = "YOUR_DATASET_NAME";
- createDataset(projectId, displayName);
- }
-
- // Create a dataset
- static void createDataset(String projectId, String displayName) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
- TablesDatasetMetadata metadata = TablesDatasetMetadata.newBuilder().build();
- Dataset dataset =
- Dataset.newBuilder()
- .setDisplayName(displayName)
- .setTablesDatasetMetadata(metadata)
- .build();
-
- Dataset createdDataset = client.createDataset(projectLocation, dataset);
-
- // Display the dataset information.
- System.out.format("Dataset name: %s%n", createdDataset.getName());
- // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
- // required for other methods.
- // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
- String[] names = createdDataset.getName().split("/");
- String datasetId = names[names.length - 1];
- System.out.format("Dataset id: %s%n", datasetId);
- }
- }
-}
-// [END automl_tables_create_dataset_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/TablesCreateModel.java b/automl/beta/src/main/java/com/example/automl/TablesCreateModel.java
deleted file mode 100644
index 3fb0bdebe52..00000000000
--- a/automl/beta/src/main/java/com/example/automl/TablesCreateModel.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_tables_create_model_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.ColumnSpec;
-import com.google.cloud.automl.v1beta1.ColumnSpecName;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.Model;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.cloud.automl.v1beta1.TablesModelMetadata;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class TablesCreateModel {
-
- public static void main(String[] args)
- throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String datasetId = "YOUR_DATASET_ID";
- String tableSpecId = "YOUR_TABLE_SPEC_ID";
- String columnSpecId = "YOUR_COLUMN_SPEC_ID";
- String displayName = "YOUR_DATASET_NAME";
- createModel(projectId, datasetId, tableSpecId, columnSpecId, displayName);
- }
-
- // Create a model
- static void createModel(
- String projectId,
- String datasetId,
- String tableSpecId,
- String columnSpecId,
- String displayName)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
-
- // Get the complete path of the column.
- ColumnSpecName columnSpecName =
- ColumnSpecName.of(projectId, "us-central1", datasetId, tableSpecId, columnSpecId);
-
- // Build the get column spec.
- ColumnSpec targetColumnSpec =
- ColumnSpec.newBuilder().setName(columnSpecName.toString()).build();
-
- // Set model metadata.
- TablesModelMetadata metadata =
- TablesModelMetadata.newBuilder()
- .setTargetColumnSpec(targetColumnSpec)
- .setTrainBudgetMilliNodeHours(24000)
- .build();
-
- Model model =
- Model.newBuilder()
- .setDisplayName(displayName)
- .setDatasetId(datasetId)
- .setTablesModelMetadata(metadata)
- .build();
-
- // Create a model with the model metadata in the region.
- OperationFuture future =
- client.createModelAsync(projectLocation, model);
- // OperationFuture.get() will block until the model is created, which may take several hours.
- // You can use OperationFuture.getInitialFuture to get a future representing the initial
- // response to the request, which contains information while the operation is in progress.
- System.out.format("Training operation name: %s%n", future.getInitialFuture().get().getName());
- System.out.println("Training started...");
- }
- }
-}
-// [END automl_tables_create_model_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/TablesImportDataset.java b/automl/beta/src/main/java/com/example/automl/TablesImportDataset.java
deleted file mode 100644
index 91863c3c5e8..00000000000
--- a/automl/beta/src/main/java/com/example/automl/TablesImportDataset.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_tables_import_dataset_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.BigQuerySource;
-import com.google.cloud.automl.v1beta1.DatasetName;
-import com.google.cloud.automl.v1beta1.GcsSource;
-import com.google.cloud.automl.v1beta1.InputConfig;
-import com.google.protobuf.Empty;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.concurrent.ExecutionException;
-
-class TablesImportDataset {
-
- public static void main(String[] args)
- throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String datasetId = "YOUR_DATASET_ID";
- String path = "gs://BUCKET_ID/path/to//data.csv or bq://project_id.dataset_id.table_id";
- importDataset(projectId, datasetId, path);
- }
-
- // Import a dataset via BigQuery or Google Cloud Storage
- static void importDataset(String projectId, String datasetId, String path)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the complete path of the dataset.
- DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);
-
- InputConfig.Builder inputConfigBuilder = InputConfig.newBuilder();
-
- // Determine which source type was used for the input path (BigQuery or GCS)
- if (path.startsWith("bq")) {
- // Get training data file to be imported from a BigQuery source.
- BigQuerySource.Builder bigQuerySource = BigQuerySource.newBuilder();
- bigQuerySource.setInputUri(path);
- inputConfigBuilder.setBigquerySource(bigQuerySource);
- } else {
- // Get multiple Google Cloud Storage URIs to import data from
- GcsSource gcsSource =
- GcsSource.newBuilder().addAllInputUris(Arrays.asList(path.split(","))).build();
- inputConfigBuilder.setGcsSource(gcsSource);
- }
-
- // Import data from the input URI
- System.out.println("Processing import...");
-
- Empty response = client.importDataAsync(datasetFullId, inputConfigBuilder.build()).get();
- System.out.format("Dataset imported. %s%n", response);
- }
- }
-}
-// [END automl_tables_import_dataset_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/TablesPredict.java b/automl/beta/src/main/java/com/example/automl/TablesPredict.java
deleted file mode 100644
index 6808ae248c5..00000000000
--- a/automl/beta/src/main/java/com/example/automl/TablesPredict.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_tables_predict_beta]
-import com.google.cloud.automl.v1beta1.AnnotationPayload;
-import com.google.cloud.automl.v1beta1.ExamplePayload;
-import com.google.cloud.automl.v1beta1.ModelName;
-import com.google.cloud.automl.v1beta1.PredictRequest;
-import com.google.cloud.automl.v1beta1.PredictResponse;
-import com.google.cloud.automl.v1beta1.PredictionServiceClient;
-import com.google.cloud.automl.v1beta1.Row;
-import com.google.cloud.automl.v1beta1.TablesAnnotation;
-import com.google.protobuf.Value;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-class TablesPredict {
-
- public static void main(String[] args) throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- // Values should match the input expected by your model.
- List values = new ArrayList<>();
- // values.add(Value.newBuilder().setBoolValue(true).build());
- // values.add(Value.newBuilder().setNumberValue(10).build());
- // values.add(Value.newBuilder().setStringValue("YOUR_STRING").build());
- predict(projectId, modelId, values);
- }
-
- static void predict(String projectId, String modelId, List values) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (PredictionServiceClient client = PredictionServiceClient.create()) {
- // Get the full path of the model.
- ModelName name = ModelName.of(projectId, "us-central1", modelId);
- Row row = Row.newBuilder().addAllValues(values).build();
- ExamplePayload payload = ExamplePayload.newBuilder().setRow(row).build();
-
- // Feature importance gives you visibility into how the features in a specific prediction
- // request informed the resulting prediction. For more info, see:
- // https://cloud.google.com/automl-tables/docs/features#local
- PredictRequest request =
- PredictRequest.newBuilder()
- .setName(name.toString())
- .setPayload(payload)
- .putParams("feature_importance", "true")
- .build();
-
- PredictResponse response = client.predict(request);
-
- System.out.println("Prediction results:");
- for (AnnotationPayload annotationPayload : response.getPayloadList()) {
- TablesAnnotation tablesAnnotation = annotationPayload.getTables();
- System.out.format(
- "Classification label: %s%n", tablesAnnotation.getValue().getStringValue());
- System.out.format("Classification score: %.3f%n", tablesAnnotation.getScore());
- // Get features of top importance
- tablesAnnotation
- .getTablesModelColumnInfoList()
- .forEach(
- info ->
- System.out.format(
- "\tColumn: %s - Importance: %.2f%n",
- info.getColumnDisplayName(), info.getFeatureImportance()));
- }
- }
- }
-}
-// [END automl_tables_predict_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/UndeployModel.java b/automl/beta/src/main/java/com/example/automl/UndeployModel.java
deleted file mode 100644
index 3597dd6cd1e..00000000000
--- a/automl/beta/src/main/java/com/example/automl/UndeployModel.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_undeploy_model_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.ModelName;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.cloud.automl.v1beta1.UndeployModelRequest;
-import com.google.protobuf.Empty;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class UndeployModel {
-
- static void undeployModel() throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String modelId = "YOUR_MODEL_ID";
- undeployModel(projectId, modelId);
- }
-
- // Undeploy a model from prediction
- static void undeployModel(String projectId, String modelId)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the model.
- ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
- UndeployModelRequest request =
- UndeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
- OperationFuture future = client.undeployModelAsync(request);
-
- future.get();
- System.out.println("Model undeployment finished");
- }
- }
-}
-// [END automl_undeploy_model_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/VideoClassificationCreateDataset.java b/automl/beta/src/main/java/com/example/automl/VideoClassificationCreateDataset.java
deleted file mode 100644
index 88f65192ccf..00000000000
--- a/automl/beta/src/main/java/com/example/automl/VideoClassificationCreateDataset.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_video_classification_create_dataset_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.Dataset;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.VideoClassificationDatasetMetadata;
-import java.io.IOException;
-
-class VideoClassificationCreateDataset {
-
- public static void main(String[] args) throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String displayName = "YOUR_DATASET_NAME";
- createDataset(projectId, displayName);
- }
-
- // Create a dataset
- static void createDataset(String projectId, String displayName) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
- VideoClassificationDatasetMetadata metadata =
- VideoClassificationDatasetMetadata.newBuilder().build();
- Dataset dataset =
- Dataset.newBuilder()
- .setDisplayName(displayName)
- .setVideoClassificationDatasetMetadata(metadata)
- .build();
-
- Dataset createdDataset = client.createDataset(projectLocation, dataset);
-
- // Display the dataset information.
- System.out.format("Dataset name: %s%n", createdDataset.getName());
- // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
- // required for other methods.
- // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
- String[] names = createdDataset.getName().split("/");
- String datasetId = names[names.length - 1];
- System.out.format("Dataset id: %s%n", datasetId);
- }
- }
-}
-// [END automl_video_classification_create_dataset_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/VideoClassificationCreateModel.java b/automl/beta/src/main/java/com/example/automl/VideoClassificationCreateModel.java
deleted file mode 100644
index 36309c5b94c..00000000000
--- a/automl/beta/src/main/java/com/example/automl/VideoClassificationCreateModel.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_video_classification_create_model_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.Model;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.cloud.automl.v1beta1.VideoClassificationModelMetadata;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class VideoClassificationCreateModel {
-
- public static void main(String[] args)
- throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String datasetId = "YOUR_DATASET_ID";
- String displayName = "YOUR_DATASET_NAME";
- createModel(projectId, datasetId, displayName);
- }
-
- // Create a model
- static void createModel(String projectId, String datasetId, String displayName)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
- // Set model metadata.
- VideoClassificationModelMetadata metadata =
- VideoClassificationModelMetadata.newBuilder().build();
- Model model =
- Model.newBuilder()
- .setDisplayName(displayName)
- .setDatasetId(datasetId)
- .setVideoClassificationModelMetadata(metadata)
- .build();
-
- // Create a model with the model metadata in the region.
- OperationFuture future =
- client.createModelAsync(projectLocation, model);
- // OperationFuture.get() will block until the model is created, which may take several hours.
- // You can use OperationFuture.getInitialFuture to get a future representing the initial
- // response to the request, which contains information while the operation is in progress.
- System.out.format("Training operation name: %s%n", future.getInitialFuture().get().getName());
- System.out.println("Training started...");
- }
- }
-}
-// [END automl_video_classification_create_model_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/VideoObjectTrackingCreateDataset.java b/automl/beta/src/main/java/com/example/automl/VideoObjectTrackingCreateDataset.java
deleted file mode 100644
index 07e6fa8f6b7..00000000000
--- a/automl/beta/src/main/java/com/example/automl/VideoObjectTrackingCreateDataset.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_video_object_tracking_create_dataset_beta]
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.Dataset;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.VideoObjectTrackingDatasetMetadata;
-import java.io.IOException;
-
-class VideoObjectTrackingCreateDataset {
-
- public static void main(String[] args) throws IOException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String displayName = "YOUR_DATASET_NAME";
- createDataset(projectId, displayName);
- }
-
- // Create a dataset
- static void createDataset(String projectId, String displayName) throws IOException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
- VideoObjectTrackingDatasetMetadata metadata =
- VideoObjectTrackingDatasetMetadata.newBuilder().build();
- Dataset dataset =
- Dataset.newBuilder()
- .setDisplayName(displayName)
- .setVideoObjectTrackingDatasetMetadata(metadata)
- .build();
-
- Dataset createdDataset = client.createDataset(projectLocation, dataset);
-
- // Display the dataset information.
- System.out.format("Dataset name: %s%n", createdDataset.getName());
- // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
- // required for other methods.
- // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
- String[] names = createdDataset.getName().split("/");
- String datasetId = names[names.length - 1];
- System.out.format("Dataset id: %s%n", datasetId);
- }
- }
-}
-// [END automl_video_object_tracking_create_dataset_beta]
diff --git a/automl/beta/src/main/java/com/example/automl/VideoObjectTrackingCreateModel.java b/automl/beta/src/main/java/com/example/automl/VideoObjectTrackingCreateModel.java
deleted file mode 100644
index cfd2b31b77a..00000000000
--- a/automl/beta/src/main/java/com/example/automl/VideoObjectTrackingCreateModel.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-// [START automl_video_object_tracking_create_model_beta]
-import com.google.api.gax.longrunning.OperationFuture;
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.Model;
-import com.google.cloud.automl.v1beta1.OperationMetadata;
-import com.google.cloud.automl.v1beta1.VideoObjectTrackingModelMetadata;
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-class VideoObjectTrackingCreateModel {
-
- public static void main(String[] args)
- throws IOException, ExecutionException, InterruptedException {
- // TODO(developer): Replace these variables before running the sample.
- String projectId = "YOUR_PROJECT_ID";
- String datasetId = "YOUR_DATASET_ID";
- String displayName = "YOUR_DATASET_NAME";
- createModel(projectId, datasetId, displayName);
- }
-
- // Create a model
- static void createModel(String projectId, String datasetId, String displayName)
- throws IOException, ExecutionException, InterruptedException {
- // 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
- // the "close" method on the client to safely clean up any remaining background resources.
- try (AutoMlClient client = AutoMlClient.create()) {
- // A resource that represents Google Cloud Platform location.
- LocationName projectLocation = LocationName.of(projectId, "us-central1");
- // Set model metadata.
- VideoObjectTrackingModelMetadata metadata =
- VideoObjectTrackingModelMetadata.newBuilder().build();
- Model model =
- Model.newBuilder()
- .setDisplayName(displayName)
- .setDatasetId(datasetId)
- .setVideoObjectTrackingModelMetadata(metadata)
- .build();
-
- // Create a model with the model metadata in the region.
- OperationFuture future =
- client.createModelAsync(projectLocation, model);
- // OperationFuture.get() will block until the model is created, which may take several hours.
- // You can use OperationFuture.getInitialFuture to get a future representing the initial
- // response to the request, which contains information while the operation is in progress.
- System.out.format("Training operation name: %s%n", future.getInitialFuture().get().getName());
- System.out.println("Training started...");
- }
- }
-}
-// [END automl_video_object_tracking_create_model_beta]
diff --git a/automl/beta/src/test/java/com/example/automl/BatchPredictTest.java b/automl/beta/src/test/java/com/example/automl/BatchPredictTest.java
deleted file mode 100644
index 04ea62a870e..00000000000
--- a/automl/beta/src/test/java/com/example/automl/BatchPredictTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class BatchPredictTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String BUCKET_ID = PROJECT_ID + "-lcm";
- private static final String MODEL_ID = "VCN0000000000000000000";
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testBatchPredict() {
- // As batch prediction can take a long time. Try to batch predict on a model and confirm that
- // the model was not found, but other elements of the request were valid.
- try {
- String inputUri = String.format("gs://%s/entity-extraction/input.csv", BUCKET_ID);
- String outputUri = String.format("gs://%s/TEST_BATCH_PREDICT/", BUCKET_ID);
- BatchPredict.batchPredict(PROJECT_ID, MODEL_ID, inputUri, outputUri);
- String got = bout.toString();
- assertThat(got).contains("does not exist");
- } catch (IOException | ExecutionException | InterruptedException e) {
- assertThat(e.getMessage()).contains("does not exist");
- }
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/CancelOperationTest.java b/automl/beta/src/test/java/com/example/automl/CancelOperationTest.java
deleted file mode 100644
index ea1f1dff638..00000000000
--- a/automl/beta/src/test/java/com/example/automl/CancelOperationTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class CancelOperationTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String OPERATION_ID = "TRL6118473245806034944";
- private String operationFullNam =
- String.format("projects/%s/locations/us-central1/operations/%s", PROJECT_ID, OPERATION_ID);
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testGetOperationStatus() throws IOException {
- CancelOperation.cancelOperation(operationFullNam);
- String got = bout.toString();
- assertThat(got).contains("Operation cancelled");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/DeleteDatasetTest.java b/automl/beta/src/test/java/com/example/automl/DeleteDatasetTest.java
deleted file mode 100644
index d1cee6b4da1..00000000000
--- a/automl/beta/src/test/java/com/example/automl/DeleteDatasetTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.Dataset;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.TextExtractionDatasetMetadata;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class DeleteDatasetTest {
-
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String datasetId;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() throws IOException {
- // Create a fake dataset to be deleted
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // To prevent name collisions when running tests in multiple java versions at once.
- // AutoML doesn't allow "-", but accepts "_"
- String datasetName =
- String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26));
- try (AutoMlClient client = AutoMlClient.create()) {
- LocationName projectLocation = LocationName.of(PROJECT_ID, "us-central1");
- TextExtractionDatasetMetadata metadata = TextExtractionDatasetMetadata.newBuilder().build();
- Dataset dataset =
- Dataset.newBuilder()
- .setDisplayName(datasetName)
- .setTextExtractionDatasetMetadata(metadata)
- .build();
- Dataset createdDataset = client.createDataset(projectLocation, dataset);
- String[] names = createdDataset.getName().split("/");
- datasetId = names[names.length - 1];
- }
-
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testDeleteDataset() throws IOException, ExecutionException, InterruptedException {
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
- String got = bout.toString();
- assertThat(got).contains("Dataset deleted.");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/DeleteModelTest.java b/automl/beta/src/test/java/com/example/automl/DeleteModelTest.java
deleted file mode 100644
index a0799721cfe..00000000000
--- a/automl/beta/src/test/java/com/example/automl/DeleteModelTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2019 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class DeleteModelTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testDeleteModel() {
- // As model creation can take many hours, instead try to delete a
- // nonexistent model and confirm that the model was not found, but other
- // elements of the request were valid.
- try {
- DeleteModel.deleteModel(PROJECT_ID, "TRL0000000000000000000");
- String got = bout.toString();
- assertThat(got).contains("The model does not exist");
- } catch (IOException | ExecutionException | InterruptedException e) {
- assertThat(e.getMessage()).contains("The model does not exist");
- }
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/DeployModelTest.java b/automl/beta/src/test/java/com/example/automl/DeployModelTest.java
deleted file mode 100644
index 372a11f2e2f..00000000000
--- a/automl/beta/src/test/java/com/example/automl/DeployModelTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class DeployModelTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String MODEL_ID = "TEN0000000000000000000";
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testDeployModel() {
- // As model deployment can take a long time, instead try to deploy a
- // nonexistent model and confirm that the model was not found, but other
- // elements of the request were valid.
- try {
- DeployModel.deployModel(PROJECT_ID, MODEL_ID);
- String got = bout.toString();
- assertThat(got).contains("The model does not exist");
- } catch (IOException | ExecutionException | InterruptedException e) {
- assertThat(e.getMessage()).contains("The model does not exist");
- }
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/GetModelEvaluationTest.java b/automl/beta/src/test/java/com/example/automl/GetModelEvaluationTest.java
deleted file mode 100644
index 12e3c558c50..00000000000
--- a/automl/beta/src/test/java/com/example/automl/GetModelEvaluationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1.AutoMlClient;
-import com.google.cloud.automl.v1.ListModelEvaluationsRequest;
-import com.google.cloud.automl.v1.ModelEvaluation;
-import com.google.cloud.automl.v1.ModelName;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class GetModelEvaluationTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID");
- private String modelEvaluationId;
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- requireEnvVar("ENTITY_EXTRACTION_MODEL_ID");
- }
-
- @Before
- public void setUp() throws IOException {
- // Get a model evaluation ID from the List request first to be used in the Get call
- try (AutoMlClient client = AutoMlClient.create()) {
- ModelName modelFullId = ModelName.of(PROJECT_ID, "us-central1", MODEL_ID);
- ListModelEvaluationsRequest modelEvaluationsrequest =
- ListModelEvaluationsRequest.newBuilder().setParent(modelFullId.toString()).build();
- ModelEvaluation modelEvaluation =
- client
- .listModelEvaluations(modelEvaluationsrequest)
- .getPage()
- .getValues()
- .iterator()
- .next();
- modelEvaluationId = modelEvaluation.getName().split("/modelEvaluations/")[1];
- }
-
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testGetModelEvaluation() throws IOException {
- GetModelEvaluation.getModelEvaluation(PROJECT_ID, MODEL_ID, modelEvaluationId);
- String got = bout.toString();
- assertThat(got).contains("Model Evaluation Name:");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/GetModelTest.java b/automl/beta/src/test/java/com/example/automl/GetModelTest.java
deleted file mode 100644
index de216b19047..00000000000
--- a/automl/beta/src/test/java/com/example/automl/GetModelTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class GetModelTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- requireEnvVar("ENTITY_EXTRACTION_MODEL_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testGetModel() throws IOException {
- GetModel.getModel(PROJECT_ID, MODEL_ID);
- String got = bout.toString();
- assertThat(got).contains("Model id: " + MODEL_ID);
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/GetOperationStatusTest.java b/automl/beta/src/test/java/com/example/automl/GetOperationStatusTest.java
deleted file mode 100644
index 7e16ad2b508..00000000000
--- a/automl/beta/src/test/java/com/example/automl/GetOperationStatusTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.longrunning.ListOperationsRequest;
-import com.google.longrunning.Operation;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class GetOperationStatusTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private String operationId;
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() throws IOException {
- // Use list operations to get a single operation id for the get call.
- try (AutoMlClient client = AutoMlClient.create()) {
- LocationName projectLocation = LocationName.of(PROJECT_ID, "us-central1");
- ListOperationsRequest request =
- ListOperationsRequest.newBuilder().setName(projectLocation.toString()).build();
- Operation operation =
- client.getOperationsClient().listOperations(request).iterateAll().iterator().next();
- operationId = operation.getName();
- }
-
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testGetOperationStatus() throws IOException {
- GetOperationStatus.getOperationStatus(operationId);
- String got = bout.toString();
- assertThat(got).contains("Operation details:");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/ImportDatasetTest.java b/automl/beta/src/test/java/com/example/automl/ImportDatasetTest.java
deleted file mode 100644
index 577f0c140d1..00000000000
--- a/automl/beta/src/test/java/com/example/automl/ImportDatasetTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.Dataset;
-import com.google.cloud.automl.v1beta1.LocationName;
-import com.google.cloud.automl.v1beta1.TextExtractionDatasetMetadata;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class ImportDatasetTest {
-
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String BUCKET_ID = PROJECT_ID + "-lcm";
- private static final String BUCKET = "gs://" + BUCKET_ID;
- private String datasetId;
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() throws IOException {
- // Create a fake dataset to be deleted
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // To prevent name collisions when running tests in multiple java versions at once.
- // AutoML doesn't allow "-", but accepts "_"
- String datasetName =
- String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26));
- try (AutoMlClient client = AutoMlClient.create()) {
- LocationName projectLocation = LocationName.of(PROJECT_ID, "us-central1");
- TextExtractionDatasetMetadata metadata = TextExtractionDatasetMetadata.newBuilder().build();
- Dataset dataset =
- Dataset.newBuilder()
- .setDisplayName(datasetName)
- .setTextExtractionDatasetMetadata(metadata)
- .build();
- Dataset createdDataset = client.createDataset(projectLocation, dataset);
- String[] names = createdDataset.getName().split("/");
- datasetId = names[names.length - 1];
- }
-
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() throws InterruptedException, ExecutionException, IOException {
- // Delete the created dataset
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
- System.setOut(null);
- }
-
- @Test
- public void testImportDataset()
- throws InterruptedException, ExecutionException, TimeoutException, IOException {
- ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity-extraction/dataset.csv");
- String got = bout.toString();
- assertThat(got).contains("Dataset imported.");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/ListDatasetsTest.java b/automl/beta/src/test/java/com/example/automl/ListDatasetsTest.java
deleted file mode 100644
index 412e63c77b6..00000000000
--- a/automl/beta/src/test/java/com/example/automl/ListDatasetsTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class ListDatasetsTest {
-
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testListDataset() throws IOException {
- ListDatasets.listDatasets(PROJECT_ID);
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/ListModelEvaluationsTest.java b/automl/beta/src/test/java/com/example/automl/ListModelEvaluationsTest.java
deleted file mode 100644
index 521c0da497b..00000000000
--- a/automl/beta/src/test/java/com/example/automl/ListModelEvaluationsTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class ListModelEvaluationsTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String MODEL_ID = System.getenv("ENTITY_EXTRACTION_MODEL_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- requireEnvVar("ENTITY_EXTRACTION_MODEL_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testListModelEvaluations() throws IOException {
- ListModelEvaluations.listModelEvaluations(PROJECT_ID, MODEL_ID);
- String got = bout.toString();
- assertThat(got).contains("Model Evaluation Name:");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/ListModelsTest.java b/automl/beta/src/test/java/com/example/automl/ListModelsTest.java
deleted file mode 100644
index 40510556067..00000000000
--- a/automl/beta/src/test/java/com/example/automl/ListModelsTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class ListModelsTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testListModels() throws IOException {
- ListModels.listModels(PROJECT_ID);
- String got = bout.toString();
- assertThat(got).contains("Model id:");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/SetEndpointIT.java b/automl/beta/src/test/java/com/example/automl/SetEndpointIT.java
deleted file mode 100644
index fb898e8321e..00000000000
--- a/automl/beta/src/test/java/com/example/automl/SetEndpointIT.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2019 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/** Tests for Automl Set Endpoint */
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class SetEndpointIT {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testSetEndpoint() throws IOException {
- // Act
- SetEndpoint.setEndpoint(PROJECT_ID);
-
- // Assert
- String got = bout.toString();
- assertThat(got).contains("display_name: \"do_not_delete_eu\"");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/TablesBatchPredictBigQueryTest.java b/automl/beta/src/test/java/com/example/automl/TablesBatchPredictBigQueryTest.java
deleted file mode 100644
index 8db9aa4b6db..00000000000
--- a/automl/beta/src/test/java/com/example/automl/TablesBatchPredictBigQueryTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class TablesBatchPredictBigQueryTest {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- 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);
- private static final String OUTPUT_URI = "bq://" + PROJECT_ID;
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testTablesBigQueryBatchPredict() {
- // As batch prediction can take a long time. Try to batch predict on a model and confirm that
- // the model was not found, but other elements of the request were valid.
- try {
- TablesBatchPredictBigQuery.batchPredict(PROJECT_ID, MODEL_ID, INPUT_URI, OUTPUT_URI);
- String got = bout.toString();
- assertThat(got).contains("does not exist");
- } catch (IOException | ExecutionException | InterruptedException e) {
- assertThat(e.getMessage()).contains("does not exist");
- }
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/TablesCreateDatasetTest.java b/automl/beta/src/test/java/com/example/automl/TablesCreateDatasetTest.java
deleted file mode 100644
index a279fd1a7ca..00000000000
--- a/automl/beta/src/test/java/com/example/automl/TablesCreateDatasetTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class TablesCreateDatasetTest {
-
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String datasetId;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() throws InterruptedException, ExecutionException, IOException {
- // Delete the created dataset
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
- System.setOut(null);
- }
-
- @Test
- public void testTablesCreateDataset()
- throws IOException, ExecutionException, InterruptedException {
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // To prevent name collisions when running tests in multiple java versions at once.
- // AutoML doesn't allow "-", but accepts "_"
- String datasetName =
- String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26));
- TablesCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- datasetId = got.split("Dataset id: ")[1].split("\n")[0];
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/TablesCreateModelTest.java b/automl/beta/src/test/java/com/example/automl/TablesCreateModelTest.java
deleted file mode 100644
index 592f2f62959..00000000000
--- a/automl/beta/src/test/java/com/example/automl/TablesCreateModelTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1.AutoMlClient;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class TablesCreateModelTest {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String DATASET_ID = "TBL2017172828410871808";
- private static final String TABLE_SPEC_ID = "3172574831249981440";
- private static final String COLUMN_SPEC_ID = "3224682886313541632";
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String operationId;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() throws IOException {
- // Cancel the operation
- try (AutoMlClient client = AutoMlClient.create()) {
- client.getOperationsClient().cancelOperation(operationId);
- }
-
- System.setOut(null);
- }
-
- @Test
- public void testTablesCreateModel() throws IOException, ExecutionException, InterruptedException {
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // 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 got = bout.toString();
- assertThat(got).contains("Training started");
-
- operationId = got.split("Training operation name: ")[1].split("\n")[0];
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/TablesImportDatasetTest.java b/automl/beta/src/test/java/com/example/automl/TablesImportDatasetTest.java
deleted file mode 100644
index 71cebe3371e..00000000000
--- a/automl/beta/src/test/java/com/example/automl/TablesImportDatasetTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class TablesImportDatasetTest {
-
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testTablesImportDataset() {
- try {
- TablesImportDataset.importDataset(
- PROJECT_ID, "TEN0000000000000000000", "gs://cloud-ml-tables-data/bank-marketing.csv");
- String got = bout.toString();
- assertThat(got).contains("The Dataset doesn't exist or is inaccessible for use with AutoMl.");
- } catch (IOException | ExecutionException | InterruptedException e) {
- assertThat(e.getMessage())
- .contains("The Dataset doesn't exist or is inaccessible for use with AutoMl.");
- }
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/TablesPredictTest.java b/automl/beta/src/test/java/com/example/automl/TablesPredictTest.java
deleted file mode 100644
index c23a097b480..00000000000
--- a/automl/beta/src/test/java/com/example/automl/TablesPredictTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1.AutoMlClient;
-import com.google.cloud.automl.v1.DeployModelRequest;
-import com.google.cloud.automl.v1.Model;
-import com.google.cloud.automl.v1.ModelName;
-import com.google.protobuf.Value;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class TablesPredictTest {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String MODEL_ID = "TBL7972827093840953344";
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() throws IOException, ExecutionException, InterruptedException {
- // Verify that the model is deployed for prediction
- try (AutoMlClient client = AutoMlClient.create()) {
- ModelName modelFullId = ModelName.of(PROJECT_ID, "us-central1", MODEL_ID);
- Model model = client.getModel(modelFullId);
- if (model.getDeploymentState() == Model.DeploymentState.UNDEPLOYED) {
- // Deploy the model if not deployed
- DeployModelRequest request =
- DeployModelRequest.newBuilder().setName(modelFullId.toString()).build();
- client.deployModelAsync(request).get();
- }
- }
-
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testTablesPredict() throws IOException {
- List values = new ArrayList<>();
- values.add(Value.newBuilder().setNumberValue(39).build()); // Age
- values.add(Value.newBuilder().setStringValue("technician").build()); // Job
- values.add(Value.newBuilder().setStringValue("married").build()); // MaritalStatus
- values.add(Value.newBuilder().setStringValue("secondary").build()); // Education
- values.add(Value.newBuilder().setStringValue("no").build()); // Default
- values.add(Value.newBuilder().setNumberValue(52).build()); // Balance
- values.add(Value.newBuilder().setStringValue("no").build()); // Housing
- values.add(Value.newBuilder().setStringValue("no").build()); // Loan
- values.add(Value.newBuilder().setStringValue("cellular").build()); // Contact
- values.add(Value.newBuilder().setNumberValue(12).build()); // Day
- values.add(Value.newBuilder().setStringValue("aug").build()); // Month
- values.add(Value.newBuilder().setNumberValue(96).build()); // Duration
- values.add(Value.newBuilder().setNumberValue(2).build()); // Campaign
- values.add(Value.newBuilder().setNumberValue(-1).build()); // PDays
- values.add(Value.newBuilder().setNumberValue(0).build()); // Previous
- values.add(Value.newBuilder().setStringValue("unknown").build()); // POutcome
-
- TablesPredict.predict(PROJECT_ID, MODEL_ID, values);
-
- String got = bout.toString();
- assertThat(got).contains("Prediction results:");
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/UndeployModelTest.java b/automl/beta/src/test/java/com/example/automl/UndeployModelTest.java
deleted file mode 100644
index 41fbb0913db..00000000000
--- a/automl/beta/src/test/java/com/example/automl/UndeployModelTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class UndeployModelTest {
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private static final String MODEL_ID = "TEN0000000000000000000";
- private ByteArrayOutputStream bout;
- private PrintStream out;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testUndeployModel() {
- // As model deployment can take a long time, instead try to deploy a
- // nonexistent model and confirm that the model was not found, but other
- // elements of the request were valid.
- try {
- UndeployModel.undeployModel(PROJECT_ID, MODEL_ID);
- String got = bout.toString();
- assertThat(got).contains("The model does not exist");
- } catch (IOException | ExecutionException | InterruptedException e) {
- assertThat(e.getMessage()).contains("The model does not exist");
- }
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/VideoClassificationCreateDatasetTest.java b/automl/beta/src/test/java/com/example/automl/VideoClassificationCreateDatasetTest.java
deleted file mode 100644
index 90a89524828..00000000000
--- a/automl/beta/src/test/java/com/example/automl/VideoClassificationCreateDatasetTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.DatasetName;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class VideoClassificationCreateDatasetTest {
-
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String datasetId;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() throws InterruptedException, ExecutionException, IOException {
- // Delete the created dataset
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the dataset.
- DatasetName datasetFullId = DatasetName.of(PROJECT_ID, "us-central1", datasetId);
- client.deleteDatasetAsync(datasetFullId).get();
- }
- System.setOut(null);
- }
-
- @Test
- public void testCreateDataset() throws IOException, ExecutionException, InterruptedException {
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // To prevent name collisions when running tests in multiple java versions at once.
- // AutoML doesn't allow "-", but accepts "_"
- String datasetName =
- String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26));
- VideoClassificationCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- datasetId = got.split("Dataset id: ")[1].split("\n")[0];
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/VideoClassificationCreateModelTest.java b/automl/beta/src/test/java/com/example/automl/VideoClassificationCreateModelTest.java
deleted file mode 100644
index 103a78e016a..00000000000
--- a/automl/beta/src/test/java/com/example/automl/VideoClassificationCreateModelTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1.AutoMlClient;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class VideoClassificationCreateModelTest {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String DATASET_ID = "VCN6166958410056073216";
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String operationId;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() throws IOException {
- // Cancel the operation
- try (AutoMlClient client = AutoMlClient.create()) {
- client.getOperationsClient().cancelOperation(operationId);
- }
-
- System.setOut(null);
- }
-
- @Test
- public void testVisionClassificationCreateModel()
- throws IOException, ExecutionException, InterruptedException {
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // 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));
- VideoClassificationCreateModel.createModel(PROJECT_ID, DATASET_ID, modelName);
-
- String got = bout.toString();
- assertThat(got).contains("Training started");
-
- operationId = got.split("Training operation name: ")[1].split("\n")[0];
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/VideoObjectTrackingCreateDatasetTest.java b/automl/beta/src/test/java/com/example/automl/VideoObjectTrackingCreateDatasetTest.java
deleted file mode 100644
index 0f043086a27..00000000000
--- a/automl/beta/src/test/java/com/example/automl/VideoObjectTrackingCreateDatasetTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1beta1.AutoMlClient;
-import com.google.cloud.automl.v1beta1.DatasetName;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class VideoObjectTrackingCreateDatasetTest {
-
- private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String datasetId;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("AUTOML_PROJECT_ID");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() throws InterruptedException, ExecutionException, IOException {
- // Delete the created dataset
- try (AutoMlClient client = AutoMlClient.create()) {
- // Get the full path of the dataset.
- DatasetName datasetFullId = DatasetName.of(PROJECT_ID, "us-central1", datasetId);
- client.deleteDatasetAsync(datasetFullId).get();
- }
- System.setOut(null);
- }
-
- @Test
- public void testCreateDataset() throws IOException, ExecutionException, InterruptedException {
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // To prevent name collisions when running tests in multiple java versions at once.
- // AutoML doesn't allow "-", but accepts "_"
- String datasetName =
- String.format("test_%s", UUID.randomUUID().toString().replace("-", "_").substring(0, 26));
- VideoObjectTrackingCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- datasetId = got.split("Dataset id: ")[1].split("\n")[0];
- }
-}
diff --git a/automl/beta/src/test/java/com/example/automl/VideoObjectTrackingCreateModelTest.java b/automl/beta/src/test/java/com/example/automl/VideoObjectTrackingCreateModelTest.java
deleted file mode 100644
index 0399b100987..00000000000
--- a/automl/beta/src/test/java/com/example/automl/VideoObjectTrackingCreateModelTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.automl;
-
-import static com.google.common.truth.Truth.assertThat;
-import static junit.framework.TestCase.assertNotNull;
-
-import com.google.cloud.automl.v1.AutoMlClient;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class VideoObjectTrackingCreateModelTest {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String DATASET_ID = "VOT1317239119331459072";
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String operationId;
-
- private static void requireEnvVar(String varName) {
- assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName));
- }
-
- @BeforeClass
- public static void checkRequirements() {
- requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
- }
-
- @Before
- public void setUp() {
- bout = new ByteArrayOutputStream();
- out = new PrintStream(bout);
- System.setOut(out);
- }
-
- @After
- public void tearDown() throws IOException {
- // Cancel the operation
- try (AutoMlClient client = AutoMlClient.create()) {
- client.getOperationsClient().cancelOperation(operationId);
- }
-
- System.setOut(null);
- }
-
- @Test
- public void testVisionClassificationCreateModel()
- throws IOException, ExecutionException, InterruptedException {
- // Create a random dataset name with a length of 32 characters (max allowed by AutoML)
- // 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));
- VideoObjectTrackingCreateModel.createModel(PROJECT_ID, DATASET_ID, modelName);
-
- String got = bout.toString();
- assertThat(got).contains("Training started");
-
- operationId = got.split("Training operation name: ")[1].split("\n")[0];
- }
-}