Class: Paraduct::ParallelRunner
- Inherits:
-
Object
- Object
- Paraduct::ParallelRunner
- Defined in:
- lib/paraduct/parallel_runner.rb
Class Method Summary collapse
-
.perform_all(script, product_variables) ⇒ Paraduct::TestResponse
run script with arguments.
Class Method Details
.perform_all(script, product_variables) ⇒ Paraduct::TestResponse
run script with arguments
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/paraduct/parallel_runner.rb', line 9 def self.perform_all(script, product_variables) test_response = Paraduct::TestResponse.new base_job_dir = Paraduct.config.work_dir FileUtils.mkdir_p(base_job_dir) unless base_job_dir.exist? Paraduct.logger.info <<-EOS ====================================================== START matrix test EOS pool = Thread.pool(Paraduct.config.max_threads) begin product_variables.each_with_index do |params, index| runner = Paraduct::Runner.new( script: script, params: params, base_job_dir: base_job_dir, job_id: index + 1, ) pool.process do runner.logger.info "[START] params: #{runner.formatted_params}" runner.setup_dir begin stdout = runner.perform successful = true rescue Paraduct::Errors::ProcessError => e runner.logger.error "exitstatus=#{e.status}, #{e.inspect}" stdout = e. successful = false rescue Exception => e runner.logger.error "Unknown error: #{e.inspect}" runner.logger.error e.backtrace.join("\n") successful = false end runner.logger.info "[END] params: #{runner.formatted_params}" test_response.jobs_push( job_name: runner.job_name, params: runner.params, formatted_params: runner.formatted_params, successful: successful, stdout: stdout, ) end end ensure pool.shutdown end raise Paraduct::Errors::DirtyExitError unless test_response.jobs_count == product_variables.count test_response end |