Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error catching for recursive tree #14

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions spockflow/components/tree/v1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,15 @@ def _identify_loops(self, *nodes: "ConditionedNode"):
def _remove_nodes_from_end(*nodes: "ConditionedNode", child_tree: ChildTree):
# Not the most pythonic method can maybe be improved
# Done to remove elements in the order they were added
nodes_to_remove = list(nodes)
nodes_to_remove = set(map(id, list(nodes)))
last_el_idx = len(child_tree.nodes) - 1
for rev_i, node in enumerate(reversed(child_tree.nodes)):
i = last_el_idx - rev_i
if node in nodes_to_remove:
if id(node) in nodes_to_remove:
child_tree.nodes.pop(i)
if len(nodes_to_remove) <= 0:
return True
nodes_to_remove.discard(id(node))
if len(nodes_to_remove) <= 0:
return True
return False

def copy(self, deep=True):
Expand Down
Loading