Commit 9ecafce8 authored by Keller Patrick's avatar Keller Patrick

Merged

parents 3d21c2b2 f1185c46
......@@ -126,7 +126,7 @@ class CWLRestAPI(FlaskView):
@route('/workflows/<workflowID>', methods=['POST'])
def restartWorkflow(self, workflowID):
"""
The status of the workflow matching the given ID (toil Workflow ID) with all job infos is returned in JSON format.
The currently stopped workflow (matching the given ID) will be restarted.
"""
#wf = self.__wfManager.restartWorkflow(workflowID)
return json.dumps(self.__wfManager.restartWorkflow(workflowID))
......@@ -246,7 +246,6 @@ class WorkflowManager:
If the pipeline was stopped by the user and the workflow has been edited, the workflow
has to start from scratch to actually apply these changes.
"""
#TODO: Restarting workflow, thread has to be started again (initializing new object, copying doesn't work)
wfToRestart = None
for i in self.workflowList:
......@@ -256,7 +255,7 @@ class WorkflowManager:
wfToRestart.restart = True
newWorkflow = WorkflowWrapper(restart=True)
#Deep Copy (function copy does not work on threads)
newWorkflow.workflowID = wfToRestart.workflowID
newWorkflow.yamlStream = wfToRestart.yamlStream
newWorkflow.cwlStream = wfToRestart.cwlStream
......@@ -273,7 +272,7 @@ class WorkflowManager:
newWorkflow.userToken = wfToRestart.userToken
newWorkflow.workflowDBID = wfToRestart.workflowDBID
newWorkflow.jobs = wfToRestart.jobs
newWorkflow.stopped = True
newWorkflow.stopped = wfToRestart.stopped
newWorkflow.jobStore = wfToRestart.jobStore
newWorkflow.jobStoreForPipeline = wfToRestart.jobStoreForPipeline
newWorkflow.dataFilesDir = wfToRestart.dataFilesDir
......@@ -316,6 +315,7 @@ class WorkflowManager:
result = i
break
if result is not None:
result.killToilRunner()
return {"workflow_id":result.workflowID}
else:
return "This Workflow does not exist"
......@@ -487,8 +487,6 @@ class WorkflowWrapper(threading.Thread):
self.toilProcess.terminate()
wesDAO.update_Workflow(self.workflowDBID, state="CANCELED")
return
def callToilRunner(self):
"""
This method executes the workflow with the toil-cwl-runner in a sub process.
......@@ -500,15 +498,16 @@ class WorkflowWrapper(threading.Thread):
if not self.restart:
self.toilProcess = subprocess.Popen(self.toilRunnerArgsList, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
else:
self.toilProcess = subprocess.Popen(self.toilRunnerArgsListRestart, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
self.stopped = False
self.restart = False
self.toilProcess = subprocess.Popen(self.toilRunnerArgsListRestart, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
for l in self.toilProcess.stdout:
self.workflowID = wesDAO.get_workflow_id(self.workflowDBID)["workflow_id"]
logfile.write(l.decode('utf-8'))
if not self.stopped:
wesParser.parse_log(self.logFilePath, wesDAO, self.workflowDBID)
def checkStatusOfJobs(self):
"""
This method is searching for all 'job' entries in the log written by the toil runner.
......
......@@ -8,10 +8,10 @@ curl -d '{"usertoken":"user1"}' -H "Content-Type: application/json" -X GET http:
curl -X GET http://localhost:5000/workflows/
DELETE workflow
curl -X DELETE http://localhost:5000/workflows/
curl -X DELETE http://localhost:5000/workflows/e78e64e5-7c4c-4c7a-9af0-61543d37dbeb
RESTART workflow
curl -X POST http://localhost:5000/workflows/
curl -X POST http://localhost:5000/workflows/e78e64e5-7c4c-4c7a-9af0-61543d37dbeb
testing flask:
https://damyanon.net/post/flask-series-testing/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment