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

Fixed problem with emit outside of condition when calls are in conditions

parent 4409a413
No related branches found
No related tags found
No related merge requests found
Pipeline #14462 failed with stage
in 2 minutes and 22 seconds
......@@ -84,6 +84,9 @@ class Block(Root):
tab+=block.get_calls_same_level()
tab+=block.get_calls_inside_level()
return tab
def get_all_calls_from_root(self):
return self.origin.get_all_calls_from_root()
#############
# CHANNELS
......
......@@ -287,6 +287,13 @@ class Executor(Nextflow_Building_Blocks):
for c in call.get_all_calls():
if(c.first_element_called.get_alias()==name):
tab.append(c)
#If there is no calls found then we search in all root
if(len(tab)==0):
for call in self.origin.get_all_calls_from_root():
#call.initialise()
for c in call.get_all_calls():
if(c.first_element_called.get_alias()==name):
tab.append(c)
return tab
else:
......
......@@ -928,6 +928,7 @@ class Operation(Executor):
index += 1
temporary_index = 1
new_body = ""
for origin in dico_origin_2_replace:
if(len(dico_origin_2_replace[origin])<=1):
for val in dico_origin_2_replace[origin]:
......@@ -937,23 +938,32 @@ class Operation(Executor):
code = code.replace(origin, val.simplify_code())
#Case there are mutiple origins then:
else:
#TODO -> fix this problem if you have the courage to -> see at what extend it is used
raise BioFlowInsightError("TODO (update): The output of a emit is ambiguous -> there are multiple instance where it exits")
#print(dico_origin_2_replace)
#for e in dico_origin_2_replace[origin]:
# print(e.get_all_conditions())
temporary_index+=1
#for o in self.origins:
# if(o.get_type()=="Call"):
# #If it's not a function -> then we rewrite it
# if(o.get_first_element_called().get_type()!="Function"):
# to_add.append(add_origin_equals(o, index))
# code = code.replace(o.get_code(get_OG=True), f"operation_{operation_id}_{index}")
# elif(o.get_type()=="Emitted"):
# code = code.replace(o.get_code(get_OG=True), o.simplify_code())
# index += 1
#For example
#if(){
# p1(ch1)
#} else {
# p1(ch2)
#}
#val = p1.out -> when wanting to rewrite this operation
calls = {}
temporary_channel = f"temporary_val_{id(self)}_{temporary_index}"
for e in dico_origin_2_replace[origin]:
try:
temp = calls[e.emitted_by]
except:
calls[e.emitted_by] = []
calls[e.emitted_by].append(e.simplify_code())
for c in calls:
#This is just one value
if(len(c.get_all_conditions())>1):
raise Exception("This shoudn't happen")
for condition in c.get_all_conditions():
new_body+=f"if({condition.get_value().strip()}) {{\n{temporary_channel} = {calls[c][0]}\n}}\n"
new_body+=temporary_channel
code = code.replace(origin, new_body)
temporary_index+=1
to_add.reverse()
for c in to_add:
code = f"{c}\n{code}"
......
......@@ -247,6 +247,11 @@ class Root(Nextflow_Building_Blocks):
all_executors = self.get_executors_same_level()+self.get_inside_executors()
for e in all_executors:
calls[e] = ''
def get_all_calls_from_root(self):
dico = {}
self.get_all_calls_in_subworkflow(calls=dico)
return list(dico.keys())
#############
......
......@@ -526,7 +526,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
return subs
def rewrite_and_initialise(self, code, processes_2_remove, render_graphs):
def rewrite_and_initialise(self, code, processes_2_remove, render_graphs, def_check_the_same = True):
temp_process_dependency_graph = self.graph.get_process_dependency_graph()
temp_spec_graph = self.graph.full_dico
......@@ -547,7 +547,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
self.initialise()
os.remove(temp_file)
self.graph.initialise(processes_2_remove = self.processes_2_remove)
if(not self.graph.check_if_process_dependendy_is_equivalent_to_other_without_subworkflows(temp_process_dependency_graph)):
if(def_check_the_same and not self.graph.check_if_process_dependendy_is_equivalent_to_other_without_subworkflows(temp_process_dependency_graph)):
if(render_graphs==True):
generate_graph(self.get_output_dir()/ "debug" /"spec_graph_OG", temp_spec_graph, render_graphs = True)
generate_graph(self.get_output_dir()/ "debug" /"spec_graph", self.graph.full_dico, render_graphs = True)
......@@ -720,11 +720,13 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
if(self.get_DSL()=="DSL1"):
code = self.convert_to_DSL2()
self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=render_graphs, def_check_the_same = False)
if(self.duplicate):
if(self.get_DSL()=="DSL2"):
code = self.simplify_workflow_code()
self.rewrite_and_initialise(code, self.processes_2_remove, render_graphs=render_graphs)
if(self.duplicate):
#DETERMING WHICH SUBWORKFLOWS ARE BROKEN WITH THE CLUSTER
......
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