From dd5b81bc043a0a23e819e9e774e4d4c5608e30ee Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Thu, 27 Jun 2019 17:29:26 -0700 Subject: [PATCH 1/8] change: print build execution time --- buildspec.yml | 25 +++++++++++++++++++++++++ ci-scripts/displaytime.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 ci-scripts/displaytime.sh diff --git a/buildspec.yml b/buildspec.yml index 3f9ac2af8b..b0de03ef49 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -10,19 +10,32 @@ phases: # run linters - TOX_PARALLEL_NO_SPINNER=1 - PY_COLORS=0 + - start_time=`date +%s` - tox -e flake8,pylint,twine,black-check --parallel all + - ./ci-scripts/displaytime.sh 'flake8,pylint,twine,black-check' $start_time + + - start_time=`date +%s` - tox -e sphinx + - ./ci-scripts/displaytime.sh 'sphinx' $start_time # run unit tests + - start_time=`date +%s` - AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_SESSION_TOKEN= AWS_CONTAINER_CREDENTIALS_RELATIVE_URI= AWS_DEFAULT_REGION= tox -e py36,py27 --parallel all -- tests/unit + - ./ci-scripts/displaytime.sh 'py36,py27 unit ' $start_time # local mode tests - | if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then + start_time=`date +%s` IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m local_mode --durations 50 + ./ci-scripts/displaytime.sh 'py36 local mode ' $start_time + + start_time=`date +%s` IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m local_mode --durations 50 + ./ci-scripts/displaytime.sh 'py27 local mode ' $start_time + else echo "skipping integration tests" fi @@ -30,9 +43,18 @@ phases: # run integration tests - | if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then + start_time=`date +%s` python3 -u ci-scripts/queue_build.py + ./ci-scripts/displaytime.sh 'Build queue' $start_time + + start_time=`date +%s` IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + ./ci-scripts/displaytime.sh 'py36 tests/integ ' $start_time + + start_time=`date +%s` IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + ./ci-scripts/displaytime.sh 'py27 tests/integ ' $start_time + else echo "skipping integration tests" fi @@ -41,7 +63,10 @@ phases: - | if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then echo "running notebook test" + start_time=`date +%s` ./tests/scripts/run-notebook-test.sh + ./ci-scripts/displaytime.sh 'notebook test ' $start_time + else echo "skipping notebook test" fi diff --git a/ci-scripts/displaytime.sh b/ci-scripts/displaytime.sh new file mode 100755 index 0000000000..d7efe221af --- /dev/null +++ b/ci-scripts/displaytime.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# Copyright 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 +# the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "license" file accompanying this file. This file is +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF +# ANY KIND, either express or implied. See the License for the specific +# language governing permissions and limitations under the License. + +set -euo pipefail + +printf '%s execution time ' $1 + +start_time=$2 +end_time=`date +%s` +total_time=$(expr $end_time - $start_time) +hours=$((total_time/60/60%24)) +minutes=$((total_time/60%60)) +secs=$((total_time%60)) + +(( $hours > 0 )) && printf '%d hours ' $hours +(( $minutes > 0 )) && printf '%d minutes ' $minutes +(( $hours > 0 || $minutes > 0 )) && printf 'and ' +printf '%d seconds\n' $secs \ No newline at end of file From bf0eb44d1563f0c26d88a33dbccda5ca6edd9971 Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Thu, 27 Jun 2019 17:36:40 -0700 Subject: [PATCH 2/8] change: print build execution time --- buildspec.yml | 14 +++++++------- ci-scripts/displaytime.sh | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index b0de03ef49..ba8696fc66 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -23,18 +23,18 @@ phases: - AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_SESSION_TOKEN= AWS_CONTAINER_CREDENTIALS_RELATIVE_URI= AWS_DEFAULT_REGION= tox -e py36,py27 --parallel all -- tests/unit - - ./ci-scripts/displaytime.sh 'py36,py27 unit ' $start_time + - ./ci-scripts/displaytime.sh 'py36,py27 unit' $start_time # local mode tests - | if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then start_time=`date +%s` IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m local_mode --durations 50 - ./ci-scripts/displaytime.sh 'py36 local mode ' $start_time + ./ci-scripts/displaytime.sh 'py36 local mode' $start_time start_time=`date +%s` IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m local_mode --durations 50 - ./ci-scripts/displaytime.sh 'py27 local mode ' $start_time + ./ci-scripts/displaytime.sh 'py27 local mode' $start_time else echo "skipping integration tests" @@ -45,15 +45,15 @@ phases: if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then start_time=`date +%s` python3 -u ci-scripts/queue_build.py - ./ci-scripts/displaytime.sh 'Build queue' $start_time + ./ci-scripts/displaytime.sh 'build queue' $start_time start_time=`date +%s` IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 - ./ci-scripts/displaytime.sh 'py36 tests/integ ' $start_time + ./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time start_time=`date +%s` IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 - ./ci-scripts/displaytime.sh 'py27 tests/integ ' $start_time + ./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time else echo "skipping integration tests" @@ -65,7 +65,7 @@ phases: echo "running notebook test" start_time=`date +%s` ./tests/scripts/run-notebook-test.sh - ./ci-scripts/displaytime.sh 'notebook test ' $start_time + ./ci-scripts/displaytime.sh 'notebook test' $start_time else echo "skipping notebook test" diff --git a/ci-scripts/displaytime.sh b/ci-scripts/displaytime.sh index d7efe221af..de309130c7 100755 --- a/ci-scripts/displaytime.sh +++ b/ci-scripts/displaytime.sh @@ -14,7 +14,7 @@ set -euo pipefail -printf '%s execution time ' $1 +printf '\n=================== %s execution time ===================\n\n ' $1 start_time=$2 end_time=`date +%s` @@ -26,4 +26,4 @@ secs=$((total_time%60)) (( $hours > 0 )) && printf '%d hours ' $hours (( $minutes > 0 )) && printf '%d minutes ' $minutes (( $hours > 0 || $minutes > 0 )) && printf 'and ' -printf '%d seconds\n' $secs \ No newline at end of file +printf '%d seconds\n\n' $secs \ No newline at end of file From 59666531c0e2204a3919075e526526ecf027b17f Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 28 Jun 2019 08:03:54 -0700 Subject: [PATCH 3/8] Update printf --- ci-scripts/displaytime.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-scripts/displaytime.sh b/ci-scripts/displaytime.sh index de309130c7..d207099f2e 100755 --- a/ci-scripts/displaytime.sh +++ b/ci-scripts/displaytime.sh @@ -14,7 +14,7 @@ set -euo pipefail -printf '\n=================== %s execution time ===================\n\n ' $1 +echo =================== $1 execution time =================== start_time=$2 end_time=`date +%s` From 6a90f28ea03770b6a4881e3bc863948d5a99b2cd Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 28 Jun 2019 09:15:11 -0700 Subject: [PATCH 4/8] change: print build execution time --- buildspec.yml | 60 +++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index ba8696fc66..7babed6455 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -25,51 +25,39 @@ phases: tox -e py36,py27 --parallel all -- tests/unit - ./ci-scripts/displaytime.sh 'py36,py27 unit' $start_time + - IGNORE_COVERAGE=- + # local mode tests - - | - if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then - start_time=`date +%s` - IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m local_mode --durations 50 - ./ci-scripts/displaytime.sh 'py36 local mode' $start_time + - has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; HAS_CHANGES=$? - start_time=`date +%s` - IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m local_mode --durations 50 - ./ci-scripts/displaytime.sh 'py27 local mode' $start_time + - start_time=`date +%s` + - test HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m local_mode --durations 50 + - ./ci-scripts/displaytime.sh 'py36 local mode' $start_time - else - echo "skipping integration tests" - fi - - # run integration tests - - | - if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then - start_time=`date +%s` - python3 -u ci-scripts/queue_build.py - ./ci-scripts/displaytime.sh 'build queue' $start_time + - start_time=`date +%s` + - test HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m local_mode --durations 50 + - ./ci-scripts/displaytime.sh 'py27 local mode' $start_time - start_time=`date +%s` - IGNORE_COVERAGE=- tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 - ./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time + # run integration tests + - start_time=`date +%s` + - test HAS_CHANGES -ne 0 && python3 -u ci-scripts/queue_build.py + - ./ci-scripts/displaytime.sh 'build queue' $start_time - start_time=`date +%s` - IGNORE_COVERAGE=- tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 - ./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time + - start_time=`date +%s` + - test HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + - ./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time - else - echo "skipping integration tests" - fi + - start_time=`date +%s` + - test HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + - ./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time # run notebook test - - | - if has-matching-changes "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then - echo "running notebook test" - start_time=`date +%s` - ./tests/scripts/run-notebook-test.sh - ./ci-scripts/displaytime.sh 'notebook test' $start_time + - has-matching-changes "src/*.py" "setup.py" "setup.cfg"; HAS_CHANGES=$? + - echo "running notebook test" + - start_time=`date +%s` + - test HAS_CHANGES -ne 0 && ./tests/scripts/run-notebook-test.sh + - ./ci-scripts/displaytime.sh 'notebook test' $start_time - else - echo "skipping notebook test" - fi post_build: finally: - FILENAME=$(ls ci-lock/) From 8138f24b2507076fe1f415b4227c67f2f00fdd65 Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 28 Jun 2019 09:29:23 -0700 Subject: [PATCH 5/8] change: print build execution time --- buildspec.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 7babed6455..d0b1ad0832 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -31,31 +31,31 @@ phases: - has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; HAS_CHANGES=$? - start_time=`date +%s` - - test HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m local_mode --durations 50 + - test $HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m local_mode --durations 50 - ./ci-scripts/displaytime.sh 'py36 local mode' $start_time - start_time=`date +%s` - - test HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m local_mode --durations 50 + - test $HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m local_mode --durations 50 - ./ci-scripts/displaytime.sh 'py27 local mode' $start_time # run integration tests - start_time=`date +%s` - - test HAS_CHANGES -ne 0 && python3 -u ci-scripts/queue_build.py + - test $HAS_CHANGES -ne 0 && python3 -u ci-scripts/queue_build.py - ./ci-scripts/displaytime.sh 'build queue' $start_time - start_time=`date +%s` - - test HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + - test $HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 - ./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time - start_time=`date +%s` - - test HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + - test $HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 - ./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time # run notebook test - has-matching-changes "src/*.py" "setup.py" "setup.cfg"; HAS_CHANGES=$? - echo "running notebook test" - start_time=`date +%s` - - test HAS_CHANGES -ne 0 && ./tests/scripts/run-notebook-test.sh + - test $HAS_CHANGES -ne 0 && ./tests/scripts/run-notebook-test.sh - ./ci-scripts/displaytime.sh 'notebook test' $start_time post_build: From b26b0b67ad0227e64a4bcea5ddc84a9e4d3c1fb3 Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 28 Jun 2019 11:10:16 -0700 Subject: [PATCH 6/8] change: print build execution time --- buildspec.yml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index d0b1ad0832..3ae7f39050 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -28,34 +28,49 @@ phases: - IGNORE_COVERAGE=- # local mode tests - - has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; HAS_CHANGES=$? - - start_time=`date +%s` - - test $HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m local_mode --durations 50 + - | + if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then + tox -e py36 -- tests/integ -m local_mode --durations 50 + fi - ./ci-scripts/displaytime.sh 'py36 local mode' $start_time - start_time=`date +%s` - - test $HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m local_mode --durations 50 + - | + if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then + tox -e py27 -- tests/integ -m local_mode --durations 50 + fi - ./ci-scripts/displaytime.sh 'py27 local mode' $start_time # run integration tests - start_time=`date +%s` - - test $HAS_CHANGES -ne 0 && python3 -u ci-scripts/queue_build.py + - | + if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then + python3 -u ci-scripts/queue_build.py + fi - ./ci-scripts/displaytime.sh 'build queue' $start_time - start_time=`date +%s` - - test $HAS_CHANGES -ne 0 && tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + - | + if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then + tox -e py36 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + fi - ./ci-scripts/displaytime.sh 'py36 tests/integ' $start_time - start_time=`date +%s` - - test $HAS_CHANGES -ne 0 && tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + - | + if has-matching-changes "tests/" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"; then + tox -e py27 -- tests/integ -m "not local_mode" -n 48 --reruns 3 --reruns-delay 5 --durations 50 + fi - ./ci-scripts/displaytime.sh 'py27 tests/integ' $start_time # run notebook test - - has-matching-changes "src/*.py" "setup.py" "setup.cfg"; HAS_CHANGES=$? - echo "running notebook test" - start_time=`date +%s` - - test $HAS_CHANGES -ne 0 && ./tests/scripts/run-notebook-test.sh + - | + if has-matching-changes "src/*.py" "setup.py" "setup.cfg"; then + ./tests/scripts/run-notebook-test.sh + fi - ./ci-scripts/displaytime.sh 'notebook test' $start_time post_build: From 2fbccae0bbe74603d7d0851fb289f2e1a4e63cab Mon Sep 17 00:00:00 2001 From: Marcio Vinicius dos Santos Date: Fri, 28 Jun 2019 16:13:12 -0700 Subject: [PATCH 7/8] Update buildspec.yml --- buildspec.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index 3ae7f39050..b84271248f 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -75,7 +75,11 @@ phases: post_build: finally: - - FILENAME=$(ls ci-lock/) - - ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}') - - S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/ - - aws s3 rm ${S3_BUCKET_DIR}${FILENAME} + - | + if [ -d "ci-lock" ]; then + FILENAME=$(ls ci-lock/ || true) + ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}') + S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/ + aws s3 rm ${S3_BUCKET_DIR}${FILENAME} + fi + From 46ca50ac63487d8c33e8620dec271f9f43964fe7 Mon Sep 17 00:00:00 2001 From: Marcio Vinicius dos Santos Date: Fri, 28 Jun 2019 16:14:15 -0700 Subject: [PATCH 8/8] Update buildspec.yml --- buildspec.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/buildspec.yml b/buildspec.yml index b84271248f..8b68da0ee9 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -76,10 +76,10 @@ phases: post_build: finally: - | - if [ -d "ci-lock" ]; then - FILENAME=$(ls ci-lock/ || true) - ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}') - S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/ - aws s3 rm ${S3_BUCKET_DIR}${FILENAME} - fi + if [ -d "ci-lock" ]; then + FILENAME=$(ls ci-lock/ || true) + ACCOUNT=$(aws sts get-caller-identity --output text | awk '{print $1}') + S3_BUCKET_DIR=s3://sagemaker-us-west-2-${ACCOUNT}/ci-lock/ + aws s3 rm ${S3_BUCKET_DIR}${FILENAME} + fi