Commit 7a989a68 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

reset / rerun from command line ok

parent da101903
......@@ -132,6 +132,14 @@ if __name__ == '__main__':
required=True, dest="workflow_id")
sub_parser.set_defaults(cmd_object="rerun")
# Add rerun workflow availability
sub_parser = subparsers.add_parser("reset", help="Reset a workflow component")
sub_parser.add_argument("--workflow-id", type=str, help="Which workflow should be used",
required=True, dest="workflow_id")
sub_parser.add_argument("--component-name", type=str, help="Which component should be reseted",
required=True, dest="component_name")
sub_parser.set_defaults(cmd_object="reset")
# Add rerun workflow availability
sub_parser = subparsers.add_parser("execution-graph", help="Display the workflow execution graph")
sub_parser.add_argument("--workflow-id", type=str, help="Which workflow should be considered",
......@@ -182,6 +190,8 @@ if __name__ == '__main__':
wfmanager.run_workflow(args["cmd_object"], args)
elif args["cmd_object"] == "rerun":
wfmanager.rerun_workflow(args["workflow_id"])
elif args["cmd_object"] == "reset":
wfmanager.reset_workflow_component(args["workflow_id"], args["component_name"])
elif args["cmd_object"] == "execution_graph":
workflow = wfmanager.get_workflow(args["workflow_id"])
print workflow.get_execution_graph()
......
......@@ -81,7 +81,11 @@ class Component(object):
else:
self.params_order.append(name)
self.__setattr__(name, new_param)
def reset(self):
for file in os.listdir(self.output_directory):
os.remove(os.path.join(self.output_directory, file))
def add_input_file_list(self, name, help, file_format="any", default=None, type="inputfile",
required=False, flag=None, group="default", display_name=None, add_to=None):
if default == None: default = []
......
......@@ -603,6 +603,19 @@ class Workflow(threading.Thread):
except: pass
return status
def reset_component(self, component_name):
# first reinit the step to the execution step
self.step = 1
found = False
for cpt in self.components:
if cpt.get_nameid() == component_name:
cpt.reset()
found = True
if not found:
sys.stderr.write("Impossible to reset component '" + component_name + "'! This one is not part of the workflow\n")
sys.exit(1)
self._serialize()
def makeflow_pretty_print_node(self, dag, node):
sys.stdout.write('{0:>10} {1} {2}\n'.format('NODE', node.id, node.symbol))
......
......@@ -89,6 +89,10 @@ class WorkflowsManager(object):
if hasattr(workflow, "stderr"):
workflow.set_stderr()
workflow.start()
def reset_workflow_component(self, workflow_id, component_name):
workflow = self.get_workflow(workflow_id)
workflow.reset_component(component_name)
def run_workflow(self, workflow_class, args, function="process"):
# Load all modules within the workflow module
......
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