Skip to content

Commit

Permalink
rest: return run start and finish times
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidalgarcia committed Feb 6, 2020
1 parent 88ea799 commit f0cff73
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
14 changes: 14 additions & 0 deletions docs/openapi.json
Expand Up @@ -53,6 +53,8 @@
"created": "2018-06-13T09:47:35.66097",
"id": "256b25f4-4cfb-4684-b7a8-73872ef455a1",
"name": "mytest.1",
"run_finished_at": "None",
"run_started_at": "2018-06-13T09:48:35.66097",
"size": "10M",
"status": "running",
"user": "00000000-0000-0000-0000-000000000000"
Expand All @@ -61,6 +63,8 @@
"created": "2018-06-13T09:47:35.66097",
"id": "3c9b117c-d40a-49e3-a6de-5f89fcada5a3",
"name": "mytest.2",
"run_finished_at": "2018-06-13T09:52:15.12200",
"run_started_at": "2018-06-13T09:49:34.62097",
"size": "12M",
"status": "finished",
"user": "00000000-0000-0000-0000-000000000000"
Expand All @@ -69,6 +73,8 @@
"created": "2018-06-13T09:47:35.66097",
"id": "72e3ee4f-9cd3-4dc7-906c-24511d9f5ee3",
"name": "mytest.3",
"run_finished_at": "None",
"run_started_at": "None",
"size": "180K",
"status": "created",
"user": "00000000-0000-0000-0000-000000000000"
Expand All @@ -77,6 +83,8 @@
"created": "2018-06-13T09:47:35.66097",
"id": "c4c0a1a6-beef-46c7-be04-bf4b3beca5a1",
"name": "mytest.4",
"run_finished_at": "None",
"run_started_at": "None",
"size": "1G",
"status": "created",
"user": "00000000-0000-0000-0000-000000000000"
Expand All @@ -95,6 +103,12 @@
"name": {
"type": "string"
},
"run_finished_at": {
"type": "string"
},
"run_started_at": {
"type": "string"
},
"size": {
"type": "string"
},
Expand Down
20 changes: 20 additions & 0 deletions reana_workflow_controller/rest/workflows.py
Expand Up @@ -94,6 +94,10 @@ def get_workflows(): # noqa
type: string
created:
type: string
run_started_at:
type: string
run_finished_at:
type: string
examples:
application/json:
[
Expand All @@ -104,6 +108,8 @@ def get_workflows(): # noqa
"size": "10M",
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
"run_started_at": "2018-06-13T09:48:35.66097",
"run_finished_at": None,
},
{
"id": "3c9b117c-d40a-49e3-a6de-5f89fcada5a3",
Expand All @@ -112,6 +118,8 @@ def get_workflows(): # noqa
"size": "12M",
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
"run_started_at": "2018-06-13T09:49:34.62097",
"run_finished_at": "2018-06-13T09:52:15.12200",
},
{
"id": "72e3ee4f-9cd3-4dc7-906c-24511d9f5ee3",
Expand All @@ -120,6 +128,8 @@ def get_workflows(): # noqa
"size": "180K",
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
"run_started_at": None,
"run_finished_at": None,
},
{
"id": "c4c0a1a6-beef-46c7-be04-bf4b3beca5a1",
Expand All @@ -128,6 +138,8 @@ def get_workflows(): # noqa
"size": "1G",
"user": "00000000-0000-0000-0000-000000000000",
"created": "2018-06-13T09:47:35.66097",
"run_started_at": None,
"run_finished_at": None,
}
]
400:
Expand Down Expand Up @@ -162,12 +174,20 @@ def get_workflows(): # noqa
{'message': 'User {} does not exist'.format(user)}), 404
workflows = []
for workflow in user.workflows:
run_started_at = (workflow.run_started_at.
strftime(WORKFLOW_TIME_FORMAT)
if workflow.run_started_at else None)
run_finished_at = (workflow.run_finished_at.
strftime(WORKFLOW_TIME_FORMAT)
if workflow.run_finished_at else None)
workflow_response = {'id': workflow.id_,
'name': get_workflow_name(workflow),
'status': workflow.status.name,
'user': user_uuid,
'created': workflow.created.
strftime(WORKFLOW_TIME_FORMAT),
'run_started_at': run_started_at,
'run_finished_at': run_finished_at,
'size': '-'}
if type == 'interactive':
if not workflow.interactive_session or \
Expand Down
8 changes: 6 additions & 2 deletions reana_workflow_controller/rest/workflows_status.py
Expand Up @@ -246,9 +246,13 @@ def get_workflow_status(workflow_id_or_name): # noqa
except Exception:
pass
run_started_at = None
run_finished_at = None
if workflow.run_started_at:
run_started_at = workflow.run_started_at.\
strftime(WORKFLOW_TIME_FORMAT)
if workflow.run_finished_at:
run_finished_at = workflow.run_finished_at.\
strftime(WORKFLOW_TIME_FORMAT)
initial_progress_status = {'total': 0, 'job_ids': []}
progress = {'total':
workflow.job_progress.get('total') or
Expand All @@ -266,8 +270,8 @@ def get_workflow_status(workflow_id_or_name): # noqa
cmd_and_step_name.get('prettified_cmd'),
'current_step_name':
cmd_and_step_name.get('current_job_name'),
'run_started_at':
run_started_at
'run_started_at': run_started_at,
'run_finished_at': run_finished_at
}

return jsonify({'id': workflow.id_,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_views.py
Expand Up @@ -57,6 +57,8 @@ def test_get_workflows(app, session, default_user, cwl_workflow_with_name):
"status": workflow.status.name,
"user": str(workflow.owner_id),
"created": response_data[0]["created"],
"run_started_at": response_data[0]["run_started_at"],
"run_finished_at": response_data[0]["run_finished_at"],
"size": "-"
}
]
Expand Down

0 comments on commit f0cff73

Please sign in to comment.