Debian Codegraph @

third_party/python/taskcluster_taskgraph/taskgraph/transforms/run/index_search.py

raw
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 """
6 This transform allows including indexed tasks from other projects in the
7 current taskgraph. The transform takes a list of indexes, and the optimization
8 phase will replace the task with the task from the other graph.
9 """
10
11 from voluptuous import Required
12
13 from taskgraph.transforms.base import TransformSequence
14 from taskgraph.transforms.run import run_task_using
15 from taskgraph.util.schema import Schema
16
17 transforms = TransformSequence()
18
19 run_task_schema = Schema(
20 {
21 Required("using"): "index-search",
22 Required(
23 "index-search",
24 "A list of indexes in decreasing order of priority at which to lookup for this "
25 "task. This is interpolated with the graph parameters.",
26 ): [str],
27 }
28 )
29
30
31 @run_task_using("always-optimized", "index-search", schema=run_task_schema)
32 def fill_template(config, task, taskdesc):
33 run = task["run"]
34 taskdesc["optimization"] = {
35 "index-search": [index.format(**config.params) for index in run["index-search"]]
36 }