Bug 1568277 - [taskgraph] Merge SETA implementation with optimization strategy r=tomprince
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 15 Aug 2019 18:54:18 +0000
changeset 488339 d7e8f80e2c85288a5f59135f147475fe7ac73ce0
parent 488338 7b59ed5d703d3a9d6eae1860487da01a697106dd
child 488340 632d943c947b359b68d7d29626ef3c51744572fd
push id113906
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 04:07:24 +0000
treeherdermozilla-inbound@d887276421d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1568277
milestone70.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 1568277 - [taskgraph] Merge SETA implementation with optimization strategy r=tomprince Differential Revision: https://phabricator.services.mozilla.com/D41012
taskcluster/taskgraph/optimize/seta.py
taskcluster/taskgraph/optimize/strategies.py
taskcluster/taskgraph/util/seta.py
rename from taskcluster/taskgraph/util/seta.py
rename to taskcluster/taskgraph/optimize/seta.py
--- a/taskcluster/taskgraph/util/seta.py
+++ b/taskcluster/taskgraph/optimize/seta.py
@@ -3,19 +3,22 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import json
 import logging
 import requests
 from collections import defaultdict
+
+import attr
 from redo import retry
 from requests import exceptions
-import attr
+
+from taskgraph.optimize import OptimizationStrategy, register_strategy
 
 logger = logging.getLogger(__name__)
 
 # It's a list of project name which SETA is useful on
 SETA_PROJECTS = ['mozilla-inbound', 'autoland']
 SETA_HIGH_PRIORITY = 1
 SETA_LOW_PRIORITY = 5
 
@@ -253,8 +256,30 @@ class SETA(object):
         if project not in self.low_value_tasks:
             self.low_value_tasks[project] = self.query_low_value_tasks(project)
         return label in self.low_value_tasks[project]
 
 
 # create a single instance of this class, and expose its `is_low_value_task`
 # bound method as a module-level function
 is_low_value_task = SETA().is_low_value_task
+
+
+@register_strategy('seta')
+class SkipLowValue(OptimizationStrategy):
+    push_interval = 5
+    time_interval = 60
+
+    def should_remove_task(self, task, params, _):
+        label = task.label
+
+        # we would like to return 'False, None' while it's high_value_task
+        # and we wouldn't optimize it. Otherwise, it will return 'True, None'
+        if is_low_value_task(label,
+                             params.get('project'),
+                             params.get('pushlog_id'),
+                             params.get('pushdate'),
+                             self.push_interval,
+                             self.time_interval):
+            # Always optimize away low-value tasks
+            return True
+        else:
+            return False
--- a/taskcluster/taskgraph/optimize/strategies.py
+++ b/taskcluster/taskgraph/optimize/strategies.py
@@ -7,17 +7,16 @@ from __future__ import absolute_import, 
 import logging
 import os
 
 from mozbuild.base import MozbuildObject
 from mozbuild.util import memoize
 
 from taskgraph import files_changed
 from taskgraph.optimize import register_strategy, OptimizationStrategy
-from taskgraph.util.seta import is_low_value_task
 from taskgraph.util.taskcluster import find_task_id
 
 logger = logging.getLogger(__name__)
 
 
 @register_strategy("index-search")
 class IndexSearch(OptimizationStrategy):
 
@@ -41,38 +40,16 @@ class IndexSearch(OptimizationStrategy):
                 return task_id
             except KeyError:
                 # 404 will end up here and go on to the next index path
                 pass
 
         return False
 
 
-@register_strategy('seta')
-class SETA(OptimizationStrategy):
-    push_interval = 5
-    time_interval = 60
-
-    def should_remove_task(self, task, params, _):
-        label = task.label
-
-        # we would like to return 'False, None' while it's high_value_task
-        # and we wouldn't optimize it. Otherwise, it will return 'True, None'
-        if is_low_value_task(label,
-                             params.get('project'),
-                             params.get('pushlog_id'),
-                             params.get('pushdate'),
-                             self.time_interval,
-                             self.push_interval):
-            # Always optimize away low-value tasks
-            return True
-        else:
-            return False
-
-
 @register_strategy("skip-unless-changed")
 class SkipUnlessChanged(OptimizationStrategy):
     def should_remove_task(self, task, params, file_patterns):
         # pushlog_id == -1 - this is the case when run from a cron.yml job
         if params.get('pushlog_id') == -1:
             return False
 
         changed = files_changed.check(params, file_patterns)