Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
ARIA-130-Passing-inputs-from-the-workflow-to-the-operation-changes-th…
…e-inputs
  • Loading branch information
mxmrlv committed Mar 23, 2017
1 parent 9841ca4 commit eecd8aca213c565f012810dd3220488e8152217c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 18 deletions.
@@ -305,11 +305,10 @@ def many_to_many(model_class,

secondary_table = '{0}_{1}'.format(this_table, other_table)

if other_property is None:
other_property = formatting.pluralize(this_table)
if prefix is not None:
secondary_table = '{0}_{1}'.format(prefix, secondary_table)
other_property = '{0}_{1}'.format(prefix, other_property)
if prefix is not None:
secondary_table = '{0}_{1}'.format(prefix, secondary_table)
if other_property is None:
other_property = '{0}_{1}'.format(prefix, this_table)

backref_kwargs = backref_kwargs or {}
backref_kwargs.setdefault('uselist', True)
@@ -202,6 +202,14 @@ def _append_raw_children(self, types):
types.append(raw_child)
child._append_raw_children(types)

@property
def hierarchy(self):
"""
Return the type hierarchy.
:return:
"""
return [self] + (self.parent.hierarchy if self.parent else [])


class MetadataBase(TemplateModelMixin):
"""
@@ -16,6 +16,7 @@
"""
Provides the tasks to be entered into the task graph
"""
import copy

from ....modeling import models
from ....utils.collections import OrderedDict
@@ -91,10 +92,10 @@ def __init__(self,
self.runs_on = runs_on

# Wrap inputs
if inputs:
for k, v in inputs.iteritems():
if not isinstance(v, models.Parameter):
inputs[k] = models.Parameter.wrap(k, v)
inputs = copy.deepcopy(inputs) if inputs else {}
for k, v in inputs.iteritems():
if not isinstance(v, models.Parameter):
inputs[k] = models.Parameter.wrap(k, v)

# TODO: Suggestion: these extra inputs could be stored as a separate entry in the task
# model, because they are different from the operation inputs. If we do this, then the two
@@ -36,7 +36,8 @@
Relationship,
NodeTemplate,
Node,
Parameter
Parameter,
Type
)

from tests import mock
@@ -835,3 +836,20 @@ def create_task(max_attempts):
create_task(max_attempts=0)
with pytest.raises(ValueError):
create_task(max_attempts=-2)


class TestType(object):
def test_type_hierarchy(self):
super_type = Type(variant='variant', name='super')
sub_type = Type(variant='variant', parent=super_type, name='sub')
additional_type = Type(variant='variant', name='non_related')

assert super_type.hierarchy == [super_type]
assert sub_type.hierarchy == [sub_type, super_type]
assert additional_type.hierarchy == [additional_type]

super_type.parent = additional_type

assert super_type.hierarchy == [super_type, additional_type]
assert sub_type.hierarchy == [sub_type, super_type, additional_type]

@@ -363,13 +363,11 @@ def _assert_loggins(ctx, inputs):
assert all(l.execution == execution for l in logs)
assert all(l in logs and l.task == task for l in task.logs)

op_start_log = [l for l in logs if
inputs['op_start'].value in l.msg and l.level.lower() == 'info']
op_start_log = [l for l in logs if inputs['op_start'] in l.msg and l.level.lower() == 'info']
assert len(op_start_log) == 1
op_start_log = op_start_log[0]

op_end_log = [l for l in logs
if inputs['op_end'].value in l.msg and l.level.lower() == 'debug']
op_end_log = [l for l in logs if inputs['op_end'] in l.msg and l.level.lower() == 'debug']
assert len(op_end_log) == 1
op_end_log = op_end_log[0]

@@ -55,8 +55,8 @@ def mock_workflow(ctx, graph):
eng = engine.Engine(executor=executor, workflow_context=context, tasks_graph=graph)
eng.execute()
out = get_node(context).runtime_properties['out']
assert out['wrapper_inputs'] == dict((k, v.value) for k, v in inputs.iteritems())
assert out['function_inputs'] == dict((k, v.value) for k, v in inputs.iteritems())
assert out['wrapper_inputs'] == inputs
assert out['function_inputs'] == inputs


@extension.process_executor
@@ -73,9 +73,9 @@ def test_apply_tracked_changes_during_an_operation(context, executor):
inputs=inputs)

expected_after_update = expected_initial.copy()
expected_after_update.update(inputs['committed'].value) # pylint: disable=no-member
expected_after_update.update(inputs['committed']) # pylint: disable=no-member
expected_after_change = expected_after_update.copy()
expected_after_change.update(inputs['changed_but_refreshed'].value) # pylint: disable=no-member
expected_after_change.update(inputs['changed_but_refreshed']) # pylint: disable=no-member
expected_after_refresh = expected_after_update

assert out['initial'] == expected_initial

0 comments on commit eecd8ac

Please sign in to comment.