class TORQUE::Qsub
- -a date_time
- -A account_string
- -b secs
- -c checkpoint_options
- -C directive_prefix
- -d path
- -D path
- -e path
- -f
- -h
- -I
- -j join
- -k keep
- -l resource_list
- -m mail_options
- -M
user_list
- -N name
- -o path
- -M
- -p priority
- -P user
- -q destination
- -r c
- -S path_list
- -t array_request
- -u
user_list
- -u
- -v
variable_list
- -V
- -W
additional_attributes
- -X
- -z
- script
- -W
Attributes
Public Class Methods
# File lib/torque_rm/qsub.rb, line 80 def initialize(opts={}, &block) @id = nil # configure when the job is submitted @a =opts[:a] || opts[:date_time] @A = opts[:A] || opts[:account] @b = opts[:b] @c = validate_checkpoint(opts[:c] || opts[:checkpoint]) @C = opts[:C] || opts[:directive_prefix] @d = opts[:d] || opts[:working_directory] # PBS_O_INITDIR @D = opts[:D] || opts[:root_directory] # PBS_O_ROOTDIR @e = opts[:e] || opts[:stderr] # [hostname:]path_name @f = opts[:f] || opts[:fault_tolerant] # boolean @h = opts[:h] || opts[:user_hold] # boolean @I = opts[:I] || opts[:interactive] @j = opts[:j] || opts[:join_stdout_stderr] @k = validate_keep(opts) # check manual because I'm not going to implement this now. @l = opts[:l] @nodes = opts[:nodes] @walltime = opts[:walltime] @gres = opts[:gres] @ppn = opts[:ppn] @procs = opts[:procs] @m = validate_mail_options(opts) @M = opts[:M] || opts[:email] @N = opts[:N] || opts[:name] @o = opts[:o] || opts[:stdout] # [hostname:]path_name @p = validate_priority(opts) # between -1024, +1023 @P = opts[:P] || opts[:root_as_user] @q = opts[:q] || opts[:queue] @r = opts[:r] || opts[:rerunnable] # y|n @S = opts[:S] || opts[:shell] @t = opts[:t] || opts[:array_request] @u = opts[:u] || opts[:user_list] @v = opts[:v] || opts[:variable_list] @V = opts[:V] || opts[:exports] #this is just a boolean @W = opts[:W] || opts[:additional_attributes] # to DEVELOP, chaining jobs together. @X = opts[:X] || opts[:X_forwardning] # boolean @z = opts[:z] || opts[:no_jobid] @script = opts[:script] if block_given? if block.arity == 1 yield self end end end
Public Instance Methods
def script(*args)
if args.size == 1 @script = args[0] else @script end
end
# File lib/torque_rm/qsub.rb, line 32 def N if @N.nil? @N = SecureRandom.urlsafe_base64(20) else @N end end
# File lib/torque_rm/qsub.rb, line 126 def config(&block) if block_given? if block.arity == 1 yield self else instance_eval &block self end end end
# File lib/torque_rm/qsub.rb, line 151 def nodes str_nodes = if @nodes @nodes elsif ppn "nodes=1" end if ppn str_nodes << ':' << "ppn=#{ppn}" elsif procs str_nodes << '+' << "procs=#{procs}" end end
delete this job from the queue
# File lib/torque_rm/qsub.rb, line 200 def rm if id.nil? warn("No job submitted") else TORQUE::Qdel.rm(id) end end
get the stats for this job
# File lib/torque_rm/qsub.rb, line 189 def stat if id.nil? warn("No job submitted") else @qstat = @qstat || TORQUE::Qstat.new @qstat.query(job_id: id) end end
Create a qsub job on the remote server and then submits it return the job_id from qsub and set it as a job variable. :dry => true will only transfer the file to the destination server and will not submit the job to the scheduler
the job object will not have an id associated.
# File lib/torque_rm/qsub.rb, line 183 def submit(opts={dry: false}) TORQUE.server.file_upload StringIO.new(to_s), script_absolute_filename @id = TORQUE.server.qsub(script_absolute_filename).first unless opts[:dry] == true end
# File lib/torque_rm/qsub.rb, line 166 def to_s pbs_script = "#!/usr/bin/env bash\n" [:a, :A,:b,:c,:C,:d,:D,:e,:f,:h,:I,:j,:k,:l,:m,:M,:N,:o,:p,:P,:q,:r,:S,:t,:u,:v,:V,:W,:X,:z].each do |option| value = send(option) pbs_script << "#PBS -#{option} #{value}\n" unless value.nil? end pbs_script << "#{script}" unless script.nil? if script.nil? warn("You are converting this qsub job into a script without a real code.") end pbs_script end
Private Instance Methods
Check if the hash contains valid PBS options. If a key is not a valid pbs option a warning message is raise but the key is ket in the ostruct def validate_pbs_options(hash=nil) end
# File lib/torque_rm/qsub.rb, line 303 def fields instance_variable_get("@table").keys end
# File lib/torque_rm/qsub.rb, line 244 def script_absolute_filename File.join(script_dir,script_filename) end
get the current work directory. if root_directory
is defined it will get precedence on working_directory
if root or working directories are not defined the user home directory is the default directory
# File lib/torque_rm/qsub.rb, line 235 def script_dir root_directory || working_directory || user_directory end
in case name of the job has not been specified, it will be generated randomly
# File lib/torque_rm/qsub.rb, line 240 def script_filename "#{name}.pbs" end
# File lib/torque_rm/qsub.rb, line 248 def user_directory if run_as_user File.join("/home",run_as_user) elsif TORQUE.username File.join("/home",TORQUE.username) end end
none - No checkpointing is to be performed. enabled - Specify that checkpointing is allowed but must be explicitly invoked by either the qhold or qchkpt commands. shutdown - Specify that checkpointing is to be done on a job at pbs_mom shutdown. periodic - Specify that periodic checkpointing is enabled. The default interval is 10 minutes and can be changed by the $checkpoint_interval option in the mom config file or by specifying an interval when the job is submitted interval=minutes - Checkpointing is to be performed at an interval of minutes, which is the integer number of minutes of wall time used by the job. This value must be greater than zero. depth=number - Specify a number (depth) of checkpoint images to be kept in the checkpoint directory. dir=path - Specify a checkpoint directory (default is /var/spool/torque/checkpoint).
# File lib/torque_rm/qsub.rb, line 267 def validate_checkpoint(value) if value.nil? || value=~/none|enabled|shutdown|periodic|interval|depth|dir/ value else raise "#{value} is not a valid option for checkpoint" end end
# File lib/torque_rm/qsub.rb, line 280 def validate_keep(opts) if (value = opts[:k] || opts[:keep]) if value =~/eo|oe|e|o|n/ value else raise "#{value} is not a valid option for keep" end end end
# File lib/torque_rm/qsub.rb, line 275 def validate_mail_options(opts) value = opts[:m] || [opts[:send_on_abort], opts[:send_on_begin], opts[:send_on_end]].select{|item| item}.join value.empty? ? nil : value end
# File lib/torque_rm/qsub.rb, line 290 def validate_priority(opts) value = opts[:p] || opts[:priority] if value.nil? || (-1024..1023).include?(value) value else raise "#{value} is out of range for priority, stay in between [-1024, +1023]" end end