Skip to content

Commit

Permalink
floe can print output per worker or all together
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Oct 16, 2024
1 parent af60de2 commit 94cc497
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/floe/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def run(args = ARGV)
create_workflow(workflow, opts[:context], input, credentials)
end

output_streams = create_loggers(workflows, opts[:segment_output])

logger.info("Checking #{workflows.count} workflows...")
ready = Floe::Workflow.wait(workflows, &:run_nonblock)
logger.info("Checking #{workflows.count} workflows...Complete - #{ready.count} ready")
Expand All @@ -35,6 +37,7 @@ def run(args = ARGV)
logger.info("===")
end

logger.info(output_streams[workflow].string) if output_streams[workflow]
logger.info(workflow.output)
end

Expand All @@ -59,6 +62,7 @@ def parse_options!(args)
opt :context, "JSON payload of the Context", :type => :string
opt :credentials, "JSON payload with Credentials", :type => :string
opt :credentials_file, "Path to a file with Credentials", :type => :string
opt :segment_output, "Segment output by each worker", :default => false

Floe::ContainerRunner.cli_options(self)

Expand Down Expand Up @@ -99,5 +103,17 @@ def create_workflow(workflow, context_payload, input, credentials)
context = Floe::Workflow::Context.new(context_payload, :input => input, :credentials => credentials)
Floe::Workflow.load(workflow, context)
end

def create_loggers(workflows, segment_output)
if workflows.size == 1 || !segment_output
# no extra work necessary
{}
else
workflows.each_with_object({}) do |workflow, h|
workflow.context.logger = Logger.new(output = StringIO.new)
h[workflow] = output
end
end
end
end
end

0 comments on commit 94cc497

Please sign in to comment.