예제 #1
0
 def _start_import(self, catalog: str, collection: str, application: str):
     job = Workflow(IMPORT).start_new({
         'catalogue': catalog,
         'collection': collection,
         'application': application,
     })
     self._wait_job_finished(job)
예제 #2
0
def start_workflow(msg):
    """
    Start a workflow using the parameters that are contained in the message header

    :param msg: The message that will be used to start a workflow
    :return: None
    """
    # Retrieve the workflow parameters
    workflow_name = msg['workflow']['workflow_name']
    step_name = msg['workflow'].get('step_name')
    # Delete the parameters so that they do not get transferred in the workflow
    del msg['workflow']

    # Start the workflow with the given message
    if workflow_name and step_name:
        Workflow(workflow_name, step_name).start(msg)
    elif workflow_name:
        Workflow(workflow_name).start(msg)
    else:
        Workflow.end_of_workflow(msg)
예제 #3
0
    def execute_command(self, command: StartCommand):
        """Executes input command

        :param command:
        :return:
        """
        input_args = self._parse_arguments(command)
        args = [command.workflow]

        if command.start_step:
            args.append(command.start_step)

        Workflow(*args).start_new(input_args)
예제 #4
0
def handle_result(msg):
    """
    Handle the result of a message.
    Result messages are received via the result queue

    The message is matched with a step in a workflow and the result handling method
    of this workflow step is executed
    :param msg: The result message
    :return: None
    """
    # Retrieve the job and step from the message header
    header = msg['header']
    jobid = header['jobid']
    stepid = header['stepid']
    # Get the job and step from the database
    job, step = get_job_step(jobid, stepid)
    # Start the result handler method with the given message
    if hooks.has_hooks(msg):
        hooks.handle_result(msg)
    else:
        Workflow(job.type, step.name).handle_result()(msg)
예제 #5
0
 def _start_relate(self, catalog: str):
     job = Workflow(RELATE).start_new({'catalogue': catalog})
     self._wait_job_finished(job)
예제 #6
0
 def setUp(self):
     self.workflow = Workflow("Workflow", "Step")
     WORKFLOWS["Workflow"]["Step"]["function"] = mock.MagicMock()
     WORKFLOWS["Workflow"]["Next"]["function"] = mock.MagicMock()
     WORKFLOWS["Workflow"]["OtherNext"]["function"] = mock.MagicMock()