Skip to content

Commit ff6a810

Browse files
authored
feature: Add release to PyPI. Change package name to sagemaker-tensorflow-training. (aws#277)
* feature: Add release to PyPI. Change package name to sagemaker-tensroflow-training. * Update latest dockerfiles to use correct binary. * Fix typo.
1 parent 9c0a7f3 commit ff6a810

10 files changed

+49
-79
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dist
33
**/*.egg-info
44
.DS_Store
55
.idea/
6+
.cache/
67
*.iml
78
**/.ipynb_checkpoints
89
**/.python-version

MANIFEST.in

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
recursive-include src/sagemaker_tensorflow_container *
2+
13
include VERSION
24
include LICENSE
3-
include README.md
5+
include README.rst
6+
7+
prune test
8+
9+
recursive-exclude * __pycache__
10+
recursive-exclude * *.py[co]

buildspec-deploy.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 0.2
2+
3+
phases:
4+
build:
5+
commands:
6+
- PACKAGE_FILE="$CODEBUILD_SRC_DIR_ARTIFACT_1/sagemaker_tensorflow_training-*.tar.gz"
7+
8+
# publish to pypi
9+
- publish-pypi-package $PACKAGE_FILE

buildspec-release.yml

+15-73
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,34 @@
11
version: 0.2
22

3-
env:
4-
variables:
5-
FRAMEWORK_VERSION: '1.15.0'
6-
GPU_INSTANCE_TYPE: 'ml.p2.xlarge'
7-
SETUP_FILE: 'setup_cmds.sh'
8-
SETUP_CMDS: '#!/bin/bash\npip install --upgrade pip\npip install -U -e .\npip install -U -e .[test]'
9-
103
phases:
11-
pre_build:
12-
commands:
13-
- start-dockerd
14-
- ACCOUNT=$(aws --region $AWS_DEFAULT_REGION sts --endpoint-url https://sts.$AWS_DEFAULT_REGION.amazonaws.com get-caller-identity --query 'Account' --output text)
15-
164
build:
175
commands:
186
# prepare the release (update versions, changelog etc.)
19-
- git-release --min-version 2.0.0 --prepare
7+
- git-release --prepare
208

21-
# run linter
22-
- tox -e flake8
9+
# run linters
10+
- tox -e flake8,twine
2311

2412
# run unit tests
25-
- tox -e py36,py27 test/unit
26-
27-
# Create pip archive
28-
- build_dir="docker/$FRAMEWORK_VERSION"
29-
- python3 setup.py sdist
30-
- tar_name=$(ls dist)
31-
- cp dist/$tar_name $build_dir
32-
33-
# Build all images
34-
- python3 scripts/build_all.py --account $ACCOUNT --region $AWS_DEFAULT_REGION
13+
- AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_SESSION_TOKEN=
14+
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI= AWS_DEFAULT_REGION=
15+
tox -e py27,py36 -- test/unit
3516

36-
# Publish all images
37-
- python3 scripts/publish_all.py --account $ACCOUNT --region $AWS_DEFAULT_REGION
17+
# run local integ tests
18+
#- $(aws ecr get-login --no-include-email --region us-west-2)
19+
#- IGNORE_COVERAGE=- tox -e py27,py36 -- test/integ/local
3820

39-
- base_name="$ACCOUNT.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/sagemaker-tensorflow-scriptmode"
40-
# run local cpu integ tests
41-
- $(aws ecr get-login --registry-ids $ACCOUNT --no-include-email --region $AWS_DEFAULT_REGION)
42-
- IGNORE_COVERAGE=- tox -e py36 -- test/integration/local --docker-base-name $base_name --framework-version $FRAMEWORK_VERSION --processor cpu
43-
- IGNORE_COVERAGE=- tox -e py36 -- test/integration/local --docker-base-name $base_name --py-version 2 --framework-version $FRAMEWORK_VERSION --processor cpu
21+
# run sagemaker integ tests
22+
#- IGNORE_COVERAGE=- tox -e py27,py36 -- test/integ/sagemaker
4423

45-
# launch remote gpu instance
46-
- prefix='ml.'
47-
- instance_type=${GPU_INSTANCE_TYPE#"$prefix"}
48-
- create-key-pair
49-
- launch-ec2-instance --instance-type $instance_type --ami-name dlami-ubuntu
50-
- printf "$SETUP_CMDS" > $SETUP_FILE
51-
52-
- py2_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/local --docker-base-name $base_name --py-version 2 --framework-version $FRAMEWORK_VERSION --processor gpu"
53-
- remote-test --github-repo sagemaker-tensorflow-container --setup-file $SETUP_FILE --branch script-mode --test-cmd "$py2_cmd"
54-
- py3_cmd="IGNORE_COVERAGE=- tox -e py36 -- test/integration/local --docker-base-name $base_name --framework-version $FRAMEWORK_VERSION --processor gpu"
55-
- remote-test --github-repo sagemaker-tensorflow-container --branch script-mode --test-cmd "$py3_cmd" --skip-setup
56-
57-
- IGNORE_COVERAGE=- tox -e py36 -- test/integration/sagemaker -n 24 --region $AWS_DEFAULT_REGION --account-id 142577830533 --docker-base-name sagemaker-tensorflow-scriptmode --framework-version $FRAMEWORK_VERSION --processor cpu,gpu --py-version 2,3
58-
59-
- |
60-
echo '[{
61-
"repository": "sagemaker-tensorflow-scriptmode",
62-
"tags": [{
63-
"source": "1.15.0-cpu-py2",
64-
"dest": ["1.15.0-cpu-py2", "1.15-cpu-py2", "1.15.0-cpu-py2-'${CODEBUILD_BUILD_ID#*:}'"]
65-
},{
66-
"source": "1.15.0-cpu-py3",
67-
"dest": ["1.15.0-cpu-py3", "1.15-cpu-py3", "1.15.0-cpu-py3-'${CODEBUILD_BUILD_ID#*:}'"]
68-
},{
69-
"source": "1.15.0-gpu-py2",
70-
"dest": ["1.15.0-gpu-py2", "1.15-gpu-py2", "1.15.0-gpu-py2-'${CODEBUILD_BUILD_ID#*:}'"]
71-
},{
72-
"source": "1.15.0-gpu-py3",
73-
"dest": ["1.15.0-gpu-py3", "1.15-gpu-py3", "1.15.0-gpu-py3-'${CODEBUILD_BUILD_ID#*:}'"]
74-
}],
75-
"test": [
76-
"IGNORE_COVERAGE=- tox -e py36 -- -m deploy_test test/integration/sagemaker -n 4 --region {region} --account-id {aws-id} --instance-type {cpu-instance-type} --docker-base-name sagemaker-tensorflow-scriptmode --framework-version 1.15.0 --processor cpu --py-version 2,3",
77-
"IGNORE_COVERAGE=- tox -e py36 -- -m deploy_test test/integration/sagemaker -n 4 --region {region} --account-id {aws-id} --docker-base-name sagemaker-tensorflow-scriptmode --framework-version 1.15.0 --processor gpu --py-version 2,3"
78-
]
79-
}]' > deployments.json
24+
# generate the distribution package
25+
- python3 setup.py sdist
8026

8127
# publish the release to github
8228
- git-release --publish
8329

84-
finally:
85-
# shut down remote gpu instance
86-
- cleanup-gpu-instances
87-
- cleanup-key-pairs
88-
8930
artifacts:
9031
files:
91-
- deployments.json
32+
- dist/sagemaker_tensorflow_training-*.tar.gz
9233
name: ARTIFACT_1
34+
discard-paths: yes

docker/1.15.0/py2/Dockerfile.cpu

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ENV LC_ALL=C.UTF-8
2222
ENV SAGEMAKER_TRAINING_MODULE=sagemaker_tensorflow_container.training:main
2323

2424
# Define framework-related package sources
25-
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_container*.tar.gz
25+
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_training*.tar.gz
2626
ARG TF_URL=https://tensorflow-aws.s3-us-west-2.amazonaws.com/1.15/AmazonLinux/cpu/final/tensorflow-1.15.0-cp27-cp27mu-manylinux2010_x86_64.whl
2727

2828
RUN apt-get update \

docker/1.15.0/py2/Dockerfile.gpu

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ENV LC_ALL=C.UTF-8
1919
ENV SAGEMAKER_TRAINING_MODULE=sagemaker_tensorflow_container.training:main
2020

2121
# Define framework-related package sources
22-
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_container*.tar.gz
22+
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_training*.tar.gz
2323
ARG TF_URL=https://tensorflow-aws.s3-us-west-2.amazonaws.com/1.15/AmazonLinux/gpu/final/tensorflow_gpu-1.15.0-cp27-cp27mu-manylinux2010_x86_64.whl
2424

2525
RUN apt-get update \

docker/1.15.0/py3/Dockerfile.cpu

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ENV LC_ALL=C.UTF-8
2222
ENV SAGEMAKER_TRAINING_MODULE=sagemaker_tensorflow_container.training:main
2323

2424
# Define framework-related package sources
25-
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_container*.tar.gz
25+
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_training*.tar.gz
2626
ARG TF_URL=https://tensorflow-aws.s3-us-west-2.amazonaws.com/1.15/AmazonLinux/cpu/final/tensorflow-1.15.0-cp36-cp36m-manylinux2010_x86_64.whl
2727

2828
RUN apt-get update \

docker/1.15.0/py3/Dockerfile.gpu

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ENV LC_ALL=C.UTF-8
1919
ENV SAGEMAKER_TRAINING_MODULE=sagemaker_tensorflow_container.training:main
2020

2121
# Define framework-related package sources
22-
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_container*.tar.gz
22+
ARG FRAMEWORK_SUPPORT_INSTALLABLE=sagemaker_tensorflow_training*.tar.gz
2323
ARG TF_URL=https://tensorflow-aws.s3-us-west-2.amazonaws.com/1.15/AmazonLinux/gpu/final/tensorflow_gpu-1.15.0-cp36-cp36m-manylinux2010_x86_64.whl
2424

2525
RUN apt-get update \

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def read_version():
2929

3030

3131
setup(
32-
name='sagemaker_tensorflow_container',
32+
name='sagemaker_tensorflow_training',
3333
version=read_version(),
3434
description='Open source library for creating '
3535
'TensorFlow containers to run on Amazon SageMaker.',

tox.ini

+11
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,14 @@ deps =
7171
flake8-future-import
7272
flake8-import-order
7373
commands = flake8
74+
75+
76+
[testenv:twine]
77+
basepython = python3
78+
# https://github.com/pypa/twine/blob/master/docs/changelog.rst
79+
deps =
80+
twine>=1.12.0
81+
# https://packaging.python.org/guides/making-a-pypi-friendly-readme/#validating-restructuredtext-markup
82+
commands =
83+
python setup.py sdist
84+
twine check dist/*.tar.gz

0 commit comments

Comments
 (0)