Skip to content
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

[automl] fix: retry vision_object_detection_predict.predict #3492

Merged
merged 3 commits into from
Apr 24, 2020
Merged
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
1 change: 1 addition & 0 deletions automl/cloud-client/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
backoff==1.10.0
pytest==5.3.2
13 changes: 10 additions & 3 deletions automl/cloud-client/vision_object_detection_predict_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import os

import backoff
from google.api_core.exceptions import DeadlineExceeded
from google.cloud import automl
import pytest

Expand All @@ -32,12 +34,17 @@ def verify_model_state():
if model.deployment_state == automl.enums.Model.DeploymentState.UNDEPLOYED:
# Deploy model if it is not deployed
response = client.deploy_model(model_full_id)
response.result()
response.result(600) # 10 minutes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be worth bumping this to 30 minutes.
Model Deployement is really slow



def test_vision_object_detection_predict(capsys, verify_model_state):
verify_model_state
file_path = "resources/salad.jpg"
vision_object_detection_predict.predict(PROJECT_ID, MODEL_ID, file_path)

# Retry the sample upon DeadlineExceeded, with a hard deadline of 5 mins.
@backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=300)
def run_sample():
vision_object_detection_predict.predict(PROJECT_ID, MODEL_ID, file_path)

run_sample()
out, _ = capsys.readouterr()
assert "Predicted class name:" in out