Class: RPipe
Overview
An object that drives all the other pipeline classes in this module. Once initialized, an array of instances of each class are available to run segments of preprocessing.
Instance Attribute Summary collapse
-
#preproc_jobs ⇒ Object
Returns the value of attribute preproc_jobs.
-
#recon_jobs ⇒ Object
Returns the value of attribute recon_jobs.
-
#stats_jobs ⇒ Object
Returns the value of attribute stats_jobs.
-
#workflow_spec ⇒ Object
Returns the value of attribute workflow_spec.
Instance Method Summary collapse
-
#initialize(driver) ⇒ RPipe
constructor
Initialize an RPipe instance by passing it a pipeline configuration driver.
- #jobs ⇒ Object
-
#read_driver_file(driver_file) ⇒ Object
Reads a YAML driver file, parses it with ERB and returns the Configuration Hash.
Methods included from DefaultLogger
Constructor Details
#initialize(driver) ⇒ RPipe
Initialize an RPipe instance by passing it a pipeline configuration driver. Drivers contain a list of entries, each of which contains all the information necessary to create an instance of the proper object that executes the job. Details on the formatting of the yaml drivers including examples will be provided in other documentation.
The driver may be either a Hash or a yaml configuration file.
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/rpipe.rb', line 246 def initialize(driver) @recon_jobs = [] @preproc_jobs = [] @stats_jobs = [] # A driver may be either a properly configured hash or a Yaml file containing # the configuration. @workflow_spec = driver.kind_of?(Hash) ? driver : read_driver_file(driver) # lib/default_logger.rb setup_logger jobs = @workflow_spec['jobs'] jobs.each do |job_params| @recon_jobs << Reconstruction.new(@workflow_spec, job_params) if job_params['step'] == 'reconstruct' @preproc_jobs << Preprocessing.new(@workflow_spec, job_params) if job_params['step'] == 'preprocess' @stats_jobs << Stats.new(@workflow_spec, job_params) if job_params['step'] == 'stats' end end |
Instance Attribute Details
#preproc_jobs ⇒ Object
Returns the value of attribute preproc_jobs.
234 235 236 |
# File 'lib/rpipe.rb', line 234 def preproc_jobs @preproc_jobs end |
#recon_jobs ⇒ Object
Returns the value of attribute recon_jobs.
234 235 236 |
# File 'lib/rpipe.rb', line 234 def recon_jobs @recon_jobs end |
#stats_jobs ⇒ Object
Returns the value of attribute stats_jobs.
234 235 236 |
# File 'lib/rpipe.rb', line 234 def stats_jobs @stats_jobs end |
#workflow_spec ⇒ Object
Returns the value of attribute workflow_spec.
234 235 236 |
# File 'lib/rpipe.rb', line 234 def workflow_spec @workflow_spec end |
Instance Method Details
#jobs ⇒ Object
266 267 268 |
# File 'lib/rpipe.rb', line 266 def jobs [@recon_jobs, @preproc_jobs, @stats_jobs].flatten end |
#read_driver_file(driver_file) ⇒ Object
Reads a YAML driver file, parses it with ERB and returns the Configuration Hash. Raises an error if the file is not found in the file system.
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/rpipe.rb', line 272 def read_driver_file(driver_file) @matlab_paths = [] # Add Application Config files to the path if they are present. application_directory = File.(File.join(File.dirname(driver_file), '..')) %w( matlab methods jobs ).each do |directory| code_dir = File.join(application_directory, directory) if File.directory?(code_dir) $LOAD_PATH.unshift(code_dir) p = ENV['MATLABPATH'].split(":") << code_dir ENV['MATLABPATH'] = p.join(":") end end raise(IOError, "Driver file not found: #{driver_file}") unless File.exist?(driver_file) YAML.load(ERB.new(File.read(driver_file)).result) end |