Skip to content

Commit

Permalink
Merge 1609880 into 67c6cda
Browse files Browse the repository at this point in the history
  • Loading branch information
roksys committed Jan 21, 2020
2 parents 67c6cda + 1609880 commit cb66006
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions reana_workflow_controller/rest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,30 @@

def start_workflow(workflow, parameters):
"""Start a workflow."""
if workflow.status in [WorkflowStatus.created, WorkflowStatus.queued]:
workflow.run_started_at = datetime.now()
workflow.status = WorkflowStatus.running
if parameters:
workflow.input_parameters = parameters.get('input_parameters')
workflow.operational_options = \
parameters.get('operational_options')
current_db_sessions = Session.object_session(workflow)
current_db_sessions.add(workflow)
current_db_sessions.commit()
kwrm = KubernetesWorkflowRunManager(workflow)
kwrm.start_batch_workflow_run()
else:
message = \
("Workflow {id_} could not be started because it {verb}"
" already {status}.").format(
id_=workflow.id_,
verb=get_workflow_status_change_verb(workflow.status.name),
status=str(workflow.status.name))
raise REANAWorkflowControllerError(message)
failure_message = \
("Workflow {id_} could not be started because it {verb} "
"already {status}.").format(
id_=workflow.id_,
verb=get_workflow_status_change_verb(workflow.status.name),
status=str(workflow.status.name))
if 'restart' in parameters.keys():
if parameters['restart']:
if workflow.status not in \
[WorkflowStatus.failed, WorkflowStatus.finished]:
raise REANAWorkflowControllerError(failure_message)
elif workflow.status not in \
[WorkflowStatus.created, WorkflowStatus.queued]:
raise REANAWorkflowControllerError(failure_message)
workflow.run_started_at = datetime.now()
workflow.status = WorkflowStatus.running
if parameters:
workflow.input_parameters = parameters.get('input_parameters')
workflow.operational_options = parameters.get('operational_options')
current_db_sessions = Session.object_session(workflow)
current_db_sessions.add(workflow)
current_db_sessions.commit()
kwrm = KubernetesWorkflowRunManager(workflow)
kwrm.start_batch_workflow_run()


def stop_workflow(workflow):
Expand Down

0 comments on commit cb66006

Please sign in to comment.