Bug 1568277 - [taskgraph] Merge SETA implementation with optimization strategy r=tomprince

Differential Revision: https://phabricator.services.mozilla.com/D41012

--HG--
rename : taskcluster/taskgraph/util/seta.py => taskcluster/taskgraph/optimize/seta.py
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2019-08-15 18:54:18 +00:00
Родитель 1d274ca26c
Коммит 60fe63b86d
2 изменённых файлов: 26 добавлений и 24 удалений

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

@ -8,9 +8,12 @@ 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__)
@ -258,3 +261,25 @@ class SETA(object):
# 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

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

@ -12,7 +12,6 @@ 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__)
@ -46,28 +45,6 @@ class IndexSearch(OptimizationStrategy):
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):