Bug 1759030 - Use 'taskgraph.register_morph' in gecko_taskgraph, r=releng-reviewers,gbrown

Differential Revision: https://phabricator.services.mozilla.com/D156705
This commit is contained in:
Andrew Halberstadt 2022-09-23 20:16:16 +00:00
Родитель 65e31d3d3d
Коммит 74359d47bc
3 изменённых файлов: 15 добавлений и 31 удалений

Просмотреть файл

@ -2,9 +2,9 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import os
from taskgraph import config as taskgraph_config
from taskgraph import morph as taskgraph_morph
from taskgraph.util import taskcluster as tc_util, schema
from gecko_taskgraph.config import graph_config_schema
@ -20,6 +20,10 @@ MAX_DEPENDENCIES = 99
# Overwrite Taskgraph's default graph_config_schema with a custom one.
taskgraph_config.graph_config_schema = graph_config_schema
# Don't use any of the upstream morphs.
# TODO Investigate merging our morphs with upstream.
taskgraph_morph.registered_morphs = []
# Default rootUrl to use if none is given in the environment; this should point
# to the production Taskcluster deployment used for CI.
tc_util.PRODUCTION_TASKCLUSTER_ROOT_URL = "https://firefox-ci-tc.services.mozilla.com"
@ -46,5 +50,6 @@ def register(graph_config):
from gecko_taskgraph import ( # noqa: trigger target task method registration
target_tasks,
)
from gecko_taskgraph import morph # noqa: trigger morph registration
register_parameters()

Просмотреть файл

@ -10,6 +10,7 @@ import attr
from taskgraph import filter_tasks
from taskgraph.config import GraphConfig, load_graph_config
from taskgraph.graph import Graph
from taskgraph.morph import morph
from taskgraph.optimize.base import optimize_task_graph
from taskgraph.parameters import parameters_loader
from taskgraph.task import Task
@ -18,7 +19,6 @@ from taskgraph.transforms.base import TransformSequence, TransformConfig
from taskgraph.util.python_path import find_object
from taskgraph.util.yaml import load_yaml
from .morph import morph
from .util.verify import verifications
logger = logging.getLogger(__name__)
@ -408,11 +408,7 @@ class TaskGraphGenerator:
)
morphed_task_graph, label_to_taskid = morph(
optimized_task_graph,
label_to_taskid,
parameters,
graph_config,
self._decision_task_id,
optimized_task_graph, label_to_taskid, parameters, graph_config
)
yield "label_to_taskid", label_to_taskid

Просмотреть файл

@ -26,6 +26,7 @@ import re
from slugid import nice as slugid
from taskgraph.graph import Graph
from taskgraph.morph import register_morph
from taskgraph.task import Task
from taskgraph.taskgraph import TaskGraph
@ -174,9 +175,8 @@ def make_index_task(
return task
def add_index_tasks(
taskgraph, label_to_taskid, parameters, graph_config, decision_task_id
):
@register_morph
def add_index_tasks(taskgraph, label_to_taskid, parameters, graph_config):
"""
The TaskCluster queue only allows 10 routes on a task, but we have tasks
with many more routes, for purposes of indexing. This graph morph adds
@ -217,9 +217,8 @@ def add_index_tasks(
return taskgraph, label_to_taskid
def add_eager_cache_index_tasks(
taskgraph, label_to_taskid, parameters, graph_config, decision_task_id
):
@register_morph
def add_eager_cache_index_tasks(taskgraph, label_to_taskid, parameters, graph_config):
"""
Some tasks (e.g. cached tasks) we want to exist in the index before they even
run/complete. Our current use is to allow us to depend on an unfinished cached
@ -254,9 +253,8 @@ def add_eager_cache_index_tasks(
return taskgraph, label_to_taskid
def add_try_task_duplicates(
taskgraph, label_to_taskid, parameters, graph_config, decision_task_id
):
@register_morph
def add_try_task_duplicates(taskgraph, label_to_taskid, parameters, graph_config):
try_config = parameters["try_task_config"]
rebuild = try_config.get("rebuild")
if rebuild:
@ -264,18 +262,3 @@ def add_try_task_duplicates(
if task.label in try_config.get("tasks", []):
task.attributes["task_duplicates"] = rebuild
return taskgraph, label_to_taskid
def morph(taskgraph, label_to_taskid, parameters, graph_config, decision_task_id):
"""Apply all morphs"""
morphs = [
add_eager_cache_index_tasks,
add_index_tasks,
add_try_task_duplicates,
]
for m in morphs:
taskgraph, label_to_taskid = m(
taskgraph, label_to_taskid, parameters, graph_config, decision_task_id
)
return taskgraph, label_to_taskid