Skip to content
Snippets Groups Projects
Commit e81608e0 authored by George Marchment's avatar George Marchment
Browse files

Added optimisation for the analysis

parent eaa562b8
No related branches found
No related tags found
No related merge requests found
Pipeline #14675 failed with stage
in 3 minutes and 35 seconds
...@@ -84,11 +84,11 @@ class Graph(): ...@@ -84,11 +84,11 @@ class Graph():
node_id = get_node_id(self.full_dico, process) node_id = get_node_id(self.full_dico, process)
remove_node(self.full_dico, node_id) remove_node(self.full_dico, node_id)
#self.get_dependency_graph()
self.get_dependency_graph()
self.intialise_process_dependency_graph() self.intialise_process_dependency_graph()
#self.networkX_wo_operations = self.get_networkx_graph(self.dico_process_dependency_graph, self.networkX_wo_operations) #self.networkX_wo_operations = self.get_networkx_graph(self.dico_process_dependency_graph, self.networkX_wo_operations)
self.dico_flattened["nodes"] = [] self.dico_flattened["nodes"] = []
self.dico_flattened["edges"] = [] self.dico_flattened["edges"] = []
...@@ -159,7 +159,7 @@ class Graph(): ...@@ -159,7 +159,7 @@ class Graph():
generate_graph(self.get_output_dir()/'graphs'/filename, graph_dico_wo_orphan_operations(self.full_dico), label_edge=False, label_node=False, render_graphs = render_graphs) generate_graph(self.get_output_dir()/'graphs'/filename, graph_dico_wo_orphan_operations(self.full_dico), label_edge=False, label_node=False, render_graphs = render_graphs)
def intialise_process_dependency_graph(self): def intialise_process_dependency_graph(self):
self.intia_link_dico() self.intia_link_dico()
#Function that replicates the workflow's structure wo the operations in the nodes #Function that replicates the workflow's structure wo the operations in the nodes
...@@ -175,33 +175,64 @@ class Graph(): ...@@ -175,33 +175,64 @@ class Graph():
dico['subworkflows'][sub] = replicate_dico_process_dependency_graphs(dico_struct['subworkflows'][sub]) dico['subworkflows'][sub] = replicate_dico_process_dependency_graphs(dico_struct['subworkflows'][sub])
return dico return dico
dico = replicate_dico_process_dependency_graphs(self.full_dico) dico = replicate_dico_process_dependency_graphs(self.full_dico)
#This is a dictionnary which links every node to it's connected process #This is a dictionnary which links every node to it's connected process
#node_2_processes = copy.deepcopy(self.link_dico)
#already_searched = {}
#for nodeA in node_2_processes:
# already_searched[nodeA] = [nodeA]
#changed = True
#while(changed):
# changed = False
# for nodeA in node_2_processes:
# temp = node_2_processes[nodeA].copy()
# for give in node_2_processes[nodeA]:
# if(is_operation(give)):
# temp.remove(give)
# if(nodeA!=give and give not in already_searched[nodeA]):
# already_searched[nodeA] += give
# temp_temp = node_2_processes[give]
# for node_temp in already_searched[nodeA]:
# try:
# temp_temp.remove(node_temp)
# except:
# None
# temp+=temp_temp
# changed = True
# node_2_processes[nodeA] = list(set(temp))
#print(node_2_processes)
topological_order = topological_sort(self.link_dico)
#topological_order.reverse()
node_2_processes = copy.deepcopy(self.link_dico) node_2_processes = copy.deepcopy(self.link_dico)
already_searched = {} for i in [len(topological_order)-1-x for x in range(len(topological_order))]:
for nodeA in node_2_processes: updating = topological_order[i]
already_searched[nodeA] = [nodeA] for y in [len(topological_order)-1-x for x in range(len(topological_order))]:
changed = True if(y>i):
while(changed): fixed = topological_order[y]
changed = False if(is_operation(fixed)):
for nodeA in node_2_processes: if(fixed in node_2_processes[updating]):
temp = node_2_processes[nodeA].copy() node_2_processes[updating]+=node_2_processes[fixed].copy()
for give in node_2_processes[nodeA]: node_2_processes[updating] = list(set(node_2_processes[updating]))
if(is_operation(give)): tab = []
temp.remove(give) for give in node_2_processes[updating]:
if(nodeA!=give and give not in already_searched[nodeA]): if(is_process(give)):
already_searched[nodeA] += give tab.append(give)
temp_temp = node_2_processes[give] #if(is_operation(give)):
for node_temp in already_searched[nodeA]: # node_2_processes[updating].remove(give)
try: #else:
temp_temp.remove(node_temp) # print("**", give)
except: node_2_processes[updating] = tab
None
temp+=temp_temp
changed = True
node_2_processes[nodeA] = list(set(temp))
#Getting the dico of paths in the workflow #Getting the dico of paths in the workflow
path_from_process_to_other_processes = {} path_from_process_to_other_processes = {}
searching = True searching = True
...@@ -229,7 +260,6 @@ class Graph(): ...@@ -229,7 +260,6 @@ class Graph():
timeout+=1 timeout+=1
if(timeout>=constant.WHILE_UPPER_BOUND): if(timeout>=constant.WHILE_UPPER_BOUND):
raise BioFlowInsightError(f"The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to create the dico of paths.", type="Unable to create the dico of paths") raise BioFlowInsightError(f"The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to create the dico of paths.", type="Unable to create the dico of paths")
#%2x%2x%2x #%2x%2x%2x
colours = ["#ffbe00", "#0055c8", "#6e6e00", "#a0006e", "#ff5a00", "#82dc73", "#ff82b4", "#d282be", "#d2d200", "#dc9600", "#6e491e", "#00643c", "#82c8e6", "#640082"] colours = ["#ffbe00", "#0055c8", "#6e6e00", "#a0006e", "#ff5a00", "#82dc73", "#ff82b4", "#d282be", "#d2d200", "#dc9600", "#6e491e", "#00643c", "#82c8e6", "#640082"]
...@@ -285,6 +315,7 @@ class Graph(): ...@@ -285,6 +315,7 @@ class Graph():
for sub in dico['subworkflows']: for sub in dico['subworkflows']:
add_edges_flow_edges(dico["subworkflows"][sub], added_in_condition) add_edges_flow_edges(dico["subworkflows"][sub], added_in_condition)
#if(self.workflow.get_duplicate_status()): #if(self.workflow.get_duplicate_status()):
if(False):#Right now not generating the colored edges if(False):#Right now not generating the colored edges
checking_conditions = True checking_conditions = True
...@@ -304,7 +335,6 @@ class Graph(): ...@@ -304,7 +335,6 @@ class Graph():
else: else:
add_edges(dico, condition="", checking_conditions=False) add_edges(dico, condition="", checking_conditions=False)
self.dico_process_dependency_graph = dico self.dico_process_dependency_graph = dico
with open(f"{self.get_output_dir()}/graphs/process_dependency_graph.json", 'w') as output_file : with open(f"{self.get_output_dir()}/graphs/process_dependency_graph.json", 'w') as output_file :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment