Commit bcba1c2e authored by Frédéric Escudié's avatar Frédéric Escudié
Browse files

Manage error in preprocess.

Fix bug in workflow_status management.
parent 93d61151
...@@ -580,7 +580,6 @@ class Workflow(threading.Thread): ...@@ -580,7 +580,6 @@ class Workflow(threading.Thread):
last_stack_location = "" last_stack_location = ""
if len(error["traceback"]) > 0: if len(error["traceback"]) > 0:
last_stack_location = error["traceback"][-1]["location"].strip() last_stack_location = error["traceback"][-1]["location"].strip()
self.status = self.STATUS_FAILED
return { "msg" : error["msg"], "location" : last_stack_location } return { "msg" : error["msg"], "location" : last_stack_location }
else: else:
return None return None
...@@ -819,7 +818,7 @@ class Workflow(threading.Thread): ...@@ -819,7 +818,7 @@ class Workflow(threading.Thread):
""" """
try: try:
# if this is the first time the workflow run # if this is the first time the workflow run
if self.__step == None : if self.__step == None:
self.start_time = time.time() self.start_time = time.time()
self.__step = 0 self.__step = 0
self.status = self.STATUS_STARTED self.status = self.STATUS_STARTED
...@@ -830,9 +829,15 @@ class Workflow(threading.Thread): ...@@ -830,9 +829,15 @@ class Workflow(threading.Thread):
self._serialize() self._serialize()
# if pre_processing has not been done yet # if pre_processing has not been done yet
if self.__step == 0: if self.__step == 0:
self.pre_process() try:
self.__step = 1 self.pre_process()
self._serialize() self.__step = 1
except:
self.status = self.STATUS_FAILED
self.end_time = time.time()
raise
finally:
self._serialize()
# if collecting components and running workflow has not been done yet # if collecting components and running workflow has not been done yet
if self.__step == 1: if self.__step == 1:
try: try:
...@@ -840,8 +845,9 @@ class Workflow(threading.Thread): ...@@ -840,8 +845,9 @@ class Workflow(threading.Thread):
self.components = [] self.components = []
self.status = self.STATUS_STARTED self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING self.postprocess_status = self.STATUS_PENDING
self._serialize()
self.wf_execution_wrapper() self.wf_execution_wrapper()
except SystemExit: except:
self.status = self.STATUS_FAILED self.status = self.STATUS_FAILED
self.end_time = time.time() self.end_time = time.time()
self._serialize() self._serialize()
...@@ -853,7 +859,7 @@ class Workflow(threading.Thread): ...@@ -853,7 +859,7 @@ class Workflow(threading.Thread):
else: else:
self._execute_weaver() self._execute_weaver()
self.__step = 3 self.__step = 3
self._serialize() self._serialize()
# if the workflow was a dynamic one # if the workflow was a dynamic one
if self.__step == 2: if self.__step == 2:
try: try:
...@@ -861,8 +867,9 @@ class Workflow(threading.Thread): ...@@ -861,8 +867,9 @@ class Workflow(threading.Thread):
self.components = [] self.components = []
self.status = self.STATUS_STARTED self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING self.postprocess_status = self.STATUS_PENDING
self._serialize()
self.wf_execution_wrapper() self.wf_execution_wrapper()
except SystemExit: except:
self.status = self.STATUS_FAILED self.status = self.STATUS_FAILED
self.end_time = time.time() self.end_time = time.time()
self._serialize() self._serialize()
...@@ -892,8 +899,10 @@ class Workflow(threading.Thread): ...@@ -892,8 +899,10 @@ class Workflow(threading.Thread):
utils.display_error_message(str(e)) utils.display_error_message(str(e))
def get_status(self): def get_status(self):
# first update the status from weaver folders """
# TODO update self.end_time @summary: Update and return self.status.
@return: [STATUS] the workflow status.
"""
try: try:
working_directory = os.path.join(self.directory, self.WORKING) working_directory = os.path.join(self.directory, self.WORKING)
make_states = [] make_states = []
...@@ -904,14 +913,12 @@ class Workflow(threading.Thread): ...@@ -904,14 +913,12 @@ class Workflow(threading.Thread):
make_states.append(log.state) make_states.append(log.state)
if len(self.reseted_components) > 0: if len(self.reseted_components) > 0:
self.status = self.STATUS_RESETED self.status = self.STATUS_RESETED
elif self.STATUS_ABORTED in make_states: elif self.STATUS_ABORTED in make_states: # Error in component execution
self.status = self.STATUS_ABORTED self.status = self.STATUS_ABORTED
elif self.STATUS_FAILED in make_states: elif self.STATUS_FAILED in make_states: # Error in component execution
self.status = self.STATUS_FAILED self.status = self.STATUS_FAILED
elif self.postprocess_status == self.STATUS_FAILED: elif self.postprocess_status == self.STATUS_FAILED: # Error in postprocess
self.status = self.STATUS_FAILED self.status = self.STATUS_FAILED
elif self.status != self.STATUS_COMPLETED:
self.status = self.STATUS_STARTED
except: pass except: pass
return self.status return self.status
......
...@@ -100,6 +100,8 @@ class WorkflowsManager(object): ...@@ -100,6 +100,8 @@ class WorkflowsManager(object):
workflow = self.get_workflow(workflow_id) workflow = self.get_workflow(workflow_id)
if hasattr(workflow, "stderr"): if hasattr(workflow, "stderr"):
workflow._set_stderr() workflow._set_stderr()
workflow.status = workflow.STATUS_STARTED
workflow.postprocess_status = workflow.STATUS_PENDING
workflow.start() workflow.start()
# Update the workflow in the cache # Update the workflow in the cache
self._dump_workflows([workflow]) self._dump_workflows([workflow])
......
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