Class: RPipe

Inherits:
Object
  • Object
show all
Includes:
DefaultLogger, Log4r
Defined in:
lib/rpipe.rb

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

Instance Method Summary collapse

Methods included from DefaultLogger

#setup_logger

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_jobsObject

Returns the value of attribute preproc_jobs.



234
235
236
# File 'lib/rpipe.rb', line 234

def preproc_jobs
  @preproc_jobs
end

#recon_jobsObject

Returns the value of attribute recon_jobs.



234
235
236
# File 'lib/rpipe.rb', line 234

def recon_jobs
  @recon_jobs
end

#stats_jobsObject

Returns the value of attribute stats_jobs.



234
235
236
# File 'lib/rpipe.rb', line 234

def stats_jobs
  @stats_jobs
end

#workflow_specObject

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

#jobsObject



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.

Raises:

  • (IOError)


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.expand_path(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