-
-
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
Teach dependees
how to work with generated subtargets
#10354
Comments
One possible internal factoring would be to have targets always depend on their subtargets, rather than owning any files of their own. That might work more naturally with a merged |
Because it's tricky to get right and also not critical for Pants to work, we, for now, punt on `dependees` using generated subtargets and instead convert back to the original base target. #10354 tracks doing the better thing. [ci skip-rust-tests]
Because it's tricky to get right and also not critical for Pants to work, we, for now, punt on `dependees` using generated subtargets and instead convert back to the original base target. pantsbuild#10354 tracks doing the better thing. [ci skip-rust-tests]
We're trying to lean in on generated subtargets. Fixing this is no longer an enhancement - it's key to removing the concerns in #10423, especially the UX concerns of sometimes having files and sometimes targets. |
Partial dupe of #10455 I think, but will keep both open and linked to ensure that both are resolved by the changes. |
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
### Problem After extensive discussion, we think that in Pants 2.0, the definition of a target in a BUILD file will be approximately: "some metadata applied to a set of files, which can be used as an alias for those files". This is a fundamental change from the previous definition, which was something like: "a target is a collection of files with metadata that must always be built together". But as described in #10455 and #10423, when "sub" (aka "file") targets are used inconsistently, it becomes necessary to worry about both: 1. whether a target builds as an atomic unit 2. whether each file in the target builds as an atomic unit ...whereas before file dependencies existed, only the former was necessary. ### Solution Given the new definition, Pants ever operating on "the target as defined in the BUILD file" as the atomic unit no longer makes sense. Instead, for consistency: files should always be the new atomic unit (with batching applied only where it is possible to do so safely and transparently). To accomplish this without also making significant changes to the `Target` API, this change adds expansion logic to the creation of `Targets` instances that replaces base targets with their corresponding file/sub targets. Additionally, base targets are adapted to always depend on their subtargets. This means that although all nodes in the build graph are still `Target` objects, post-expansion in `Targets`, each `Target` object will own either zero or one file. Graph introspection goals mostly continue to operate directly on the targets as defined in BUILD files, and so an `UnexpandedTargets` type is introduced to be used in cases where the BUILD definitions should be used verbatim. Other cases where these are used include: 1. deleted files in `Owners`: a deleted file is matched against `UnexpandedTargets` to ensure that we detect what the owner "would have been" if the file had not been deleted. 2. in the `filedeps` goal, when the `--globs` option is used: it's likely that this case should migrate to a goal that is capable of introspecting the fields of all `Target` objects, possibly in a way that is symmetrical to the `filter` goal. Unfortunately, this differentiation is not typesafe: both `Targets` and `UnexpandedTargets` contain `Target` objects, but with different guarantees. We will likely want to follow up in the future to adapt the `Target` API to make this case typesafe. ### Result From a user perspective, the most visible impact of this change will be that a goal like `./pants test` will now _always_ operate per-file. This will mean that it is critically important for us to optimize per-test-run overhead before 2.0, and to work with users to determine whether implementing dynamic batching strategies is necessary. `dependencies` and `dependees` will now result in both file and target addresses showing up, unless the target has no source files. This will happen even if the user is not using explicit file deps and dep inference. Fixes #10354, and fixes #10455.
Right now,
./pants dependees
will always return original addresses, rather than generated subtargets:In contrast,
dependencies
understands generated subtargets:It would be helpful if
dependees
also understood generated subtargets. The output would be more consistent with the rest of Pants and it would result in finer grained caching when using--changed-dependees
.The tricky part is that the goal must continue to understand traditional targets that are not generated.
The text was updated successfully, but these errors were encountered: