Call for testing/feedback: Improvements to AWS Lambda and Google Cloud Functions support in 2.17 and 2.18 #19544
Replies: 3 comments 7 replies
-
Feedback python_awslambda (2.17)Included RequirementsFirst I deployed the lambda with the inclusion of the requirements, everything worked as expected. Excluded RequirementsExcluding the requirements did also work as expected. HybridWhen using dependencies like awswrangler users have to include a pre packed layer provided by AWS, because the pypi version is too big (https://aws-sdk-pandas.readthedocs.io/en/stable/install.html). Hence, it would be nice if the target would allow certain 3rd party dependencies to be excluded. I tried using I think an exclusion of individual third party dependencies should be possible in |
Beta Was this translation helpful? Give feedback.
-
@cponfick-bhs noted on slack that the |
Beta Was this translation helpful? Give feedback.
-
Review Python AWS Lambda Layer (2.18.0rc5)I finally found the time to try out the lambda layer packaging. I tried following configuration. python_aws_lambda_layer(
name="layer",
dependencies=[
"//src/python/a/lambda_a.py",
"//src/python/b/lambda_b.py",
"//src/python/c/lambda_c.py",",
"!!//src/python:reqs#awswrangler", # part of my requirement.txt, but has a own layer provided by AWS.
],
include_sources=False,
runtime="python3.10",
) The layer was created as I expected it. I deployed the lambdas and the layer using |
Beta Was this translation helpful? Give feedback.
-
In Pants 2.17 and 2.18 (and 2.19), there's a bunch of improvements to Pants' support for building AWS Lambda and Google Cloud Function artifacts for Python code.
I've mostly tested these locally and in my own work repo, but it'd be great for others to experiment with them: the earlier we identify issues and improvements, the better!
The changes are:
python_awslambda
andpython_google_cloud_function
, with dependencies and code all at the top level, without requiring the dynamic PEX initialisation (that is, no use of Lambdex/PEX at runtime, only build time)python_aws_lambda_layer
targetpython_awslambda
target renamed topython_aws_lambda_function
, for consistency with the layer target andpython_google_cloud_function
runtime=...
field can be inferred, if the interpreter constraints are unambiguous, e.g.CPython==3.10.*
will implyruntime="python3.10"
runtime
field value is known to pants (including when inferred, above), a static complete platform JSON file is used, for more precise/useful dependency selection (cf. Some recipes for AWS Lambda and Docker Python artefacts (including cross-building from macOS) #18756). NB. this is currently only for AWS Lambda (Include appropriatecomplete_platforms
for serverless/FaaS environmentsruntime
#18195 (comment)).For testing, the usual approach for pants is upgrading one major release at a time:
pants_version = "2.17.0rc3"
at the time of writing), resolve the warnings and validate itpants_version = "2.18.0a0"
), resolve the warnings and validate it. Both of these are pre-releases, so testing locally or in a dev environment is fine, but a reasonably accurate simulation of your prod environment(s) will find the most bugs 😄The 2.17 docs are at https://www.pantsbuild.org/v2.17/docs/awslambda-python and https://www.pantsbuild.org/v2.17/docs/google-cloud-function-python.
The 2.18 docs are at https://github.com/pantsbuild/pants/blob/bff43abdc632b6e196b9e97882353eee23baaf61/docs/markdown/Python/python-integrations/awslambda-python.md and https://github.com/pantsbuild/pants/blob/bff43abdc632b6e196b9e97882353eee23baaf61/docs/markdown/Python/python-integrations/google-cloud-function-python.md
Let me know here any issues/hitches/questions, e.g. with errors/warnings, with runtime behaviour, with how to configure
BUILD
files, anything else!Beta Was this translation helpful? Give feedback.
All reactions