lib/sushi_fabric/sushiApp.rb in sushi_fabric-0.2.1 vs lib/sushi_fabric/sushiApp.rb in sushi_fabric-0.2.2
- old
+ new
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
# encoding: utf-8
-# Version = '20140523-144630'
+# Version = '20140612-161952'
require 'csv'
require 'fileutils'
require 'yaml'
require 'drb/drb'
@@ -578,141 +578,173 @@
preprocess
set_output_files
set_user_parameters
failures = 0
+ err_msgs = []
print 'check project name: '
unless @project
- puts "\e[31mFAILURE\e[0m: project number is required but not found. you should set it in usecase."
- puts "\tex.)"
- puts "\tapp = #{self.class}.new"
- puts "\tapp.project = 'p1001'"
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: project number is required but not found. you should set it in usecase."
+ err_msg << "\tex.)"
+ err_msg << "\tapp = #{self.class}.new"
+ err_msg << "\tapp.project = 'p1001'"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:\n\t@project=#{@project}"
end
print 'check user name: '
unless @user
- puts "\e[31mWARNING\e[0m: user number is ought to be added but not found. you should set it in usecase. Default will be 'sushi lover'"
- puts "\tex.)"
- puts "\tapp = #{self.class}.new"
- puts "\tapp.user = 'masa'"
+ err_msg = []
+ err_msg << "\e[31mWARNING\e[0m: user number is ought to be added but not found. you should set it in usecase. Default will be 'sushi lover'"
+ err_msg << "\tex.)"
+ err_msg << "\tapp = #{self.class}.new"
+ err_msg << "\tapp.user = 'masa'"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
else
puts "\e[32mPASSED\e[0m:\n\t@user=#{@user}"
end
print 'check application name: '
if @name.to_s.empty?
- puts "\e[31mFAILURE\e[0m: application name is required but not found. you should set it in application class."
- puts "\tex.)"
- puts "\tclass #{self.class}"
- puts "\t def initialize"
- puts "\t @name = '#{self.class}'"
- puts "\t end"
- puts "\tend"
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: application name is required but not found. you should set it in application class."
+ err_msg << "\tex.)"
+ err_msg << "\tclass #{self.class}"
+ err_msg << "\t def initialize"
+ err_msg << "\t @name = '#{self.class}'"
+ err_msg << "\t end"
+ err_msg << "\tend"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:\n\t@name=#{@name}"
end
print 'check analysis_category: '
if @analysis_category.to_s.empty?
- puts "\e[31mFAILURE\e[0m: analysis_category is required but not found. you should set it in application class."
- puts "\tex.)"
- puts "\tclass #{self.class}"
- puts "\t def initialize"
- puts "\t @analysis_category = 'Mapping'"
- puts "\t end"
- puts "\tend"
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: analysis_category is required but not found. you should set it in application class."
+ err_msg << "\tex.)"
+ err_msg << "\tclass #{self.class}"
+ err_msg << "\t def initialize"
+ err_msg << "\t @analysis_category = 'Mapping'"
+ err_msg << "\t end"
+ err_msg << "\tend"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:\n\t@analysis_category=#{@analysis_category}"
end
print 'check dataset: '
if !@dataset_hash or @dataset_hash.empty?
- puts "\e[31mFAILURE\e[0m: dataset is not found. you should set it by using #{self.class}#dataset_sushi_id or #{self.class}#dataset_tsv_file properties"
- puts "\tex.)"
- puts "\tusecase = #{self.class}.new"
- puts "\tusecase.dataset_tsv_file = \"dataset.tsv\""
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: dataset is not found. you should set it by using #{self.class}#dataset_sushi_id or #{self.class}#dataset_tsv_file properties"
+ err_msg << "\tex.)"
+ err_msg << "\tusecase = #{self.class}.new"
+ err_msg << "\tusecase.dataset_tsv_file = \"dataset.tsv\""
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:\n\t@dataset_hash.length = #{@dataset_hash.length}"
end
print 'check required columns: '
unless check_required_columns
- puts "\e[31mFAILURE\e[0m: required_column(s) is not found in dataset. you should set it in application class."
- puts "\tex.)"
- puts "\tdef initialize"
- puts "\t @required_columns = ['Name', 'Read1']"
- puts
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: required_column(s) is not found in dataset. you should set it in application class."
+ err_msg << "\tex.)"
+ err_msg << "\tdef initialize"
+ err_msg << "\t @required_columns = ['Name', 'Read1']"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:"
end
puts "\trequired columns: #{@required_columns}"
puts "\tdataset columns: #{@dataset_hash.map{|row| row.keys}.flatten.uniq}" if @dataset_hash
print 'check required parameters: '
unless check_application_parameters
- puts "\e[31mFAILURE\e[0m: required_param(s) is not set yet. you should set it in usecase"
- puts "\tmissing params: #{@required_params-@params.keys}" if @required_params
- puts "\tex.)"
- puts "\tusecase = #{self.class}.new"
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: required_param(s) is not set yet. you should set it in usecase"
+ err_msg << "\tmissing params: #{@required_params-@params.keys}" if @required_params
+ err_msg << "\tex.)"
+ err_msg << "\tusecase = #{self.class}.new"
if @required_params
- puts "\tusecase.params['#{(@required_params-@params.keys)[0]}'] = parameter"
+ err_msg << "\tusecase.params['#{(@required_params-@params.keys)[0]}'] = parameter"
else
- puts "\tusecase.params['parameter name'] = default_parameter"
+ err_msg << "\tusecase.params['parameter name'] = default_parameter"
end
- puts
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:"
end
puts "\tparameters: #{@params.keys}"
puts "\trequired : #{@required_params}"
print 'check next dataset: '
@dataset={}
unless self.next_dataset
- puts "\e[31mFAILURE\e[0m: next dataset is not set yet. you should overwrite SushiApp#next_dataset method in #{self.class}"
- puts "\tnote: the return value should be Hash (key: column title, value: value in a tsv table)"
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: next dataset is not set yet. you should overwrite SushiApp#next_dataset method in #{self.class}"
+ err_msg << "\tnote: the return value should be Hash (key: column title, value: value in a tsv table)"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:"
end
print 'check output files: '
if !@output_files or @output_files.empty?
- puts "\e[31mWARNING\e[0m: no output files. you will not get any output files after the job running. you can set @output_files (array) in #{self.class}"
- puts "\tnote: usually it should be define in initialize method"
- puts "\t the elements of @output_files should be chosen from #{self.class}#next_dataset.keys"
- puts "\t #{self.class}#next_dataset.keys: #{self.next_dataset.keys}" if self.next_dataset
+ err_msg = []
+ err_msg << "\e[31mWARNING\e[0m: no output files. you will not get any output files after the job running. you can set @output_files (array) in #{self.class}"
+ err_msg << "\tnote: usually it should be define in initialize method"
+ err_msg << "\t the elements of @output_files should be chosen from #{self.class}#next_dataset.keys"
+ err_msg << "\t #{self.class}#next_dataset.keys: #{self.next_dataset.keys}" if self.next_dataset
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
else
puts "\e[32mPASSED\e[0m:"
end
print 'check commands: '
if @params['process_mode'] == 'SAMPLE'
@dataset_hash.each do |row|
@dataset = Hash[*row.map{|key,value| [key.gsub(/\[.+\]/,'').strip, value]}.flatten]
unless com = commands
- puts "\e[31mFAILURE\e[0m: any commands is not defined yet. you should overwrite SushiApp#commands method in #{self.class}"
- puts "\tnote: the return value should be String (this will be in the main body of submitted job script)"
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: any commands is not defined yet. you should overwrite SushiApp#commands method in #{self.class}"
+ err_msg << "\tnote: the return value should be String (this will be in the main body of submitted job script)"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:"
puts "generated command will be:"
puts "\t"+com.split(/\n/).join("\n\t")+"\n"
end
end
elsif @params['process_mode'] == 'DATASET'
unless com = commands
- puts "\e[31mFAILURE\e[0m: any commands is not defined yet. you should overwrite SushiApp#commands method in #{self.class}"
- puts "\tnote: the return value should be String (this will be in the main body of submitted job script)"
+ err_msg = []
+ err_msg << "\e[31mFAILURE\e[0m: any commands is not defined yet. you should overwrite SushiApp#commands method in #{self.class}"
+ err_msg << "\tnote: the return value should be String (this will be in the main body of submitted job script)"
+ puts err_msg.join("\n")
+ err_msgs.concat(err_msg)
failures += 1
else
puts "\e[32mPASSED\e[0m:"
puts "generated command will be:"
puts "\t"+com.split(/\n/).join("\n\t")+"\n"
@@ -723,19 +755,23 @@
begin
hello = `wfm_hello #{WORKFLOW_MANAGER}`
rescue
end
unless hello =~ /hello/
- puts "\e[31mFAILURE\e[0m: workflow_manager does not reply. check if workflow_manager is working"
+ err_msg = "\e[31mFAILURE\e[0m: workflow_manager does not reply. check if workflow_manager is working"
+ puts err_msg
+ err_msgs.concat([err_msg])
failures += 1
else
puts "\e[32mPASSED\e[0m:"
end
if failures > 0
puts
- puts "\e[31mFailures (#{failures})\e[0m: All failures should be solved"
- raise "test run fails"
+ err_msg = "\e[31mFailures (#{failures})\e[0m: All failures should be solved"
+ puts err_msg
+ err_msgs.unshift(err_msg)
+ raise "\n"+err_msgs.join("\n")+"\n\n"
else
puts "All checks \e[32mPASSED\e[0m"
end
end
end