Bug 1748926 - [taskgraph] Move Task.name to a utility file, r=taskgraph-reviewers,aki

The standalone taskgraph does not have this property. Rather than upstream it,
I prefer to move it to a utility file. This is because it's not clear what
"name" means, or why the label minus the kind equals a "name", or why if a task
doesn't have the kind in its label it raises an Exception.

Plus this property was only used in two places, and both were Gecko specific.

Differential Revision: https://phabricator.services.mozilla.com/D140081
This commit is contained in:
Andrew Halberstadt 2022-03-03 16:51:18 +00:00
Родитель bdafb0a98c
Коммит 091750ae52
4 изменённых файлов: 14 добавлений и 10 удалений

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

@ -49,13 +49,6 @@ class Task:
def __attrs_post_init__(self):
self.attributes["kind"] = self.kind
@property
def name(self):
if self.label.startswith(self.kind + "-"):
return self.label[len(self.kind) + 1 :]
else:
raise AttributeError(f"Task {self.label} does not have a name.")
def to_json(self):
rv = {
"kind": self.kind,

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

@ -17,7 +17,10 @@ from gecko_taskgraph.util.schema import (
resolve_keyed_by,
taskref_or_string,
)
from gecko_taskgraph.util.attributes import copy_attributes_from_dependent_job
from gecko_taskgraph.util.attributes import (
copy_attributes_from_dependent_job,
task_name,
)
from gecko_taskgraph.util.taskcluster import get_artifact_prefix
from gecko_taskgraph.util.treeherder import add_suffix
from gecko_taskgraph.transforms.job import job_description_schema
@ -159,7 +162,7 @@ def setup_name(config, jobs):
dep = job["primary-dependency"]
# Set the name to the same as the dep task, without kind name.
# Label will get set automatically with this kinds name.
job["name"] = job.get("name", dep.name)
job["name"] = job.get("name", task_name(dep))
yield job

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

@ -9,6 +9,7 @@ Transform the beetmover task into an actual task description.
from copy import deepcopy
from gecko_taskgraph.transforms.base import TransformSequence
from gecko_taskgraph.util.attributes import task_name
from gecko_taskgraph.util.treeherder import add_suffix, inherit_treeherder_from_dep
transforms = TransformSequence()
@ -22,7 +23,7 @@ def add_command(config, tasks):
"update-verify-config" in dep.kind
or "update-verify-next-config" in dep.kind
):
config_tasks[dep.name] = dep
config_tasks[task_name(dep)] = dep
for task in tasks:
config_task = config_tasks[task["name"]]

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

@ -172,3 +172,10 @@ def is_try(params):
`mach try fuzzy`.
"""
return "try" in params["project"] or params["try_mode"] == "try_select"
def task_name(task):
if task.label.startswith(task.kind + "-"):
return task.label[len(task.kind) + 1 :]
else:
raise AttributeError(f"Task {task.label} does not have a name.")