diff --git a/src/workflow.py b/src/workflow.py index 35d9e9cacb729dc2133484d6ae33412ec63ddbb5..96c7f6d0f21695c72d03b9ca9da577eb947e38bf 100644 --- a/src/workflow.py +++ b/src/workflow.py @@ -419,10 +419,22 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen nb_2_select = int(alpha*len(processes_called)) sampled = random.sample(set(processes_called), nb_2_select) + + + def get_object(address): + address = int(re.findall(r"\dx\w+", address)[0], base=16) + return ctypes.cast(address, ctypes.py_object).value + + edges_create_cycles_names = [] + for e in edges_create_cycles: + n1, n2 = e + obj1, obj2 = get_object(n1), get_object(n2) + edges_create_cycles_names.append((obj1.get_alias(), obj2.get_alias())) + sampled_str = [] for s in sampled: - sampled_str.append(str(s)) - for e in edges_create_cycles: + sampled_str.append(s.get_alias()) + for e in edges_create_cycles_names: if(e[0] in sampled_str and e[1] in sampled_str): #So that means there are the 2 nodes which form the cycle edge in the relevant processes #-> it means we need to regenerated relevant processes @@ -788,6 +800,15 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen return match.group(1) return re.sub(f"(\w+)_GG_\d+", replacer, code) + def check_multiple_subworkflow(self): + seen= [] + for sub in self.get_subworkflows_called(): + if(sub.get_code() in seen): + raise BioFlowInsightError(f"The subworkflow '{sub.get_name()}' is called multiple times in the workflow, I cannot rewritte it. Try defining the workflow in a different way.", type="Rewrite Error") + else: + seen.append(sub.get_code()) + + #Method which rewrites the workflow follwong the user view #Conert workflow to user_view only makes sense when the option duplicate is activated -> otherwise is doesn't make sense + it makes the analysis way more complicated def convert_workflow_2_user_view(self, relevant_processes = [], render_graphs = True): @@ -814,6 +835,7 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen if(self.duplicate): #First check if there are any duplicate operations #That method is in the "get_order_execution_executors" method -> so we just run that first + self.check_multiple_subworkflow() self.get_order_execution_executors() if(self.get_DSL()=="DSL1"):