Skip to content

Commit

Permalink
rest: agregate input parameters on diff
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidalgarcia committed Mar 18, 2020
1 parent b5b45a3 commit 274aed1
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions reana_workflow_controller/rest/utils.py
Expand Up @@ -252,6 +252,16 @@ def get_specification_diff(workflow_a, workflow_b, output_format='unified'):
:rtype: List with lines of differences.
"""

def _aggregated_inputs(workflow):
inputs = workflow.reana_specification.get('inputs', {})
input_parameters = inputs.get('parameters', {})
if workflow.input_parameters:
input_parameters = dict(input_parameters,
**workflow.input_parameters)
inputs['parameters'] = input_parameters
return inputs

if output_format not in ['unified', 'context', 'html']:
raise ValueError('Unknown output format.'
'Please select one of unified, context or html.')
Expand All @@ -265,12 +275,14 @@ def get_specification_diff(workflow_a, workflow_b, output_format='unified'):

specification_diff = dict.fromkeys(workflow_a.reana_specification.keys())
for section in specification_diff:
section_a = pprint.pformat(
workflow_a.reana_specification.get(section, '')).\
splitlines()
section_b = pprint.pformat(
workflow_b.reana_specification.get(section, '')).\
splitlines()
if section == 'inputs':
section_value_a = _aggregated_inputs(workflow_a)
section_value_b = _aggregated_inputs(workflow_b)
else:
section_value_a = workflow_a.reana_specification.get(section, '')
section_value_b = workflow_b.reana_specification.get(section, '')
section_a = pprint.pformat(section_value_a).splitlines()
section_b = pprint.pformat(section_value_b).splitlines()
# skip first 2 lines of diff relevant if input comes from files
specification_diff[section] = list(diff_method(section_a,
section_b))[2:]
Expand Down

0 comments on commit 274aed1

Please sign in to comment.