Class: Roast::Workflow::WorkflowRunner
- Inherits:
-
Object
- Object
- Roast::Workflow::WorkflowRunner
- Defined in:
- lib/roast/workflow/workflow_runner.rb
Overview
Handles running workflows for files/targets and orchestrating execution
Instance Method Summary collapse
-
#execute_workflow(workflow) ⇒ Object
Public for backward compatibility with tests.
-
#initialize(configuration, options = {}) ⇒ WorkflowRunner
constructor
A new instance of WorkflowRunner.
- #run_for_files(files) ⇒ Object
- #run_for_targets ⇒ Object
- #run_targetless ⇒ Object
Constructor Details
#initialize(configuration, options = {}) ⇒ WorkflowRunner
7 8 9 10 11 12 |
# File 'lib/roast/workflow/workflow_runner.rb', line 7 def initialize(configuration, = {}) @configuration = configuration @options = @output_handler = OutputHandler.new @execution_context = WorkflowExecutionContext.new end |
Instance Method Details
#execute_workflow(workflow) ⇒ Object
Public for backward compatibility with tests
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/roast/workflow/workflow_runner.rb', line 81 def execute_workflow(workflow) steps = @configuration.steps # Handle replay option if @options[:replay] replay_handler = ReplayHandler.new(workflow) steps = replay_handler.process_replay(steps, @options[:replay]) end # Execute the steps executor = WorkflowExecutor.new(workflow, @configuration.config_hash, @configuration.context_path) executor.execute_steps(steps) # Save outputs @output_handler.save_final_output(workflow) @output_handler.write_results(workflow) $stderr.puts "🔥🔥🔥 ROAST COMPLETE! 🔥🔥🔥" end |
#run_for_files(files) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/roast/workflow/workflow_runner.rb', line 14 def run_for_files(files) if @configuration.has_target? $stderr.puts "WARNING: Ignoring target parameter because files were provided: #{@configuration.target}" end # Execute pre-processing steps once before any targets if @configuration.pre_processing.any? $stderr.puts "Running pre-processing steps..." run_pre_processing end # Execute main workflow for each file files.each do |file| $stderr.puts "Running workflow for file: #{file}" run_single_workflow(file.strip) end # Execute post-processing steps once after all targets if @configuration.post_processing.any? $stderr.puts "Running post-processing steps..." run_post_processing end end |
#run_for_targets ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/roast/workflow/workflow_runner.rb', line 38 def run_for_targets # Split targets by line and clean up target_lines = @configuration.target.lines.map(&:strip).reject(&:empty?) # Execute pre-processing steps once before any targets if @configuration.pre_processing.any? $stderr.puts "Running pre-processing steps..." run_pre_processing end # Execute main workflow for each target target_lines.each do |file| $stderr.puts "Running workflow for file: #{file}" run_single_workflow(file) end # Execute post-processing steps once after all targets if @configuration.post_processing.any? $stderr.puts "Running post-processing steps..." run_post_processing end end |
#run_targetless ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/roast/workflow/workflow_runner.rb', line 61 def run_targetless $stderr.puts "Running targetless workflow" # Execute pre-processing steps if @configuration.pre_processing.any? $stderr.puts "Running pre-processing steps..." run_pre_processing end # Execute main workflow run_single_workflow(nil) # Execute post-processing steps if @configuration.post_processing.any? $stderr.puts "Running post-processing steps..." run_post_processing end end |