这是indexloc提供的服务,不要输入任何密码
Skip to content

Store TaskDefinitions in the Graph by Task ID #3428

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

Merged
merged 20 commits into from
Jan 24, 2023

Conversation

mehulkar
Copy link
Contributor

@mehulkar mehulkar commented Jan 23, 2023

Moves TaskDefinitions in the CompleteGraph struct, so we can look it up during execution.
We want to do this here, because during execution, The TaskGraph has already been constructed,
so it is too late to change the definition at the point. Although this commit does not try to
change any TaskDefinitions, we will implement that for composable configs in the future.

This means we look up a task's dependencies when iterating per-workspace,
rather than per-task. This will allow us to customize each task per workspace
based on additional config that may be present in that workspace
This will enable us to compose TaskDefinitions per workspace, so they
can be distinctly looked up.
@vercel
Copy link

vercel bot commented Jan 23, 2023

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

Name Status Preview Comments Updated
examples-kitchensink-blog 🔄 Building (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
examples-tailwind-web 🔄 Building (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
9 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
turbo-site ⬜️ Ignored (Inspect) Visit Preview Jan 24, 2023 at 5:25AM (UTC)
turbo-vite-web ⬜️ Ignored (Inspect) Jan 24, 2023 at 5:25AM (UTC)

@mehulkar mehulkar changed the title Refactor Task dependencies retrieval to support composable configs Store TaskDefinitions in the Graph by Task ID Jan 23, 2023
if !notcool {
// Return an empty fs.TaskDefinition
return nil, fmt.Errorf("No task defined in pipeline")
taskDefinition, ok := g.TaskDefinitions[taskID]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of looking for a taskDefinition in the Pipeline, we now look for it in the TaskDefinitions map. The TaskDefinitions in this map will later become composed from multiple configs.

@@ -388,7 +389,7 @@ func (r *run) initCache(ctx gocontext.Context, rs *runSpec, analyticsClient anal
}

func buildTaskGraphEngine(g *graph.CompleteGraph, rs *runSpec) (*core.Engine, error) {
engine := core.NewEngine(&g.WorkspaceGraph)
engine := core.NewEngine(g)
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 not great, and it really blurs the line between Engine and Graph. This line already seems pretty blurry to me, so I made the call to pass the whole thing in, rather than just TaskDefinitions, Pipeline, etc. There's some room for improvement with this architecture after Composable Turbo is done.

"libB": &fs.PackageJSON{},
"libC": &fs.PackageJSON{},
"libD": &fs.PackageJSON{},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All these engine tests are really coupled to the implementation, so they have to change when things change. I would like to convert a lot of them to integration tests with prysk, so we can validate what we really need to validate.

@@ -328,6 +363,7 @@ func (e *Engine) ValidatePersistentDependencies(graph *graph.CompleteGraph) erro
packageName, taskName := util.GetPackageTaskFromId(depTaskID)

// Get the Task Definition so we can check if it is Persistent
// TODO(mehulkar): Do we need to get a resolved taskDefinition here?
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 have a separate ticket for this

@mehulkar mehulkar marked this pull request as ready for review January 23, 2023 06:38
@mehulkar mehulkar requested a review from a team as a code owner January 23, 2023 06:38
@mehulkar mehulkar requested review from nathanhammond and arlyon and removed request for a team January 23, 2023 06:38
@@ -174,6 +174,8 @@ func (th *Tracker) CalculateFileHashes(allTasks []dag.Vertex, workerCount int, r
continue
}

// TODO(mehulkar): Once we start composing turbo.json, we need to change this
// to look in the graph for TaskDefinitions, rather than the root pipeline.
Copy link
Contributor Author

@mehulkar mehulkar Jan 23, 2023

Choose a reason for hiding this comment

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

I have another ticket for this. Things should still work correctly after this PR, since there is only one turbo.json so far.

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Looks good to me, glad to see more tests!

Base automatically changed from mk/refactor-dep-construction to main January 24, 2023 02:43
Co-authored-by: Chris Olszewski <chris.olszewski@vercel.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2023

🟢 CI successful 🟢

Thanks

@mehulkar mehulkar merged commit a44b461 into main Jan 24, 2023
@mehulkar mehulkar deleted the mk/refactor-task-definitions branch January 24, 2023 06:34
@mehulkar mehulkar mentioned this pull request Feb 6, 2023
5 tasks
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.

2 participants