[usage] 1. submit -i include.yaml job.yaml this will add include.yaml content to job.yaml, and priority is higher than job.yaml 2. submit -i 1.yaml -i 2.yaml job.yaml this will add 1.yaml and 2.yaml to job.yaml
Signed-off-by: Wei Jihui weijihuiall@163.com --- lib/job.rb | 12 ++++++++---- sbin/submit | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/lib/job.rb b/lib/job.rb index 631ebfc9..1650eb2f 100755 --- a/lib/job.rb +++ b/lib/job.rb @@ -215,6 +215,7 @@ class Job attr_accessor :overrides attr_accessor :defaults attr_accessor :cmdline_defaults + attr_accessor :include_yamls
def initialize(job = {}, defaults = {}, overrides = {}, cmdline_defaults={}) @job = job @@ -222,6 +223,7 @@ class Job @overrides = overrides # from command line @cmdline_defaults = cmdline_defaults # from command line @available_programs = {} + @include_yamls = [] end
def source_file_symkey(file) @@ -254,8 +256,8 @@ class Job @overrides.merge!(hash['override']){ |_key, a, _b| a} hash.delete('override') end - hash.merge!(@overrides) - hash.merge!(fault_reproduction) if hash.has_key?("id") + hash.merge!(@overrides) unless @overrides.empty? + hash.merge!(load_include_yamls) unless @include_yamls.empty? @jobs.concat(multi_args(hash)) # return [hash] or [h1,h2] end rescue StandardError => e @@ -286,8 +288,10 @@ class Job @jobfile = jobfile end
- def fault_reproduction - wait = load_yaml("#{lkp_src}/jobs/fault_reproduction.yaml", {}) + def load_include_yamls + include_hash = {} + include_hash[comment_to_symbol('auto generated by load_include_yamls()')] = nil + include_hash.merge!(load_yaml_merge(@include_yamls, {})) end
def multi_args(hash) diff --git a/sbin/submit b/sbin/submit index 39cdcf57..6eca3b6e 100755 --- a/sbin/submit +++ b/sbin/submit @@ -14,6 +14,7 @@ opt_set_key_value = {} opt_cmdline_defaults = {} opt_output_dir = nil opt_auto_define_files = false +opt_include_yamls = [] opt_monitor = false opt_monitor_query = {} opt_my_queue = false @@ -43,6 +44,10 @@ options = OptionParser.new do |opts| opt_auto_define_files = true end
+ opts.on('-i include.yaml', '--include include.yaml', 'include other job yamls') do |yaml| + opt_include_yamls << yaml + end + opts.on('-c', '--connect', 'auto connect to the host') do actions << 'connect' end @@ -103,6 +108,14 @@ def find_jobfile(jobfile) exit 1 end
+def find_jobfiles(jobfile_list) + search_jobfile_list = [] + jobfile_list.each do |jobfile| + search_jobfile_list << find_jobfile(jobfile) + end + return search_jobfile_list +end + submit_id = %x(uuidgen).chomp puts "submit_id=#{submit_id}"
@@ -111,6 +124,7 @@ ARGV.each do |jobfile| jobs = Job2sh.new jobs.cmdline_defaults = opt_cmdline_defaults jobs.overrides = opt_set_key_value + jobs.include_yamls = find_jobfiles(opt_include_yamls) jobs.load(jobfile, true) || next jobs[:expand_params] = true jobs['testbox'] = opt_set_key_value['testbox'] if opt_set_key_value['testbox']