Skip to content

Commit 4ff66be

Browse files
committed
WIP: apply if-dependencies at target phase
1 parent 9a27f0b commit 4ff66be

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/taskgraph/generator.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,20 @@ def _run(self):
513513
f"Adding {len(always_target_tasks) - len(always_target_tasks & target_tasks)} tasks with `always_target` attribute" # type: ignore
514514
)
515515
requested_tasks = target_tasks | always_target_tasks # type: ignore
516+
517+
# Ensure if a task has any `if-dependencies`, it isn't responsible for
518+
# pulling any of them into the target graph when computing the
519+
# transitive closure.
520+
for label in requested_tasks:
521+
task = all_tasks[label]
522+
if_dep_labels = {task.dependencies[e] for e in task.if_dependencies}
523+
524+
# Find any if-dependencies that aren't in `requested_tasks` and
525+
# delete them.
526+
for missing in if_dep_labels - requested_tasks:
527+
task.if_dependencies.remove(m)
528+
del task.dependencies[m]
529+
516530
target_graph = full_task_graph.graph.transitive_closure(requested_tasks)
517531
target_task_graph = TaskGraph(
518532
{l: all_tasks[l] for l in target_graph.nodes},

0 commit comments

Comments
 (0)