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

Propagate foreach-stack in all tasks #2074

Merged
merged 1 commit into from
Oct 3, 2024
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
7 changes: 7 additions & 0 deletions metaflow/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def _init_foreach(self, step_name, join_type, inputs, split_index):
# 2) join - pop the topmost frame from the stack
# 3) step following a split - push a new frame in the stack

# We have a non-modifying case (case 4)) where we propagate the
# foreach-stack information to all tasks in the foreach. This is
# then used later to write the foreach-stack metadata for that task

# case 1) - reset the stack
if step_name == "start":
self.flow._foreach_stack = []
Expand Down Expand Up @@ -264,6 +268,9 @@ def lineage():
stack = inputs[0]["_foreach_stack"]
stack.append(frame)
self.flow._foreach_stack = stack
# case 4) - propagate in the foreach nest
elif "_foreach_stack" in inputs[0]:
self.flow._foreach_stack = inputs[0]["_foreach_stack"]

def _clone_flow(self, datastore):
x = self.flow.__class__(use_cli=False)
Expand Down
Loading