Merge "Simplify deduplicate_steps"

This commit is contained in:
Zuul 2020-04-21 00:37:15 +00:00 committed by Gerrit Code Review
commit 6a95e216f6
1 changed files with 5 additions and 16 deletions

View File

@ -2144,6 +2144,10 @@ def check_versions(provided_version=None):
node_version=provided_version)
def _step_sort_key(step):
return (-step['hwm']['support'], -step['priority'], step['hwm']['name'])
def deduplicate_steps(candidate_steps):
"""Remove duplicated clean or deploy steps
@ -2188,22 +2192,7 @@ def deduplicate_steps(candidate_steps):
steps[step['step']].append(step)
for step_name, step_list in steps.items():
# determine the max support level among candidate steps
max_support = max([x['hwm']['support'] for x in step_list])
# filter out any steps that are not at the max support for this step
max_support_steps = [x for x in step_list
if x['hwm']['support'] == max_support]
# determine the max priority among remaining steps
max_priority = max([x['priority'] for x in max_support_steps])
# filter out any steps that are not at the max priority for this step
max_priority_steps = [x for x in max_support_steps
if x['priority'] == max_priority]
# if there are still multiple steps, sort by hwm name and take
# the first result
winning_step = sorted(max_priority_steps,
key=lambda x: x['hwm']['name'])[0]
winning_step = sorted(step_list, key=_step_sort_key)[0]
# Remove extra metadata we added to the step for filtering
manager = winning_step.pop('hwm')['name']
# Add winning step to deduped_steps