-
-
Notifications
You must be signed in to change notification settings - Fork 652
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
Proposal: get rid of UnexpandedTargets
#13086
Comments
Thanks a lot for writing this up: it's an important issue.
This also impacts compiled languages: both Go and Java will only want to look at direct dependencies (for Scala it will likely be a toggle to use direct/transitive). Also, we had discussed the possibility that MyPy might be able to operate on only direct dependencies: I'm curious whether it can. As you say: In general, I think that "Targets with aliases expanded" and "Targets without aliases expanded" are two reasonable states... there are cases that will want to operate on aliases, and that seems fine. Perhaps this would be less objectionable as a boolean flag on
Removing the ability to actually specify an alias on the CLI seems unnecessary. The vast majority of the time rule authors would want alias expansion (as demonstrated by ~all goals other than graph introspection currently using it): removing expansion seems like it disadvantages these goals in favor of graph introspection... when, really, it seems like we should be able to satisfy both.
This part makes sense, but as far as I can tell it has nothing to do with removing I continue to wonder whether only adjusting the
In short, I think that it's fairly likely that just adjusting globby But I'm curious to better understand the Go case you encountered, and whether there is a useful way to resolve it. In #13087 at least, I think that I realized that having a flag on the request to include/exclude aliases (i.e. |
Looks like direct dependencies also impact I'm starting to warm up to your feedback that we may indeed want to keep alias expansion and that callers determine which semantics are used - albeit in a revamped way.
Hm, I don't recall that? MyPy must have the transitive closure in the chroot to work, so I don't think it's possible. |
Okay, yeah. Closing this particular proposal. It raises some important discussion like Stu's suggestion about For me, the main reason I'm convinced is the handling of direct dependencies. |
… target (#13190) Part of #12954 and the proposal at https://docs.google.com/document/d/1HpJn2jTWf5sKob6zhe4SqHZ7KWBlX4a6OJOwnuw-IHo/edit. End functionality is the same, but we're now safe in followups to expose `files` vs. `file` targets, where the former has an `overrides` field. This brings to light an issue explored in #13086: when looking at direct dependencies, should you replace the target generator with its generated targets? Here, we need to for the `archive(files=`) and `relocated_files(files_targets=)` fields to work when you put an address for a `files` target rather than a `file` target. As the author of those two targets, I did not realize this nuance, even though we had file targets in Pants 2.0+ and this dynamic still existed. This is subtle and awkward, but I think valuable to bring to light something we need to figure out vs. hiding it. [ci skip-rust] [ci skip-build-wheels]
(Relates to the proposal for address-less target generators. This proposal makes that one even more compelling, but they are independent.)
Status quo
#10511 started treating target generators (aka "BUILD targets") as aliases in most situations. We replace the target generator with all of its generated targets, including here:
./pants test project:tests
is shorthand for./pants test project:tests#f1_test.ext project:tests#f2_test.ext
etcdependencies
field, depending on the target generator results in depending on everything it generatesBut we don't always do this replacement, notably with project introspection (#12952) (#12951).
./pants list ::
and./pants peek ::
will not output generated targets, which is limiting and violates the conceptual space that what Pants really cares about are atom targets likepython_source
andpython_test
(target generators are only for boilerplate reduction).It also continues to be confusing to rule authors whether to use
UnexpandedTargets
vs.Targets
, such as me accidentally breaking our Go code today by usingTargets
because it resulted in depending on any_go_external_package
pulling in a dep on every one of them generated from the samego_mod
target.Proposal
Get rid of
UnexpandedTargets
and always haveTargets
. Remove the replacement/alias mechanism.Impact to
dependencies
For most contexts, there will be no impact. Target generators will still depend on their generated targets, so when you depend on a target generator, you transitively depend on everything you generate.
This proposal only impacts contexts that solely look at direct dependencies, which are currently:
./pants dependencies --no-transitive
. That's a good change, the output becomes more predictable.python_library
andpython_tests
targets - you'd have to switch to deps on the generated files.python_library
,python_tests
, andtarget
.If we have other cases like Pylint that only need direct deps, we can likewise choose to use transitive targets or add special casing to expand some targets.
Impact to CLI specs
Build-oriented goals like
test
,lint
, andcheck
will no longer operate when using a literal address spec on a target generator, likeproject:lib
. Instead, they'll warn that the target generator cannot be operated on, and suggest other target types, e.g. usepython_source
instead ofpython_sources
.This is mitigated by our other CLI specs—you can use
dir:
,dir::
, and filesystem specs to glob over all the generated targets. (Directory specs would make this even better #12286)Project introspection goals will behave much more consistently:
./pants peek
will give back the target you asked for, rather than replacing it with the generators. This is crucial because target generators might have different fields than the generated target, and users should be able to programmatically query the generator.The text was updated successfully, but these errors were encountered: