From 67b931258e8df30331576cc45fef5826b79b99ca Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Fri, 25 Apr 2025 09:54:06 +0200 Subject: [PATCH] Updated the rewrite of the operations (reduce map) + added view into that group --- src/code_.py | 8 +++++--- src/constant.py | 5 +++-- src/graph.py | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/code_.py b/src/code_.py index cc2bc82..fb34001 100644 --- a/src/code_.py +++ b/src/code_.py @@ -142,10 +142,11 @@ class Code: while(searching and timeout<constant.WHILE_UPPER_BOUND): searching = False #TODO -> do the same with flatMap -> 668 - for word in ["map", "flatMap"]: + for word in ["map", "flatMap", "view"]: for end_char in ['{', '\(']: pattern = fr"(\.|\|)\s*"+word+r"\s*"+end_char for match in re.finditer(pattern, code): + connector = match.group(1) start_map, end = match.span(0) if(end_char=="{"): end_map = extract_curly(code, end) @@ -158,7 +159,7 @@ class Code: self.add_map_element(old, new) old_code = code[start_map:end_map] - new_code = f".{word}_modified {{ {new} }}" + new_code = f"{connector}{word}_modified {{ {new} }}" code = code.replace(old_code, new_code) searching = True @@ -166,13 +167,14 @@ class Code: break #For reduce for match in re.finditer(r"(\.|\|)\s*reduce[^{]+{", code): + connector = match.group(1) start_map, end = match.span(0) end_map = extract_curly(code, end) old = code[end:end_map-1] new = f"¤{id(self)}_{index}¤" self.add_map_element(old, new) old_code = code[start_map:end_map] - new_code = f".{word}_modified {{ {new} }}" + new_code = f"{connector}reduce_modified {{ {new} }}" code = code.replace(old_code, new_code) searching = True index+=1 diff --git a/src/constant.py b/src/constant.py index 8f32dbe..a5cd310 100644 --- a/src/constant.py +++ b/src/constant.py @@ -15,12 +15,13 @@ ILLEGAL_IMPORTS = ["groovy", "java"] LIST_AS = ["as ", "As ", "AS ", "aS "] LIST_OPERATORS = ["distinct", "filter", "first", "last", "randomSample", "take", "unique", - "until","buffer","collate","collect","flatten","flatMap", "flatMap_modified","groupBy","groupTuple","map","map_modified","reduce","toList","toSortedList","transpose", + "until","buffer","collate","collect","flatten","flatMap","groupBy","groupTuple","map","toList","toSortedList","transpose", "splitCsv","splitFasta","splitFastq","splitText", "cross","collectFile","combine","concat","join","merge","mix","phase","spread","tap", "branch","choice","multiMap","into","separate","tap", "count","countBy","min","max","sum","toInteger", - "close","dump","ifEmpty","print","println","set","view", + "close","dump","ifEmpty","print","println","set","view", + "map_modified","reduce_modified", "flatMap_modified", "view_modified", #The articifiel operations "empty", "of", "fromPath", "fromList", "subscribe", "value", "from"]#This last line is added by me:) TOOLS = [ diff --git a/src/graph.py b/src/graph.py index 18b5464..5e22b22 100644 --- a/src/graph.py +++ b/src/graph.py @@ -233,7 +233,8 @@ class Graph(): add_edges(dico["subworkflows"][sub], condition, checking_conditions, index=index) return checking_conditions - if(self.workflow.get_duplicate_status()): + #if(self.workflow.get_duplicate_status()): + if(False):#Right now not generating the colored edges checking_conditions = True most_influential_conditions = self.workflow.get_most_influential_conditions() list_most_influential_conditions = list(most_influential_conditions.keys()) -- GitLab