@@ -2,7 +2,7 @@ version: 0.2
2
2
3
3
env :
4
4
variables :
5
- FRAMEWORK_VERSION : ' 1.15 .0'
5
+ FRAMEWORK_VERSION : ' 2.1 .0'
6
6
ECR_REPO : ' sagemaker-test'
7
7
GITHUB_REPO : ' sagemaker-tensorflow-container'
8
8
SETUP_FILE : ' setup_cmds.sh'
@@ -20,66 +20,65 @@ phases:
20
20
build :
21
21
commands :
22
22
# install
23
- - pip3 install -U -e .
24
23
- pip3 install -U -e .[test]
25
24
26
25
# run flake8
27
26
- tox -e flake8,twine
28
27
29
- # run unit tests
30
- - tox -e py36,py27 test/unit
31
-
32
- # Create pip archive
33
28
- root_dir=$(pwd)
34
29
- build_id="$(echo $CODEBUILD_BUILD_ID | sed -e 's/:/-/g')"
35
- - python3 setup.py sdist
36
- - tar_name=$(ls dist)
37
30
38
31
# Find build artifacts
39
- - build_artifacts=$root_dir/docker/artifacts
32
+ - build_artifacts=$root_dir/docker/build_artifacts
40
33
41
34
# build py2 images
42
35
43
36
# prepare build context
44
37
- build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py2"
45
- - cp $root_dir/dist/$tar_name $build_dir
46
38
- cp $build_artifacts/* $build_dir/
47
39
- cd $build_dir
48
40
49
41
# build cpu image
50
42
- cpu_dockerfile="Dockerfile.cpu"
51
43
- CPU_TAG_PY2="$FRAMEWORK_VERSION-cpu-py2-$build_id"
52
- - docker build -f $cpu_dockerfile -t $PREPROD_IMAGE:$CPU_TAG_PY2 .
44
+ - build_cmd="docker build -f $cpu_dockerfile -t $PREPROD_IMAGE:$CPU_TAG_PY2 . "
45
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
53
46
54
47
# build gpu image
55
48
- gpu_dockerfile="Dockerfile.gpu"
56
49
- GPU_TAG_PY2="$FRAMEWORK_VERSION-gpu-py2-$build_id"
57
- - docker build -f $gpu_dockerfile -t $PREPROD_IMAGE:$GPU_TAG_PY2 .
50
+ - build_cmd="docker build -f $gpu_dockerfile -t $PREPROD_IMAGE:$GPU_TAG_PY2 . "
51
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
58
52
59
53
# build py3 images
60
54
61
55
# prepare build context
62
56
- build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py3"
63
- - cp $root_dir/dist/$tar_name $build_dir
64
57
- cp $build_artifacts/* $build_dir/
65
58
- cd $build_dir
66
59
67
60
# build cpu image
68
61
- cpu_dockerfile="Dockerfile.cpu"
69
62
- CPU_TAG_PY3="$FRAMEWORK_VERSION-cpu-py3-$build_id"
70
- - docker build -f $cpu_dockerfile -t $PREPROD_IMAGE:$CPU_TAG_PY3 .
63
+ - build_cmd="docker build -f $cpu_dockerfile -t $PREPROD_IMAGE:$CPU_TAG_PY3 . "
64
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
71
65
72
66
# build gpu image
73
67
- gpu_dockerfile="Dockerfile.gpu"
74
68
- GPU_TAG_PY3="$FRAMEWORK_VERSION-gpu-py3-$build_id"
75
- - docker build -f $gpu_dockerfile -t $PREPROD_IMAGE:$GPU_TAG_PY3 .
69
+ - build_cmd="docker build -f $gpu_dockerfile -t $PREPROD_IMAGE:$GPU_TAG_PY3 . "
70
+ - execute-command-if-has-matching-changes "$build_cmd" "test/" "docker/*" "buildspec.yml"
76
71
77
72
# push images to ecr
78
73
- $(aws ecr get-login --registry-ids $ACCOUNT --no-include-email --region $AWS_DEFAULT_REGION)
79
- - docker push $PREPROD_IMAGE:$CPU_TAG_PY2
80
- - docker push $PREPROD_IMAGE:$GPU_TAG_PY2
81
- - docker push $PREPROD_IMAGE:$CPU_TAG_PY3
82
- - docker push $PREPROD_IMAGE:$GPU_TAG_PY3
74
+ - push_cmd="docker push $PREPROD_IMAGE:$CPU_TAG_PY2"
75
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
76
+ - push_cmd="docker push $PREPROD_IMAGE:$GPU_TAG_PY2"
77
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
78
+ - push_cmd="docker push $PREPROD_IMAGE:$CPU_TAG_PY3"
79
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
80
+ - push_cmd="docker push $PREPROD_IMAGE:$GPU_TAG_PY3"
81
+ - execute-command-if-has-matching-changes "$push_cmd" "test/" "docker/*" "buildspec.yml"
83
82
84
83
# launch remote gpu instance
85
84
- instance_type='p2.xlarge'
@@ -89,36 +88,40 @@ phases:
89
88
# run cpu integration tests
90
89
- 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
90
- 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"
92
- - execute-command-if-has-matching-changes "$py3_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
93
- - execute-command-if-has-matching-changes "$py2_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
91
+ - execute-command-if-has-matching-changes "$py3_cmd" "test/" "docker/*" "buildspec.yml"
92
+ - execute-command-if-has-matching-changes "$py2_cmd" "test/" "docker/*" "buildspec.yml"
94
93
95
94
# run gpu integration tests
96
95
- printf "$SETUP_CMDS" > $SETUP_FILE
97
96
- 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"
98
97
- py3_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\""
99
- - execute-command-if-has-matching-changes "$py3_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
98
+ - execute-command-if-has-matching-changes "$py3_cmd" "test/" "docker/*" "buildspec.yml"
100
99
101
100
- 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
101
- py2_cmd="remote-test --github-repo $GITHUB_REPO --test-cmd \"$cmd\" --setup-file $SETUP_FILE --pr-number \"$PR_NUM\""
103
- - execute-command-if-has-matching-changes "$py2_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
102
+ - execute-command-if-has-matching-changes "$py2_cmd" "test/" "docker/*" "buildspec.yml"
104
103
105
104
# run sagemaker tests
106
105
- 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"
107
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
106
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
108
107
- 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"
109
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
108
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
110
109
- 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"
111
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
110
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
112
111
- 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"
113
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" " docker/*" "buildspec.yml"
112
+ - execute-command-if-has-matching-changes "$test_cmd" "test/" "docker/*" "buildspec.yml"
114
113
115
114
finally :
116
115
# shut down remote gpu instance
117
116
- cleanup-gpu-instances
118
117
- cleanup-key-pairs
119
118
120
119
# remove ecr image
121
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY2
122
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY2
123
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY3
124
- - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY3
120
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY2"
121
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
122
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY2"
123
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
124
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG_PY3"
125
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
126
+ - delete_cmd="aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG_PY3"
127
+ - execute-command-if-has-matching-changes "$delete_cmd" "test/" "docker/*" "buildspec.yml"
0 commit comments