class Rub2::JobScript
Constants
- ScriptTemplate
Attributes
array_request[RW]
commands[RW]
inherit_environment[RW]
log[RW]
log_path[RW]
name[R]
queue[RW]
resource[RW]
shell[RW]
source[R]
uri[RW]
Public Class Methods
new(name)
click to toggle source
# File lib/rub2.rb, line 28 def initialize(name) @name = name @shell = '/bin/bash' @log_path = make_default_log_path(name) @uri = nil end
Public Instance Methods
build()
click to toggle source
# File lib/rub2.rb, line 35 def build @source = ERB.new(ScriptTemplate, nil, '-').result(binding) end
make_array_request_string()
click to toggle source
Range (1..100) or Array [1,10,50] -> '-t 1-100' or -t '1,10,50'
# File lib/rub2.rb, line 40 def make_array_request_string @array_request = (1..@commands.size) if @array_request.nil? limit = '' unless @slot_limit.nil? limit = "%#{@slot_limit}" end if @array_request.kind_of?(Range) last = nil if @array_request.exclude_end? last = @array_request.last - 1 else last = @array_request.last end return sprintf("%d-%d%s", @array_request.first, last, limit) end return @array_request.sort.join(',') + limit end
Private Instance Methods
make_default_log_path(name)
click to toggle source
return path to “pwd/log_ymd_hms/jobname_log”
# File lib/rub2.rb, line 62 def make_default_log_path(name) t = Time.now.strftime('%Y%m%d_%H%M%S') Pathname.new(Dir.pwd).join("log_#{t}", "#{name}.log") end
make_pbs_resources_string()
click to toggle source
return key=value
# File lib/rub2.rb, line 68 def make_pbs_resources_string return '' if @resource.empty? s = [] @resource.each do |k, v| s.push("#{k}=#{v}") end return s.join(',') end