Skip to content

Commit e3dc3b5

Browse files
authored
Wrap training timeout for integ tests (#339)
1 parent fa88325 commit e3dc3b5

15 files changed

+44
-41
lines changed

tests/integ/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import os
1717

1818
DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data')
19+
TRAINING_DEFAULT_TIMEOUT_MINUTES = 20
20+
TUNING_DEFAULT_TIMEOUT_MINUTES = 20
1921

2022
logging.getLogger('boto3').setLevel(logging.INFO)
2123
logging.getLogger('botocore').setLevel(logging.INFO)

tests/integ/test_byo_estimator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from sagemaker.amazon.amazon_estimator import registry
2525
from sagemaker.estimator import Estimator
2626
from sagemaker.utils import name_from_base
27-
from tests.integ import DATA_DIR
27+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2828
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2929

3030

@@ -55,7 +55,7 @@ def test_byo_estimator(sagemaker_session, region):
5555
image_name = registry(region) + "/factorization-machines:1"
5656
training_data_path = os.path.join(DATA_DIR, 'dummy_tensor')
5757

58-
with timeout(minutes=15):
58+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
5959
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')
6060
pickle_args = {} if sys.version_info.major == 2 else {'encoding': 'latin1'}
6161

tests/integ/test_chainer_train.py

Lines changed: 4 additions & 4 deletions
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
25+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

2828

@@ -40,7 +40,7 @@ def test_distributed_gpu_training(sagemaker_session, chainer_full_version):
4040

4141

4242
def test_training_with_additional_hyperparameters(sagemaker_session, chainer_full_version):
43-
with timeout(minutes=15):
43+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
4444
script_path = os.path.join(DATA_DIR, 'chainer_mnist', 'mnist.py')
4545
data_path = os.path.join(DATA_DIR, 'chainer_mnist')
4646

@@ -101,7 +101,7 @@ def test_async_fit(sagemaker_session):
101101

102102

103103
def test_failed_training_job(sagemaker_session, chainer_full_version):
104-
with timeout(minutes=15):
104+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
105105
script_path = os.path.join(DATA_DIR, 'chainer_mnist', 'failure_script.py')
106106
data_path = os.path.join(DATA_DIR, 'chainer_mnist')
107107

@@ -119,7 +119,7 @@ def test_failed_training_job(sagemaker_session, chainer_full_version):
119119

120120
def _run_mnist_training_job(sagemaker_session, instance_type, instance_count,
121121
chainer_full_version, wait=True):
122-
with timeout(minutes=15):
122+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
123123

124124
script_path = os.path.join(DATA_DIR, 'chainer_mnist', 'mnist.py') if instance_type == 1 else \
125125
os.path.join(DATA_DIR, 'chainer_mnist', 'distributed_mnist.py')

tests/integ/test_factorization_machines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
from sagemaker import FactorizationMachines, FactorizationMachinesModel
2424
from sagemaker.utils import name_from_base
25-
from tests.integ import DATA_DIR
25+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

2828

2929
@pytest.mark.continuous_testing
3030
def test_factorization_machines(sagemaker_session):
31-
with timeout(minutes=15):
31+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3232
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')
3333
pickle_args = {} if sys.version_info.major == 2 else {'encoding': 'latin1'}
3434

tests/integ/test_kmeans.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
from sagemaker import KMeans, KMeansModel
2424
from sagemaker.utils import name_from_base
25-
from tests.integ import DATA_DIR
25+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

2828

2929
@pytest.mark.continuous_testing
3030
def test_kmeans(sagemaker_session):
31-
with timeout(minutes=15):
31+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3232
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')
3333
pickle_args = {} if sys.version_info.major == 2 else {'encoding': 'latin1'}
3434

tests/integ/test_knn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
from sagemaker import KNN, KNNModel
2424
from sagemaker.utils import name_from_base
25-
from tests.integ import DATA_DIR
25+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2626
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2727

2828

2929
@pytest.mark.continuous_testing
3030
def test_knn_regressor(sagemaker_session):
31-
with timeout(minutes=15):
31+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3232
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')
3333
pickle_args = {} if sys.version_info.major == 2 else {'encoding': 'latin1'}
3434

tests/integ/test_lda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
from sagemaker import LDA, LDAModel
2121
from sagemaker.amazon.common import read_records
2222
from sagemaker.utils import name_from_base
23-
from tests.integ import DATA_DIR
23+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2424
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2525
from tests.integ.record_set import prepare_record_set_from_local_files
2626

2727

2828
@pytest.mark.continuous_testing
2929
def test_lda(sagemaker_session):
30-
with timeout(minutes=15):
30+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3131
data_path = os.path.join(DATA_DIR, 'lda')
3232
data_filename = 'nips-train_1.pbr'
3333

tests/integ/test_linear_learner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
from sagemaker.amazon.linear_learner import LinearLearner, LinearLearnerModel
2525
from sagemaker.utils import name_from_base, sagemaker_timestamp
26-
from tests.integ import DATA_DIR
26+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2727
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2828

2929

3030
@pytest.mark.continuous_testing
3131
def test_linear_learner(sagemaker_session):
32-
with timeout(minutes=15):
32+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3333
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')
3434
pickle_args = {} if sys.version_info.major == 2 else {'encoding': 'latin1'}
3535

@@ -93,7 +93,7 @@ def test_linear_learner(sagemaker_session):
9393

9494

9595
def test_linear_learner_multiclass(sagemaker_session):
96-
with timeout(minutes=15):
96+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
9797
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')
9898
pickle_args = {} if sys.version_info.major == 2 else {'encoding': 'latin1'}
9999

@@ -125,7 +125,7 @@ def test_async_linear_learner(sagemaker_session):
125125
training_job_name = ""
126126
endpoint_name = 'test-linear-learner-async-{}'.format(sagemaker_timestamp())
127127

128-
with timeout(minutes=5):
128+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
129129
data_path = os.path.join(DATA_DIR, 'one_p_mnist', 'mnist.pkl.gz')
130130
pickle_args = {} if sys.version_info.major == 2 else {'encoding': 'latin1'}
131131

tests/integ/test_mxnet_train.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
from sagemaker.mxnet.estimator import MXNet
2222
from sagemaker.mxnet.model import MXNetModel
2323
from sagemaker.utils import sagemaker_timestamp
24-
from tests.integ import DATA_DIR
24+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2525
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2626

2727

2828
@pytest.fixture(scope='module')
2929
def mxnet_training_job(sagemaker_session, mxnet_full_version):
30-
with timeout(minutes=15):
30+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3131
script_path = os.path.join(DATA_DIR, 'mxnet_mnist', 'mnist.py')
3232
data_path = os.path.join(DATA_DIR, 'mxnet_mnist')
3333

@@ -100,7 +100,7 @@ def test_async_fit(sagemaker_session):
100100

101101

102102
def test_failed_training_job(sagemaker_session, mxnet_full_version):
103-
with timeout(minutes=15):
103+
with timeout():
104104
script_path = os.path.join(DATA_DIR, 'mxnet_mnist', 'failure_script.py')
105105
data_path = os.path.join(DATA_DIR, 'mxnet_mnist')
106106

tests/integ/test_ntm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
from sagemaker import NTM, NTMModel
2121
from sagemaker.amazon.common import read_records
2222
from sagemaker.utils import name_from_base
23-
from tests.integ import DATA_DIR
23+
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
2424
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2525
from tests.integ.record_set import prepare_record_set_from_local_files
2626

2727

2828
@pytest.mark.continuous_testing
2929
def test_ntm(sagemaker_session):
30-
with timeout(minutes=15):
30+
with timeout(minutes=TRAINING_DEFAULT_TIMEOUT_MINUTES):
3131
data_path = os.path.join(DATA_DIR, 'ntm')
3232
data_filename = 'nips-train_1.pbr'
3333

0 commit comments

Comments
 (0)