Skip to content

Commit

Permalink
rest: return interactive sessions on verbose workflows request
Browse files Browse the repository at this point in the history
  • Loading branch information
audrium committed Oct 16, 2020
1 parent c9dc85e commit d1b14ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 7 additions & 5 deletions reana_workflow_controller/rest/workflows.py
Expand Up @@ -229,13 +229,15 @@ def get_workflows(paginate=None): # noqa
"progress": get_workflow_progress(workflow),
"size": "-",
}
if type_ == "interactive":
if type_ == "interactive" or verbose:
int_session = workflow.sessions.first()
if not int_session:
if int_session:
workflow_response["session_type"] = int_session.type_.name
workflow_response["session_uri"] = int_session.path
workflow_response["session_status"] = int_session.status.name
# Skip workflow if type is interactive and there is no session
elif type_ == "interactive":
continue
workflow_response["session_type"] = int_session.type_.name
workflow_response["session_uri"] = int_session.path
workflow_response["session_status"] = int_session.status.name
if verbose:
try:
disk_usage_info = workflow.get_workspace_disk_usage(
Expand Down
6 changes: 4 additions & 2 deletions reana_workflow_controller/workflow_run_manager.py
Expand Up @@ -359,9 +359,11 @@ def stop_interactive_session(self, interactive_session_id):
)
finally:
if action_completed:
int_session.status = RunStatus.stopped
# TODO: once multiple sessions will be supported instead of
# deleting a session, its status should be changed to "stopped"
# int_session.status = RunStatus.stopped
current_db_sessions = Session.object_session(self.workflow)
current_db_sessions.add(int_session)
current_db_sessions.delete(int_session)
current_db_sessions.commit()

def stop_batch_workflow_run(self):
Expand Down
5 changes: 1 addition & 4 deletions tests/test_workflow_run_manager.py
Expand Up @@ -136,7 +136,4 @@ def test_interactive_session_closure(sample_serial_workflow_in_db, session):
).first()
assert int_session.status == RunStatus.created
kwrm.stop_interactive_session(int_session.id_)
int_session = InteractiveSession.query.filter_by(
owner_id=workflow.owner_id, type_=InteractiveSessionType(0).name,
).first()
assert int_session.status == RunStatus.stopped
assert not workflow.sessions.first()

0 comments on commit d1b14ee

Please sign in to comment.