Skip to content

Commit 5201c60

Browse files
authored
Skip gpu tests in regions without ml.p2.xlarge (#461)
1 parent 8d76437 commit 5201c60

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

tests/integ/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
import os
1717
import sys
1818

19+
import boto3
20+
1921
DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data')
2022
TRAINING_DEFAULT_TIMEOUT_MINUTES = 20
2123
TUNING_DEFAULT_TIMEOUT_MINUTES = 20
2224
TRANSFORM_DEFAULT_TIMEOUT_MINUTES = 20
2325
PYTHON_VERSION = 'py' + str(sys.version_info.major)
26+
REGION = boto3.session.Session().region_name
2427

2528
logging.getLogger('boto3').setLevel(logging.INFO)
2629
logging.getLogger('botocore').setLevel(logging.INFO)

tests/integ/test_chainer_train.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from sagemaker.chainer.estimator import Chainer
2323
from sagemaker.chainer.model import ChainerModel
2424
from sagemaker.utils import sagemaker_timestamp
25-
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES
25+
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES, REGION
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

2828

@@ -35,6 +35,8 @@ def test_distributed_cpu_training(sagemaker_session, chainer_full_version):
3535
_run_mnist_training_job(sagemaker_session, "ml.c4.xlarge", 2, chainer_full_version)
3636

3737

38+
@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'],
39+
reason='No ml.p2.xlarge supported in these regions')
3840
def test_distributed_gpu_training(sagemaker_session, chainer_full_version):
3941
_run_mnist_training_job(sagemaker_session, "ml.p2.xlarge", 2, chainer_full_version)
4042

tests/integ/test_pytorch_train.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from sagemaker.pytorch.estimator import PyTorch
1919
from sagemaker.pytorch.model import PyTorchModel
2020
from sagemaker.utils import sagemaker_timestamp
21-
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES
21+
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES, REGION
2222
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2323

2424
MNIST_DIR = os.path.join(DATA_DIR, 'pytorch_mnist')
@@ -69,6 +69,8 @@ def test_deploy_model(pytorch_training_job, sagemaker_session):
6969
assert output.shape == (batch_size, 10)
7070

7171

72+
@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'],
73+
reason='No ml.p2.xlarge supported in these regions')
7274
def test_async_fit_deploy(sagemaker_session, pytorch_full_version):
7375
training_job_name = ""
7476
# TODO: add tests against local mode when it's ready to be used

tests/integ/test_tf_cifar.py

Lines changed: 3 additions & 1 deletion
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, PYTHON_VERSION
22+
from tests.integ import DATA_DIR, PYTHON_VERSION, REGION
2323
from tests.integ.timeout import timeout_and_delete_endpoint_by_name, timeout
2424

2525
PICKLE_CONTENT_TYPE = 'application/python-pickle'
@@ -35,6 +35,8 @@ def __call__(self, data):
3535

3636
@pytest.mark.continuous_testing
3737
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
38+
@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'],
39+
reason='No ml.p2.xlarge supported in these regions')
3840
def test_cifar(sagemaker_session, tf_full_version):
3941
with timeout(minutes=45):
4042
script_path = os.path.join(DATA_DIR, 'cifar_10', 'source')

tests/integ/test_tf_keras.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
import pytest
1919

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

2424

2525
@pytest.mark.continuous_testing
2626
@pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.")
27+
@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'],
28+
reason='No ml.p2.xlarge supported in these regions')
2729
def test_keras(sagemaker_session, tf_full_version):
2830
script_path = os.path.join(DATA_DIR, 'cifar_10', 'source')
2931
dataset_path = os.path.join(DATA_DIR, 'cifar_10', 'data')

0 commit comments

Comments
 (0)