Skip to content

Commit

Permalink
Merge dcc3dfd into 08f2eef
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego committed Jan 15, 2018
2 parents 08f2eef + dcc3dfd commit f189b83
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions reana_workflow_controller/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ def set_workflow_status(workflow_id): # noqa
{'message': 'User {} is not allowed to access workflow {}'
.format(user_uuid, workflow_id)}), 403
if status == START:
return start_workflow(organization, user_uuid, workflow)
return start_workflow(organization, workflow)
else:
raise NotImplemented("Status {} is not supported yet"
.format(status))
Expand All @@ -1059,24 +1059,27 @@ def set_workflow_status(workflow_id): # noqa
return jsonify({"message": str(e)}), 500


def start_workflow(organization, user_uuid, workflow):
def start_workflow(organization, workflow):
"""Start a workflow."""
workflow.status = WorkflowStatus.running
db.session.commit()
if workflow.type_ == 'yadage':
return run_yadage_workflow_from_spec(organization,
user_uuid,
workflow)
elif workflow.type_ == 'cwl':
pass


def run_yadage_workflow_from_spec(organization, user_uuid, workflow):
def run_yadage_workflow_from_spec(organization, workflow):
"""Run a yadage workflow."""
try:
# Remove organization from workspace path since workflow
# engines already work in its organization folder.
workspace_path_without_organization = \
'/'.join(workflow.workspace_path.strip('/').split('/')[1:])
kwargs = {
"workflow_uuid": str(workflow.id_),
"workflow_workspace": workflow.workspace_path,
"workflow_workspace": workspace_path_without_organization,
"workflow_json": workflow.specification,
"parameters": workflow.parameters
}
Expand All @@ -1090,7 +1093,7 @@ def run_yadage_workflow_from_spec(organization, user_uuid, workflow):
'workflow_id': workflow.id_,
'status': workflow.status.name,
'organization': organization,
'user': user_uuid}), 200
'user': str(workflow.owner_id)}), 200

except(KeyError, ValueError):
traceback.print_exc()
Expand Down

0 comments on commit f189b83

Please sign in to comment.