From 0d92a6ada038f67d21577ae64ac5805d726083b0 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Wed, 7 May 2025 15:14:56 +0200
Subject: [PATCH] Fix small bug in the case the process dependency graph is not
 connexe

---
 src/graph.py    | 6 ++++++
 src/workflow.py | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/src/graph.py b/src/graph.py
index d132cd5..a06890f 100644
--- a/src/graph.py
+++ b/src/graph.py
@@ -320,6 +320,7 @@ class Graph():
             
         
         #if(self.workflow.get_duplicate_status()):
+        #    print("here")
         if(False):#Right now not generating the colored edges
             checking_conditions = True
             most_influential_conditions = self.workflow.get_most_influential_conditions()
@@ -813,6 +814,11 @@ class Graph():
     #    with open(self.get_output_dir() / "graphs/metadata_graph_wo_operations.json", 'w') as output_file :
     #        json.dump(dico, output_file, indent=4)
 
+    def get_number_weakly_connected_components_in_process_dependency_graph(self):
+        G = self.get_networkx_graph(self.dico_process_dependency_graph, None)
+        weakly_connected_components = list(nx.weakly_connected_components(G))
+        return len(weakly_connected_components)
+
     def get_topogical_order(self, clusters):
         #if(self.get_process_dependency_graph_dico()=={}):
         #    self.intialise_process_dependency_graph()  
diff --git a/src/workflow.py b/src/workflow.py
index bce20cb..bb2575f 100644
--- a/src/workflow.py
+++ b/src/workflow.py
@@ -1207,6 +1207,11 @@ George Marchment, Bryan Brancotte, Marie Schmit, Frédéric Lemoine, Sarah Cohen
                 else:
                     #This means that the subworkflow is broken
                     broken_subworkflows.append(sub)
+            if(broken_subworkflows==[]):
+                #TODO need to update that so that the rewritte is done locally in the subworkflows and not at the level of the entire workflow
+                #See x-kiana/nextflow_pipeline for a good example
+                if(self.graph.get_number_weakly_connected_components_in_process_dependency_graph()>1):
+                    return list(subworkflow_2_executors.keys())
             return broken_subworkflows
             
         #Get the clusters and the code
-- 
GitLab