@@ -2,7 +2,11 @@ version: 0.2
2
2
3
3
env :
4
4
variables :
5
- FRAMEWORK_VERSION : ' 1.15.0'
5
+ FRAMEWORK_VERSION : ' 1.13.1'
6
+ CPU_FRAMEWORK_BINARY : ' https://s3-us-west-2.amazonaws.com/tensorflow-aws/1.13/AmazonLinux/cpu/latest-patch-latest-patch/tensorflow-1.13.1-cp36-cp36m-linux_x86_64.whl'
7
+ CPU_PY_VERSION : ' 3'
8
+ GPU_FRAMEWORK_BINARY : ' https://s3-us-west-2.amazonaws.com/tensorflow-aws/1.13/AmazonLinux/gpu/latest-patch-latest-patch/tensorflow-1.13.1-cp36-cp36m-linux_x86_64.whl'
9
+ GPU_PY_VERSION : ' 3'
6
10
ECR_REPO : ' sagemaker-test'
7
11
GITHUB_REPO : ' sagemaker-tensorflow-container'
8
12
SETUP_FILE : ' setup_cmds.sh'
@@ -30,95 +34,80 @@ phases:
30
34
- tox -e py36,py27 test/unit
31
35
32
36
# Create pip archive
33
- - root_dir=$(pwd)
37
+ - build_dir="docker/$FRAMEWORK_VERSION"
34
38
- build_id="$(echo $CODEBUILD_BUILD_ID | sed -e 's/:/-/g')"
35
39
- python3 setup.py sdist
36
40
- tar_name=$(ls dist)
37
-
38
- # Find build artifacts
39
- - build_artifacts=$root_dir/docker/artifacts
40
-
41
- # build py2 images
42
-
43
- # prepare build context
44
- - build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py2"
45
- - cp $root_dir/dist/$tar_name $build_dir
46
- - cp $build_artifacts/* $build_dir/
47
- - cd $build_dir
41
+ - cp dist/$tar_name $build_dir
48
42
49
43
# build cpu image
50
44
- 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 .
53
45
54
- # 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 .
46
+ # Download framework binary
47
+ - cpu_fw_binary=$(basename $CPU_FRAMEWORK_BINARY)
48
+ - wget -O $build_dir/$cpu_fw_binary $CPU_FRAMEWORK_BINARY
58
49
59
- # build py3 images
50
+ - CPU_TAG="$FRAMEWORK_VERSION-cpu-py$CPU_PY_VERSION-$build_id"
60
51
61
- # prepare build context
62
- - build_dir="$root_dir/docker/$FRAMEWORK_VERSION/py3"
63
- - cp $root_dir/dist/$tar_name $build_dir
64
- - cp $build_artifacts/* $build_dir/
65
52
- cd $build_dir
66
-
67
- # 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 .
53
+ - docker build -f $cpu_dockerfile --build-arg framework_support_installable=$tar_name --build-arg py_version=$CPU_PY_VERSION --build-arg framework_installable=$cpu_fw_binary -t $PREPROD_IMAGE:$CPU_TAG .
54
+ - cd ../../
71
55
72
56
# build gpu image
73
57
- 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 .
58
+
59
+ # Download framework binary
60
+ - gpu_fw_binary=$(basename $GPU_FRAMEWORK_BINARY)
61
+ - wget -O $build_dir/$gpu_fw_binary $GPU_FRAMEWORK_BINARY
62
+
63
+ - GPU_TAG="$FRAMEWORK_VERSION-gpu-py$GPU_PY_VERSION-$build_id"
64
+
65
+ - cd $build_dir
66
+ - docker build -f $gpu_dockerfile --build-arg framework_support_installable=$tar_name --build-arg py_version=$GPU_PY_VERSION --build-arg framework_installable=$gpu_fw_binary -t $PREPROD_IMAGE:$GPU_TAG .
67
+ - cd ../../
76
68
77
69
# push images to ecr
78
70
- $(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
71
+ - docker push $PREPROD_IMAGE:$CPU_TAG
72
+ - docker push $PREPROD_IMAGE:$GPU_TAG
83
73
84
74
# launch remote gpu instance
85
75
- instance_type='p2.xlarge'
86
76
- create-key-pair
87
77
- launch-ec2-instance --instance-type $instance_type --ami-name dlami-ubuntu
88
78
89
79
# 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"
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"
80
+ - |
81
+ if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then
82
+ pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $CPU_TAG --framework-version $FRAMEWORK_VERSION --py-version $CPU_PY_VERSION --processor cpu
83
+ else
84
+ echo "skipping cpu integration tests"
85
+ fi
94
86
95
87
# run gpu integration tests
96
- - 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"
98
- - 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 "
100
-
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\" "
103
- - execute-command-if-has-matching-changes "$py2_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
88
+ - |
89
+ if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then
90
+ printf "$SETUP_CMDS" > $SETUP_FILE
91
+ cmd="pytest test/integration/local --region $AWS_DEFAULT_REGION --docker-base-name $PREPROD_IMAGE --tag $GPU_TAG --framework-version $FRAMEWORK_VERSION --py-version $GPU_PY_VERSION --processor gpu "
92
+ remote-test --github-repo $GITHUB_REPO --test-cmd "$cmd" --setup-file $SETUP_FILE --pr-number "$PR_NUM"
93
+ else
94
+ echo "skipping gpu integration tests "
95
+ fi
104
96
105
97
# 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"
107
- - 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"
109
- - 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"
111
- - 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"
113
- - execute-command-if-has-matching-changes "$test_cmd" "test/" "src/*.py" "setup.py" "docker/*" "buildspec.yml"
98
+ - |
99
+ if has-matching-changes "test/" "tests/" "src/*.py" "docker/*" "buildspec.yml"; then
100
+ pytest test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $CPU_TAG --py-version $CPU_PY_VERSION --processor cpu
101
+ pytest test/integration/sagemaker -n 8 --region $AWS_DEFAULT_REGION --docker-base-name $ECR_REPO --account-id $ACCOUNT --tag $GPU_TAG --py-version $GPU_PY_VERSION --processor gpu
102
+ else
103
+ echo "skipping sagemaker tests"
104
+ fi
114
105
115
106
finally :
116
107
# shut down remote gpu instance
117
108
- cleanup-gpu-instances
118
109
- cleanup-key-pairs
119
110
120
111
# 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
112
+ - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$CPU_TAG
113
+ - aws ecr batch-delete-image --repository-name $ECR_REPO --region $AWS_DEFAULT_REGION --image-ids imageTag=$GPU_TAG
0 commit comments