Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/taskgraph/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,20 @@ def _run(self):
f"Adding {len(always_target_tasks) - len(always_target_tasks & target_tasks)} tasks with `always_target` attribute" # type: ignore
)
requested_tasks = target_tasks | always_target_tasks # type: ignore

# Ensure if a task has any `if-dependencies`, it isn't responsible for
# pulling any of them into the target graph when computing the
# transitive closure.
for label in requested_tasks:
task = all_tasks[label]
if_dep_labels = {task.dependencies[e] for e in task.if_dependencies}

# Find any if-dependencies that aren't in `requested_tasks` and
# delete them.
for missing in if_dep_labels - requested_tasks:
task.if_dependencies.remove(m)
del task.dependencies[m]

target_graph = full_task_graph.graph.transitive_closure(requested_tasks)
target_task_graph = TaskGraph(
{l: all_tasks[l] for l in target_graph.nodes},
Expand Down
Loading