@@ -154,19 +154,6 @@ def accept(self, visitor: AnyVisitor) -> bool:
154154"""Utility to simplify code"""
155155
156156
157- def _remove_duplicated_node (nodes : List [FreExNode ]) -> List [FreExNode ]:
158- """return a copy of provided the list without duplicates, a duplicate is defined by its id"""
159- filtered_list = []
160- for n in nodes :
161- found = False
162- for in_list in filtered_list :
163- if n .id == in_list .id :
164- found = True
165- if not found :
166- filtered_list .append (n )
167- return filtered_list
168-
169-
170157class FreExGraph :
171158 """Execution Graph main class"""
172159
@@ -182,8 +169,6 @@ def __init__(self):
182169 @staticmethod
183170 def _make_node_id_with_fork (node_id : str , fork_id : str ) -> str :
184171 """make a unique id for the new fork"""
185- if node_id == root_node :
186- return node_id
187172 return f"{ node_id } ::{ fork_id } "
188173
189174 def add_nodes (self , nodes : List [AnyFreExNode ]) -> None :
@@ -339,21 +324,25 @@ def fork_from_node(
339324 id will be appended with the fork_id set on the forked_node. For this reason it is required to have a fork_id
340325 set on the forked_node.
341326
342- > It is the user responsibility to ensure that those id doesn't collide.
343-
344327 If the provided join_node doesn't exist, an exception is thrown.
345328 If a join node is provided, all node from the provided one until the join node is encountered are duplicated. if
346329 the join node is not encountered, duplicate node until leaf
347330
331+ warning:
332+ It is the user responsibility to ensure that those id doesn't collide.
333+
348334 side_note:
349335 ':' is used as a separator for the id and the fork_id to ensure a unique name. This is the reason why '::'
350336 is reserved and cannot be used.
351337
338+ raise Assertion failure:
339+ * if the node defined by forked_node.id doesn't exist in the graph.
340+ * if the forked_node doesn't contains a fork_id.
341+ * if a join_node is provided but does not exist.
342+
352343 :param forked_node: node to replace the fork one, its fork_id field has to be set
353- :param join_id: node to stop duplication (used for map_reduce)
354- :exception: Assertion failure in case that the node defined by forked_node.id doesn't exist in the graph or is a
355- GraphNode, or if the forked_node doesn't contains a fork_id. Assertion failure if a join_node is provided but
356- does not exist or that the join_node is not linking all last node to be forked.
344+ :param join_id: node to stop duplication (used for map_reduce) if encountered
345+
357346 """
358347 assert self ._graph .has_node (
359348 forked_node .id
@@ -365,10 +354,9 @@ def fork_from_node(
365354 join_id
366355 ), f"Error fork of node { forked_node .id } with join_id { join_id } : join_id node doesn't exist in graph "
367356
368- join_node_list = [join_id ] if join_id else []
369357 sub_graph , removed_parents = self .sub_graph (
370358 from_node_id = forked_node .id ,
371- to_nodes_id = join_node_list ,
359+ to_nodes_id = [ join_id ] if join_id else [] ,
372360 return_removed_parents = True ,
373361 )
374362 sub_graph ._graph .remove_node (root_node )
0 commit comments