-
Notifications
You must be signed in to change notification settings - Fork 2.9k
automl: break up and simplify the dataset tests #1930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d4cdaf
automl: break up and simplify dataset tests
nnegrey 52c2ebc
remove bom from automl until bom is released with v1 of client library
nnegrey ccdd2c3
Fix assert statement
nnegrey 8549165
Update license years and clean up comments
nnegrey 528d07e
Remove score_threshold from Batch Predict
nnegrey 05f8d25
Fix typo in test
nnegrey f2af154
Switch tests to use centralized automl project, temporarily ignore lo…
nnegrey 114833b
Fix which project is used
nnegrey c4af04d
Fix bucket path typo
nnegrey ec5cab5
lint: remove extra semi-colon
nnegrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
automl/cloud-client/src/test/java/com/example/automl/DeleteDatasetTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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."); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
automl/cloud-client/src/test/java/com/example/automl/GetDatasetTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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:"); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the new version not in the BOM? If so do we know when it will be released?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not yet.
It is pushed to java-cloud-bom: https://github.com/googleapis/java-cloud-bom/blob/master/pom.xml#L207
Which is also in cloud-opensource-java: https://github.com/GoogleCloudPlatform/cloud-opensource-java/blob/ca1dede295e2db75fc7a8148fddadbbf102af80c/boms/cloud-oss-bom/pom.xml#L48
But not sure of their release process. But 3.3.0 did not contain it.