Skip to content

Commit 5304595

Browse files
author
Jon Wayne Parrott
committed
Fix flaky for ml engine tests
1 parent 3298f05 commit 5304595

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ml_engine/online_prediction/predict_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import json
1616
import socket
1717

18+
from gcp_devrel.testing.flaky import flaky
1819
import pytest
1920

2021
import predict
@@ -41,29 +42,29 @@
4142
BYTESTRING = f.read()
4243

4344

44-
@pytest.mark.flaky
45+
@flaky
4546
def test_predict_json():
4647
result = predict.predict_json(
4748
PROJECT, MODEL, [JSON, JSON], version=JSON_VERSION)
4849
assert [EXPECTED_OUTPUT, EXPECTED_OUTPUT] == result
4950

5051

51-
@pytest.mark.flaky
52+
@flaky
5253
def test_predict_json_error():
5354
with pytest.raises(RuntimeError):
5455
predict.predict_json(
5556
PROJECT, MODEL, [{"foo": "bar"}], version=JSON_VERSION)
5657

5758

58-
@pytest.mark.flaky
59+
@flaky
5960
def test_census_example_to_bytes():
6061
import tensorflow as tf
6162
b = predict.census_to_example_bytes(JSON)
6263
assert tf.train.Example.FromString(b) == tf.train.Example.FromString(
6364
BYTESTRING)
6465

6566

66-
@pytest.mark.flaky
67+
@flaky(max_runs=6)
6768
def test_predict_examples():
6869
result = predict.predict_examples(
6970
PROJECT, MODEL, [BYTESTRING, BYTESTRING], version=EXAMPLES_VERSION)

nox.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def _setup_appengine_sdk(session):
136136
PYTEST_COMMON_ARGS = [
137137
'--cov',
138138
'--cov-config', os.path.abspath('.coveragerc'),
139-
'--cov-report', 'term']
139+
'--cov-report', 'term',
140+
'--no-success-flaky-report']
140141

141142
FLAKE8_COMMON_ARGS = [
142143
'--show-source', '--builtin', 'gettext', '--max-complexity', '20',
@@ -171,7 +172,7 @@ def _setup_appengine_sdk(session):
171172
NON_GAE_STANDARD_SAMPLES, CHANGED_FILES)
172173

173174

174-
def _session_tests(session, sample, post_install):
175+
def _session_tests(session, sample, post_install=None):
175176
"""Runs py.test for a particular sample."""
176177
session.install('-r', 'testing/requirements.txt')
177178

testing/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ WebTest==2.0.25
1414
webapp2==2.5.2
1515
google-api-python-client==1.6.2
1616
google-cloud-core==0.23.0
17-
gcp-devrel-py-tools==0.0.1
17+
gcp-devrel-py-tools==0.0.4

0 commit comments

Comments
 (0)