-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
Add API for root requests with multiple parameters #6478
Comments
### Problem As described in #5788: `@rules` need a way to rely on values that are provided at request time, but which do not necessarily participate in the signatures of all `@rules` between the root and the consuming `@rule`. This is related to the existing concept of "variants", but requires an implementation that does not introduce variants into `Node` identities in subgraphs where they are not required. Additionally, as described a while back in #4304, it should be possible to generate concrete subgraphs by removing ambiguity from the `RuleGraph`... but ambiguity is currently a "feature" required for composability of `@rule`s that do not know about one another. ### Solution This change merges `Variants` and "subjects" into `Params`, and statically determines which `Params` are required in each subgraph. In order to handle cases where multiple providers of an `@rule` type dependency are available with different required input `Params`, the change "monomorphizes" (duplicates) `RuleGraph` entries per used parameter set. This allows us to remove runtime `Noop`s, because every `RuleGraph` entry (and thus `Node`) has exactly one `@rule` provider for each of its declared dependencies. ### Result Lays groundwork for #4020 and #5788. Fixes #4304 by monomorphizing `RuleGraph` entries and removing `Noop`. Fixes #4027 by... deleting that code. This change does not yet expose any sort of UX for providing more than one `Param` in a `Get` or root request, but it was already way too large, so I've opened #6478 for followup.
Considered working on this for a bit, but given the time I put into expanding the description, it would be good if someone else could grab it this week. |
@stuhood trying to show this with an example. at the end of this change, we will go from: from (subject, product) pairs: to (list of subject/params, product) pairs: So, on the Python side we would have to accumulate the
or when writing this ^ were you thinking of letting the invocations come through and have validation later? |
Hm... I don't think so. It's more like going from our current API, which is:
to one of the syntaxes mentioned in the description. Expanding them a bit here and using
No: it's only the members of an individual "Params" instance that need to be distinct. In the expanded example above, one instance of Params contains
Since this can fail if I were to do something like |
this got put on the backburner in lieu of other higher priority issues - picking this back up tomorrow |
Thank you! |
i will get this branch to an unfinished but working state this weekend and post an update to this so its easier for anyone who wants to pick it up |
Added my old wip branch here - https://github.com/ity/pants/tree/ity/p3 If I get some more time today, I will clean it up, otherwise these are all the changes I had so far against this issue. |
### Problem `Params::expect_single` was a compatibility API that was meant to simplify the transition from "Node has a single Subject" to "Node has a set of Params", but usage of that API inherently blocks exposing the ability to pass multiple `Params` in a run (and thus blocks #6478). ### Solution Remove the three distinct usages of `Params::expect_single` by: 1. simplifying the signature of `scheduler_execute`, which was returning a copy of the subject that was unused anyway 2. directly displaying `Params` rather than looking for a single subject value 3. inlining `Select::gen_node` and resolving a TODO to consume `Entry::Param` and `Params::find` to expect parameter values ### Result Progress toward #6478, and a ~5% speedup due to taking better advantage of the static rule_graph in `Select`.
#6766 landed to address the third and fourth paragraph from the description. Have converted to checkboxes and ticked them to make that clear. I'm going to put this down for the evening to more directly investigate what blocks demoability. |
Annnd, after a brief investigation, it looks like this might still be the largest blocker for demoability. Resuming. |
I might start tackling #5869 concurrently with this issue, in order to better experiment with the API. |
Putting this down, because it looks like #5869 is not blocked on it. |
### Problem Although consumption of multiple `Params` is now supported, there is currently no way to actually provide them to a request. See #6478 for more info. ### Solution Expose and test the ability to pass in a small `Params` datatype as a subject, which is flattened into a corresponding set of rust-side `Params` in `add_root_select`. ### Result Fixes #6478.
In order to implement #5869, root requests will need to provide multiple input
Params
. #6170 added the ability for Nodes to have multiple parameters, but did not yet expose that viaGet
orScheduler.product_request
.This issue should add the ability to make a root product request with multiple
Params
, but it should probably not expose that ability in the context ofyield Get
(since that does not block #5869, afaik).To avoid a tight coupling where callers need to know exactly what
Params
their callees need (both in a rootScheduler.product_request
call and in aGet
),Params
which are not used by a subgraph should be ignored. As an example, the OptionsParseRequest that will be passed into@console_rule
execution might be ignored by a particular subgraph... but the caller should not need to know that, which will allow it to safely pass it for everyScheduler.product_request
.This issue should also handle updating the engine README for the new UX, and replacing the mentions of Variants.
This PR will primarily involve addressing a few TODOs from #6170:
Safely constructing instances of
Params
containing keys with distinctTypeId
s will require adding a constructor that validates that the inputKey
s' types are distinct (and failing politely otherwise).Methods between Scheduler.product_request and the TODO in RuleGraph::find_root_edges will need to be updated in order to pass down Params collections, rather than individual "subject"
Key
s.All usage of the Params::expect_single method should be replaced with consuming the relevant
Param
: sinceParams
contain distinctKey
s per type, this will usually involve callingParams::find(type_we_need)
and asserting that it is present.Finally, to avoid propagating
Params
into subgraphs where they are not required, all of the constructors of Select should userule_graph::Entry::params()
to filter the set ofParams
(probably by adding a helper method toParams
) that they are given to just what is actually required by theEntry
. This will resolve a TODO in theSelect
constructors and half of the TODO in gen_get (the other half will be resolved when we add UX for passing multiple Params withGet
).At the end of this PR, you should be able to call something like:
...to trigger a
@rule
that requires two inputs.The text was updated successfully, but these errors were encountered: