From 270a5d9ec3cf4658e882695ec446554d073bd109 Mon Sep 17 00:00:00 2001 From: Yu Date: Tue, 6 Nov 2018 14:06:43 -0800 Subject: [PATCH 1/2] Skip gpu tests in regions without gpu --- tests/integ/__init__.py | 3 +++ tests/integ/test_tf_cifar.py | 3 ++- tests/integ/test_tf_keras.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/integ/__init__.py b/tests/integ/__init__.py index 3ebe07a9c6..591ed43200 100644 --- a/tests/integ/__init__.py +++ b/tests/integ/__init__.py @@ -16,11 +16,14 @@ import os import sys +import boto3 + DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data') TRAINING_DEFAULT_TIMEOUT_MINUTES = 20 TUNING_DEFAULT_TIMEOUT_MINUTES = 20 TRANSFORM_DEFAULT_TIMEOUT_MINUTES = 20 PYTHON_VERSION = 'py' + str(sys.version_info.major) +REGION = boto3.session.Session().region_name logging.getLogger('boto3').setLevel(logging.INFO) logging.getLogger('botocore').setLevel(logging.INFO) diff --git a/tests/integ/test_tf_cifar.py b/tests/integ/test_tf_cifar.py index f569b782ff..abe95899bc 100644 --- a/tests/integ/test_tf_cifar.py +++ b/tests/integ/test_tf_cifar.py @@ -19,7 +19,7 @@ import pytest from sagemaker.tensorflow import TensorFlow -from tests.integ import DATA_DIR, PYTHON_VERSION +from tests.integ import DATA_DIR, PYTHON_VERSION, REGION from tests.integ.timeout import timeout_and_delete_endpoint_by_name, timeout PICKLE_CONTENT_TYPE = 'application/python-pickle' @@ -35,6 +35,7 @@ def __call__(self, data): @pytest.mark.continuous_testing @pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.") +@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1']) def test_cifar(sagemaker_session, tf_full_version): with timeout(minutes=45): script_path = os.path.join(DATA_DIR, 'cifar_10', 'source') diff --git a/tests/integ/test_tf_keras.py b/tests/integ/test_tf_keras.py index 301bff87d0..b52dd12f00 100644 --- a/tests/integ/test_tf_keras.py +++ b/tests/integ/test_tf_keras.py @@ -18,12 +18,13 @@ import pytest from sagemaker.tensorflow import TensorFlow -from tests.integ import DATA_DIR, PYTHON_VERSION +from tests.integ import DATA_DIR, PYTHON_VERSION, REGION from tests.integ.timeout import timeout_and_delete_endpoint_by_name, timeout @pytest.mark.continuous_testing @pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.") +@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1']) def test_keras(sagemaker_session, tf_full_version): script_path = os.path.join(DATA_DIR, 'cifar_10', 'source') dataset_path = os.path.join(DATA_DIR, 'cifar_10', 'data') From 682854a877394087b6ec3a6724f9aeeee0527c52 Mon Sep 17 00:00:00 2001 From: Yu Date: Wed, 7 Nov 2018 11:45:19 -0800 Subject: [PATCH 2/2] Update reason --- tests/integ/test_chainer_train.py | 4 +++- tests/integ/test_pytorch_train.py | 4 +++- tests/integ/test_tf_cifar.py | 3 ++- tests/integ/test_tf_keras.py | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/integ/test_chainer_train.py b/tests/integ/test_chainer_train.py index 26fe199367..ed82946334 100644 --- a/tests/integ/test_chainer_train.py +++ b/tests/integ/test_chainer_train.py @@ -22,7 +22,7 @@ from sagemaker.chainer.estimator import Chainer from sagemaker.chainer.model import ChainerModel from sagemaker.utils import sagemaker_timestamp -from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES +from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES, REGION from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name @@ -35,6 +35,8 @@ def test_distributed_cpu_training(sagemaker_session, chainer_full_version): _run_mnist_training_job(sagemaker_session, "ml.c4.xlarge", 2, chainer_full_version) +@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'], + reason='No ml.p2.xlarge supported in these regions') def test_distributed_gpu_training(sagemaker_session, chainer_full_version): _run_mnist_training_job(sagemaker_session, "ml.p2.xlarge", 2, chainer_full_version) diff --git a/tests/integ/test_pytorch_train.py b/tests/integ/test_pytorch_train.py index 7b604becaf..fb627baf53 100644 --- a/tests/integ/test_pytorch_train.py +++ b/tests/integ/test_pytorch_train.py @@ -18,7 +18,7 @@ from sagemaker.pytorch.estimator import PyTorch from sagemaker.pytorch.model import PyTorchModel from sagemaker.utils import sagemaker_timestamp -from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES +from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES, REGION from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name MNIST_DIR = os.path.join(DATA_DIR, 'pytorch_mnist') @@ -69,6 +69,8 @@ def test_deploy_model(pytorch_training_job, sagemaker_session): assert output.shape == (batch_size, 10) +@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'], + reason='No ml.p2.xlarge supported in these regions') def test_async_fit_deploy(sagemaker_session, pytorch_full_version): training_job_name = "" # TODO: add tests against local mode when it's ready to be used diff --git a/tests/integ/test_tf_cifar.py b/tests/integ/test_tf_cifar.py index abe95899bc..e5a2354493 100644 --- a/tests/integ/test_tf_cifar.py +++ b/tests/integ/test_tf_cifar.py @@ -35,7 +35,8 @@ def __call__(self, data): @pytest.mark.continuous_testing @pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.") -@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1']) +@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'], + reason='No ml.p2.xlarge supported in these regions') def test_cifar(sagemaker_session, tf_full_version): with timeout(minutes=45): script_path = os.path.join(DATA_DIR, 'cifar_10', 'source') diff --git a/tests/integ/test_tf_keras.py b/tests/integ/test_tf_keras.py index b52dd12f00..5335058b04 100644 --- a/tests/integ/test_tf_keras.py +++ b/tests/integ/test_tf_keras.py @@ -24,7 +24,8 @@ @pytest.mark.continuous_testing @pytest.mark.skipif(PYTHON_VERSION != 'py2', reason="TensorFlow image supports only python 2.") -@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1']) +@pytest.mark.skipif(REGION in ['us-west-1', 'eu-west-2', 'ca-central-1'], + reason='No ml.p2.xlarge supported in these regions') def test_keras(sagemaker_session, tf_full_version): script_path = os.path.join(DATA_DIR, 'cifar_10', 'source') dataset_path = os.path.join(DATA_DIR, 'cifar_10', 'data')