def _deserialize_task(self, workflow, s_state):
        assert isinstance(workflow, Workflow)
        # task_spec
        task_spec = workflow.get_task_spec_from_name(s_state['task_spec'])
        task = Task(workflow, task_spec)

        # id
        task.id = s_state['id']

        # parent
        # as the task_tree might not be complete yet
        # keep the ids so they can be processed at the end
        task.parent = s_state['parent']

        # children
        task.children = [
            self._deserialize_task(workflow, c) for c in s_state['children']
        ]

        # state
        task._state = s_state['state']
        task.triggered = s_state['triggered']

        # last_state_change
        task.last_state_change = s_state['last_state_change']

        # data
        task.data = s_state['data']

        # internal_data
        #if 'subworkflow' in s_state['internal_data']:
        #
        task.internal_data = self._deserialize_dict(s_state['internal_data'])

        return task
    def _deserialize_task(self, workflow, s_state):
        assert isinstance(workflow, Workflow)
        # task_spec
        task_spec = workflow.get_task_spec_from_name(s_state['task_spec'])
        task = Task(workflow, task_spec)

        # id
        task.id = s_state['id']

        # parent
        task.parent = workflow.get_task(s_state['parent'])

        # children
        task.children = [
            self._deserialize_task(workflow, c) for c in s_state['children']
        ]

        # state
        task._state = s_state['state']
        task.triggered = s_state['triggered']

        # last_state_change
        task.last_state_change = s_state['last_state_change']

        # attributes
        task.attributes = s_state['attributes']

        # internal_attributes
        task.internal_attributes = s_state['internal_attributes']

        return task
Ejemplo n.º 3
0
    def _deserialize_task(self, workflow, s_state):
        assert isinstance(workflow, Workflow)
        # task_spec
        task_spec = workflow.get_task_spec_from_name(s_state['task_spec'])
        task = Task(workflow, task_spec)

        # id
        task.id = s_state['id']

        # parent
        task.parent = workflow.get_task(s_state['parent'])

        # children
        task.children = [self._deserialize_task(workflow, c) for c in s_state['children']]

        # state
        task._state = s_state['state']
        task.triggered = s_state['triggered']

        # last_state_change
        task.last_state_change = s_state['last_state_change']

        # attributes
        task.attributes = s_state['attributes']

        # internal_attributes
        task.internal_attributes = s_state['internal_attributes']

        return task
Ejemplo n.º 4
0
    def _deserialize_task(self, workflow, s_state):
        assert isinstance(workflow, Workflow)
        # task_spec
        task_spec = workflow.get_task_spec_from_name(s_state['task_spec'])
        task = Task(workflow, task_spec)

        # id
        task.id = s_state['id']

        # parent
        # as the task_tree might not be complete yet
        # keep the ids so they can be processed at the end
        task.parent = s_state['parent']

        # children
        task.children = [self._deserialize_task(workflow, c) for c in s_state['children']]

        # state
        task._state = s_state['state']
        task.triggered = s_state['triggered']

        # last_state_change
        task.last_state_change = s_state['last_state_change']

        # data
        task.data = s_state['data']

        # internal_data
        task.internal_data = s_state['internal_data']

        return task
Ejemplo n.º 5
0
    def _retry_failed_task_clone(self, failed_task):
        '''
        Retry failed task by cloning it, leaving exisitng task as is. 
        (marat): personally a like this way much better, then _retry_failed_task(), but 
        there is a problem with leaving failed_task in ERROR state, 
        cause workflow becomes incompleted forever
        '''
        cloned_task = Task(failed_task.workflow,
                           failed_task.task_spec,
                           parent=failed_task.parent,
                           state=Task.FUTURE,
                           internal_data={
                               'error_data':
                               failed_task.internal_data['error_data']
                           })
        # Correct position
        siblings = failed_task.parent.children
        siblings.pop()
        siblings.insert(siblings.index(failed_task) + 1, cloned_task)

        for child in failed_task.children[:]:
            if child.task_spec in failed_task.task_spec.outputs:
                cloned_task.children.append(child)
                failed_task.children.remove(child)

        cloned_task.task_spec._update_state(cloned_task)
Ejemplo n.º 6
0
 def accept_message(self, message):
     """
     Indicate to the workflow that a message has been received. The message will be processed
     by any waiting Intermediate or Boundary Message Events, that are waiting for the message.
     """
     assert not self.read_only
     self.refresh_waiting_tasks()
     self.do_engine_steps()
     for my_task in Task.Iterator(self.task_tree, Task.WAITING):
         my_task.task_spec.accept_message(my_task, message)
Ejemplo n.º 7
0
 def _branch_is_complete(self, my_task):
     # Determine whether that branch is now completed by checking whether
     # it has any waiting items other than myself in it.
     skip = None
     for task in Task.Iterator(my_task, my_task.NOT_FINISHED_MASK):
         # If the current task is a child of myself, ignore it.
         if skip is not None and task._is_descendant_of(skip):
             continue
         if task.task_spec == self:
             skip = task
             continue
         return False
     return True
Ejemplo n.º 8
0
    def _deserialize_task(self, workflow, s_state):
        assert isinstance(workflow, Workflow)
        # task_spec
        task_spec = workflow.get_task_spec_from_name(s_state['task_spec'])
        if task_spec.name == "Root":  # Don't create two roots
            task = workflow.task_tree
        else:
            task = Task(workflow, task_spec)

        # id
        task.id = s_state['id']

        # parent
        task.parent = workflow.get_task(s_state['parent'])
        # We need to add children in before deserializing child tasks so they can
        # find their parent (Task.Iter uses children to traverse the hierarchy
        if task.parent and task not in task.parent.children:
            task.parent.children.append(task)
        assert task.parent is not None or task.get_name() == 'Root'

        # children
        for c in s_state['children']:
            self._deserialize_task(workflow, c)

        # state
        task._state = s_state['state']

        # last_state_change
        task.last_state_change = s_state['last_state_change']

        # attributes
        task.attributes = s_state['attributes']

        # internal_attributes
        task.internal_attributes = s_state['internal_attributes']

        return task
    def _deserialize_task(self, workflow, s_state):
        assert isinstance(workflow, Workflow), ("The workflow parameter did "
                                                "not receive a Workflow "
                                                "object. Instead, it got a "
                                                "'%s'" %
                                                workflow.__class__)
        # task_spec
        task_spec = workflow.get_task_spec_from_name(s_state['task_spec'])
        if task_spec.name == "Root":  # Don't create two roots
            task = workflow.task_tree
        else:
            task = Task(workflow, task_spec)

        # id
        task.id = s_state['id']

        # parent
        task.parent = workflow.get_task(s_state['parent'])
        # We need to add children in before deserializing child tasks so they can
        # find their parent (Task.Iter uses children to traverse the hierarchy
        if task.parent and task not in task.parent.children:
            task.parent.children.append(task)
        #assert task.parent is not None or task.get_name() == 'Root', ("Task "
        #    "'%s' parent is None" % task.get_name())

        # children
        for c in s_state['children']:
            self._deserialize_task(workflow, c)

        # state
        task._state = s_state['state']

        # last_state_change
        task.last_state_change = s_state['last_state_change']

        # attributes
        task.attributes = s_state['attributes']

        # internal_attributes
        task.internal_attributes = s_state['internal_attributes']

        return task