@@ -2,18 +2,21 @@ version: 0.2
2
2
3
3
env :
4
4
variables :
5
- FRAMEWORK_VERSION : ' 1.15.0 '
5
+ FRAMEWORK_VERSION : ' 1.15.2 '
6
6
ECR_REPO : ' sagemaker-test'
7
7
GITHUB_REPO : ' sagemaker-tensorflow-container'
8
8
SETUP_FILE : ' setup_cmds.sh'
9
9
SETUP_CMDS : ' #!/bin/bash\npip install --upgrade pip\npip install -U -e .\npip install -U -e .[test]'
10
+ CPU_DOCKERFILE : ' Dockerfile.cpu'
11
+ GPU_DOCKERFILE : ' Dockerfile.gpu'
10
12
11
13
phases :
12
14
pre_build :
13
15
commands :
14
16
- start-dockerd
15
17
- ACCOUNT=$(aws --region $AWS_DEFAULT_REGION sts --endpoint-url https://sts.$AWS_DEFAULT_REGION.amazonaws.com get-caller-identity --query 'Account' --output text)
16
18
- PREPROD_IMAGE="$ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$ECR_REPO"
19
+ - PROD_IMAGE="763104351884.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/tensorflow-training"
17
20
- PR_NUM=$(echo $CODEBUILD_SOURCE_VERSION | grep -o '[0-9]\+')
18
21
- echo 'Pull request number:' $PR_NUM '. No value means this build is not from pull request.'
19
22
@@ -36,43 +39,50 @@ phases:
36
39
- tar_name=$(ls dist)
37
40
38
41
# Find build artifacts
39
- - build_artifacts=$root_dir/docker/artifacts
42
+ - build_artifacts=$root_dir/docker/build_artifacts
43
+
44
+ # login so we can pull prod images for cache
45
+ - $(aws ecr get-login --registry-ids 763104351884 --no-include-email --region $AWS_DEFAULT_REGION)
40
46
41
47
# build py2 images
42
48
43
49
# prepare build context
44
50
- build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py2"
45
51
- cp $root_dir/dist/$tar_name $build_dir
46
- - cp $build_artifacts/* $build_dir/
52
+ - cp $build_artifacts/*.py $build_dir/
47
53
- cd $build_dir
48
54
49
55
# build cpu image
50
- - cpu_dockerfile="Dockerfile.cpu"
51
- - CPU_TAG_PY2="$FRAMEWORK_VERSION-cpu-py2-$build_id"
52
- - docker build -f $cpu_dockerfile -t $PREPROD_IMAGE:$CPU_TAG_PY2 .
56
+ - prod_tag="$FRAMEWORK_VERSION-cpu-py2"
57
+ - CPU_TAG_PY2="$prod_tag-$build_id"
58
+ - docker pull $PROD_IMAGE:$prod_tag
59
+ - docker build --cache-from $PROD_IMAGE:$prod_tag -f $CPU_DOCKERFILE -t $PREPROD_IMAGE:$CPU_TAG_PY2 .
53
60
54
61
# build gpu image
55
- - gpu_dockerfile="Dockerfile.gpu"
56
- - GPU_TAG_PY2="$FRAMEWORK_VERSION-gpu-py2-$build_id"
57
- - docker build -f $gpu_dockerfile -t $PREPROD_IMAGE:$GPU_TAG_PY2 .
62
+ - prod_tag="$FRAMEWORK_VERSION-gpu-py2"
63
+ - GPU_TAG_PY2="$prod_tag-$build_id"
64
+ - docker pull $PROD_IMAGE:$prod_tag
65
+ - docker build --cache-from $PROD_IMAGE:$prod_tag -f $GPU_DOCKERFILE -t $PREPROD_IMAGE:$GPU_TAG_PY2 .
58
66
59
67
# build py3 images
60
68
61
69
# prepare build context
62
70
- build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py3"
63
71
- cp $root_dir/dist/$tar_name $build_dir
64
- - cp $build_artifacts/* $build_dir/
72
+ - cp $build_artifacts/*.py $build_dir/
65
73
- cd $build_dir
66
74
67
75
# build cpu image
68
- - cpu_dockerfile="Dockerfile.cpu"
69
- - CPU_TAG_PY3="$FRAMEWORK_VERSION-cpu-py3-$build_id"
70
- - docker build -f $cpu_dockerfile -t $PREPROD_IMAGE:$CPU_TAG_PY3 .
76
+ - prod_tag="$FRAMEWORK_VERSION-cpu-py3"
77
+ - CPU_TAG_PY3="$prod_tag-$build_id"
78
+ - docker pull $PROD_IMAGE:$prod_tag
79
+ - docker build --cache-from $PROD_IMAGE:$prod_tag -f $CPU_DOCKERFILE -t $PREPROD_IMAGE:$CPU_TAG_PY3 .
71
80
72
81
# build gpu image
73
- - gpu_dockerfile="Dockerfile.gpu"
74
- - GPU_TAG_PY3="$FRAMEWORK_VERSION-gpu-py3-$build_id"
75
- - docker build -f $gpu_dockerfile -t $PREPROD_IMAGE:$GPU_TAG_PY3 .
82
+ - prod_tag="$FRAMEWORK_VERSION-gpu-py3"
83
+ - GPU_TAG_PY3="$prod_tag-$build_id"
84
+ - docker pull $PROD_IMAGE:$prod_tag
85
+ - docker build --cache-from $PROD_IMAGE:$prod_tag -f $GPU_DOCKERFILE -t $PREPROD_IMAGE:$GPU_TAG_PY3 .
76
86
77
87
# push images to ecr
78
88
- $(aws ecr get-login --registry-ids $ACCOUNT --no-include-email --region $AWS_DEFAULT_REGION)
@@ -87,29 +97,29 @@ phases:
87
97
- launch-ec2-instance --instance-type $instance_type --ami-name dlami-ubuntu
88
98
89
99
# run cpu integration tests
90
- - py3_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $CPU_TAG_PY2 --framework-version $FRAMEWORK_VERSION --py-version 2 --processor cpu"
91
- - py2_cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $CPU_TAG_PY3 --framework-version $FRAMEWORK_VERSION --py-version 3 --processor cpu"
100
+ - py3_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $CPU_TAG_PY3 --framework-version $FRAMEWORK_VERSION --py-version 3 --processor cpu --durations 10"
92
101
- execute-command-if-has-matching-changes "$py3_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
102
+ - py2_cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $CPU_TAG_PY2 --framework-version $FRAMEWORK_VERSION --py-version 2 --processor cpu --durations 10"
93
103
- execute-command-if-has-matching-changes "$py2_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
94
104
95
105
# run gpu integration tests
96
106
- printf "$SETUP_CMDS" > $SETUP_FILE
97
- - cmd="pytest test/integration/local -- region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $GPU_TAG_PY2 --framework-version $FRAMEWORK_VERSION --py-version 2 --processor gpu"
107
+ - cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/local -n 4 -- region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $GPU_TAG_PY3 --framework-version $FRAMEWORK_VERSION --py-version 3 --processor gpu --durations 10 "
98
108
- py3_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\""
99
109
- execute-command-if-has-matching-changes "$py3_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
100
110
101
- - cmd="pytest test/integration/local -- region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $GPU_TAG_PY3 --framework-version $FRAMEWORK_VERSION --py-version 3 --processor gpu"
102
- - py2_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\""
111
+ - cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/local -n 4 -- region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $GPU_TAG_PY2 --framework-version $FRAMEWORK_VERSION --py-version 2 --processor gpu --durations 10 "
112
+ - py2_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\" --skip-setup "
103
113
- execute-command-if-has-matching-changes "$py2_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
104
114
105
115
# run sagemaker tests
106
- - test_cmd="pytest test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $CPU_TAG_PY2 --py-version 2 --processor cpu"
116
+ - test_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $CPU_TAG_PY3 --py-version 3 --processor cpu --durations 10 "
107
117
- execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
108
- - test_cmd="pytest test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $GPU_TAG_PY2 --py-version 2 --processor gpu"
118
+ - test_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $GPU_TAG_PY3 --py-version 3 --processor gpu --durations 10 "
109
119
- execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
110
- - test_cmd="pytest test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $CPU_TAG_PY3 --py-version 3 --processor cpu"
120
+ - test_cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $CPU_TAG_PY2 --py-version 2 --processor cpu --durations 10 "
111
121
- execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
112
- - test_cmd="pytest test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $GPU_TAG_PY3 --py-version 3 --processor gpu"
122
+ - test_cmd="IGNORE_COVERAGE=- tox -e py27 -- test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $GPU_TAG_PY2 --py-version 2 --processor gpu --durations 10 "
113
123
- execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
114
124
115
125
finally :
0 commit comments