lib/ripe/worker_controller/preparer.rb
##
# Organize worker blocks into tasks and prepare them.
#
# @param worker_sample_blocks [Array<Hash<String, Blocks::Block>>] a list
# containing as many elements as there are samples in the group
# @param worker [DB::Worker] worker
# @return [Array<Blocks::Block>] a list of all the prepared blocks for a
#   worker
Organize worker blocks into tasks and prepare them.
Organize worker blocks into tasks and prepare them .
def prepare_worker_blocks(worker_sample_blocks, worker)
        worker_sample_blocks.map do |sample, block|
          post_var_assign = lambda do |subblock|
            if subblock.blocks.length == 0
              task = worker.tasks.create({
                sample: sample,
                block:  subblock.id,
              })
              subblock.vars.merge!(log: task.log)
              File.open(task.sh, 'w') { |f| f.write(subblock.command) }
              subblock.vars
            else
              subblock.blocks.each(&post_var_assign)
            end
          end
          post_var_assign.call(block)
          block
        end
      end
def prepare_worker_blocks ( worker_sample_blocks , worker ) worker_sample_blocks . map do | sample , block | post_var_assign = lambda do | subblock | if subblock . blocks . length == 0 task = worker . tasks . create ( { sample : sample , block : subblock . id , } ) subblock . vars . merge! ( log : task . log ) File . open ( task . sh , 'w' ) { | f | f . write ( subblock . command ) } subblock . vars else subblock . blocks . each ( & post_var_assign ) end end post_var_assign . call ( block ) block end end
Organize worker blocks into tasks and prepare them.
Organize worker blocks into tasks and prepare them .
# Preorder traversal of blocks -- assign incremental numbers starting from # 1 to each node as it is being traversed, as well as producing the job # file for each task. # This section is only called when the subblock is actually a working # block (a leaf in the block arborescence).
a list of all the prepared blocks for a worker
a list of all the prepared blocks for a worker
Array<Blocks::Block>
worker_sample_blocks
a list containing as many elements as there are samples in the group
a list containing as many elements as there are samples in the group
worker
None