Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 86a552c

Browse filesBrowse files
author
Takashi Matsuo
authored
[automl] fix: retry vision_object_detection_predict.predict (GoogleCloudPlatform#3492)
fixes GoogleCloudPlatform#3415 Also setting a hard deadline for model deployment.
1 parent 00a395d commit 86a552c
Copy full SHA for 86a552c

File tree

Expand file treeCollapse file tree

2 files changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-3
lines changed
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
backoff==1.10.0
12
pytest==5.3.2

‎automl/cloud-client/vision_object_detection_predict_test.py

Copy file name to clipboardExpand all lines: automl/cloud-client/vision_object_detection_predict_test.py
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import os
1616

17+
import backoff
18+
from google.api_core.exceptions import DeadlineExceeded
1719
from google.cloud import automl
1820
import pytest
1921

@@ -32,12 +34,17 @@ def verify_model_state():
3234
if model.deployment_state == automl.enums.Model.DeploymentState.UNDEPLOYED:
3335
# Deploy model if it is not deployed
3436
response = client.deploy_model(model_full_id)
35-
response.result()
37+
response.result(600) # 10 minutes
3638

3739

3840
def test_vision_object_detection_predict(capsys, verify_model_state):
39-
verify_model_state
4041
file_path = "resources/salad.jpg"
41-
vision_object_detection_predict.predict(PROJECT_ID, MODEL_ID, file_path)
42+
43+
# Retry the sample upon DeadlineExceeded, with a hard deadline of 5 mins.
44+
@backoff.on_exception(backoff.expo, DeadlineExceeded, max_time=300)
45+
def run_sample():
46+
vision_object_detection_predict.predict(PROJECT_ID, MODEL_ID, file_path)
47+
48+
run_sample()
4249
out, _ = capsys.readouterr()
4350
assert "Predicted class name:" in out

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.