Skip to content

Re-enable AutoML model create tests #3721

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions translate/automl/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime
import os
import uuid

from google.cloud import automl_v1beta1 as automl
import pytest
Expand All @@ -26,29 +26,32 @@
compute_region = "us-central1"


@pytest.mark.skip(reason="creates too many models")
def test_model_create_status_delete(capsys):
# create model
@pytest.fixture
def model():
client = automl.AutoMlClient()
model_name = "test_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
model_name = "test_{}".format(uuid.uuid4()).replace("-", "")[:32]
project_location = client.location_path(project_id, compute_region)
my_model = {
"display_name": model_name,
"dataset_id": "3876092572857648864",
"translation_model_metadata": {"base_model": ""},
}
response = client.create_model(project_location, my_model)
operation_name = response.operation.name
operation = client.create_model(project_location, my_model)

yield operation

operation.cancel()


def test_model_create_status_delete(capsys, model):
operation_name = model.operation.name
assert operation_name

# get operation status
automl_translation_model.get_operation_status(operation_name)
out, _ = capsys.readouterr()
assert "Operation status: " in out

# cancel operation
response.cancel()


def test_model_list_get_evaluate(capsys):
# list models
Expand Down
19 changes: 11 additions & 8 deletions vision/automl/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime
import os
import uuid

from google.cloud import automl_v1beta1 as automl
import pytest
Expand All @@ -24,20 +24,23 @@
compute_region = "us-central1"


@pytest.mark.skip(reason="creates too many models")
def test_model_create_status_delete(capsys):
# create model
@pytest.fixture
def model():
client = automl.AutoMlClient()
model_name = "test_" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
model_name = "test_{}".format(uuid.uuid4()).replace("-", "")[:32]
project_location = client.location_path(project_id, compute_region)
my_model = {
"display_name": model_name,
"dataset_id": "3946265060617537378",
"image_classification_model_metadata": {"train_budget": 24},
}
response = client.create_model(project_location, my_model)
operation_name = response.operation.name
assert operation_name

# cancel operation
yield response

response.cancel()


def test_model_create_status_delete(capsys, model):
operation_name = model.operation.name
assert operation_name