-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(query): adding indirect and all dependencies for tasks #9207
feat(query): adding indirect and all dependencies for tasks #9207
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
8 Skipped Deployments
|
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @NicholasLYang and the rest of your teammates on Graphite |
c0e5833
to
c1242c8
Compare
adb85f8
to
ea55c51
Compare
c1242c8
to
60d2f51
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.
lgtm
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 think this looks good, minor suggestion that makes transitive_closure
easier for me to understand.
pub fn transitive_closure< | ||
'a, | ||
'b, | ||
N: Hash + Eq + PartialEq + Clone + 'b, | ||
M: TryFrom<N> + Hash + Eq + PartialEq, | ||
I: IntoIterator<Item = &'b N>, | ||
>( | ||
graph: &'a Graph<N, ()>, | ||
node_lookup: &'a HashMap<M, petgraph::graph::NodeIndex>, | ||
nodes: I, | ||
direction: petgraph::Direction, | ||
) -> HashSet<&'a N> { | ||
let indices = nodes | ||
.into_iter() | ||
.filter_map(|node| node_lookup.get(&node.to_owned().try_into().ok()?)) | ||
.copied(); |
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 think having callers resolve the nodes to indices themselves makes this a lot more legible and easier to call in a lot of cases
pub fn transitive_closure< | |
'a, | |
'b, | |
N: Hash + Eq + PartialEq + Clone + 'b, | |
M: TryFrom<N> + Hash + Eq + PartialEq, | |
I: IntoIterator<Item = &'b N>, | |
>( | |
graph: &'a Graph<N, ()>, | |
node_lookup: &'a HashMap<M, petgraph::graph::NodeIndex>, | |
nodes: I, | |
direction: petgraph::Direction, | |
) -> HashSet<&'a N> { | |
let indices = nodes | |
.into_iter() | |
.filter_map(|node| node_lookup.get(&node.to_owned().try_into().ok()?)) | |
.copied(); | |
pub fn transitive_closure< | |
N: Hash + Eq + PartialEq, | |
I: IntoIterator<Item = NodeIndex>, | |
>( | |
graph: &Graph<N, ()>, | |
indicies: I, | |
direction: petgraph::Direction, | |
) -> HashSet<&N> { |
A majority of the calls go from something like
let mut dependencies = turborepo_graph_utils::transitive_closure(
self.transitive_closure_inner(Some(node), petgraph::Direction::Outgoing);
&self.graph,
&self.node_lookup,
Some(node),
petgraph::Direction::Outgoing,
);
to
let mut dependencies = turborepo_graph_utils::transitive_closure(
self.transitive_closure_inner(Some(node), petgraph::Direction::Outgoing);
&self.graph,
self.node_lookup.get(node).copied(),
petgraph::Direction::Outgoing,
);
60d2f51
to
dcf4ae0
Compare
Description
Adds indirect and all dependencies as fields on tasks.
You can review commit by commit.
Testing Instructions
Adds tests along with a new fixture based off of
task-dependencies/complex