Created
November 29, 2019 00:20
-
-
Save haranjackson/f28d27a9e8edd19c4cafa85bfd232c8e to your computer and use it in GitHub Desktop.
Deploys Python sumy library to an AWS Lambda layer. You can specify the region, library version, and runtime. You must specify a temporary S3 bucket to use.
This file contains 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
# must set environment variable NLTK_DATA=/opt/python in the lambda function | |
REGION=eu-west-1 | |
RUNTIME=python3.7 | |
BUCKET= | |
VER=0.8.1 | |
NUMPY_VER=1.17.4 | |
OUT_DIR=/out/build/sumy/python | |
docker run -v $(pwd):/out -it lambci/lambda:build-$RUNTIME /bin/bash -c \ | |
"pip install sumy==$VER numpy==$NUMPY_VER -t $OUT_DIR && | |
cd $OUT_DIR && | |
python -m nltk.downloader punkt -d . | |
" | |
pushd build/sumy | |
zip -r ../../sumy.zip python/ | |
popd | |
aws s3 cp sumy.zip s3://$BUCKET/sumy.zip | |
aws lambda publish-layer-version \ | |
--layer-name Sumy \ | |
--region $REGION \ | |
--description $VER \ | |
--content S3Bucket=$BUCKET,S3Key=sumy.zip \ | |
--compatible-runtimes $RUNTIME | |
rm -rf build *.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment