Skip to content

Commit 54d67b5

Browse files
authored
fix: run tests if buildspec.yml has been modified (#786)
1 parent d1e2ab7 commit 54d67b5

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

buildspec.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ phases:
2121

2222
# run notebook test
2323
- |
24-
if has-matching-changes "src/*.py" "setup.py" "setup.cfg"; then
24+
if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
2525
echo "running notebook test"
2626
./tests/scripts/run-notebook-test.sh
2727
else
@@ -30,7 +30,7 @@ phases:
3030
3131
# run integration tests
3232
- |
33-
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg"; then
33+
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
3434
IGNORE_COVERAGE=- tox -e py36,py27 -- tests/integ -n 24 --boxed --reruns 2
3535
else
3636
echo "skipping integration tests"

tests/integ/test_chainer_train.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"). You
44
# may not use this file except in compliance with the License. A copy of
@@ -21,7 +21,7 @@
2121
from sagemaker.chainer.defaults import CHAINER_VERSION
2222
from sagemaker.chainer.estimator import Chainer
2323
from sagemaker.chainer.model import ChainerModel
24-
from sagemaker.utils import sagemaker_timestamp
24+
from sagemaker.utils import unique_name_from_base
2525
import tests.integ
2626
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES
2727
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
@@ -62,14 +62,15 @@ def test_training_with_additional_hyperparameters(sagemaker_session, chainer_ful
6262
test_input = chainer.sagemaker_session.upload_data(path=os.path.join(data_path, 'test'),
6363
key_prefix='integ-test-data/chainer_mnist/test')
6464

65-
chainer.fit({'train': train_input, 'test': test_input})
65+
job_name = unique_name_from_base('test-chainer-training')
66+
chainer.fit({'train': train_input, 'test': test_input}, job_name=job_name)
6667
return chainer.latest_training_job.name
6768

6869

6970
@pytest.mark.canary_quick
7071
@pytest.mark.regional_testing
7172
def test_attach_deploy(chainer_training_job, sagemaker_session):
72-
endpoint_name = 'test-chainer-attach-deploy-{}'.format(sagemaker_timestamp())
73+
endpoint_name = unique_name_from_base('test-chainer-attach-deploy')
7374

7475
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
7576
estimator = Chainer.attach(chainer_training_job, sagemaker_session=sagemaker_session)
@@ -78,7 +79,7 @@ def test_attach_deploy(chainer_training_job, sagemaker_session):
7879

7980

8081
def test_deploy_model(chainer_training_job, sagemaker_session):
81-
endpoint_name = 'test-chainer-deploy-model-{}'.format(sagemaker_timestamp())
82+
endpoint_name = unique_name_from_base('test-chainer-deploy-model')
8283
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
8384
desc = sagemaker_session.sagemaker_client.describe_training_job(TrainingJobName=chainer_training_job)
8485
model_data = desc['ModelArtifacts']['S3ModelArtifacts']
@@ -89,15 +90,14 @@ def test_deploy_model(chainer_training_job, sagemaker_session):
8990

9091

9192
def test_async_fit(sagemaker_session):
92-
endpoint_name = 'test-chainer-attach-deploy-{}'.format(sagemaker_timestamp())
93-
9493
with timeout(minutes=5):
9594
training_job_name = _run_mnist_training_job(sagemaker_session, "ml.c4.xlarge", 1,
9695
chainer_full_version=CHAINER_VERSION, wait=False)
9796

9897
print("Waiting to re-attach to the training job: %s" % training_job_name)
9998
time.sleep(20)
10099

100+
endpoint_name = unique_name_from_base('test-chainer-async-fit')
101101
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session):
102102
print("Re-attaching now to: %s" % training_job_name)
103103
estimator = Chainer.attach(training_job_name=training_job_name, sagemaker_session=sagemaker_session)
@@ -115,7 +115,7 @@ def test_failed_training_job(sagemaker_session, chainer_full_version):
115115
sagemaker_session=sagemaker_session)
116116

117117
with pytest.raises(ValueError) as e:
118-
chainer.fit()
118+
chainer.fit(job_name=unique_name_from_base('test-chainer-training'))
119119
assert 'ExecuteUserScriptError' in str(e.value)
120120

121121

@@ -138,7 +138,8 @@ def _run_mnist_training_job(sagemaker_session, instance_type, instance_count,
138138
test_input = chainer.sagemaker_session.upload_data(path=os.path.join(data_path, 'test'),
139139
key_prefix='integ-test-data/chainer_mnist/test')
140140

141-
chainer.fit({'train': train_input, 'test': test_input}, wait=wait)
141+
job_name = unique_name_from_base('test-chainer-training')
142+
chainer.fit({'train': train_input, 'test': test_input}, wait=wait, job_name=job_name)
142143
return chainer.latest_training_job.name
143144

144145

0 commit comments

Comments
 (0)