Repository navigation
Consolidate lambda processing requirements - #546
Open
duckduckgrayduck wants to merge 5 commits into
Open
duckduckgrayduck wants to merge 5 commits into
duckduckgrayduck wants to merge 5 commits into
Conversation
…sh way to manage lambda dependencies
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How it works
Lambda requirements now live in config/aws/lambda/requirements/, as three tiers.
Each tier builds on the one above it:
processing.inpdf.ininfo_and_image.inEach lower tier has -r on the one above it, to include its packages, and -c on its compiled .txt, so shared packages stay on the same versions in every lambda. Each compiled .txt pins every package, including dependencies.
aioboto3 is in the shared tier, even though only info_and_image uses it, so that boto3, botocore and aiobotocore are always resolved together. If they’re compiled in separate tiers, botocore can end up newer than aiobotocore allows. As mentioned, it adds a little bit of bloat, but makes centralization much easier while allowing for some divergence between lambdas for space savings.
Each build_*.sh script copies its compiled file to $CODE_DIR/requirements.txt, which is what sam build installs from.
Updating dependencies
inv pip-compile-lambdas # compile without changing existing pins
inv pip-compile-lambdas --package pillow==13.0.0 # bump one package across all tiers
inv pip-compile-lambdas --upgrade # upgrade everything
To add a package for one lambda only, add it to that lambda’s tier. To give another lambda its own extras, add a new .in with -r/-c on the tier it builds on, add it to the task, and point that lambda’s build script at the new file.
Changes
Top-level pins all carried over unchanged, except:
Additional changes:
Testing
[x] Deployed to staging successfully using
inv deploy-lambdas --staging[x] Each tier installed and imports in a clean Python
[x] PDF upload (image based & machine-generated)
[x] Tesseract OCR
[x] Forced Textract OCR
[x] redaction
[x] Libreoffice conversion (.png & .docx)
[x] Zipped package size for each individual lambda is under Lambda’s 250 MB unzipped limit: info_and_image dependencies are 193 MB, and the built document_conversion package is 182 MB.
[x] No errors on documentcloud-staging-serverless on Sentry.
Closes
#539 #27 #537