forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infer FaaS runtime from interpreter constraints, when unambiguous (pa…
…ntsbuild#19314) This allows the `runtime` argument to `python_aws_lambda_function`, `python_aws_lambda_layer` and `python_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 infer `runtime="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 the `runtime` field explicitly. Failure cases: - if the interpreter constraints are too wide (for instance, `>=3.7,<3.9` covering 2 versions, or `>=3.11` that'll eventually include many versions), we can't be sure which is meant - if the interpreter constraints limit the patch versions (for instance, `==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 - if the interpreter constraints are non-obvious (for instance, `>=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.*"]` in `pants.toml`, one can build a lambda artefact like (and similarly for a GCF artifact): ```python python_sources() python_aws_lambda_function(name="func", entry_point="./foo.py:handler") ``` This is the final piece* of my work to improve the FaaS backends in Pants 2.18: - using the simpler "zip" layout as recommended by AWS and GCF, deprecating Lambdex (pantsbuild#18879) - support for AWS Lambda layers (pantsbuild#18880) - Pants-provided complete platforms JSON files* when specifying a known `runtime` (pantsbuild#18195) - this PR, inferring the `runtime` from ICs, when unambiguous (including using the new Pants-provided complete platform when available) (pantsbuild#19304) (* The fixed complete platform files are currently only provided for AWS Lambda, not GCF. pantsbuild#18195.) The commits are individually reviewable. Fixes pantsbuild#19304
- Loading branch information
Showing
13 changed files
with
458 additions
and
271 deletions.
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.