From 9ae43646fadf688b0befd9969d1bae2c16b1a750 Mon Sep 17 00:00:00 2001 From: Nadia Yakimakha <32335935+nadiaya@users.noreply.github.com> Date: Sun, 9 Feb 2020 22:21:46 -0800 Subject: [PATCH] feature: Add release to PyPI. Change package name to sagemaker-pytorch-inference. --- MANIFEST.in | 10 ++++++++++ buildspec-deploy.yml | 9 +++++++++ buildspec-release.yml | 34 +++++++++++++++++++++++++++++++++ buildspec.yml | 12 ++++++------ docker/1.3.1/py2/Dockerfile.cpu | 6 +++--- docker/1.3.1/py2/Dockerfile.gpu | 6 +++--- docker/1.3.1/py3/Dockerfile.cpu | 6 +++--- docker/1.3.1/py3/Dockerfile.gpu | 6 +++--- setup.py | 2 +- tox.ini | 10 ++++++++++ 10 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 MANIFEST.in create mode 100644 buildspec-deploy.yml create mode 100644 buildspec-release.yml diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..cac629cf --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,10 @@ +recursive-include src/sagemaker_pytorch_serving_container * + +include VERSION +include LICENSE +include README.rst + +prune test + +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/buildspec-deploy.yml b/buildspec-deploy.yml new file mode 100644 index 00000000..a9f179b3 --- /dev/null +++ b/buildspec-deploy.yml @@ -0,0 +1,9 @@ +version: 0.2 + +phases: + build: + commands: + - PACKAGE_FILE="$CODEBUILD_SRC_DIR_ARTIFACT_1/sagemaker_pytorch_inference-*.tar.gz" + + # publish to pypi + - publish-pypi-package $PACKAGE_FILE diff --git a/buildspec-release.yml b/buildspec-release.yml new file mode 100644 index 00000000..b404bb8a --- /dev/null +++ b/buildspec-release.yml @@ -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_inference-*.tar.gz + name: ARTIFACT_1 + discard-paths: yes diff --git a/buildspec.yml b/buildspec.yml index 2a7d07b4..9ea0056f 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -37,17 +37,17 @@ phases: # run unit tests - pytest test/unit - # create wheel in dist/ - - python3 setup.py bdist_wheel - - whl_name=$(ls dist/sagemaker_pytorch_serving_container*.whl) - - cp $whl_name sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl + # create tar in dist/ + - python3 setup.py sdist + - tar_name=$(ls dist/sagemaker_pytorch_inference-*.tar.gz) + - cp $tar_name sagemaker_pytorch_inference.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_serving_container-1.3-py2.py3-none-any.whl $build_dir/ + - cp sagemaker_pytorch_inference.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" @@ -56,7 +56,7 @@ phases: # build py3 image - build_dir="docker/$FRAMEWORK_VERSION/py$GPU_PY3_VERSION" - - cp sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl $build_dir/ + - cp sagemaker_pytorch_inference.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" diff --git a/docker/1.3.1/py2/Dockerfile.cpu b/docker/1.3.1/py2/Dockerfile.cpu index 826de8de..346249a7 100644 --- a/docker/1.3.1/py2/Dockerfile.cpu +++ b/docker/1.3.1/py2/Dockerfile.cpu @@ -77,10 +77,10 @@ COPY config.properties /home/model-server RUN chmod +x /usr/local/bin/dockerd-entrypoint.py -COPY sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl +COPY sagemaker_pytorch_inference.tar.gz /sagemaker_pytorch_inference.tar.gz RUN pip install --no-cache-dir \ - /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl \ - && rm /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl + /sagemaker_pytorch_inference.tar.gz \ + && rm /sagemaker_pytorch_inference.tar.gz RUN curl https://aws-dlc-licenses.s3.amazonaws.com/pytorch/license.txt -o /license.txt diff --git a/docker/1.3.1/py2/Dockerfile.gpu b/docker/1.3.1/py2/Dockerfile.gpu index 4546cca3..9a626a8c 100644 --- a/docker/1.3.1/py2/Dockerfile.gpu +++ b/docker/1.3.1/py2/Dockerfile.gpu @@ -101,10 +101,10 @@ RUN apt-get install -y --no-install-recommends \ # RUN pip install --no-cache-dir 'opencv-python>=4.0,<4.1' -COPY sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl +COPY sagemaker_pytorch_inference.tar.gz /sagemaker_pytorch_inference.tar.gz RUN pip install --no-cache-dir \ - /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl \ - && rm /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl + /sagemaker_pytorch_inference.tar.gz \ + && rm /sagemaker_pytorch_inference.tar.gz RUN curl https://aws-dlc-licenses.s3.amazonaws.com/pytorch/license.txt -o /license.txt diff --git a/docker/1.3.1/py3/Dockerfile.cpu b/docker/1.3.1/py3/Dockerfile.cpu index d49b4abd..d2e7b800 100644 --- a/docker/1.3.1/py3/Dockerfile.cpu +++ b/docker/1.3.1/py3/Dockerfile.cpu @@ -76,10 +76,10 @@ COPY config.properties /home/model-server RUN chmod +x /usr/local/bin/dockerd-entrypoint.py -COPY sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl +COPY sagemaker_pytorch_inference.tar.gz /sagemaker_pytorch_inference.tar.gz RUN pip install --no-cache-dir \ - /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl \ - && rm /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl + /sagemaker_pytorch_inference.tar.gz \ + && rm /sagemaker_pytorch_inference.tar.gz RUN curl https://aws-dlc-licenses.s3.amazonaws.com/pytorch/license.txt -o /license.txt diff --git a/docker/1.3.1/py3/Dockerfile.gpu b/docker/1.3.1/py3/Dockerfile.gpu index a6281a4e..fd23f785 100644 --- a/docker/1.3.1/py3/Dockerfile.gpu +++ b/docker/1.3.1/py3/Dockerfile.gpu @@ -93,10 +93,10 @@ COPY config.properties /home/model-server RUN chmod +x /usr/local/bin/dockerd-entrypoint.py -COPY sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl +COPY sagemaker_pytorch_inference.tar.gz /sagemaker_pytorch_inference.tar.gz RUN pip install --no-cache-dir \ - /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl \ - && rm /sagemaker_pytorch_serving_container-1.3-py2.py3-none-any.whl + /sagemaker_pytorch_inference.tar.gz \ + && rm /sagemaker_pytorch_inference.tar.gz RUN curl https://aws-dlc-licenses.s3.amazonaws.com/pytorch/license.txt -o /license.txt diff --git a/setup.py b/setup.py index f55060c8..b743ec29 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def read(fname): setup( - name='sagemaker_pytorch_serving_container', + name='sagemaker_pytorch_inference', version='1.3', description='Open source library for creating PyTorch containers to run on Amazon SageMaker.', diff --git a/tox.ini b/tox.ini index 6cd0592e..0796b484 100644 --- a/tox.ini +++ b/tox.ini @@ -69,3 +69,13 @@ deps = flake8 flake8-future-import commands = flake8 + +[testenv:twine] +basepython = python3 +# https://github.com/pypa/twine/blob/master/docs/changelog.rst +deps = + twine>=1.12.0 +# https://packaging.python.org/guides/making-a-pypi-friendly-readme/#validating-restructuredtext-markup +commands = + python setup.py sdist + twine check dist/*.tar.gz