-
-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement layout="zip" for Lambda/GCF, skipping lambdex #19022
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
59ea698
Add rule/targets for 'pex3 venv create' invocations
huonw 6ff0d48
refactor: track module/func separately in ResolvedPythonFaaSHandler
huonw 7a0d5c2
refactor: pull out logic for major, minor -> interpreter platform
huonw 012cd5b
New target types
huonw 4193be5
Implement 'venv create'-calling builder rule
huonw 0346958
Allow Lambdas and GCF to build using new rules
huonw 8087903
synthesise a handler module
huonw 82399f7
Review: docs: artefact -> artifact, recommend layout=zip
huonw ec3f56e
Review: reexport handler as `lambda_function` rather than `lambdex_ha…
huonw bde2d5a
Review: document reexporting behaviour
huonw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good opportunity to get rid of this name, since we're churning anyway. It'll be harder to do later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But also, are we sure we want this at all? Why not use the handler name the user configured directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so. The
BUILD
file target must contain the entry point (at least the file/module part ofentry_point="path/to.py:handler"
), in order to compute dependencies/build the package, and it's annoying to have to carefully reproduce that elsewhere (handler: 'parent.modules.path.to.handler'
in templates/IaC code). Synthesising a fixed module avoids that, and is all info pants already knows.For instance, in our repo, we use AWS CDK, and have a generic
PythonLambda
construct where the basic "get the code running" config is just pointing it to the package (e.g.foo.bar/target.zip
), because it can just sethandler: 'lambdex_handler.handler'
globally, not requiring customisation per lambda. I think this is really nice!(There's obviously often per-lambda config required like any extra env vars or permissions, but CDK/the infra configuration is the source of truth there, it's not just directly duplicated from the
BUILD
files.)Sure, I'm happy to choose another name, e.g. some options:
lambda_function
: https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html suggests AWS configureslambda_function.lambda_handler
by default, when creating a Python function using the consoleindex
: using "inline code" in AWS's CDK usesindex
as the file name (https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#handler), but... thehandler
property always needs to be setpython_awslambda
,pants_python_awslambda
or__pants_lambda
or some other pants-y nameI think we can also make this customisable in future (including the ability to turn it off), e.g.
synthetic_handler_module="my_custom_name"
orsynthetic_handler_module=None
, if required/desired.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone with
lambda_function
, but more than happy to change. (Thought of another option too:main
to be consistent with GCF.)