Search code examples
python-3.xamazon-web-servicesaws-lambdaspacyzappa

Can Zappa Update be used with the output package from Zappa Package?


I'm trying to load a model on AWS lambda using Zappa. The problem is that the total unzipped file size from the package created by Zappa and uploaded to S3 is about 550mb, which exceeds the limit. One of the packages I'm using is Spacy (an NLP dependency that is very large), and I'm able to reduce the size of this package by manually removing unused languages in the lang folder. Doing this I can get the unzipped file size under 500mb. Problem is that Zappa automatically downloads the full Spacy version (spacy==2.1.4: Using locally cached manylinux wheel) on deploy and update.

I've learned that I can call Zappa Package, and it will generate a package that I can then upload myself. What I've done is unzipped the generated package and removed the unnecessary lang files, then I zipped it back up. Is it possible for me to call Zappa Deploy/Update and use the modified package and handler that was created by Zappa Package? This way Zappa can still handle the deployment.


Solution

  • Here's how I solved the issue, there are two ways:

    1. The first is to simply move the dependency folder from the site-packages directory to the root folder, and then make any modifications there. This will force zappa to not download a wheels on linux version of the dependency upon upload
    2. The simpler solution is to remove the *dist folder for a specific module that you modify. Removing this will force zappa to bypass re-downlading modules from wheels on linux; meaning your modified module will be packaged during deployment.