Skip to content

Commit fbdd1ca

Browse files
authored
Zero code change automation (aws#128)
* changes for automatic zero_code_changes_testing. This is first step towards automated release
1 parent 9180582 commit fbdd1ca

File tree

4 files changed

+110
-2
lines changed

4 files changed

+110
-2
lines changed

config/buildspec_zero_code_change.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Build Spec for AWS CodeBuild CI
2+
3+
version: 0.2
4+
env:
5+
variables:
6+
## below enviornment variables are overridden in respective code build.
7+
# for example for pytorch build run_pytest_pytorch and run_integration_pytest_pytorch will be enabled
8+
run_pytest_pytorch: "disable"
9+
run_pytest_mxnet: "enable"
10+
run_pytest_tensorflow: "disable"
11+
run_pytest_xgboost: "disable"
12+
run_integration_pytest_pytorch: "disable"
13+
run_integration_pytest_mxnet: "enable"
14+
run_integration_pytest_tensorflow: "disable"
15+
run_integration_pytest_xgboost: "disable"
16+
# below needs to be enabled
17+
zero_code_change_test: "enable"
18+
phases:
19+
install:
20+
commands:
21+
- . config/change_branch.sh
22+
- su && apt-get update
23+
- apt-get install sudo -qq -o=Dpkg::Use-Pty=0 # silence output: https://askubuntu.com/a/668859/724247
24+
- sudo apt-get update -qq -o=Dpkg::Use-Pty=0
25+
- sudo apt-get install unzip -qq -o=Dpkg::Use-Pty=0
26+
- cd $CODEBUILD_SRC_DIR && chmod +x config/protoc_downloader.sh && ./config/protoc_downloader.sh
27+
- pip install -U pip
28+
- pip install -q pytest wheel pyYaml pytest-html pre-commit
29+
30+
build:
31+
commands:
32+
- cd $CODEBUILD_SRC_DIR && chmod +x config/install_smdebug.sh && chmod +x config/check_smdebug_install.sh && ./config/install_smdebug.sh && cd ..
33+
- cd $RULES_CODEBUILD_SRC_DIR && python setup.py bdist_wheel --universal && pip install dist/*.whl && cd ..
34+
- cd $CODEBUILD_SRC_DIR && chmod +x config/tests.sh && ./config/tests.sh && mkdir -p upload/$CURRENT_COMMIT_PATH/wheels && cp ./dist/*.whl upload/$CURRENT_COMMIT_PATH/wheels && cd ..
35+
- cd $RULES_CODEBUILD_SRC_DIR && chmod +x config/tests.sh && mkdir -p upload/$CURRENT_COMMIT_PATH/wheels && ./config/tests.sh && cp ./dist/*.whl upload/$CURRENT_COMMIT_PATH/wheels && cd ..
36+
37+
post_build:
38+
commands:
39+
- . $CODEBUILD_SRC_DIR/config/upload_on_end.sh
40+
- rm -rf $CODEBUILD_SRC_DIR/upload/$CURRENT_COMMIT_PATH
41+
- rm -rf $RULES_CODEBUILD_SRC_DIR/upload/$CURRENT_COMMIT_PATH
42+
- if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 0 ]; then echo "ERROR BUILD FAILED " && exit 1 ; fi
43+
- if [ "$CODEBUILD_BUILD_SUCCEEDING" -eq 1 ]; then echo "INFO BUILD SUCCEEDED !!! " ; fi

config/check_smdebug_install.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -ex
3+
set -o pipefail
4+
python -c "import smdebug"
5+
res="$?"
6+
echo "output of import smdebug is: $res"
7+
8+
#version=python -c "exec(\"import smdebug\nprint(smdebug.__version__)\")`
9+
version="$(python -c "exec(\"import smdebug\nprint(smdebug.__version__)\")")"
10+
# force check version, you can set this env variable in build env when releasing
11+
12+
if [ "$force_check_smdebug_version" ] && [ "$force_check_smdebug_version" != "${version}" ]; then
13+
echo "force_check_version $force_check_smdebug_version doesn't match version found: ${version}"
14+
exit 1
15+
fi
16+
17+
if [ $1 ]; then
18+
python -c "import $1"
19+
res="$?"
20+
echo "output of import $1 is: $res"
21+
exit $res
22+
fi
23+
exit $res

config/install_smdebug.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -ex
3+
set -o pipefail
4+
5+
6+
cd $CODEBUILD_SRC_DIR
7+
# you can provide bip binary as s3 path in the build environment
8+
if [ "$SMDEBUG_S3_BINARY" ]; then
9+
mkdir -p s3_pip_binary
10+
aws s3 cp "$SMDEBUG_S3_BINARY" s3_pip_binary
11+
pip install --force-reinstall --upgrade s3_pip_binary/*.whl
12+
else
13+
python setup.py bdist_wheel --universal && pip install --upgrade --force-reinstall dist/*.whl
14+
fi
15+
16+
17+
if [ "$run_pytest_mxnet" == 'enable' ]; then
18+
./config/check_smdebug_install.sh mxnet
19+
fi
20+
if [ "$run_pytest_tensorflow" == 'enable' ]; then
21+
./config/check_smdebug_install.sh tensorflow
22+
fi
23+
if [ "$run_pytest_pytorch" == 'enable' ]; then
24+
./config/check_smdebug_install.sh torch
25+
fi

config/tests.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,20 @@ check_logs() {
1515
}
1616

1717
run_for_framework() {
18-
python -m pytest --durations=50 --html=$REPORT_DIR/report_$1.html -v -s --self-contained-html tests/$1
18+
if [ "$zero_code_change_test" = "enable" ] ; then
19+
# ignoring some test becuase they require multiple frmaeworks to be installed, these tests need to be broken down
20+
python -m pytest --durations=50 --html=$REPORT_DIR/report_$1.html -v -s --self-contained-html --ignore=tests/core/test_hook_save_scalar.py --ignore=tests/core/test_paths.py --ignore=tests/core/test_index_utils.py --ignore=tests/core/test_collections.py tests/$1
21+
if [ "$1" = "mxnet" ] ; then
22+
python tests/zero_code_change/mxnet_gluon_integration_test.py
23+
elif [ "$1" = "pytorch" ] ; then
24+
python tests/zero_code_change/pytorch_integration_tests.py
25+
elif [ "$1" = "tensorflow" ] ; then
26+
python -m pytest tests/zero_code_change/tensorflow_integration_tests.py
27+
fi
28+
29+
else
30+
python -m pytest --durations=50 --html=$REPORT_DIR/report_$1.html -v -s --self-contained-html tests/$1
31+
fi
1932
}
2033

2134
export TF_CPP_MIN_LOG_LEVEL=1
@@ -26,7 +39,8 @@ export SMDEBUG_LOG_LEVEL=info
2639
export OUT_DIR=upload/$CURRENT_COMMIT_PATH
2740
export REPORT_DIR=$OUT_DIR/pytest_reports
2841
python -m pytest -v -W=ignore --durations=50 --html=$REPORT_DIR/report_analysis.html --self-contained-html tests/analysis
29-
python -m pytest -v -W=ignore --durations=50 --html=$REPORT_DIR/report_core.html --self-contained-html tests/core
42+
43+
run_for_framework core
3044

3145
if [ "$run_pytest_xgboost" = "enable" ] ; then
3246
run_for_framework xgboost
@@ -48,6 +62,9 @@ check_logs $REPORT_DIR/*
4862

4963
# Only look at newly added files
5064
if [ -n "$(git status --porcelain | grep ^?? | grep -v smdebugcodebuildtest | grep -v upload)" ]; then
65+
if [ "$zero_code_change_test" = "enable" ] ; then
66+
exit 0
67+
fi
5168
echo "ERROR: Test artifacts were created. Please place these in /tmp."
5269
exit 1
5370
fi

0 commit comments

Comments
 (0)