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

wf.status becomes private

parent bcba1c2e
......@@ -63,7 +63,7 @@ class MINIWorkflow(object):
self.id = id
self.name = name
self.description = description
self.status = status
self._status = status
self.start_time = start_time
self.end_time = end_time
self.metadata = metadata
......@@ -84,7 +84,7 @@ class MINIWorkflow(object):
return self.errors
def get_status(self):
return self.status
return self._status
class Workflow(threading.Thread):
......@@ -118,8 +118,8 @@ class Workflow(threading.Thread):
self.makes = {}
self.globals = {}
self.options = Options()
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self._status = self.STATUS_STARTED
self._postprocess_status = self.STATUS_PENDING
self.start_time = None
self.end_time = None
self.__step = None
......@@ -645,7 +645,7 @@ class Workflow(threading.Thread):
msg = MIMEText(message, 'html')
me = froma
you = toa
if not subject: subject = "JFlow - Workflow #" + str(self.id) + " is " + self.status
if not subject: subject = "JFlow - Workflow #" + str(self.id) + " is " + self._status
msg['Subject'] = subject
msg['From'] = me
msg['To'] = you
......@@ -821,8 +821,8 @@ class Workflow(threading.Thread):
if self.__step == None:
self.start_time = time.time()
self.__step = 0
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self._status = self.STATUS_STARTED
self._postprocess_status = self.STATUS_PENDING
self.end_time = None
# if some args are provided, let's fill the parameters
self._set_parameters(self.args)
......@@ -833,7 +833,7 @@ class Workflow(threading.Thread):
self.pre_process()
self.__step = 1
except:
self.status = self.STATUS_FAILED
self._status = self.STATUS_FAILED
self.end_time = time.time()
raise
finally:
......@@ -843,12 +843,12 @@ class Workflow(threading.Thread):
try:
self.reseted_components = []
self.components = []
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self._status = self.STATUS_STARTED
self._postprocess_status = self.STATUS_PENDING
self._serialize()
self.wf_execution_wrapper()
except:
self.status = self.STATUS_FAILED
self._status = self.STATUS_FAILED
self.end_time = time.time()
self._serialize()
self._send_email()
......@@ -865,12 +865,12 @@ class Workflow(threading.Thread):
try:
self.reseted_components = []
self.components = []
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self._status = self.STATUS_STARTED
self._postprocess_status = self.STATUS_PENDING
self._serialize()
self.wf_execution_wrapper()
except:
self.status = self.STATUS_FAILED
self._status = self.STATUS_FAILED
self.end_time = time.time()
self._serialize()
self._send_email()
......@@ -882,12 +882,12 @@ class Workflow(threading.Thread):
# if post processing has ne been done yet
if self.__step == 3:
try:
self.postprocess_status = self.STATUS_STARTED
self._postprocess_status = self.STATUS_STARTED
self.post_process()
self.postprocess_status = self.STATUS_COMPLETED
self.status = self.STATUS_COMPLETED
self._postprocess_status = self.STATUS_COMPLETED
self._status = self.STATUS_COMPLETED
except:
self.postprocess_status = self.STATUS_FAILED
self._postprocess_status = self.STATUS_FAILED
raise
finally:
self.end_time = time.time()
......@@ -897,10 +897,21 @@ class Workflow(threading.Thread):
except Exception as e:
self._log(str(e), traceback=traceback.format_exc(chain=False))
utils.display_error_message(str(e))
def restart(self):
"""
@summary: Reruns incompleted steps.
@note: This method is asynchrone.
"""
if hasattr(self, "stderr"):
self._set_stderr()
self._status = self.STATUS_STARTED
self._postprocess_status = self.STATUS_PENDING
self.start()
def get_status(self):
"""
@summary: Update and return self.status.
@summary: Updates and returns self._status.
@return: [STATUS] the workflow status.
"""
try:
......@@ -912,15 +923,15 @@ class Workflow(threading.Thread):
log.parse()
make_states.append(log.state)
if len(self.reseted_components) > 0:
self.status = self.STATUS_RESETED
self._status = self.STATUS_RESETED
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: # Error in component execution
self.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._postprocess_status == self.STATUS_FAILED: # Error in postprocess
self._status = self.STATUS_FAILED
except: pass
return self.status
return self._status
def get_resource(self, resource):
return self.jflow_config_reader.get_resource(resource)
......@@ -984,7 +995,7 @@ class Workflow(threading.Thread):
if not found:
raise Exception("Impossible to reset component '" + component_name + "'! This one is not part of the workflow!")
self.reseted_components.append(component_name)
self.status = self.STATUS_RESETED
self._status = self.STATUS_RESETED
self._serialize()
def minimize(self):
......@@ -1054,7 +1065,7 @@ class Workflow(threading.Thread):
# create the DAG
nest.compile()
except Exception as e:
self.status = self.STATUS_FAILED
self._status = self.STATUS_FAILED
self.end_time = time.time()
self._serialize()
raise
......@@ -1066,7 +1077,7 @@ class Workflow(threading.Thread):
# close dag_file after execution to avoid nfs troubles
nest.dag_file.close()
except:
self.status = self.STATUS_FAILED
self._status = self.STATUS_FAILED
self.end_time = time.time()
self._serialize()
raise
......
......@@ -98,11 +98,7 @@ class WorkflowsManager(object):
def rerun_workflow(self, workflow_id):
workflow = self.get_workflow(workflow_id)
if hasattr(workflow, "stderr"):
workflow._set_stderr()
workflow.status = workflow.STATUS_STARTED
workflow.postprocess_status = workflow.STATUS_PENDING
workflow.start()
workflow.restart()
# Update the workflow in the cache
self._dump_workflows([workflow])
return 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