96
loading...
This website collects cookies to deliver better user experience
pandas
and scikit-learn
and exceeding the maximum size thresholds imposed by AWS. AWS enforces a 250 MB hard limit on Lambda packages and scikit-learn
alone is 100 MB unzipped. Deploying yields:ServerlessError: An error occurred: Resource handler returned message: "Unzipped size must be smaller than 262144000 bytes (Service: Lambda, Status Code: 400)"
serverless-python-requirements
plugin to slim down packages:custom:
pythonRequirements:
slim: true
strip: false
strip: false
option was required to prevent an error during execution which manifested as:Runtime.ImportModuleError: Unable to import module 'handler': /var/task/scipy/linalg/_fblas.cpython-38-x86_64-linux-gnu.so: ELF load command address/offset not properly aligned
poetry run pytest --cov-report=html\
--cov=/path/to/site-packages
serverless-scriptable-plugin
was required to remove dependencies added by the serverless-python-requirements
plugin. plugins:
- serverless-python-requirements
- serverless-scriptable-plugin
...
custom:
pythonRequirements:
slim: true
strip: false
scriptable:
hooks:
after:package:createDeploymentArtifacts:
- ./shake.sh
#/bin/sh
filelist="_distutils_hack/__init__.py
_distutils_hack/override.py
...
wheel/util.py
wheel/vendored/packaging/_typing.py
wheel/vendored/packaging/tags.py
wheel/wheelfile.py"
for file in $filelist
do
zip --delete ./.serverless/data-science-api.zip $file
done