Skip to content

Add Override, to replace the task which provides a key - #6

Open
sengjea wants to merge 1 commit into
masterfrom
override-bindings
Open

sengjea wants to merge 1 commit into
masterfrom
override-bindings

Conversation

@sengjea

@sengjea sengjea commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Tasks often create things for themselves, such as clients of other services, which leaves a graph with no way to give it fakes in a test. An input wrapped in Override replaces the task providing its key, which does not run, instead of being a duplicate binding.

A plain input for a provided key is still an error, so a key is only ever replaced on purpose. Overriding a key no task provides, or only some of the keys a task provides, is an error too, as is overriding a key twice. An absent override replaces the task with a failure. Overrides are part of the Binder returned from Run, and inputs only a replaced task needed are no longer required. Graph.Check validates overrides.

Skipped tasks are not signalled by the tasks they depend on, which would otherwise block on a channel with no receiver.

taskgraphtest's Test and Suite take Overrides, those of a Test replacing those of its Suite for the same key.

@sengjea
sengjea force-pushed the override-bindings branch 3 times, most recently from e3d6a59 to 55a4614 Compare November 3, 2026 16:28
…s a key

Tasks often create things for themselves, such as clients of other
services, which leaves a graph with no way to give it fakes in a test.
taskgraphtest.RunWithOverrides runs a graph with the tasks providing the
keys of some bindings replaced by them. The replaced tasks do not run.

Replacing tasks is for tests, so it is not part of the Graph API: the
engine's support is reached through an internal package, which nothing
outside this module can import, and taskgraphtest is the only package
which exposes it. Graph.Run and Graph.Check are unchanged, and an input
for a key which a task provides is still a duplicate binding, so a key
is only ever replaced on purpose.

Overriding a key no task provides, or only some of the keys a task
provides, is an error, as is overriding a key twice or a key which is
also an input. An absent override replaces the task with a failure.
Overrides are part of the Binder returned, and inputs only a replaced
task needed are no longer required. CheckWithOverrides validates them
without running the graph.

Skipped tasks are not signalled by the tasks they depend on, which would
otherwise block on a channel with no receiver.

Overrider holds one set of overrides for code which runs several graphs,
such as an operator with a graph to create and one to delete: each graph
takes the overrides for the keys it provides, and Check finds any which
are for none of them. taskgraphtest's Test and Suite take Overrides,
those of a Test replacing those of its Suite for the same key.
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.

1 participant