Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/mars/execution_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def record(step_name, output)
@current_input = output
end

def fork(input: current_input)
self.class.new(input: input, global_state: global_state)
def fork(input: current_input, state: {})
self.class.new(input: input, global_state: global_state.merge(state))
end

def merge(child_contexts)
Expand Down
5 changes: 3 additions & 2 deletions lib/mars/workflows/parallel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def aggregate_results(results)
def execute_steps(context, errors, child_contexts)
Async do |workflow|
tasks = steps.map do |step|
child_ctx = context.fork
child_ctx = context.fork(state: step.state)
child_contexts << child_ctx

workflow.async do
Expand All @@ -54,7 +54,8 @@ def workflow_step(step, child_ctx)
step.run_before_hooks(child_ctx)

step_input = step.formatter.format_input(child_ctx)
result = step.run(step_input)
child_ctx.current_input = step_input
result = step.run(child_ctx)

if result.is_a?(Halt)
step.run_after_hooks(child_ctx, result)
Expand Down
3 changes: 2 additions & 1 deletion lib/mars/workflows/sequential.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def run(input)
step.run_before_hooks(context)

step_input = step.formatter.format_input(context)
result = step.run(step_input)
step_context = context.fork(input: step_input, state: step.state)
result = step.run(step_context)

if result.is_a?(Halt)
if result.global?
Expand Down
Loading