Skip to content

Commit 536baf6

Browse files
author
Jon Wayne Parrott
committed
Mark ml engine tests as flaky
1 parent a73c15c commit 536baf6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ml_engine/online_prediction/predict_test.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Tests for predict.py ."""
16-
1715
import json
16+
import socket
1817

1918
import pytest
2019

2120
import predict
2221

23-
2422
MODEL = 'census'
2523
JSON_VERSION = 'v1json'
2624
EXAMPLES_VERSION = 'v1example'
@@ -30,6 +28,10 @@
3028
u'predictions': u' <=50K'
3129
}
3230

31+
# Raise the socket timeout. The requests involved in the sample can take
32+
# a long time to complete.
33+
socket.setdefaulttimeout(60)
34+
3335

3436
with open('resources/census_test_data.json') as f:
3537
JSON = json.load(f)
@@ -39,26 +41,29 @@
3941
BYTESTRING = f.read()
4042

4143

44+
@pytest.mark.flaky
4245
def test_predict_json():
4346
result = predict.predict_json(
4447
PROJECT, MODEL, [JSON, JSON], version=JSON_VERSION)
4548
assert [EXPECTED_OUTPUT, EXPECTED_OUTPUT] == result
4649

4750

51+
@pytest.mark.flaky
4852
def test_predict_json_error():
4953
with pytest.raises(RuntimeError):
5054
predict.predict_json(
5155
PROJECT, MODEL, [{"foo": "bar"}], version=JSON_VERSION)
5256

5357

54-
@pytest.mark.slow
58+
@pytest.mark.flaky
5559
def test_census_example_to_bytes():
5660
import tensorflow as tf
5761
b = predict.census_to_example_bytes(JSON)
5862
assert tf.train.Example.FromString(b) == tf.train.Example.FromString(
5963
BYTESTRING)
6064

6165

66+
@pytest.mark.flaky
6267
def test_predict_examples():
6368
result = predict.predict_examples(
6469
PROJECT, MODEL, [BYTESTRING, BYTESTRING], version=EXAMPLES_VERSION)

0 commit comments

Comments
 (0)