If -n $number, and $number is a integer and $number > 1, submit $number times. And 'nr_run' would be added in the job.yaml. Else, submit once.
[usage] submit xxx xxx -n 3 xxx.yaml
Signed-off-by: Li Yuanchao lyc163mail@163.com --- sbin/submit | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/sbin/submit b/sbin/submit index edb207cc0..a35ca0dac 100755 --- a/sbin/submit +++ b/sbin/submit @@ -19,6 +19,7 @@ opt_monitor_query = {} opt_my_queue = false actions = ['output', 'stop'] result_roots = [] +nr_run = 1
options = OptionParser.new do |opts| opts.banner = 'Usage: submit [options] job1.yaml job2.yaml ...' @@ -57,6 +58,11 @@ options = OptionParser.new do |opts| actions << 'mirror_result' end
+ opts.on('-n job_number', '--number job_number', 'number to submit job') do |number| + nr_run = number.to_i + nr_run = 1 if nr_run < 1 + end + opts.on('-m', '--monitor', "monitor job status: use -m 'KEY: VALUE' to add rule") do opt_monitor = true k, v = ARGV[0].sub(' ', '').split(':', 2) if ARGV[0] @@ -195,16 +201,19 @@ ARGV.each do |jobfile| scheduler_client = SchedulerClient.new(job['SCHED_HOST'], job['SCHED_PORT'])
# submit job + job_hash['nr_run'] = nr_run job_json = job_hash.to_json - messages = scheduler_client.submit_job(job_json) - JSON.parse(messages).each do |msg| - if msg['message'].empty? - result_roots << msg['result_root'] - job_ids << msg['job_id'].to_s - puts("submit #{jobfile}, got job id=#{msg['job_id']}") - else - opt_monitor = false - puts("submit #{jobfile} failed, got job id=#{msg['job_id']}, error: #{msg['message']}") + nr_run.times do + messages = scheduler_client.submit_job(job_json) + JSON.parse(messages).each do |msg| + if msg['message'].empty? + result_roots << msg['result_root'] + job_ids << msg['job_id'].to_s + puts("submit #{jobfile}, got job id=#{msg['job_id']}") + else + opt_monitor = false + puts("submit #{jobfile} failed, got job id=#{msg['job_id']}, error: #{msg['message']}") + end end end end