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

user view correctly implmented

parent 1118ddbf
No related branches found
No related tags found
No related merge requests found
Pipeline #14043 passed with stage
in 2 minutes and 18 seconds
......@@ -294,9 +294,10 @@ class Graph():
self.initialise_flattened_dico(self.dico_process_dependency_graph)
dico = self.dico_flattened
relev_user_view_builder(dico, relevant_modules=relevant_processes)
#generate_graph(self.get_output_dir()/'graphs'/"temp", dico, label_edge=True, label_node=True, render_graphs = render_graphs)
user_view = relev_user_view_builder(dico, relevant_modules=relevant_processes)
with open(self.get_output_dir()/ "graphs/user_view.json", 'w') as output_file :
json.dump(user_view, output_file, indent=4)
generate_graph(self.get_output_dir()/'graphs'/"user_view", user_view, label_edge=True, label_node=True, render_graphs = render_graphs)
......
......@@ -515,6 +515,20 @@ def get_names_tab(dico, tab):
final.append(names)
return final
def get_name_new_node(new_nodes, relevant_modules):
for r in relevant_modules:
if([r] in new_nodes):
return r
#Arbitrary choice of choosing the name with the longest name
longest_name = new_nodes[0][0]
for name in new_nodes:
if(len(longest_name)<len(name[0])):
longest_name = name[0]
return longest_name
def check_same_elements(list1, list2):
return set(list1)==set(list2)
def relev_user_view_builder(dico, relevant_modules):
R = []
for r in relevant_modules:
......@@ -526,7 +540,7 @@ def relev_user_view_builder(dico, relevant_modules):
for out in outputs:
dico["edges"].append({'A':out, 'B':'output'})
#TODO remove this -> it's to replicate the one in the algortihm demo
dico["edges"].append({'A':get_id_from_name(dico, "M5")[0], 'B':'output'})
#dico["edges"].append({'A':get_id_from_name(dico, "M5")[0], 'B':'output'})
for input in inputs:
dico["edges"].append({'A':"input", 'B':input})
U = []
......@@ -560,15 +574,13 @@ def relev_user_view_builder(dico, relevant_modules):
#Line 10
for r in R:
M = set([r]).union(set(in_r[r])).union(set(out_r[r]))
U = set(U).union(M)
U.append(list(M))
#Step 2
NRC = []
for n in set(N) - set(R):
if(marked_statues[n] == 'unmarked'):
def condition_line_13(NRC, n, dico, R, inputs, outputs):
def check_same_elements(list1, list2):
return set(list1)==set(list2)
#Ms = generate_subsets(NRC)
for i in range(len(NRC)):
M = NRC[i]
if(check_same_elements(rPredM(M, dico, R, ["input"]), rPred(n, dico, R, ["input"])) and
......@@ -584,9 +596,8 @@ def relev_user_view_builder(dico, relevant_modules):
else:
M = [n]
NRC.append(M)
print(get_names_tab(dico, NRC))
#print(get_names_tab(dico, NRC))
1/0
#Step 3
changes_in_NRC = True
while(changes_in_NRC):
......@@ -604,19 +615,47 @@ def relev_user_view_builder(dico, relevant_modules):
#Line 23
condition_left, condition_right = True, True
for n in V_plus:
if(rPred(n, dico, R, ['input'])!=rPredM(M, dico, R, ["input"])):
if(not check_same_elements(rPred(n, dico, R, ['input']), rPredM(M, dico, R, ["input"]))):
condition_left = False
for n in V_minus:
if(rSucc(n, dico, R, ['output'])!=rSuccM(M, dico, R, ["output"])):
if(not check_same_elements(rSucc(n, dico, R, ['output']), rSuccM(M, dico, R, ["output"]))):
condition_left = False
if(condition_left and condition_right):
NRC.remove(M1)
NRC.remove(M2)
NRC.append(M)
changes_in_NRC = True
tab = list(U)+NRC
print(tab)
print(get_names_tab(dico, tab))
return
new_nodes = list(U)+NRC
new_dico = {}
new_dico["nodes"] = []
new_dico["edges"] = []
new_dico["subworkflows"] = []
for i in range(len(new_nodes)):
new_nodes[i].sort()
node = {"id": ''.join(new_nodes[i]).replace('<', '').replace('>', ''),
"name": get_name_new_node(get_names_tab(dico, new_nodes[i]), relevant_modules),
"shape": "ellipse",
"xlabel": "",
"fillcolor": ""}
new_dico["nodes"].append(node)
added_edges = []
for edge in dico["edges"]:
for i in range(len(new_dico["nodes"])):
nA = new_dico["nodes"][i]
for y in range(len(new_dico["nodes"])):
if(i!=y):
nB = new_dico["nodes"][y]
edge_string = f'{nA["id"]}->{nB["id"]}'
if(edge["A"].replace('<', '').replace('>', '') in nA["id"]
and edge["B"].replace('<', '').replace('>', '') in nB["id"]
and edge_string not in added_edges):#So we don't have dupliacte edges
new_dico["edges"].append({
"A": nA["id"],
"B": nB["id"],
"label": ""
})
added_edges.append(edge_string)
return new_dico
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