Skip to content
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

Use TransitiveTargetsRequest as input for resolving TransitiveTargets #10915

Merged

Conversation

Eric-Arellano
Copy link
Contributor

@Eric-Arellano Eric-Arellano commented Oct 6, 2020

Problem

As explained in #10888, we are not properly handling "special-cased" dependencies-like fields, such as python_tests's runtime_package_dependencies field.

We need those fields' dependencies to show up in project introspection, such as ./pants dependencies, but not in other contexts like when resolving the transitive targets to determine what source files are used by Pytest.

That is, we need to be able to parametrize await Get(TransitiveTargets) so call sites can determine the behavior they want.

Solution

Add TransitiveTargetsRequest, which will allow us to add new fields to it to change its behavior. This mirrors how we have DependenciesRequest for direct deps.

Note that this means you can no longer request TransitiveTargets as a parameter to your rule and have it be evaluated automatically by looking at the Specs. You must now request Addresses, and then use await Get. There's an argument for this being a good thing. It's a bit confusing (imo) how some types like Addresses can be in a rule signature and will be evaluated by using the Specs. This means that you can now only do that with Addresses and Targets, but not TransitiveTargets.

To work around #10917, we add a DependenciesRequestLite and TransitiveTargetsLite for use with codegen. These behave almost the same, but don't work with dep inference.

[ci skip-rust]
[ci skip-build-wheels]

…ets`

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@coveralls
Copy link

coveralls commented Oct 6, 2020

Coverage Status

Coverage remained the same at 0.0% when pulling d3d5ad6 on Eric-Arellano:transitive-targets-request into 45c44f6 on pantsbuild:master.

These behave almost the same, but don't work with dep inference

[ci skip-rust]
[ci skip-build-wheels]
Copy link
Contributor Author

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready. PTAL, particularly at TransitiveTargetsLite and DependenciesRequestLite.

Comment on lines +357 to +359
direct_dependencies_addresses_per_tgt = await MultiGet(
Get(Addresses, DependenciesRequestLite(tgt.get(Dependencies))) for tgt in queued
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails if we change it to Get(Targets).

Comment on lines +387 to +390
wrapped_transitive_excludes = await MultiGet(
Get(
WrappedTarget, AddressInput, AddressInput.parse(addr, relative_to=tgt.address.spec_path)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use Get(Targets, UnparsedAddressInputs).

Comment on lines +908 to +910
subtargets = await Get(
Subtargets, Address, request.field.address.maybe_convert_to_base_target()
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we only do this if inference isn't at play. Because we never use inference here, we always perform this step.

@Eric-Arellano Eric-Arellano merged commit ff02ef0 into pantsbuild:master Oct 7, 2020
@Eric-Arellano Eric-Arellano deleted the transitive-targets-request branch October 7, 2020 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants