From 61715f38dda28dd79add59fd8f7893b99cf4b9d3 Mon Sep 17 00:00:00 2001
From: George Marchment <georgemarchment@yahoo.fr>
Date: Wed, 19 Mar 2025 14:42:25 +0100
Subject: [PATCH] updated the link the emits of subworkflows and their uses
 outside -> basically emits like 'ch = value' and sub.out.ch ere not linked
 correctly

---
 src/operation.py   | 39 ++++++++++++++++++++++-----------------
 src/subworkflow.py |  7 +++++++
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/src/operation.py b/src/operation.py
index 7d2b11c..fbcb5a9 100644
--- a/src/operation.py
+++ b/src/operation.py
@@ -88,25 +88,30 @@ class Operation(Executor):
         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]
+                origin = self.origin
             else:
-                channel = Channel(name=name, origin=self.origin)
-                self.origin.takes_channels.append(channel)
+                origin = self.origin.root
+            
+            #First check that the channel is not defined at the same level
+            channels = origin.get_channels_from_name_same_level(name)
+            #Then check that the channel is defined in the below level
+            if(channels==[]):
+                channels = origin.get_channels_from_name_inside_level(name)
+            #Finally check if the channels is defined above
+            if(channels==[]):
+                channels = origin.get_channels_from_name_above_level(name)
+            if(channels==[]):
+                channels = 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=origin)
+                origin.add_channel(channel)
                 channels = [channel]
+            #else:
+            #    print(name)
+            #    channel = Channel(name=name, origin=self.origin)
+            #    self.origin.takes_channels.append(channel)
+            #    channels = [channel]
             
             for channel in channels:
                 self.origins.append(channel)
diff --git a/src/subworkflow.py b/src/subworkflow.py
index 0e0d1ad..1f8bb5e 100644
--- a/src/subworkflow.py
+++ b/src/subworkflow.py
@@ -307,6 +307,13 @@ class Subworkflow(Main):
             self.initialise_emit()
             
 
+    def get_all_executors_in_subworkflow(self):
+        dico = {}
+        self.root.get_all_executors_in_subworkflow(calls = dico)
+        for operation in self.emit:
+            dico[operation] = ""
+        return list(dico.keys())
+
     def get_structure(self, dico):
         super().get_structure(dico)
 
-- 
GitLab