Skip to content

Commit 92eeb58

Browse files
nadiayaPiali Das
authored and
Piali Das
committed
Do not run tensorflow integ tests when running python 3. (aws#374)
* Do not run tensorflow integ tests when running python 3 since we do not have python 3 image for tensorflow. * Correct docs to reflect that upload_data would create only default bucket. (aws#373) * Skip TF when running local mode and tuner integ tests in python3.
1 parent 9c7c031 commit 92eeb58

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-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_local_mode.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from sagemaker.mxnet import MXNet, MXNetModel
2525
from sagemaker.tensorflow import TensorFlow
2626
from sagemaker.fw_utils import tar_and_upload_dir
27-
from tests.integ import DATA_DIR
27+
from tests.integ import DATA_DIR, PYTHON_VERSION
2828
from tests.integ.timeout import timeout
2929

3030
DATA_PATH = os.path.join(DATA_DIR, 'iris', 'data')
@@ -75,6 +75,7 @@ def mxnet_model(sagemaker_local_session):
7575
return model
7676

7777

78+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
7879
def test_tf_local_mode(tf_full_version, sagemaker_local_session):
7980
local_mode_lock_fd = open(LOCK_PATH, 'w')
8081
local_mode_lock = local_mode_lock_fd.fileno()
@@ -120,6 +121,7 @@ def test_tf_local_mode(tf_full_version, sagemaker_local_session):
120121
fcntl.lockf(local_mode_lock, fcntl.LOCK_UN)
121122

122123

124+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
123125
def test_tf_distributed_local_mode(sagemaker_local_session):
124126
local_mode_lock_fd = open(LOCK_PATH, 'w')
125127
local_mode_lock = local_mode_lock_fd.fileno()
@@ -164,6 +166,7 @@ def test_tf_distributed_local_mode(sagemaker_local_session):
164166
fcntl.lockf(local_mode_lock, fcntl.LOCK_UN)
165167

166168

169+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
167170
def test_tf_local_data(sagemaker_local_session):
168171
local_mode_lock_fd = open(LOCK_PATH, 'w')
169172
local_mode_lock = local_mode_lock_fd.fileno()
@@ -206,6 +209,7 @@ def test_tf_local_data(sagemaker_local_session):
206209
fcntl.lockf(local_mode_lock, fcntl.LOCK_UN)
207210

208211

212+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
209213
def test_tf_local_data_local_script():
210214
local_mode_lock_fd = open(LOCK_PATH, 'w')
211215
local_mode_lock = local_mode_lock_fd.fileno()

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/integ/test_tuner.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from sagemaker.pytorch import PyTorch
3333
from sagemaker.tensorflow import TensorFlow
3434
from sagemaker.tuner import IntegerParameter, ContinuousParameter, CategoricalParameter, HyperparameterTuner
35-
from tests.integ import DATA_DIR, TUNING_DEFAULT_TIMEOUT_MINUTES
35+
from tests.integ import DATA_DIR, PYTHON_VERSION, TUNING_DEFAULT_TIMEOUT_MINUTES
3636
from tests.integ.record_set import prepare_record_set_from_local_files
3737
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
3838

@@ -218,6 +218,7 @@ def test_tuning_mxnet(sagemaker_session):
218218

219219

220220
@pytest.mark.continuous_testing
221+
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
221222
def test_tuning_tf(sagemaker_session):
222223
with timeout(minutes=TUNING_DEFAULT_TIMEOUT_MINUTES):
223224
script_path = os.path.join(DATA_DIR, 'iris', 'iris-dnn-classifier.py')

0 commit comments

Comments
 (0)