-
-
Notifications
You must be signed in to change notification settings - Fork 672
Allow passing arbitrary args to PEX invocation when building FaaS artifacts #20237
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
Conversation
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'm wondering if we want an option under [pex]
to set this globally. And if we have that, do we need to be able to set this at the target level as well?
@@ -342,3 +342,75 @@ def test_layer_must_have_dependencies(rule_runner: PythonRuleRunner) -> None: | |||
expected_extra_log_lines=(" Runtime: python3.7",), | |||
layer=True, | |||
) | |||
|
|||
|
|||
def test_collisions_ok(rule_runner: PythonRuleRunner) -> None: |
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.
Do we need these tests given the generic one in pex_venv_test.py ?
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 was assuming we want to validate we've hooked up the field appropriately.
I guess technically this could be a normal test that checks the pex_venv.py
rule is called with the expected args, rather than needing to be a full integration test...
Do you think it's worth switching over?
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.
We have so many large lumbering tests, our CI is already so heavyweight, that yeah, I think it's worth keeping this light.
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 switched them all to be fully mocked, basically just testing that PexCliProcess
gets the expected args.
Hm, not a bad idea, to simplify the code. However, personally, I'd prefer to be able to set this only on targets where it matters (i.e. this particular lambda happens to use conflicting dependencies), rather than having a blanket allow that might let an unexpected/undesirable collision slip through in a different artifact. If someone has a lot of conflicts, What do you think? |
I'm not convinced we need this level of granularity yet. Note that pip, the de facto standard, silently allows collisions, so users clearly accept it as normal, and in some cases distributions expect it to work... The fact that pex is far stricter is nice-to-have, but I think a global - allow/warn/error setting might be fine to start with. |
Okay, I'll add a setting like |
Hm, alternative: what if we just allow passing This feels like less of a proliferation of narrow-use-case arguments, and is more clearly attached to the relevant targets. |
That works for me. |
Hi, do you have any updates on this? Would be great if this feature will be out soon for pants |
Sorry, had a bit of work crunch over the last weeks, so this has had to pause; maybe over the next day/week. |
Okay, this now exists as the |
…ifacts (#20237) This adds an `pex3_venv_create_extra_args` field to all FaaS targets (`python_aws_lambda_function`, `python_aws_lambda_layer`, `python_google_cloud_function`). This allows adding arbitrary extra arguments that are passed to the `pex3 venv create --layout=flat-zipped ...` invocation that is used to create the final zip file. Most acutely, this is driven by making it possible to pass the `--collisions-ok` flag. This allows work around dependencies that are packaged with files outside a namespaced directories, e.g. commonly a LICENCE or README file, or `tests/` directory, since they'll have different content. A command like `pip install ...` will happily install them and have one of the files "win" arbitrarily, while PEX is more correct and flags that it doesn't know what to do in that circumstance. Fixes #20224 This is marked for cherry picking back to 2.18 because it can block adoption of the new layout, and the old (lambdex) layout is deprecated and using it is noisy in 2.18.
I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants. ❌ 2.18.xI was unable to cherry-pick this PR to 2.18.x, likely due to merge-conflicts. Steps to Cherry-Pick locallyTo resolve:
Please note that I cannot re-run CI if a job fails. Please work with your PR approver(s) to re-run CI if necessary. ✔️ 2.19.xSuccessfully opened #20280. When you're done manually cherry-picking, please remove the Thanks again for your contributions! |
…ifacts (#20237) This adds an `pex3_venv_create_extra_args` field to all FaaS targets (`python_aws_lambda_function`, `python_aws_lambda_layer`, `python_google_cloud_function`). This allows adding arbitrary extra arguments that are passed to the `pex3 venv create --layout=flat-zipped ...` invocation that is used to create the final zip file. Most acutely, this is driven by making it possible to pass the `--collisions-ok` flag. This allows work around dependencies that are packaged with files outside a namespaced directories, e.g. commonly a LICENCE or README file, or `tests/` directory, since they'll have different content. A command like `pip install ...` will happily install them and have one of the files "win" arbitrarily, while PEX is more correct and flags that it doesn't know what to do in that circumstance. Fixes #20224 This is marked for cherry picking back to 2.18 because it can block adoption of the new layout, and the old (lambdex) layout is deprecated and using it is noisy in 2.18.
…ifacts (Cherry-pick of #20237) (#20280) This adds an `pex3_venv_create_extra_args` field to all FaaS targets (`python_aws_lambda_function`, `python_aws_lambda_layer`, `python_google_cloud_function`). This allows adding arbitrary extra arguments that are passed to the `pex3 venv create --layout=flat-zipped ...` invocation that is used to create the final zip file. Most acutely, this is driven by making it possible to pass the `--collisions-ok` flag. This allows work around dependencies that are packaged with files outside a namespaced directories, e.g. commonly a LICENCE or README file, or `tests/` directory, since they'll have different content. A command like `pip install ...` will happily install them and have one of the files "win" arbitrarily, while PEX is more correct and flags that it doesn't know what to do in that circumstance. Fixes #20224 This is marked for cherry picking back to 2.18 because it can block adoption of the new layout, and the old (lambdex) layout is deprecated and using it is noisy in 2.18. Co-authored-by: Huon Wilson <huon@exoflare.io>
…ifacts (Cherry-pick of #20237) (#20281) This adds an `pex3_venv_create_extra_args` field to all FaaS targets (`python_aws_lambda_function`, `python_aws_lambda_layer`, `python_google_cloud_function`). This allows adding arbitrary extra arguments that are passed to the `pex3 venv create --layout=flat-zipped ...` invocation that is used to create the final zip file. Most acutely, this is driven by making it possible to pass the `--collisions-ok` flag. This allows work around dependencies that are packaged with files outside a namespaced directories, e.g. commonly a LICENCE or README file, or `tests/` directory, since they'll have different content. A command like `pip install ...` will happily install them and have one of the files "win" arbitrarily, while PEX is more correct and flags that it doesn't know what to do in that circumstance. Fixes #20224 This is marked for cherry picking back to 2.18 because it can block adoption of the new layout, and the old (lambdex) layout is deprecated and using it is noisy in 2.18.
Similar to #20237, this allows passing arbitrary arguments to the first pex invocation when building a FaaS (AWS Lambda or Google Cloud Function) artifact. This can serve as a stop-gap for #19256, because a user can write then pass `--exclude` themselves when they really need that (or similar) functionality. --------- Co-authored-by: Huon Wilson <huon@exoflare.io>
This adds an
pex3_venv_create_extra_args
field to all FaaS targets (python_aws_lambda_function
,python_aws_lambda_layer
,python_google_cloud_function
). This allows adding arbitrary extra arguments that are passed to thepex3 venv create --layout=flat-zipped ...
invocation that is used to create the final zip file.Most acutely, this is driven by making it possible to pass the
--collisions-ok
flag. This allows work around dependencies that are packaged with files outside a namespaced directories, e.g. commonly a LICENCE or README file, ortests/
directory, since they'll have different content. A command likepip install ...
will happily install them and have one of the files "win" arbitrarily, while PEX is more correct and flags that it doesn't know what to do in that circumstance.Fixes #20224
This is marked for cherry picking back to 2.18 because it can block adoption of the new layout, and the old (lambdex) layout is deprecated and using it is noisy in 2.18.