Skip to content

Commit

Permalink
feature: Add release to PyPI. Change package name to sagemaker-pytorc…
Browse files Browse the repository at this point in the history
…h-training. (#160)

* feauture: Add release to PyPI. Change package name to sagemaker-pytorch-training.
  • Loading branch information
nadiaya authored Feb 6, 2020
1 parent 2114dfa commit 9e876e0
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 21 deletions.
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
recursive-include src/sagemaker_pytorch_container *

include VERSION
include LICENSE
include README.rst

prune test

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
9 changes: 9 additions & 0 deletions buildspec-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 0.2

phases:
build:
commands:
- PACKAGE_FILE="$CODEBUILD_SRC_DIR_ARTIFACT_1/sagemaker_pytorch_training-*.tar.gz"

# publish to pypi
- publish-pypi-package $PACKAGE_FILE
34 changes: 34 additions & 0 deletions buildspec-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 0.2

phases:
build:
commands:
# prepare the release (update versions, changelog etc.)
- git-release --prepare

# run linters
- tox -e flake8,twine

# run unit tests
- AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_SESSION_TOKEN=
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI= AWS_DEFAULT_REGION=
tox -e py27,py36 -- test/unit

# run local integ tests
#- $(aws ecr get-login --no-include-email --region us-west-2)
#- IGNORE_COVERAGE=- tox -e py27,py36 -- test/integ/local

# run sagemaker integ tests
#- IGNORE_COVERAGE=- tox -e py27,py36 -- test/integ/sagemaker

# generate the distribution package
- python3 setup.py sdist

# publish the release to github
- git-release --publish

artifacts:
files:
- dist/sagemaker_pytorch_training-*.tar.gz
name: ARTIFACT_1
discard-paths: yes
10 changes: 5 additions & 5 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ phases:
- pytest test/unit

# create wheel in dist/
- python3 setup.py bdist_wheel
- whl_name=$(ls dist/sagemaker_pytorch_container*.whl)
- cp $whl_name sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
- python3 setup.py sdist
- tar_name=$(ls dist/sagemaker_pytorch_training-*.tar.gz)
- cp $tar_name sagemaker_pytorch_training.tar.gz

- cpu_dockerfile="Dockerfile.cpu"
- gpu_dockerfile="Dockerfile.gpu"

# build py2 images
- build_dir="docker/$FRAMEWORK_VERSION/py$CPU_PY2_VERSION"
- cp sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl $build_dir/
- cp sagemaker_pytorch_training.tar.gz $build_dir/
- cp -r docker/build_artifacts/* $build_dir/
- CPU_PY2_TAG="$FRAMEWORK_VERSION-cpu-py2-$BUILD_ID"
- GPU_PY2_TAG="$FRAMEWORK_VERSION-gpu-py2-$BUILD_ID"
Expand All @@ -54,7 +54,7 @@ phases:

# build py3 image
- build_dir="docker/$FRAMEWORK_VERSION/py$GPU_PY3_VERSION"
- cp sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl $build_dir/
- cp sagemaker_pytorch_training.tar.gz $build_dir/
- cp -r docker/build_artifacts/* $build_dir/
- CPU_PY3_TAG="$FRAMEWORK_VERSION-cpu-py3-$BUILD_ID"
- GPU_PY3_TAG="$FRAMEWORK_VERSION-gpu-py3-$BUILD_ID"
Expand Down
6 changes: 3 additions & 3 deletions docker/1.3.1/py2/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ RUN conda install -c conda-forge \
# Copy workaround script for incorrect hostname
COPY changehostname.c /
COPY start_with_right_hostname.sh /usr/local/bin/start_with_right_hostname.sh
COPY sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
COPY sagemaker_pytorch_training.tar.gz /sagemaker_pytorch_training.tar.gz

# The following section uninstalls torch and torchvision before installing the
# custom versions from an S3 bucket. This will need to be removed in the future
RUN pip install --no-cache-dir \
scipy==1.2.2 \
/sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl \
/sagemaker_pytorch_training.tar.gz \
&& pip uninstall -y torch \
&& pip install -U --no-cache-dir https://pytorch-aws.s3.amazonaws.com/pytorch-1.3.1/py2/cpu/torch-1.3.1-cp27-cp27mu-manylinux1_x86_64.whl \
&& pip uninstall -y torchvision \
&& pip install --no-cache-dir \
https://torchvision-build.s3.amazonaws.com/1.3.1/cpu/torchvision-0.4.2-cp27-cp27mu-linux_x86_64.whl \
&& rm /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
&& rm /sagemaker_pytorch_training.tar.gz

WORKDIR /

Expand Down
6 changes: 3 additions & 3 deletions docker/1.3.1/py2/Dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86
# Copy workaround script for incorrect hostname
COPY changehostname.c /
COPY start_with_right_hostname.sh /usr/local/bin/start_with_right_hostname.sh
COPY sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
COPY sagemaker_pytorch_training.tar.gz /sagemaker_pytorch_training.tar.gz

RUN wget https://www.open-mpi.org/software/ompi/v4.0/downloads/openmpi-$OPEN_MPI_VERSION.tar.gz \
&& gunzip -c openmpi-$OPEN_MPI_VERSION.tar.gz | tar xf - \
Expand Down Expand Up @@ -117,14 +117,14 @@ RUN conda install -c pytorch magma-cuda101==2.5.1 \
# custom versions from an S3 bucket. This will need to be removed in the future
RUN /opt/conda/bin/conda config --set ssl_verify False \
&& pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org \
/sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl \
/sagemaker_pytorch_training.tar.gz \
&& pip uninstall torch -y \
&& pip install -U --no-cache-dir \
https://pytorch-aws.s3.amazonaws.com/pytorch-1.3.1/py2/gpu/torch-1.3.1-cp27-cp27mu-manylinux1_x86_64.whl \
&& pip uninstall -y torchvision \
&& pip install --no-cache-dir \
https://torchvision-build.s3.amazonaws.com/1.3.1/gpu/torchvision-0.4.2-cp27-cp27mu-linux_x86_64.whl \
&& rm /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
&& rm /sagemaker_pytorch_training.tar.gz

# Install Horovod
RUN ldconfig /usr/local/cuda-10.1/targets/x86_64-linux/lib/stubs \
Expand Down
6 changes: 3 additions & 3 deletions docker/1.3.1/py3/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN ompi_info --parsable --all | grep mpi_built_with_cuda_support:value
# Copy workaround script for incorrect hostname
COPY changehostname.c /
COPY start_with_right_hostname.sh /usr/local/bin/start_with_right_hostname.sh
COPY sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
COPY sagemaker_pytorch_training.tar.gz /sagemaker_pytorch_training.tar.gz

RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
Expand Down Expand Up @@ -96,12 +96,12 @@ RUN pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pytho
scipy==1.2.2 \
smdebug==0.5.0.post0 \
sagemaker-experiments==0.1.3 \
/sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl \
/sagemaker_pytorch_training.tar.gz \
&& pip install --no-cache-dir -U https://pytorch-aws.s3.amazonaws.com/pytorch-1.3.1/py3/cpu/torch-1.3.1-cp36-cp36m-manylinux1_x86_64.whl \
&& pip uninstall -y torchvision \
&& pip install --no-cache-dir -U \
https://torchvision-build.s3.amazonaws.com/1.3.1/cpu/torchvision-0.4.2-cp36-cp36m-linux_x86_64.whl \
&& rm /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
&& rm /sagemaker_pytorch_training.tar.gz

RUN chmod +x /usr/local/bin/start_with_right_hostname.sh

Expand Down
6 changes: 3 additions & 3 deletions docker/1.3.1/py3/Dockerfile.gpu
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ RUN apt-get install -y --no-install-recommends openssh-client openssh-server \

WORKDIR /

COPY sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
COPY sagemaker_pytorch_training.tar.gz /sagemaker_pytorch_training.tar.gz

RUN pip install --no-cache-dir /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl \
&& rm /sagemaker_pytorch_container-1.3.1-py2.py3-none-any.whl
RUN pip install --no-cache-dir /sagemaker_pytorch_training.tar.gz \
&& rm /sagemaker_pytorch_training.tar.gz

RUN chmod +x /usr/local/bin/start_with_right_hostname.sh

Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
# language governing permissions and limitations under the License.
from __future__ import absolute_import

import os
from glob import glob
import os
from os.path import basename
from os.path import splitext

from setuptools import setup, find_packages
from setuptools import find_packages, setup


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()


setup(
name='sagemaker_pytorch_container',
version='1.3.1',
name='sagemaker_pytorch_training',
version=read('VERSION').strip(),
description='Open source library for creating PyTorch containers to run on Amazon SageMaker.',

packages=find_packages(where='src', exclude=('test',)),
Expand All @@ -35,6 +35,7 @@ def read(fname):

long_description=read('README.rst'),
author='Amazon Web Services',
url='https://github.com/aws/sagemaker-pytorch-container',
license='Apache License 2.0',

classifiers=[
Expand All @@ -46,6 +47,7 @@ def read(fname):
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.6',
],

install_requires=['numpy==1.16.4', 'Pillow==6.2.0', 'retrying==1.3.3', 'sagemaker-containers>=2.6.2',
'six==1.12.0', 'torch==1.3.1'],
extras_require={
Expand Down

0 comments on commit 9e876e0

Please sign in to comment.