Bug 1551738: Add a helper to extract the task name from the final task; r=Callek
authorTom Prince <mozilla@hocat.ca>
Wed, 15 May 2019 18:04:47 +0000
changeset 532801 edb8694f6ab184ebe26eae9d999e99b8120225d6
parent 532800 ceb51645406eff2eb84c90a41a71375b3454c92b
child 532802 a17faa0e5bf8f1680c750e81a5424715a7825387
push id11272
push userapavel@mozilla.com
push dateThu, 16 May 2019 15:28:22 +0000
treeherdermozilla-beta@2265bfc5920d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCallek
bugs1551738
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551738: Add a helper to extract the task name from the final task; r=Callek Differential Revision: https://phabricator.services.mozilla.com/D31160
taskcluster/taskgraph/task.py
taskcluster/taskgraph/transforms/l10n.py
--- a/taskcluster/taskgraph/task.py
+++ b/taskcluster/taskgraph/task.py
@@ -41,16 +41,25 @@ class Task(object):
     release_artifacts = attr.ib(
         converter=attr.converters.optional(frozenset),
         default=None,
     )
 
     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:]
+        elif self.label.startswith("build-docker-image-"):
+            return self.label[len("build-docker-image-"):]
+        else:
+            raise AttributeError("Task {} does not have a name.".format(self.label))
+
     def to_json(self):
         rv = {
             'kind': self.kind,
             'label': self.label,
             'attributes': self.attributes,
             'dependencies': self.dependencies,
             'soft_dependencies': self.soft_dependencies,
             'optimization': self.optimization,
--- a/taskcluster/taskgraph/transforms/l10n.py
+++ b/taskcluster/taskgraph/transforms/l10n.py
@@ -182,18 +182,17 @@ def _remove_locales(locales, to_remove=N
 
 
 @transforms.add
 def setup_name(config, jobs):
     for job in 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.task['metadata']['name'][len(dep.kind) + 1:])
+        job['name'] = job.get('name', dep.name)
         yield job
 
 
 @transforms.add
 def copy_in_useful_magic(config, jobs):
     for job in jobs:
         dep = job['primary-dependency']
         attributes = copy_attributes_from_dependent_job(dep)