Skip to content

Commit a460a96

Browse files
committed
Do not run tensorflow integ tests when running python 3 since we do not have python 3 image for tensorflow.
1 parent 1aec497 commit a460a96

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

tests/integ/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414

1515
import logging
1616
import os
17+
import sys
1718

1819
DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data')
1920
TRAINING_DEFAULT_TIMEOUT_MINUTES = 20
2021
TUNING_DEFAULT_TIMEOUT_MINUTES = 20
22+
PYTHON_VERSION = 'py' + str(sys.version_info.major)
2123

2224
logging.getLogger('boto3').setLevel(logging.INFO)
2325
logging.getLogger('botocore').setLevel(logging.INFO)

tests/integ/test_tf.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import pytest
1919

2020
from sagemaker.tensorflow import TensorFlow
21-
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
21+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES, PYTHON_VERSION
2222
from tests.integ.timeout import timeout_and_delete_endpoint_by_name, timeout
2323
from tests.integ.vpc_utils import get_or_create_subnet_and_security_group
2424

@@ -27,6 +27,7 @@
2727

2828

2929
@pytest.mark.continuous_testing
30+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
3031
def test_tf(sagemaker_session, tf_full_version):
3132
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3233
script_path = os.path.join(DATA_DIR, 'iris', 'iris-dnn-classifier.py')
@@ -60,6 +61,7 @@ def test_tf(sagemaker_session, tf_full_version):
6061
assert dict_result == list_result
6162

6263

64+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
6365
def test_tf_async(sagemaker_session):
6466
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
6567
script_path = os.path.join(DATA_DIR, 'iris', 'iris-dnn-classifier.py')
@@ -89,6 +91,7 @@ def test_tf_async(sagemaker_session):
8991
print('predict result: {}'.format(result))
9092

9193

94+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
9295
def test_failed_tf_training(sagemaker_session, tf_full_version):
9396
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
9497
script_path = os.path.join(DATA_DIR, 'iris', 'failure_script.py')

tests/integ/test_tf_cifar.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import pytest
2020

2121
from sagemaker.tensorflow import TensorFlow
22-
from tests.integ import DATA_DIR
22+
from tests.integ import DATA_DIR, PYTHON_VERSION
2323
from tests.integ.timeout import timeout_and_delete_endpoint_by_name, timeout
2424

2525
PICKLE_CONTENT_TYPE = 'application/python-pickle'
@@ -34,6 +34,7 @@ def __call__(self, data):
3434

3535

3636
@pytest.mark.continuous_testing
37+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
3738
def test_cifar(sagemaker_session, tf_full_version):
3839
with timeout(minutes=45):
3940
script_path = os.path.join(DATA_DIR, 'cifar_10', 'source')

tests/integ/test_tf_keras.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
import pytest
1919

2020
from sagemaker.tensorflow import TensorFlow
21-
from tests.integ import DATA_DIR
21+
from tests.integ import DATA_DIR, PYTHON_VERSION
2222
from tests.integ.timeout import timeout_and_delete_endpoint_by_name, timeout
2323

2424

2525
@pytest.mark.continuous_testing
26+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
2627
def test_keras(sagemaker_session, tf_full_version):
2728
script_path = os.path.join(DATA_DIR, 'cifar_10', 'source')
2829
dataset_path = os.path.join(DATA_DIR, 'cifar_10', 'data')

tests/unit/test_pytorch.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424
from sagemaker.pytorch import PyTorch
2525
from sagemaker.pytorch import PyTorchPredictor, PyTorchModel
2626

27+
from tests.integ import DATA_DIR, PYTHON_VERSION
2728

28-
DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data')
2929
SCRIPT_PATH = os.path.join(DATA_DIR, 'dummy_script.py')
3030
TIMESTAMP = '2017-11-06-14:14:15.672'
3131
TIME = 1507167947
3232
BUCKET_NAME = 'mybucket'
3333
INSTANCE_COUNT = 1
3434
INSTANCE_TYPE = 'ml.c4.4xlarge'
35-
PYTHON_VERSION = 'py' + str(sys.version_info.major)
3635
IMAGE_NAME = 'sagemaker-pytorch'
3736
JOB_NAME = '{}-{}'.format(IMAGE_NAME, TIMESTAMP)
3837
IMAGE_URI_FORMAT_STRING = "520713654638.dkr.ecr.{}.amazonaws.com/{}:{}-{}-{}"

0 commit comments

Comments
 (0)