Skip to content

Commit 316999d

Browse files
nadiayaPiali Das
authored andcommitted
Run chainer and mxnet integ tests for python 2 and 3 images. (aws#376)
1 parent 92eeb58 commit 316999d

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

tests/integ/test_chainer_train.py

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

2828

@@ -47,6 +47,7 @@ def test_training_with_additional_hyperparameters(sagemaker_session, chainer_ful
4747
chainer = Chainer(entry_point=script_path, role='SageMakerRole',
4848
train_instance_count=1, train_instance_type="ml.c4.xlarge",
4949
framework_version=chainer_full_version,
50+
py_version=PYTHON_VERSION,
5051
sagemaker_session=sagemaker_session, hyperparameters={'epochs': 1},
5152
use_mpi=True,
5253
num_processes=2,
@@ -106,7 +107,7 @@ def test_failed_training_job(sagemaker_session, chainer_full_version):
106107
data_path = os.path.join(DATA_DIR, 'chainer_mnist')
107108

108109
chainer = Chainer(entry_point=script_path, role='SageMakerRole',
109-
framework_version=chainer_full_version,
110+
framework_version=chainer_full_version, py_version=PYTHON_VERSION,
110111
train_instance_count=1, train_instance_type='ml.c4.xlarge',
111112
sagemaker_session=sagemaker_session)
112113

@@ -127,7 +128,7 @@ def _run_mnist_training_job(sagemaker_session, instance_type, instance_count,
127128
data_path = os.path.join(DATA_DIR, 'chainer_mnist')
128129

129130
chainer = Chainer(entry_point=script_path, role='SageMakerRole',
130-
framework_version=chainer_full_version,
131+
framework_version=chainer_full_version, py_version=PYTHON_VERSION,
131132
train_instance_count=instance_count, train_instance_type=instance_type,
132133
sagemaker_session=sagemaker_session, hyperparameters={'epochs': 1})
133134

tests/integ/test_local_mode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_mxnet_local_mode(sagemaker_local_session):
313313
script_path = os.path.join(DATA_DIR, 'mxnet_mnist', 'mnist.py')
314314
data_path = os.path.join(DATA_DIR, 'mxnet_mnist')
315315

316-
mx = MXNet(entry_point=script_path, role='SageMakerRole',
316+
mx = MXNet(entry_point=script_path, role='SageMakerRole', py_version=PYTHON_VERSION,
317317
train_instance_count=1, train_instance_type='local',
318318
sagemaker_session=sagemaker_local_session)
319319

tests/integ/test_mxnet_train.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
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, TRAINING_DEFAULT_TIMEOUT_MINUTES
24+
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES
2525
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2626

2727

@@ -32,7 +32,7 @@ def mxnet_training_job(sagemaker_session, mxnet_full_version):
3232
data_path = os.path.join(DATA_DIR, 'mxnet_mnist')
3333

3434
mx = MXNet(entry_point=script_path, role='SageMakerRole', framework_version=mxnet_full_version,
35-
train_instance_count=1, train_instance_type='ml.c4.xlarge',
35+
py_version=PYTHON_VERSION, train_instance_count=1, train_instance_type='ml.c4.xlarge',
3636
sagemaker_session=sagemaker_session)
3737

3838
train_input = mx.sagemaker_session.upload_data(path=os.path.join(data_path, 'train'),
@@ -62,7 +62,8 @@ def test_deploy_model(mxnet_training_job, sagemaker_session):
6262
desc = sagemaker_session.sagemaker_client.describe_training_job(TrainingJobName=mxnet_training_job)
6363
model_data = desc['ModelArtifacts']['S3ModelArtifacts']
6464
script_path = os.path.join(DATA_DIR, 'mxnet_mnist', 'mnist.py')
65-
model = MXNetModel(model_data, 'SageMakerRole', entry_point=script_path, sagemaker_session=sagemaker_session)
65+
model = MXNetModel(model_data, 'SageMakerRole', entry_point=script_path,
66+
py_version=PYTHON_VERSION, sagemaker_session=sagemaker_session)
6667
predictor = model.deploy(1, 'ml.m4.xlarge', endpoint_name=endpoint_name)
6768

6869
data = numpy.zeros(shape=(1, 1, 28, 28))
@@ -76,7 +77,7 @@ def test_async_fit(sagemaker_session):
7677
script_path = os.path.join(DATA_DIR, 'mxnet_mnist', 'mnist.py')
7778
data_path = os.path.join(DATA_DIR, 'mxnet_mnist')
7879

79-
mx = MXNet(entry_point=script_path, role='SageMakerRole',
80+
mx = MXNet(entry_point=script_path, role='SageMakerRole', py_version=PYTHON_VERSION,
8081
train_instance_count=1, train_instance_type='ml.c4.xlarge',
8182
sagemaker_session=sagemaker_session)
8283

@@ -105,7 +106,7 @@ def test_failed_training_job(sagemaker_session, mxnet_full_version):
105106
data_path = os.path.join(DATA_DIR, 'mxnet_mnist')
106107

107108
mx = MXNet(entry_point=script_path, role='SageMakerRole', framework_version=mxnet_full_version,
108-
train_instance_count=1, train_instance_type='ml.c4.xlarge',
109+
py_version=PYTHON_VERSION, train_instance_count=1, train_instance_type='ml.c4.xlarge',
109110
sagemaker_session=sagemaker_session)
110111

111112
train_input = mx.sagemaker_session.upload_data(path=os.path.join(data_path, 'train'),

tests/integ/test_pytorch_train.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@
1313
from __future__ import absolute_import
1414
import numpy
1515
import os
16-
import sys
1716
import time
1817
import pytest
1918
from sagemaker.pytorch.estimator import PyTorch
2019
from sagemaker.pytorch.model import PyTorchModel
2120
from sagemaker.utils import sagemaker_timestamp
22-
from tests.integ import DATA_DIR, TRAINING_DEFAULT_TIMEOUT_MINUTES
21+
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES
2322
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
2423

2524
MNIST_DIR = os.path.join(DATA_DIR, 'pytorch_mnist')
2625
MNIST_SCRIPT = os.path.join(MNIST_DIR, 'mnist.py')
27-
PYTHON_VERSION = 'py' + str(sys.version_info.major)
2826

2927

3028
@pytest.fixture(scope='module', name='pytorch_training_job')

tests/integ/test_tuner.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def test_tuning_mxnet(sagemaker_session):
188188

189189
estimator = MXNet(entry_point=script_path,
190190
role='SageMakerRole',
191+
py_version=PYTHON_VERSION,
191192
train_instance_count=1,
192193
train_instance_type='ml.m4.xlarge',
193194
sagemaker_session=sagemaker_session,
@@ -270,6 +271,7 @@ def test_tuning_chainer(sagemaker_session):
270271

271272
estimator = Chainer(entry_point=script_path,
272273
role='SageMakerRole',
274+
py_version=PYTHON_VERSION,
273275
train_instance_count=1,
274276
train_instance_type='ml.c4.xlarge',
275277
sagemaker_session=sagemaker_session,
@@ -319,7 +321,8 @@ def test_attach_tuning_pytorch(sagemaker_session):
319321
mnist_dir = os.path.join(DATA_DIR, 'pytorch_mnist')
320322
mnist_script = os.path.join(mnist_dir, 'mnist.py')
321323

322-
estimator = PyTorch(entry_point=mnist_script, role='SageMakerRole', train_instance_count=1,
324+
estimator = PyTorch(entry_point=mnist_script, role='SageMakerRole',
325+
train_instance_count=1, py_version=PYTHON_VERSION,
323326
train_instance_type='ml.c4.xlarge', sagemaker_session=sagemaker_session)
324327

325328
with timeout(minutes=TUNING_DEFAULT_TIMEOUT_MINUTES):

0 commit comments

Comments
 (0)