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

feat: Re-run dependent tasks in watch mode #7898

Merged
merged 4 commits into from Apr 18, 2024

Conversation

NicholasLYang
Copy link
Contributor

@NicholasLYang NicholasLYang commented Apr 3, 2024

Description

Instead of using --filter in our re-running of tasks for watch mode, we instead prune the task graph to run the changed task and its dependent tasks. This has the benefit of following the task graph and not the package graph.

Testing Instructions

You can verify this works by creating a task dependency relation that is not in the package graph. So, make a ui#test task that depends on a docs#test task, but don't have ui depend on docs. Then verify that when the docs are changed, we re-run the ui#test task too.

Closes TURBO-2752

Copy link

vercel bot commented Apr 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-gatsby-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 7:22pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 7:22pm
examples-vite-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 7:22pm
turbo-turbo-tracing-next-plugin ❌ Failed (Inspect) Apr 17, 2024 7:22pm
7 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 7:22pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 7:22pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 7:22pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 7:22pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 7:22pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 7:22pm
rust-docs ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 7:22pm

Copy link
Contributor Author

NicholasLYang commented Apr 3, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @NicholasLYang and the rest of your teammates on Graphite Graphite

Copy link
Contributor

github-actions bot commented Apr 3, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Apr 3, 2024

🟢 CI successful 🟢

Thanks

@@ -433,6 +460,12 @@ impl RunBuilder {
}))
.build()?;

// If we have an initial task, we prune out the engine to only
// tasks that are reachable from that initial task.
if let Some(entrypoint_tasks) = &self.entrypoint_tasks {
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 is a little hacky, but I couldn't figure out how to do this otherwise without cloning Run and we can't implement Clone on Run since we have the AnalyticsHandle.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we rebuilding the original task graph each time?

Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to consider separating the Engine from an instance of Run. Run isn't really meant to be reusable, but it might take a little work to make it possible to use multiple of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think we need to work out what exactly is reusable and what is persistent across runs. Like we can reuse the same analytics handle and cache handle, but maybe not the same task graph

self
}

pub fn hide_prelude(mut self) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this because the prelude makes less sense with re-run tasks. It prints the packages in scope, but the tasks in those packages are not always run, since the task graph is pruned.

@@ -425,6 +448,12 @@ impl RunBuilder {
}))
.build()?;

// If we have an initial task, we prune out the engine to only
// tasks that are reachable from that initial task.
if let Some(entrypoint_package) = &self.entrypoint_package {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will eventually need to be a set of packages, especially with debouncing and waiting for current runs to finish being cancelled or completed

@NicholasLYang NicholasLYang merged commit 0d7d8d2 into nicholasyang/watch-mode Apr 18, 2024
59 checks passed
@NicholasLYang NicholasLYang deleted the nicholasyang/watch-walker branch April 18, 2024 14:24
NicholasLYang added a commit that referenced this pull request Apr 19, 2024
Instead of using `--filter` in our re-running of tasks for watch mode,
we instead prune the task graph to run the changed task and its
dependent tasks. This has the benefit of following the task graph and
not the package graph.

You can verify this works by creating a task dependency relation that is
not in the package graph. So, make a `ui#test` task that depends on a
`docs#test` task, but don't have `ui` depend on `docs`. Then verify that
when the `docs` are changed, we re-run the `ui#test` task too.

Closes TURBO-2752
NicholasLYang added a commit that referenced this pull request Apr 19, 2024
Instead of using `--filter` in our re-running of tasks for watch mode,
we instead prune the task graph to run the changed task and its
dependent tasks. This has the benefit of following the task graph and
not the package graph.

You can verify this works by creating a task dependency relation that is
not in the package graph. So, make a `ui#test` task that depends on a
`docs#test` task, but don't have `ui` depend on `docs`. Then verify that
when the `docs` are changed, we re-run the `ui#test` task too.

Closes TURBO-2752
NicholasLYang added a commit that referenced this pull request Apr 19, 2024
Instead of using `--filter` in our re-running of tasks for watch mode,
we instead prune the task graph to run the changed task and its
dependent tasks. This has the benefit of following the task graph and
not the package graph.

You can verify this works by creating a task dependency relation that is
not in the package graph. So, make a `ui#test` task that depends on a
`docs#test` task, but don't have `ui` depend on `docs`. Then verify that
when the `docs` are changed, we re-run the `ui#test` task too.

Closes TURBO-2752
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants