Skip to content

Commit b1a20b9

Browse files
committed
Add a function to get tasks from multiple kinds in one pass
This is especially useful when some of the kinds the caller is interested in is a dependency of another kind.
1 parent 0f5bd70 commit b1a20b9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/taskgraph/generator.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,28 @@ def verify(self, name, *args, **kwargs):
446446
return name, args[0]
447447

448448

449-
def load_tasks_for_kind(parameters, kind, root_dir=None):
449+
def load_tasks_for_kinds(parameters, kinds, root_dir=None):
450450
"""
451-
Get all the tasks of a given kind.
451+
Get all the tasks of a the given kinds.
452452
453453
This function is designed to be called from outside of taskgraph.
454454
"""
455455
# make parameters read-write
456456
parameters = dict(parameters)
457-
parameters["target-kinds"] = [kind]
457+
parameters["target-kinds"] = kinds
458458
parameters = parameters_loader(spec=None, strict=False, overrides=parameters)
459459
tgg = TaskGraphGenerator(root_dir=root_dir, parameters=parameters)
460460
return {
461461
task.task["metadata"]["name"]: task
462462
for task in tgg.full_task_set
463-
if task.kind == kind
463+
if task.kind in kinds
464464
}
465+
466+
467+
def load_tasks_for_kind(parameters, kind, root_dir=None):
468+
"""
469+
Get all the tasks of a given kind.
470+
471+
This function is designed to be called from outside of taskgraph.
472+
"""
473+
return load_tasks_for_kind(parameters, [kind], root_dir)

0 commit comments

Comments
 (0)