From a29053468853a4fd3e9330fe0be65e3342433d1b Mon Sep 17 00:00:00 2001 From: Lauren Yu <6631887+laurenyu@users.noreply.github.com> Date: Wed, 8 May 2019 15:29:08 -0700 Subject: [PATCH 1/2] fix: run tests if buildspec.yml has been modified --- buildspec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index c04bcc3061..af7e071a4d 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -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 @@ -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" From d89e57764919e2ceb60e8ff96d2f0d41f6553594 Mon Sep 17 00:00:00 2001 From: Lauren Yu <6631887+laurenyu@users.noreply.github.com> Date: Wed, 15 May 2019 07:49:10 -0700 Subject: [PATCH 2/2] use unique_name_from_base for Chainer integ tests --- tests/integ/test_chainer_train.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/integ/test_chainer_train.py b/tests/integ/test_chainer_train.py index 50e79cc015..0d39e17245 100644 --- a/tests/integ/test_chainer_train.py +++ b/tests/integ/test_chainer_train.py @@ -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 @@ -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 @@ -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) @@ -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'] @@ -89,8 +90,6 @@ 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) @@ -98,6 +97,7 @@ def test_async_fit(sagemaker_session): 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) @@ -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) @@ -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