diff --git a/.kokoro/tests/run_tests.sh b/.kokoro/tests/run_tests.sh
index 8035afe15b9..2b160c72cff 100755
--- a/.kokoro/tests/run_tests.sh
+++ b/.kokoro/tests/run_tests.sh
@@ -65,6 +65,7 @@ if [[ "$SCRIPT_DEBUG" != "true" ]]; then
source "${KOKORO_GFILE_DIR}/storage-hmac-credentials.sh"
source "${KOKORO_GFILE_DIR}/dlp_secrets.txt"
source "${KOKORO_GFILE_DIR}/bigtable_secrets.txt"
+ source "${KOKORO_GFILE_DIR}/automl_secrets.txt"
# Activate service account
gcloud auth activate-service-account \
--key-file="$GOOGLE_APPLICATION_CREDENTIALS" \
diff --git a/automl/cloud-client/pom.xml b/automl/cloud-client/pom.xml
index cd7ec71a4f3..27d243ff225 100644
--- a/automl/cloud-client/pom.xml
+++ b/automl/cloud-client/pom.xml
@@ -27,30 +27,17 @@
- 1.11
- 1.11
+ 11
+ 11
UTF-8
-
-
-
-
-
- com.google.cloud
- libraries-bom
- 3.0.0
- pom
- import
-
-
-
-
+
com.google.cloud
google-cloud-automl
+ 0.115.1-beta
@@ -77,7 +64,5 @@
1.0
test
-
-
\ No newline at end of file
diff --git a/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java b/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java
index 3eb4d9beaa8..3144f863544 100644
--- a/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java
+++ b/automl/cloud-client/src/main/java/com/example/automl/BatchPredict.java
@@ -62,8 +62,6 @@ static void batchPredict(String projectId, String modelId, String inputUri, Stri
.setName(name.toString())
.setInputConfig(inputConfig)
.setOutputConfig(outputConfig)
- // [0.0-1.0] Only produce results higher than this value
- .putParams("score_threshold", "0.8")
.build();
OperationFuture future =
diff --git a/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java
new file mode 100644
index 00000000000..f54201f500c
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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 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 InterruptedException, ExecutionException, IOException {
+ bout = new ByteArrayOutputStream();
+ out = new PrintStream(bout);
+ System.setOut(out);
+
+ // 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));
+ LanguageEntityExtractionCreateDataset.createDataset(PROJECT_ID, datasetName);
+ String got = bout.toString();
+ datasetId = got.split("Dataset id: ")[1].split("\n")[0];
+
+ 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/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java
similarity index 56%
rename from automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationDatasetManagementIT.java
rename to automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java
index 54dcaacc429..9f4b221e720 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationDatasetManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/ExportDatasetTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Google LLC
+ * 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.
@@ -27,7 +27,6 @@
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;
@@ -37,29 +36,28 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-// Tests for Automl natural language text classification datasets.
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class LanguageTextClassificationDatasetManagementIT {
+public class ExportDatasetTest {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String DATASET_ID = System.getenv("ENTITY_EXTRACTION_DATASET_ID");
private static final String BUCKET_ID = PROJECT_ID + "-lcm";
private static final String BUCKET = "gs://" + BUCKET_ID;
private ByteArrayOutputStream bout;
private PrintStream out;
- private String getdatasetId = "TCN2551826603472450019";
private static void requireEnvVar(String varName) {
assertNotNull(
- System.getenv(varName),
- "Environment variable '%s' is required to perform these tests.".format(varName)
- );
+ 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");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("ENTITY_EXTRACTION_DATASET_ID");
}
@Before
@@ -71,68 +69,7 @@ public void setUp() {
@After
public void tearDown() {
- System.setOut(null);
- }
-
- @Test
- public void testCreateImportDeleteDataset()
- 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));
-
- // Act
- LanguageTextClassificationCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- // Assert
- String got = bout.toString();
- String datasetId = got.split("Dataset id: ")[1].split("\n")[0];
-
- // Act
- ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/happiness.csv");
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset id:");
-
- // Act
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset deleted.");
- }
-
- @Test
- public void testListDataset() throws IOException {
- // Act
- ListDatasets.listDatasets(PROJECT_ID);
-
- // Assert
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testGetDataset() throws IOException {
- // Act
- GetDataset.getDataset(PROJECT_ID, getdatasetId);
-
- // Assert
- String got = bout.toString();
-
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testExportDataset() throws IOException, ExecutionException, InterruptedException {
- ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/");
-
- String got = bout.toString();
- assertThat(got).contains("Dataset exported.");
-
+ // Delete the created files from GCS
Storage storage = StorageOptions.getDefaultInstance().getService();
Page blobs =
storage.list(
@@ -152,5 +89,14 @@ public void testExportDataset() throws IOException, ExecutionException, Interrup
}
}
}
+
+ System.setOut(null);
+ }
+
+ @Test
+ public void testExportDataset() throws IOException, ExecutionException, InterruptedException {
+ ExportDataset.exportDataset(PROJECT_ID, DATASET_ID, BUCKET + "/TEST_EXPORT_OUTPUT/");
+ String got = bout.toString();
+ assertThat(got).contains("Dataset exported.");
}
}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java
index 6813cf04bd9..a2facbb6140 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/GenericModelManagementIT.java
@@ -34,7 +34,7 @@
// Tests for Automl models.
@RunWith(JUnit4.class)
public class GenericModelManagementIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
private String modelId;
private String modelEvaluationId;
private ByteArrayOutputStream bout;
@@ -50,7 +50,7 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java
new file mode 100644
index 00000000000..1bc25813a89
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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 GetDatasetTest {
+
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String DATASET_ID = System.getenv("ENTITY_EXTRACTION_DATASET_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_DATASET_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 testGetDataset() throws IOException {
+ GetDataset.getDataset(PROJECT_ID, DATASET_ID);
+ String got = bout.toString();
+ assertThat(got).contains("Dataset id:");
+ }
+}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java
new file mode 100644
index 00000000000..987f35cc5a7
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/ImportDatasetTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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 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 InterruptedException, ExecutionException, IOException {
+ bout = new ByteArrayOutputStream();
+ out = new PrintStream(bout);
+ System.setOut(out);
+
+ // Create a dataset that can be used for the import test
+ // 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));
+ LanguageEntityExtractionCreateDataset.createDataset(PROJECT_ID, datasetName);
+ String got = bout.toString();
+ datasetId = got.split("Dataset id: ")[1].split("\n")[0];
+
+ 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 IOException, ExecutionException, InterruptedException {
+ ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity-extraction/dataset.csv");
+ String got = bout.toString();
+ assertThat(got).contains("Dataset imported.");
+ }
+}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java
new file mode 100644
index 00000000000..2773d606d32
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionCreateDatasetTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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 LanguageEntityExtractionCreateDatasetTest {
+
+ 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 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));
+ LanguageEntityExtractionCreateDataset.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/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionDatasetManagementIT.java
deleted file mode 100644
index 550ff61e31e..00000000000
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionDatasetManagementIT.java
+++ /dev/null
@@ -1,156 +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 com.google.api.gax.paging.Page;
-import com.google.cloud.storage.Blob;
-import com.google.cloud.storage.Storage;
-import com.google.cloud.storage.StorageOptions;
-
-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;
-
-// Tests for Automl natural language entity extraction datasets
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class LanguageEntityExtractionDatasetManagementIT {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET_ID = PROJECT_ID + "-lcm";
- private static final String BUCKET = "gs://" + BUCKET_ID;
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String getdatasetId = "TEN477786180780294144";
-
- 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 testCreateImportDeleteDataset()
- 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));
-
- // Act
- LanguageEntityExtractionCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- // Assert
- String got = bout.toString();
- String datasetId = got.split("Dataset id: ")[1].split("\n")[0];
-
- // Act
- ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/entity_extraction/dataset.csv");
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset id:");
-
- // Act
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset deleted.");
- }
-
- @Test
- public void testListDataset() throws IOException {
- // Act
- ListDatasets.listDatasets(PROJECT_ID);
-
- // Assert
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testGetDataset() throws IOException {
- // Act
- GetDataset.getDataset(PROJECT_ID, getdatasetId);
-
- // Assert
- String got = bout.toString();
-
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testExportDataset() throws IOException, ExecutionException, InterruptedException {
- ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/");
-
- String got = bout.toString();
- assertThat(got).contains("Dataset exported.");
-
- Storage storage = StorageOptions.getDefaultInstance().getService();
- Page blobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/"));
-
- for (Blob blob : blobs.iterateAll()) {
- Page fileBlobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix(blob.getName()));
- for (Blob fileBlob : fileBlobs.iterateAll()) {
- if (!fileBlob.isDirectory()) {
- fileBlob.delete();
- }
- }
- }
- }
-}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java
index 3c460343346..a49c8c8d4e6 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionModelManagementIT.java
@@ -27,15 +27,17 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
// Tests for Automl natural language entity extraction models.
@RunWith(JUnit4.class)
+@Ignore
public class LanguageEntityExtractionModelManagementIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String MODEL_ID = "TEN1974951581904273408";
+ 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;
@@ -49,7 +51,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("ENTITY_EXTRACTION_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java
index 7c9af56b6a6..701143c0e86 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageEntityExtractionPredictIT.java
@@ -31,6 +31,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -39,9 +40,9 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class LanguageEntityExtractionPredictIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET_ID = PROJECT_ID + "-lcm";
- private static final String modelId = "TEN1974951581904273408";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-lcm";
+ private static final String modelId = System.getenv("ENTITY_EXTRACTION_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -56,6 +57,8 @@ private static void requireEnvVar(String varName) {
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("ENTITY_EXTRACTION_MODEL_ID");
}
@Before
@@ -78,10 +81,10 @@ public void testPredict() throws IOException {
// Assert
String got = bout.toString();
- assertThat(got).contains("Text Extract Entity Types:");
+ assertThat(got).contains("Text Extract Entity Type:");
}
- @Test
+ @Ignore
public void testBatchPredict() throws IOException, ExecutionException, InterruptedException {
String inputUri = String.format("gs://%s/entity_extraction/input.jsonl", BUCKET_ID);
String outputUri = String.format("gs://%s/TEST_BATCH_PREDICT/", BUCKET_ID);
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java
new file mode 100644
index 00000000000..2a9878f6a11
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisCreateDatasetTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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 LanguageSentimentAnalysisCreateDatasetTest {
+
+ 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 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));
+ LanguageSentimentAnalysisCreateDataset.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/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisDatasetManagementIT.java
deleted file mode 100644
index 64e07c3b349..00000000000
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisDatasetManagementIT.java
+++ /dev/null
@@ -1,157 +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 com.google.api.gax.paging.Page;
-import com.google.cloud.storage.Blob;
-import com.google.cloud.storage.Storage;
-import com.google.cloud.storage.StorageOptions;
-
-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;
-
-// Tests for Automl natural language sentiment analysis datasets.
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class LanguageSentimentAnalysisDatasetManagementIT {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET_ID = PROJECT_ID + "-lcm";
- private static final String BUCKET = "gs://" + BUCKET_ID;
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String getdatasetId = "TST3960250460385409610";
-
- 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 testCreateImportDeleteDataset()
- 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));
-
- // Act
- LanguageSentimentAnalysisCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- // Assert
- String got = bout.toString();
- String datasetId = got.split("Dataset id: ")[1].split("\n")[0];
-
- // Act
- ImportDataset.importDataset(
- PROJECT_ID, datasetId, BUCKET + "/automl-sentiment/sentiment_dataset.csv");
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset id:");
-
- // Act
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset deleted.");
- }
-
- @Test
- public void testListDataset() throws IOException {
- // Act
- ListDatasets.listDatasets(PROJECT_ID);
-
- // Assert
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testGetDataset() throws IOException {
- // Act
- GetDataset.getDataset(PROJECT_ID, getdatasetId);
-
- // Assert
- String got = bout.toString();
-
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testExportDataset() throws IOException, ExecutionException, InterruptedException {
- ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/");
-
- String got = bout.toString();
- assertThat(got).contains("Dataset exported.");
-
- Storage storage = StorageOptions.getDefaultInstance().getService();
- Page blobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/"));
-
- for (Blob blob : blobs.iterateAll()) {
- Page fileBlobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix(blob.getName()));
- for (Blob fileBlob : fileBlobs.iterateAll()) {
- if (!fileBlob.isDirectory()) {
- fileBlob.delete();
- }
- }
- }
- }
-}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java
index 0bc7f68f6c7..72e495c73d9 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisModelManagementIT.java
@@ -27,15 +27,17 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
// Tests for Automl natural language sentiment analysis models.
@RunWith(JUnit4.class)
+@Ignore
public class LanguageSentimentAnalysisModelManagementIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String MODEL_ID = "TST864310464894223026";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String MODEL_ID = System.getenv("SENTIMENT_ANALYSIS_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -49,7 +51,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("SENTIMENT_ANALYSIS_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java
index d0613385ffb..13627760f92 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageSentimentAnalysisPredictIT.java
@@ -34,8 +34,8 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class LanguageSentimentAnalysisPredictIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String modelId = "TST864310464894223026";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String modelId = System.getenv("SENTIMENT_ANALYSIS_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -49,7 +49,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("SENTIMENT_ANALYSIS_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java
new file mode 100644
index 00000000000..de31b016e01
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationCreateDatasetTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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 LanguageTextClassificationCreateDatasetTest {
+
+ 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 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));
+ LanguageTextClassificationCreateDataset.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/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java
index 2d630da6b6a..e0f4e5c3d2f 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationModelManagementIT.java
@@ -27,15 +27,17 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
// Tests for Automl natural language text classification models.
@RunWith(JUnit4.class)
+@Ignore
public class LanguageTextClassificationModelManagementIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String MODEL_ID = "TCN6871084728972835631";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String MODEL_ID = System.getenv("TEXT_CLASSIFICATION_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -49,7 +51,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("TEXT_CLASSIFICATION_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java
index 5034047f9c1..59dac164afc 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/LanguageTextClassificationPredictIT.java
@@ -34,8 +34,8 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class LanguageTextClassificationPredictIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String modelId = "TCN6871084728972835631";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String modelId = System.getenv("TEXT_CLASSIFICATION_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -49,7 +49,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("TEXT_CLASSIFICATION_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java
new file mode 100644
index 00000000000..4938783e0f6
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/ListDatasetsTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java
new file mode 100644
index 00000000000..a1c871ff0fe
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/TranslateCreateDatasetTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.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 TranslateCreateDatasetTest {
+
+ 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 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));
+ TranslateCreateDataset.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/cloud-client/src/test/java/com/example/automl/TranslateDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/TranslateDatasetManagementIT.java
deleted file mode 100644
index 62d8ea87e08..00000000000
--- a/automl/cloud-client/src/test/java/com/example/automl/TranslateDatasetManagementIT.java
+++ /dev/null
@@ -1,158 +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 com.google.api.gax.paging.Page;
-import com.google.cloud.storage.Blob;
-import com.google.cloud.storage.Storage;
-import com.google.cloud.storage.StorageOptions;
-
-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;
-
-// Tests for Automl translation datasets
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class TranslateDatasetManagementIT {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET = "gs://" + PROJECT_ID + "-vcm";
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String datasetId;
- private String getdatasetId = "TRL3946265060617537378";
-
- 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 testCreateImportDeleteDataset()
- 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));
-
- // Act
- TranslateCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- // Assert
- String got = bout.toString();
- datasetId = got.split("Dataset id: ")[1].split("\n")[0];
-
- // Act
- ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/en-ja-short.csv");
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset id:");
-
- // Act
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset deleted.");
- }
-
- @Test
- public void testListDataset() throws IOException {
- // Act
- ListDatasets.listDatasets(PROJECT_ID);
-
- // Assert
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testGetDataset() throws IOException {
- // Act
- GetDataset.getDataset(PROJECT_ID, getdatasetId);
-
- // Assert
- String got = bout.toString();
-
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testExportDataset() throws IOException, ExecutionException, InterruptedException {
- ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/");
-
- Storage storage = StorageOptions.getDefaultInstance().getService();
-
- String got = bout.toString();
-
- assertThat(got).contains("Dataset exported.");
-
- Page blobs =
- storage.list(
- PROJECT_ID + "-vcm",
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/"));
-
- for (Blob blob : blobs.iterateAll()) {
- Page fileBlobs =
- storage.list(
- PROJECT_ID + "-vcm",
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix(blob.getName()));
- for (Blob fileBlob : fileBlobs.iterateAll()) {
- if (!fileBlob.isDirectory()) {
- fileBlob.delete();
- }
- }
- }
- }
-}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/TranslateModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/TranslateModelManagementIT.java
index fb416e42f10..27ab477ae27 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/TranslateModelManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/TranslateModelManagementIT.java
@@ -36,8 +36,8 @@
// Tests for Automl translation models.
@RunWith(JUnit4.class)
public class TranslateModelManagementIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String DATASET_ID = "TRL3946265060617537378";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String DATASET_ID = System.getenv("TRANSLATION_DATASET_ID");
private static final String MODEL_NAME = "translation_test_create_model";
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -54,7 +54,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("TRANSLATION_DATASET_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java
index 24a0ff952f7..9f903230537 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/TranslatePredictIT.java
@@ -35,8 +35,8 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class TranslatePredictIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String modelId = "TRL2188848820815848149";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String modelId = System.getenv("TRANSLATION_MODEL_ID");
private static final String filePath = "./resources/input.txt";
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -51,7 +51,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("TRANSLATION_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java
new file mode 100644
index 00000000000..b6af9cff1d8
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationCreateDatasetTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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 VisionClassificationCreateDatasetTest {
+
+ 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 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));
+ VisionClassificationCreateDataset.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/cloud-client/src/test/java/com/example/automl/VisionClassificationDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDatasetManagementIT.java
deleted file mode 100644
index 90873692297..00000000000
--- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationDatasetManagementIT.java
+++ /dev/null
@@ -1,156 +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 com.google.api.gax.paging.Page;
-import com.google.cloud.storage.Blob;
-import com.google.cloud.storage.Storage;
-import com.google.cloud.storage.StorageOptions;
-
-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;
-
-// Tests for Automl vision image classification datasets.
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class VisionClassificationDatasetManagementIT {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET_ID = PROJECT_ID + "-vcm";
- private static final String BUCKET = "gs://" + BUCKET_ID;
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String getdatasetId = "ICN3876092572857648864";
-
- 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 testCreateImportDeleteDataset()
- 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));
-
- // Act
- VisionClassificationCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- // Assert
- String got = bout.toString();
- String datasetId = got.split("Dataset id: ")[1].split("\n")[0];
-
- // Act
- ImportDataset.importDataset(PROJECT_ID, datasetId, BUCKET + "/flower_traindata.csv");
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset id:");
-
- // Act
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset deleted.");
- }
-
- @Test
- public void testListDataset() throws IOException {
- // Act
- ListDatasets.listDatasets(PROJECT_ID);
-
- // Assert
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testGetDataset() throws IOException {
- // Act
- GetDataset.getDataset(PROJECT_ID, getdatasetId);
-
- // Assert
- String got = bout.toString();
-
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testExportDataset() throws IOException, ExecutionException, InterruptedException {
- ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/");
-
- String got = bout.toString();
- assertThat(got).contains("Dataset exported.");
-
- Storage storage = StorageOptions.getDefaultInstance().getService();
- Page blobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/"));
-
- for (Blob blob : blobs.iterateAll()) {
- Page fileBlobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix(blob.getName()));
- for (Blob fileBlob : fileBlobs.iterateAll()) {
- if (!fileBlob.isDirectory()) {
- fileBlob.delete();
- }
- }
- }
- }
-}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java
index b7f053f6e18..cf1ab01076c 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationModelManagementIT.java
@@ -27,15 +27,17 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
// Tests for Automl vision image classification models.
@RunWith(JUnit4.class)
+@Ignore
public class VisionClassificationModelManagementIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String MODEL_ID = "ICN6418888056864606028";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String MODEL_ID = System.getenv("VISION_CLASSIFICATION_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -49,7 +51,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("VISION_CLASSIFICATION_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java
index ff60b569dd1..c9d7ed4bc93 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/VisionClassificationPredictIT.java
@@ -31,6 +31,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -39,9 +40,9 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class VisionClassificationPredictIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET_ID = PROJECT_ID + "-vcm";
- private static final String modelId = "ICN6418888056864606028";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-vcm";
+ private static final String modelId = System.getenv("VISION_CLASSIFICATION_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -56,6 +57,8 @@ private static void requireEnvVar(String varName) {
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("VISION_CLASSIFICATION_MODEL_ID");
}
@Before
@@ -81,7 +84,7 @@ public void testPredict() throws IOException {
assertThat(got).contains("Predicted class name:");
}
- @Test
+ @Ignore
public void testBatchPredict() throws IOException, ExecutionException, InterruptedException {
String inputUri = String.format("gs://%s/batch_predict_test.csv", BUCKET_ID);
String outputUri = String.format("gs://%s/TEST_BATCH_PREDICT/", BUCKET_ID);
diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java
new file mode 100644
index 00000000000..1e765354db2
--- /dev/null
+++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionCreateDatasetTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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 VisionObjectDetectionCreateDatasetTest {
+
+ 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 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));
+ VisionObjectDetectionCreateDataset.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/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDatasetManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDatasetManagementIT.java
deleted file mode 100644
index 0feb2187a6f..00000000000
--- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionDatasetManagementIT.java
+++ /dev/null
@@ -1,157 +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 com.google.api.gax.paging.Page;
-import com.google.cloud.storage.Blob;
-import com.google.cloud.storage.Storage;
-import com.google.cloud.storage.StorageOptions;
-
-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;
-
-// Tests for Automl vision object detection datasets.
-@RunWith(JUnit4.class)
-@SuppressWarnings("checkstyle:abbreviationaswordinname")
-public class VisionObjectDetectionDatasetManagementIT {
-
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET_ID = PROJECT_ID + "-vcm";
- private static final String BUCKET = "gs://" + BUCKET_ID;
- private ByteArrayOutputStream bout;
- private PrintStream out;
- private String getdatasetId = "IOD2036031651850485760";
-
- 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 testCreateImportDeleteDataset()
- 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));
-
- // Act
- VisionObjectDetectionCreateDataset.createDataset(PROJECT_ID, datasetName);
-
- // Assert
- String got = bout.toString();
- String datasetId = got.split("Dataset id: ")[1].split("\n")[0];
-
- // Act
- ImportDataset.importDataset(
- PROJECT_ID, datasetId, "gs://cloud-ml-data/img/openimage/csv/salads_ml_use.csv");
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset id:");
-
- // Act
- DeleteDataset.deleteDataset(PROJECT_ID, datasetId);
-
- // Assert
- got = bout.toString();
- assertThat(got).contains("Dataset deleted.");
- }
-
- @Test
- public void testListDataset() throws IOException {
- // Act
- ListDatasets.listDatasets(PROJECT_ID);
-
- // Assert
- String got = bout.toString();
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testGetDataset() throws IOException {
- // Act
- GetDataset.getDataset(PROJECT_ID, getdatasetId);
-
- // Assert
- String got = bout.toString();
-
- assertThat(got).contains("Dataset id:");
- }
-
- @Test
- public void testExportDataset() throws IOException, ExecutionException, InterruptedException {
- ExportDataset.exportDataset(PROJECT_ID, getdatasetId, BUCKET + "/TEST_EXPORT_OUTPUT/");
-
- String got = bout.toString();
- assertThat(got).contains("Dataset exported.");
-
- Storage storage = StorageOptions.getDefaultInstance().getService();
- Page blobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix("TEST_EXPORT_OUTPUT/"));
-
- for (Blob blob : blobs.iterateAll()) {
- Page fileBlobs =
- storage.list(
- BUCKET_ID,
- Storage.BlobListOption.currentDirectory(),
- Storage.BlobListOption.prefix(blob.getName()));
- for (Blob fileBlob : fileBlobs.iterateAll()) {
- if (!fileBlob.isDirectory()) {
- fileBlob.delete();
- }
- }
- }
- }
-}
diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java
index e77efa8d319..703ae7e12eb 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionModelManagementIT.java
@@ -27,15 +27,17 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
// Tests for Automl vision object detection models.
@RunWith(JUnit4.class)
+@Ignore
public class VisionObjectDetectionModelManagementIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String MODEL_ID = "IOD1854128448151224320";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String MODEL_ID = System.getenv("OBJECT_DETECTION_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -49,7 +51,8 @@ private static void requireEnvVar(String varName) {
@BeforeClass
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
- requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("OBJECT_DETECTION_MODEL_ID");
}
@Before
diff --git a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java
index a9f5029033d..347779037e8 100644
--- a/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java
+++ b/automl/cloud-client/src/test/java/com/example/automl/VisionObjectDetectionPredictIT.java
@@ -31,6 +31,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -39,9 +40,9 @@
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
public class VisionObjectDetectionPredictIT {
- private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
- private static final String BUCKET_ID = PROJECT_ID + "-vcm";
- private static final String modelId = "IOD1854128448151224320";
+ private static final String PROJECT_ID = System.getenv("AUTOML_PROJECT_ID");
+ private static final String BUCKET_ID = System.getenv("GOOGLE_CLOUD_PROJECT") + "-vcm";
+ private static final String modelId = System.getenv("OBJECT_DETECTION_MODEL_ID");
private ByteArrayOutputStream bout;
private PrintStream out;
@@ -56,6 +57,8 @@ private static void requireEnvVar(String varName) {
public static void checkRequirements() {
requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS");
requireEnvVar("GOOGLE_CLOUD_PROJECT");
+ requireEnvVar("AUTOML_PROJECT_ID");
+ requireEnvVar("OBJECT_DETECTION_MODEL_ID");
}
@Before
@@ -82,7 +85,7 @@ public void testPredict() throws IOException {
assertThat(got).contains("Y:");
}
- @Test
+ @Ignore
public void testBatchPredict() throws IOException, ExecutionException, InterruptedException {
String inputUri =
String.format("gs://%s/vision_object_detection_batch_predict_test.csv", BUCKET_ID);