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

Fixed bug with pipe operators when rewritting (within operations and calls) ->...

Fixed bug with pipe operators when rewritting (within operations and calls) -> using the modified code instead of the OG
parent 61715f38
No related branches found
No related tags found
No related merge requests found
Pipeline #14476 failed with stage
in 2 minutes and 7 seconds
...@@ -50,7 +50,13 @@ class Main(Nextflow_Building_Blocks): ...@@ -50,7 +50,13 @@ class Main(Nextflow_Building_Blocks):
for exe in sorted_executor_2_length: for exe in sorted_executor_2_length:
if(exe.get_type()=="Call" or exe.get_type()=="Operation"): if(exe.get_type()=="Call" or exe.get_type()=="Operation"):
code = code.replace(exe.get_code(get_OG = True), exe.simplify_code(), 1) old = exe.get_code(get_OG = True)
new = exe.simplify_code()
if(new!=old):
temp = code
code = code.replace(exe.get_code(get_OG = True), exe.simplify_code(), 1)
if(temp==code):
raise Exception("This shouldn't happen the Exeutor was not replaced")
else: else:
raise Exception("This shouldn't happen") raise Exception("This shouldn't happen")
return code return code
......
...@@ -80,6 +80,39 @@ class Operation(Executor): ...@@ -80,6 +80,39 @@ class Operation(Executor):
tab+=o.get_elements_called() tab+=o.get_elements_called()
return tab return tab
#def add_origin_channel(self, name):
# from .channel import Channel
# #Check that the name is not the list of illegal words
# #and Check that the thing extarcted is not WorkflowNameFile like 'WorkflowHgtseq' in nf-core/hgtseq
# if(name not in constant.ERROR_WORDS_ORIGINS):# and name.lower()!=f"workflow{self.get_name_file().lower()}"):
# #channel = Channel(name=name, origin=self.origin)
# if(self.origin.get_type()!="Subworkflow"):
# #First check that the channel is not defined at the same level
# channels = self.origin.get_channels_from_name_same_level(name)
# #Then check that the channel is defined in the below level
# if(channels==[]):
# channels = self.origin.get_channels_from_name_inside_level(name)
# #Finally check if the channels is defined above
# if(channels==[]):
# channels = self.origin.get_channels_from_name_above_level(name)
# if(channels==[]):
# channels = self.origin.get_channels_from_name_other_blocks_on_same_level(name)
# #If it still doesn't exist -> we create it
# if(channels==[]):
# channel = Channel(name=name, origin=self.origin)
# self.origin.add_channel(channel)
# channels = [channel]
# else:
# channel = Channel(name=name, origin=self.origin)
# self.origin.takes_channels.append(channel)
# channels = [channel]
#
# for channel in channels:
# self.origins.append(channel)
# #channel.initialise()
# channel.add_sink(self)
def add_origin_channel(self, name): def add_origin_channel(self, name):
from .channel import Channel from .channel import Channel
...@@ -890,7 +923,12 @@ class Operation(Executor): ...@@ -890,7 +923,12 @@ class Operation(Executor):
#Method that rewrites operations to simplify it -> decompose it into multiple line -> to be able to manipulate the calls in a easier way #Method that rewrites operations to simplify it -> decompose it into multiple line -> to be able to manipulate the calls in a easier way
def simplify_code(self): def simplify_code(self):
code = self.get_code(get_OG=True) code = self.get_code(replace_calls =False, clean_pipe=True)
#Remove "emit:" and "takes:" for the subworkklfow inputs and outputs
if(code[:6] in ["emit: ", "take: "]):
code = code[6:]
code = code.strip()
#code = self.get_code(get_OG=True)
index = 1 index = 1
operation_id = str(self)[-7:-2] operation_id = str(self)[-7:-2]
...@@ -907,17 +945,18 @@ class Operation(Executor): ...@@ -907,17 +945,18 @@ class Operation(Executor):
to_add = [] to_add = []
dico_origin_2_replace = {} dico_origin_2_replace = {}
for o in self.origins: for o in self.origins:
OG_code = o.get_code(get_OG=True)
try: try:
tmp = dico_origin_2_replace[o.get_code(get_OG=True)] tmp = dico_origin_2_replace[OG_code]
except: except:
dico_origin_2_replace[o.get_code(get_OG=True)] = [] dico_origin_2_replace[OG_code] = []
if(o.get_type()=="Call"): if(o.get_type()=="Call"):
#If it's not a function -> then we rewrite it #If it's not a function -> then we rewrite it
if(o.get_first_element_called().get_type()!="Function"): if(o.get_first_element_called().get_type()!="Function"):
to_add.append(add_origin_equals(o, index)) to_add.append(add_origin_equals(o, index))
dico_origin_2_replace[o.get_code(get_OG=True)].append(f"operation_{operation_id}_{index}") dico_origin_2_replace[OG_code].append(f"operation_{operation_id}_{index}")
elif(o.get_type()=="Emitted"): elif(o.get_type()=="Emitted"):
dico_origin_2_replace[o.get_code(get_OG=True)].append(o) dico_origin_2_replace[OG_code].append(o)
index += 1 index += 1
temporary_index = 1 temporary_index = 1
......
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