Commit b1d3e27c authored by Jerome Mariette's avatar Jerome Mariette
Browse files

remove unused inputs from the graph

parent c668371a
...@@ -335,24 +335,38 @@ class Workflow(threading.Thread): ...@@ -335,24 +335,38 @@ class Workflow(threading.Thread):
def get_execution_graph(self): def get_execution_graph(self):
gr = digraph() gr = digraph()
# build a all_nodes table to store all nodes
all_nodes = {}
for ioparameter in self.__dict__.values(): for ioparameter in self.__dict__.values():
if issubclass(ioparameter.__class__, InputFile): if issubclass(ioparameter.__class__, InputFile):
gr.add_node(ioparameter.name) gr.add_node(ioparameter.name)
gr.add_node_attribute(ioparameter.name, self.INPUT_GRAPH_LABEL) gr.add_node_attribute(ioparameter.name, self.INPUT_GRAPH_LABEL)
all_nodes[ioparameter.name] = None
elif issubclass(ioparameter.__class__, InputFileList): elif issubclass(ioparameter.__class__, InputFileList):
gr.add_node(ioparameter.name) gr.add_node(ioparameter.name)
gr.add_node_attribute(ioparameter.name, self.INPUTS_GRAPH_LABEL) gr.add_node_attribute(ioparameter.name, self.INPUTS_GRAPH_LABEL)
all_nodes[ioparameter.name] = None
for cpt in self.components: for cpt in self.components:
gr.add_node(cpt.get_nameid()) gr.add_node(cpt.get_nameid())
gr.add_node_attribute(cpt.get_nameid(), self.COMPONENT_GRAPH_LABEL) gr.add_node_attribute(cpt.get_nameid(), self.COMPONENT_GRAPH_LABEL)
all_nodes[cpt.get_nameid()] = None
for cpt in self.components: for cpt in self.components:
for ioparameter in cpt.__dict__.values(): for ioparameter in cpt.__dict__.values():
if issubclass( ioparameter.__class__, InputFile ) or issubclass( ioparameter.__class__, InputFileList): if issubclass( ioparameter.__class__, InputFile ) or issubclass( ioparameter.__class__, InputFileList):
for parent in ioparameter.parent_linkTrace_nameid: for parent in ioparameter.parent_linkTrace_nameid:
try: gr.add_edge((parent, ioparameter.linkTrace_nameid)) try: gr.add_edge((parent, ioparameter.linkTrace_nameid))
except: pass except: pass
# check if all nodes are connected
for edge in gr.edges():
if all_nodes.has_key(edge[0]):
del all_nodes[edge[0]]
if all_nodes.has_key(edge[1]):
del all_nodes[edge[1]]
# then remove all unconnected nodes: to delete inputs not defined by the user
for orphan_node in all_nodes.keys():
gr.del_node(orphan_node)
return gr return gr
def set_stderr(self): def set_stderr(self):
if hasattr(self, "stderr") and self.stderr is not None: if hasattr(self, "stderr") and self.stderr is not None:
os.rename( self.stderr, os.path.join(self.directory, str(time.time()) + "wf_stderr.old") ) os.rename( self.stderr, os.path.join(self.directory, str(time.time()) + "wf_stderr.old") )
......
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