-
Notifications
You must be signed in to change notification settings - Fork 162
Add release build #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add release build #191
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
include VERSION | ||
include LICENSE | ||
include README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.0.1.dev0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
version: 0.2 | ||
|
||
env: | ||
variables: | ||
FRAMEWORK_VERSION: '1.13.1' | ||
GPU_INSTANCE_TYPE: 'ml.p2.xlarge' | ||
SETUP_CMDS: '#!/bin/bash\npip install --upgrade pip\npip install -U -e .\npip install -U -e .[test]' | ||
|
||
phases: | ||
pre_build: | ||
commands: | ||
- start-dockerd | ||
- ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text) | ||
|
||
build: | ||
commands: | ||
# prepare the release (update versions, changelog etc.) | ||
- git-release --prepare | ||
|
||
# run linter | ||
- tox -e flake8 | ||
|
||
# run unit tests | ||
- tox -e py36,py27 test/unit | ||
|
||
# Create pip archive | ||
- build_dir="docker/$FRAMEWORK_VERSION" | ||
- python3 setup.py sdist | ||
- tar_name=$(ls dist) | ||
- cp dist/$tar_name $build_dir | ||
|
||
# Build all images | ||
- python3 scripts/build_all.py --account $ACCOUNT --region $AWS_DEFAULT_REGION | ||
|
||
# run local cpu integ tests | ||
- $(aws ecr get-login --registry-ids $ACCOUNT --no-include-email --region $AWS_DEFAULT_REGION) | ||
- tox -e py36 -- test/integration/local --docker-base-name sagemaker-tensorflow-scriptmode --framework-version $FRAMEWORK_VERSION --processor cpu | ||
- tox -e py36 -- test/integration/local --docker-base-name sagemaker-tensorflow-scriptmode --py-version 2 --framework-version $FRAMEWORK_VERSION --processor cpu | ||
|
||
# launch remote gpu instance | ||
- prefix='ml.' | ||
- instance_type=${GPU_INSTANCE_TYPE#"$prefix"} | ||
- create-key-pair | ||
- launch-ec2-instance --instance-type $instance_type --ami-name dlami-ubuntu | ||
|
||
- printf "$SETUP_CMDS" > $SETUP_FILE | ||
- py2_cmd="tox -e py36 -- test/integration/local --docker-base-name sagemaker-tensorflow-scriptmode --py-version 2 --framework-version $FRAMEWORK_VERSION --processor gpu" | ||
- remote-test --github-repo $GITHUB_REPO --test-cmd "$py2_cmd" --setup-file $SETUP_FILE | ||
- py3_cmd="tox -e py36 -- test/integration/local --docker-base-name sagemaker-tensorflow-scriptmode --framework-version $FRAMEWORK_VERSION --processor gpu" | ||
- remote-test --github-repo $GITHUB_REPO --test-cmd "$py3_cmd" --setup-file $SETUP_FILE | ||
|
||
# Publish all images | ||
- python3 scripts/publish_all.py --account $ACCOUNT --region $AWS_DEFAULT_REGION | ||
|
||
- | | ||
echo '[{ | ||
"repository": "sagemaker-tensorflow-scriptmode", | ||
"tags": [{ | ||
"source": "1.13.1-cpu-py2", | ||
"dest": ["1.13.1-cpu-py2", "1.13-cpu-py2", "1.13.1-cpu-py2-'${CODEBUILD_BUILD_ID#*:}'"] | ||
},{ | ||
"source": "1.13.1-cpu-py3", | ||
"dest": ["1.13.1-cpu-py3", "1.13-cpu-py3", "1.13.1-cpu-py3-'${CODEBUILD_BUILD_ID#*:}'"] | ||
},{ | ||
"source": "1.13.1-gpu-py2", | ||
"dest": ["1.13.1-gpu-py2", "1.13-gpu-py2", "1.13.1-gpu-py2-'${CODEBUILD_BUILD_ID#*:}'"] | ||
},{ | ||
"source": "1.13.1-gpu-py3", | ||
"dest": ["1.13.1-gpu-py3", "1.13-gpu-py3", "1.13.1-gpu-py3-'${CODEBUILD_BUILD_ID#*:}'"] | ||
}], | ||
"test": [ | ||
"tox -e py36 -- test/integration/sagemaker -n auto --region {region} --account-id 520713654638 --docker-base-name sagemaker-tensorflow-scriptmode --framework-version 1.13.1 --processor cpu", | ||
"tox -e py36 -- test/integration/sagemaker -n auto --region {region} --account-id 520713654638 --docker-base-name sagemaker-tensorflow-scriptmode --py-version 2 --framework-version 1.13.1 --processor cpu", | ||
"tox -e py36 -- test/integration/sagemaker -n auto --region {region} --account-id 520713654638 --docker-base-name sagemaker-tensorflow-scriptmode --framework-version 1.13.1 --processor gpu", | ||
"tox -e py36 -- test/integration/sagemaker -n auto --region {region} --account-id 520713654638 --docker-base-name sagemaker-tensorflow-scriptmode --py-version 2 --framework-version 1.13.1 --processor gpu" | ||
] | ||
}]' > deployments.json | ||
|
||
# publish the release to github | ||
- git-release --publish | ||
|
||
finally: | ||
# shut down remote gpu instance | ||
- cleanup-gpu-instances | ||
- cleanup-key-pairs | ||
|
||
artifacts: | ||
files: | ||
- deployments.json | ||
name: ARTIFACT_1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# 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. | ||
from __future__ import absolute_import | ||
|
||
import argparse | ||
import os | ||
import subprocess | ||
|
||
VERSION = '1.13.1' | ||
REPO = 'sagemaker-tensorflow-scriptmode' | ||
PY2_CPU_BINARY = 'https://s3-us-west-2.amazonaws.com/tensorflow-aws/1.13/AmazonLinux/cpu/latest-patch-latest-patch/tensorflow-1.13.1-cp27-cp27mu-linux_x86_64.whl' # noqa | ||
PY3_CPU_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' # noqa | ||
PY2_GPU_BINARY = 'https://s3-us-west-2.amazonaws.com/tensorflow-aws/1.13/AmazonLinux/gpu/latest-patch-latest-patch/tensorflow-1.13.1-cp27-cp27mu-linux_x86_64.whl' # noqa | ||
PY3_GPU_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' # noqa | ||
DEV_ACCOUNT = '142577830533' | ||
REGION = 'us-west-2' | ||
|
||
|
||
def _parse_args(): | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument('--account', type=str, default=DEV_ACCOUNT) | ||
parser.add_argument('--region', type=str, default=REGION) | ||
parser.add_argument('--version', type=str, default=VERSION) | ||
parser.add_argument('--py2-cpu-binary', type=str, default=PY2_CPU_BINARY) | ||
parser.add_argument('--py3-cpu-binary', type=str, default=PY3_CPU_BINARY) | ||
parser.add_argument('--py2-gpu-binary', type=str, default=PY2_GPU_BINARY) | ||
parser.add_argument('--py3-gpu-binary', type=str, default=PY3_GPU_BINARY) | ||
parser.add_argument('--repo', type=str, default=REPO) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
args = _parse_args() | ||
binaries = { | ||
'py2-cpu': args.py2_cpu_binary, | ||
'py3-cpu': args.py3_cpu_binary, | ||
'py2-gpu': args.py2_gpu_binary, | ||
'py3-gpu': args.py3_gpu_binary | ||
} | ||
build_dir = os.path.join('docker', args.version) | ||
|
||
# Run docker-login so we can pull the cached image | ||
login_cmd = subprocess.check_output( | ||
'aws ecr get-login --no-include-email --registry-id {}'.format(args.account).split()) | ||
print('Executing docker login command: '.format(login_cmd)) | ||
subprocess.check_call(login_cmd.split()) | ||
|
||
for arch in ['cpu', 'gpu']: | ||
for py_version in ['2', '3']: | ||
binary_url = binaries['py{}-{}'.format(py_version, arch)] | ||
binary_file = os.path.basename(binary_url) | ||
cmd = 'wget -O {}/{} {}'.format(build_dir, binary_file, binary_url) | ||
print('Downloading binary file {}: '.format(cmd)) | ||
subprocess.check_call(cmd.split()) | ||
tag = '{}-{}-py{}'.format(args.version, arch, py_version) | ||
prev_image_uri = '{}.dkr.ecr.{}.amazonaws.com/{}:{}'.format(args.account, args.region, args.repo, tag) | ||
dockerfile = os.path.join(build_dir, 'Dockerfile.{}'.format(arch)) | ||
build_cmd = 'docker build -f {} --cache-from {} ' \ | ||
'--build-arg py_version={} --build-arg framework_installable={} ' \ | ||
'-t {}:{} {}'.format(dockerfile, prev_image_uri, py_version, binary_file, args.repo, tag, build_dir) | ||
print('Building docker image: {}'.format(build_cmd)) | ||
subprocess.check_call(build_cmd.split()) | ||
print('Deleting binary file {}'.format(binary_file)) | ||
subprocess.check_call('rm {}'.format(os.path.join(build_dir, binary_file)).split()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# 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. | ||
from __future__ import absolute_import | ||
|
||
import argparse | ||
import subprocess | ||
|
||
DEV_ACCOUNT = '142577830533' | ||
VERSION = '1.13.1' | ||
REGION = 'us-west-2' | ||
REPO = 'sagemaker-tensorflow-scriptmode' | ||
|
||
|
||
def _parse_args(): | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument('--account', type=str, default=DEV_ACCOUNT) | ||
parser.add_argument('--version', type=str, default=VERSION) | ||
parser.add_argument('--repo', type=str, default=REPO) | ||
parser.add_argument('--region', type=str, default=REGION) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
args = _parse_args() | ||
|
||
for arch in ['cpu', 'gpu']: | ||
for py_version in ['2', '3']: | ||
source = '{}:{}-{}-py{}'.format(args.repo, args.version, arch, py_version) | ||
dest = '{}.dkr.ecr.{}.amazonaws.com/{}'.format(args.account, args.region, source) | ||
tag_cmd = 'docker tag {} {}'.format(source, dest) | ||
print('Tagging image: {}'.format(tag_cmd)) | ||
subprocess.check_call(tag_cmd.split()) | ||
login_cmd = subprocess.check_output( | ||
'aws ecr get-login --no-include-email --registry-id {} --region {}' | ||
.format(args.account, args.region).split()) | ||
print('Executing docker login command: {}'.format(login_cmd)) | ||
subprocess.check_call(login_cmd.split()) | ||
push_cmd = 'docker push {}'.format(dest) | ||
print('Pushing image: {}'.format(push_cmd)) | ||
subprocess.check_call(push_cmd.split()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.