Skip to content

fix: run tests if buildspec.yml has been modified #786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ phases:

# run notebook test
- |
if has-matching-changes "src/*.py" "setup.py" "setup.cfg"; then
if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
echo "running notebook test"
./tests/scripts/run-notebook-test.sh
else
Expand All @@ -30,7 +30,7 @@ phases:

# run integration tests
- |
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg"; then
if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then
IGNORE_COVERAGE=- tox -e py36,py27 -- tests/integ -n 24 --boxed --reruns 2
else
echo "skipping integration tests"
Expand Down
19 changes: 10 additions & 9 deletions tests/integ/test_chainer_train.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
Expand All @@ -21,7 +21,7 @@
from sagemaker.chainer.defaults import CHAINER_VERSION
from sagemaker.chainer.estimator import Chainer
from sagemaker.chainer.model import ChainerModel
from sagemaker.utils import sagemaker_timestamp
from sagemaker.utils import unique_name_from_base
import tests.integ
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name
Expand Down Expand Up @@ -62,14 +62,15 @@ def test_training_with_additional_hyperparameters(sagemaker_session, chainer_ful
test_input = chainer.sagemaker_session.upload_data(path=os.path.join(data_path, 'test'),
key_prefix='integ-test-data/chainer_mnist/test')

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


@pytest.mark.canary_quick
@pytest.mark.regional_testing
def test_attach_deploy(chainer_training_job, sagemaker_session):
endpoint_name = 'test-chainer-attach-deploy-{}'.format(sagemaker_timestamp())
endpoint_name = unique_name_from_base('test-chainer-attach-deploy')

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


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


def test_async_fit(sagemaker_session):
endpoint_name = 'test-chainer-attach-deploy-{}'.format(sagemaker_timestamp())

with timeout(minutes=5):
training_job_name = _run_mnist_training_job(sagemaker_session, "ml.c4.xlarge", 1,
chainer_full_version=CHAINER_VERSION, wait=False)

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

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

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


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

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


Expand Down