cool-easter-32542
05/02/2023, 12:54 AMpython_awslambda and python_google_cloud_function use pex+lambdex to build artefacts, which work well, but they do the pex dynamic initialisation on cold start, which, for many of our lambdas, takes about a second.
Describe the solution you'd like
Use pex3 venv create --layout=flat-zipped ... pantsbuild/pex#2140 (in 2.1.135) to export deps/src in the format expected.
Notes:
• This could naturally also allow --layout=flat to support #18282.
• This is potentially a breaking change, as it loses the dynamic initialisation that lambdex currently supports: I believe it is currently possible to use python_awslambda(complete_platforms=[":arm.json", ":x86.json"]) to build a single artefact that runs on multiple lambda platforms (e.g. x86 vs arm there, but also 3.9 vs. 3.10). However, these use-cases can be replaced by `pex_binary`: setting __pex__.path.to.handler works now.
• It is convenient for deployment that all python_awslambda packages have the same entry point (lambdex_handler.handler), e.g. our CDK code only needs to know the location of the package and can set handler: 'lambdex_handler.handler' automatically, rather than needing to duplicate the entrypoint in the target definition and in the deploy templates. It would be good to retain this in some form, e.g. __pants_entrypoint.handler, potentially disableable.
• To ease transition, I think the lambdex-based building should be deprecated and continue to be used by default, with global (and per target?) flags to switch over to this new form.
Describe alternatives you've considered
A new target instead of reusing `python_awslambda`: deprecating the existing functionality over a few releases seems okay?
Additional context
N/A
pantsbuild/pantscool-easter-32542
05/20/2023, 2:07 AMcool-easter-32542
05/20/2023, 11:38 PMcool-easter-32542
05/23/2023, 8:48 PM