-
-
Notifications
You must be signed in to change notification settings - Fork 640
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
Infer FaaS runtime from interpreter constraints, when unambiguous #19314
Merged
Conversation
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
benjyw
approved these changes
Jun 15, 2023
benjyw
approved these changes
Jun 16, 2023
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 like it!
Final commit just cleans out the remnants of the old approach that I had missed earlier (including updating the comment). |
huonw
added a commit
that referenced
this pull request
Aug 7, 2024
This updates the Lambda and GCF docs (very belatedly) for the "new" behaviours related to choosing platform specific code, like inference of the `runtime` field (#19314), and associated complete platforms (#19253). This includes stripping out the `runtime` field from the "main" flow, and adding an separate subsection for how to specify the runtime explicitly.
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.
This allows the
runtime
argument topython_aws_lambda_function
,python_aws_lambda_layer
andpython_google_cloud_function
to be inferred from the relevant interpreter constraints, when they cover only one major/minor version. For instance, having==3.9.*
will inferruntime="python3.9"
for AWS Lambda.The inference is powered by checking for two patterns of interpreter constraints that limit to a single major version: equality
==3.9.*
(implies 3.9) and range>=3.10,<3.11
(implies 3.10). This inference doesn't always work: when it doesn't work, the user gets an error message to clarify by providing theruntime
field explicitly. Failure cases:>=3.7,<3.9
covering 2 versions, or>=3.11
that'll eventually include many versions), we can't be sure which is meant==3.8.9
matching a specific version, or==3.9.*,!=3.9.10
excluding one), we can't be sure the cloud environment runs that version, so inferring the runtime would be misleading>=3.7,<3.10,!=3.9.*
is technically 3.8 only), we don't try too hard to handle it. We can expand the inference if required in future.For instance, if one has set
[python].interpreter_constraints = ["==3.9.*"]
inpants.toml
, one can build a lambda artefact like (and similarly for a GCF artifact):This is the final piece* of my work to improve the FaaS backends in Pants 2.18:
runtime
(Include appropriatecomplete_platforms
for serverless/FaaS environmentsruntime
#18195)runtime
from ICs, when unambiguous (including using the new Pants-provided complete platform when available) (Infer appropriate FaaSruntime
from interpreter constraints #19304)(* The fixed complete platform files are currently only provided for AWS Lambda, not GCF. #18195.)
The commits are individually reviewable.
Fixes #19304