Esempio n. 1
0
    def __init__(self, operation_id, name, input_property_order,
            output_properties):
        WorkflowNetBase.__init__(self, operation_id=operation_id, name=name)

        self.converge_action = FutureAction(cls=ConvergeAction,
                operation_id=operation_id,
                input_property_order=input_property_order,
                output_properties=output_properties)
        self.converge_transition = self.add_basic_transition(
                name='converge(%s)' % operation_id,
                action=self.converge_action)

        self.starting_place = self.bridge_transitions(
                self.internal_start_transition,
                self.converge_transition,
                name='starting')
        self.succeeding_place = self.bridge_transitions(
                self.converge_transition,
                self.internal_success_transition,
                name='succeeding')

        self.observe_transition(self.internal_start_transition,
                FutureAction(actions.UpdateOperationStatus,
                    operation_id=operation_id, status='running',
                    calculate_start_time=True))

        self.observe_transition(self.internal_success_transition,
                FutureAction(actions.UpdateOperationStatus,
                    operation_id=operation_id, status='done',
                    calculate_end_time=True))
Esempio n. 2
0
    def __init__(self, name, operation_id, resources, action_type,
            action_id, shortcut_action_class, execute_action_class,
            lsf_queue=None, job_group=None, project_name=None):
        WorkflowNetBase.__init__(self, operation_id=operation_id, name=name)

        base_action_args = {
            'operation_id': operation_id,
            'action_id': action_id,
            'action_type': action_type,
        }
        if 'resources' in resources:
            base_action_args['resources'] = resources['resources']
        self.shortcut_net = self.add_subnet(ShortcutShellCommandNet, name=name,
                dispatch_action_class=shortcut_action_class,
                method='shortcut', **base_action_args)

        lsf_options = {
            'job_name': name,
        }
        if project_name:
            lsf_options['project'] = project_name
        if lsf_queue:
            lsf_options['queue'] = lsf_queue
        if job_group:
            lsf_options['job_group'] = job_group

        self.execute_net = self.add_subnet(ExecuteShellCommandNet, name=name,
                dispatch_action_class=execute_action_class,
                lsf_options=lsf_options, method='execute',
                **base_action_args)

        # Connect subnets
        self.starting_shortcut_place = self.bridge_transitions(
                self.internal_start_transition,
                self.shortcut_net.start_transition,
                name='starting-shortcut')
        self.starting_execute_place = self.bridge_transitions(
                self.shortcut_net.failure_transition,
                self.execute_net.start_transition,
                name='starting-execute')

        self.succeeding_place = self.join_transitions_as_or(
                self.internal_success_transition,
                [self.shortcut_net.success_transition,
                    self.execute_net.success_transition],
                name='succeeding')
        self.failing_place = self.bridge_transitions(
                self.execute_net.failure_transition,
                self.internal_failure_transition,
                name='failing')

        self.observe_transition(self.internal_success_transition,
                FutureAction(UpdateOperationStatus, operation_id=operation_id,
                    status='done', calculate_end_time=True))
Esempio n. 3
0
    def __init__(self, name, operation_id, subnets, edges):
        WorkflowNetBase.__init__(self, operation_id=operation_id, name=name)

        for name, subnet in subnets.iteritems():
            self.subnets.add(subnet)

        for source_name, dest_names in edges.iteritems():
            for dest_name in dest_names:
                self.bridge_transitions(subnets[source_name].success_transition,
                        subnets[dest_name].start_transition)

        self.starting_place = self.bridge_transitions(
                self.internal_start_transition,
                subnets['input connector'].start_transition,
                name='starting')

        self.observe_transition(self.internal_start_transition,
                FutureAction(actions.UpdateChildrenStatuses,
                    operation_id=operation_id, status='new'))

        self.succeeding_place = self.bridge_transitions(
                subnets['output connector'].success_transition,
                self.internal_success_transition,
                name='succeeding')

        self.failing_place = self.join_transitions_as_or(
                self.internal_failure_transition,
                [s.failure_transition for s in subnets.itervalues()],
                name='failing')


        self.observe_transition(self.internal_start_transition,
                FutureAction(actions.UpdateOperationStatus,
                    operation_id=operation_id, status='running',
                    calculate_start_time=True))

        self.observe_transition(self.internal_success_transition,
                FutureAction(actions.UpdateOperationStatus,
                    operation_id=operation_id, status='done',
                    calculate_end_time=True))

        self.observe_transition(self.internal_failure_transition,
                FutureAction(actions.UpdateOperationStatus,
                    operation_id=operation_id, status='crashed',
                    calculate_end_time=True))
Esempio n. 4
0
    def __init__(self, target_net, parallel_property):

        self.target_net = target_net

        operation_id = target_net.operation_id
        name = target_net.name
        WorkflowNetBase.__init__(self, operation_id=operation_id, name=name)


        self.subnets.add(target_net)


        # split_transition
        split_action = FutureAction(cls=actions.ParallelBySplit,
                operation_id=operation_id,
                parallel_property=parallel_property)
        self.split_transition = self.add_basic_transition(
                name='ParallelBy(%s) split' % operation_id,
                action=split_action)
        self.starting_split_place = self.bridge_transitions(
                self.internal_start_transition,
                self.split_transition,
                name='starting-split')
        self.succeeding_split_place = self.bridge_transitions(
                self.split_transition,
                target_net.start_transition,
                name='succeeding-split')

        # historian observers
        self.observe_transition(self.split_transition,
                FutureAction(UpdateOperationStatus,
                    operation_id=self.operation_id, status='new'))
        self.observe_transition(self.internal_start_transition,
                FutureAction(UpdateOperationStatus,
                    operation_id=self.operation_id, status='running',
                    name=display_name(name)))
        self.observe_transition(self.internal_failure_transition,
                FutureAction(UpdateOperationStatus,
                    operation_id=self.operation_id, status='crashed',
                    name=display_name(name)))
        self.observe_transition(self.internal_success_transition,
                FutureAction(UpdateOperationStatus,
                    operation_id=self.operation_id, status='done',
                    name=display_name(name)))

        # join_transition
        join_action = FutureAction(cls=actions.ParallelByJoin,
                operation_id=operation_id)
        self.join_transition = self.add_barrier_transition(
                name='ParallelBy(%s) join' % operation_id,
                action=join_action)
        self.starting_join_place = self.bridge_transitions(
                target_net.success_transition,
                self.join_transition,
                name='starting-join')
        self.succeeding_join_place = self.bridge_transitions(
                self.join_transition,
                self.internal_success_transition,
                name='succeeding-join')

        # fail transition
        target_fail_action = FutureAction(cls=actions.ParallelByFail)
        self.target_fail_transition = self.add_basic_transition(
                name='ParallelBy(%s) fail' % operation_id,
                action=target_fail_action)
        self.failing_target_place = self.bridge_transitions(
                target_net.failure_transition,
                self.target_fail_transition,
                name='failing-target')
        self.failing_place = self.bridge_transitions(
                self.target_fail_transition,
                self.internal_failure_transition,
                name='failing')