From 5c478d8ee9a6483541c253cba56c234c9c947398 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Wed, 19 Feb 2025 13:40:54 +0100 Subject: [PATCH] Removed emits in paramters when simplify code + slighly optimised user view --- src/call.py | 4 +++- src/outils_graph.py | 33 ++++++++++++++++++++++----------- src/process.py | 2 +- src/workflow.py | 10 +++------- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/call.py b/src/call.py index 19fdfc4..ad58672 100644 --- a/src/call.py +++ b/src/call.py @@ -98,7 +98,9 @@ class Call(Executor): raise Exception("This shouldn't happen") None elif(param.get_type()=="Emitted"): - None + code = code.replace(param.get_code(get_OG=True), param_new_name) + new_bit = f"{param_new_name} = {param.get_code(get_OG=True)}" + code = code.replace(tag_to_add, f"{tag_to_add}\n{new_bit}") else: raise Exception("This shouldn't happen") index+=1 diff --git a/src/outils_graph.py b/src/outils_graph.py index 01eb94f..9dad12f 100644 --- a/src/outils_graph.py +++ b/src/outils_graph.py @@ -587,12 +587,17 @@ def nr_path_pred(r, n, dico, R): return True return False - +#Added a dico so it knows what it's already searched +dico_rSucc = {} def rSucc(n, dico, R, outputs): - tab = [] - for r in set(R).union(set(outputs)): - if(nr_path_succ(n, r, dico, R+list(outputs))): - tab.append(r) + try: + tab = dico_rSucc[n] + except: + tab = [] + for r in set(R).union(set(outputs)): + if(nr_path_succ(n, r, dico, R+list(outputs))): + tab.append(r) + dico_rSucc[n] = tab return tab def rSuccM(M, dico, R, outputs): @@ -601,11 +606,17 @@ def rSuccM(M, dico, R, outputs): tab += rSucc(n, dico, R, outputs) return list(set(tab)) +#Added a dico so it knows what it's already searched +dico_rPred = {} def rPred(n, dico, R, inputs): - tab = [] - for r in set(R).union(set(inputs)): - if(nr_path_pred(r, n, dico, R+list(inputs))): - tab.append(r) + try: + tab = dico_rPred[n] + except: + tab = [] + for r in set(R).union(set(inputs)): + if(nr_path_pred(r, n, dico, R+list(inputs))): + tab.append(r) + dico_rPred[n] = tab return tab def rPredM(M, dico, R, inputs): @@ -773,7 +784,7 @@ def relev_user_view_builder(dico_param, relevant_modules): M = [n] NRC.append(M) - + #Step 3 changes_in_NRC = True while(changes_in_NRC): @@ -806,7 +817,7 @@ def relev_user_view_builder(dico_param, relevant_modules): break if(changes_in_NRC): break - + new_nodes = list(U)+NRC new_dico = {} diff --git a/src/process.py b/src/process.py index a6317a7..7d689dd 100644 --- a/src/process.py +++ b/src/process.py @@ -398,7 +398,7 @@ class Process(Nextflow_Building_Blocks): self.name = self.name.replace('"', '') if(self.alias==""): self.alias = self.name - self.printed_name = self.name + self.printed_name = self.alias def get_name_to_print(self): return self.printed_name diff --git a/src/workflow.py b/src/workflow.py index 777d01a..eaae290 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -452,12 +452,12 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Adding processes into code for p in processes: - if(p.get_code() not in code): + if(p.get_code_with_alias() not in code): code = code.replace(process_section, '\n'+p.get_code_with_alias()+'\n'+process_section) #Adding subworkflows into code for sub in subworkflows: - if(sub.get_code() not in code): + if(sub.get_code_with_alias() not in code): code = code.replace(subworkflow_section, subworkflow_section+'\n'+sub.get_code_with_alias()+'\n') #Adding functions into code @@ -484,7 +484,6 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen code = self.get_first_file().get_code() code, ankers = self.write_workflow_into_one_file() all_executors = self.get_workflow_main().get_all_executors_in_workflow() - #We do this so that the longest operation and calls are rewritten first in the code -> to avoid problems executor_2_length = {} for e in all_executors: @@ -661,15 +660,12 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen if(self.duplicate): code = self.simplify_workflow_code() - print(code) self.rewrite_and_initialise(code) #Get the clusters and the code self.check_relevant_processes_in_workflow(relevant_processes) - print("started Generating first user view") self.generate_user_view(relevant_processes = relevant_processes, processes_2_remove = []) clusters = self.graph.get_clusters_from_user_view() - print("Generated first user view") #DETERMING WHICH SUBWORKFLOWS ARE BROKEN WITH THE CLUSTER #Creating the clusters with calls instead of processes or subworkflows @@ -735,7 +731,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen #Get the clusters and the code self.generate_user_view(relevant_processes = relevant_processes, processes_2_remove = []) clusters = self.graph.get_clusters_from_user_view() - print("Generated second user view") + #Get the clsuters with the corresponding operations inside #for i in range(len(clusters)): -- GitLab