Bug 1351010 - Fix return statements in optimize.py; r=dustin
MozReview-Commit-ID: ctgm1fw0Fo *** Bug 1351010 - Completely fixed; r?dustin MozReview-Commit-ID: HKoWcINVSnV
This commit is contained in:
@@ -76,11 +76,11 @@ def optimize_task(task, params):
|
||||
for opt in task.optimizations:
|
||||
opt_type, args = opt[0], opt[1:]
|
||||
opt_fn = _optimizations[opt_type]
|
||||
optimized, task_id = opt_fn(task, params, *args)
|
||||
if optimized or task_id:
|
||||
return optimized, task_id
|
||||
opt_result = opt_fn(task, params, *args)
|
||||
if opt_result:
|
||||
return opt_result
|
||||
|
||||
return False, None
|
||||
return False
|
||||
|
||||
|
||||
def annotate_task_graph(target_task_graph, params, do_not_optimize,
|
||||
@@ -118,7 +118,15 @@ def annotate_task_graph(target_task_graph, params, do_not_optimize,
|
||||
replacement_task_id = existing_tasks[label]
|
||||
# otherwise, examine the task itself (which may be an expensive operation)
|
||||
else:
|
||||
optimized, replacement_task_id = optimize_task(task, params)
|
||||
opt_result = optimize_task(task, params)
|
||||
|
||||
# use opt_result to determine values for optimized, replacement_task_id
|
||||
optimized = True
|
||||
replacement_task_id = None
|
||||
if opt_result is False:
|
||||
optimized = False
|
||||
elif opt_result is not True:
|
||||
replacement_task_id = opt_result
|
||||
|
||||
task.optimized = optimized
|
||||
task.task_id = replacement_task_id
|
||||
@@ -195,11 +203,11 @@ def opt_index_search(task, params, index_path):
|
||||
index_path,
|
||||
use_proxy=bool(os.environ.get('TASK_ID')))
|
||||
|
||||
return True, task_id
|
||||
return task_id or True
|
||||
except requests.exceptions.HTTPError:
|
||||
pass
|
||||
|
||||
return False, None
|
||||
return False
|
||||
|
||||
|
||||
@optimization('seta')
|
||||
@@ -221,20 +229,20 @@ def opt_seta(task, params):
|
||||
params.get('pushdate'),
|
||||
bbb_task):
|
||||
# Always optimize away low-value tasks
|
||||
return True, None
|
||||
return True
|
||||
else:
|
||||
return False, None
|
||||
return False
|
||||
|
||||
|
||||
@optimization('files-changed')
|
||||
def opt_files_changed(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 True, None
|
||||
return True
|
||||
|
||||
changed = files_changed.check(params, file_patterns)
|
||||
if not changed:
|
||||
logger.debug('no files found matching a pattern in `when.files-changed` for ' +
|
||||
task.label)
|
||||
return True, None
|
||||
return False, None
|
||||
return True
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user