-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
More flexible binary and run rules. #9529
More flexible binary and run rules. #9529
Conversation
I was working on an experiment that used two binary targets in the same directory and I went to build them with With this change the ergonomics of binary and run change - I think for the better: Before:
After:
Before:
After:
The Before:
After:
Before:
After:
Before:
After:
|
Note to self: update with #9528 for improved |
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.
Thanks. This is a nice UX win.
) -> Run: | ||
address = addresses.expect_single() |
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.
Huh, neat. Sounds good to me to support globbing.
In a followup, we will likely want to add this flexibility to test --debug
:
pants/src/python/pants/rules/core/test.py
Lines 255 to 256 in 45bf1da
if options.values.debug: | |
target_with_origin = targets_with_origins.expect_single() |
And we should consider removing the expect_single()
methods entirely.
191d850
to
bde9b80
Compare
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.
This looks great.
Thank you for only factoring one level higher and not more than that - I'm not yet sure how we'll want to generalize all this Config code and want to finish porting lint
, repl
, and setup-py
first.
union_membership: UnionMembership, | ||
registered_target_types: RegisteredTargetTypes, | ||
) -> Binary: | ||
valid_config_types_by_target = gather_valid_binary_configuration_types( |
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 love how this rule reads now. Wonderful.
Kill coordinator_of_binaries and implement binary and run validation separately. The `binary` goal now supports both globbing that includes targets that do not produce a binary as well as production of multiple binaries per target. The `run` goal now also supports globbing as long as exactly one of the globbed targets can produce a binary. [ci skip-rust-tests] [ci skip-jvm-tests]
This cenralizes complex logic for binary and run to share. Error messages are made a bit easier to read by riffling lists as well. [ci skip-jvm-tests]
bde9b80
to
c26372c
Compare
## Problem #9529 introduced the following flexible behavior for `binary` and `run`: * Both `run` and `binary` will error if no valid targets were given. * `run` will error if more than one _valid_ target was given. It doesn't care if there are invalid targets. * `binary` will filter out all irrelevant targets. The PR intentionally did not generalize the functionality because of the provisional status of the Configuration code. So, `test --debug` did not benefit and still would error if given more than one address, regardless of the address is irrelevant. `awslambda` also was duplicating the functionality of `binary` in a worse way. ## Solution This PR generalizes the pattern and uses it with `awslambda`, `binary`, `run`, and `test`. We do not use it with `fmt`, `lint`, and `repl` because they all interact with the Target API differently. ## Result `./v2 test --debug src/python/pants/util::` now works. Invalid targets give nicer messages for `awslambda` and `test`: ``` ▶ ./v2 --no-print-exception-stacktrace test 'src/python/pants/util/*util.py' ERROR: The `test` goal only works with the following target types: * python_tests You specified `src/python/pants/util/*util.py`, which only included the following target types: * files * python_library ``` [ci skip-rust-tests] [ci skip-jvm-tests]
Kill coordinator_of_binaries and implement binary and run validation
separately.
The
binary
goal now supports both globbing that includes targets that do notproduce a binary as well as production of multiple binaries per target.
The
run
goal now also supports globbing as long as exactly one of the globbedtargets can produce a binary.
[ci skip-rust-tests]
[ci skip-jvm-tests]