Class: TORQUE::Qsub

Inherits:
Object
  • Object
show all
Defined in:
lib/torque_rm/qsub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &block) ⇒ Qsub

Returns a new instance of Qsub.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# 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

Instance Attribute Details

#aObject Also known as: when

Returns the value of attribute a.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def a
  @a
end

#AObject Also known as: account

Returns the value of attribute A.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def A
  @A
end

#bObject

Returns the value of attribute b.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def b
  @b
end

#cObject Also known as: checkpoint

Returns the value of attribute c.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def c
  @c
end

#CObject

Returns the value of attribute C.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def C
  @C
end

#dObject Also known as: wd, working_directory

Returns the value of attribute d.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def d
  @d
end

#DObject Also known as: root_directory

Returns the value of attribute D.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def D
  @D
end

#eObject Also known as: stderr

Returns the value of attribute e.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def e
  @e
end

#fObject

Returns the value of attribute f.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def f
  @f
end

#gresObject

Returns the value of attribute gres.



20
21
22
# File 'lib/torque_rm/qsub.rb', line 20

def gres
  @gres
end

#hObject

Returns the value of attribute h.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def h
  @h
end

#IObject

Returns the value of attribute I.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def I
  @I
end

#idObject

Returns the value of attribute id.



21
22
23
# File 'lib/torque_rm/qsub.rb', line 21

def id
  @id
end

#jObject

Returns the value of attribute j.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def j
  @j
end

#kObject

Returns the value of attribute k.



18
19
20
# File 'lib/torque_rm/qsub.rb', line 18

def k
  @k
end

#lObject

config



137
138
139
# File 'lib/torque_rm/qsub.rb', line 137

def l
  @l
end

#mObject

Returns the value of attribute m.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def m
  @m
end

#MObject Also known as: email

Returns the value of attribute M.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def M
  @M
end

#NObject Also known as: name

def script(*args)

if args.size == 1
  @script =  args[0]
else
  @script
end

end



32
33
34
35
36
37
38
# File 'lib/torque_rm/qsub.rb', line 32

def N
  if @N.nil?
    @N = SecureRandom.urlsafe_base64(20)
  else
    @N
  end
end

#nodesObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/torque_rm/qsub.rb', line 146

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

#oObject Also known as: stdout

Returns the value of attribute o.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def o
  @o
end

#PObject Also known as: run_as_user

Returns the value of attribute P.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def P
  @P
end

#pObject

Returns the value of attribute p.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def p
  @p
end

#ppnObject Also known as: cpus

Returns the value of attribute ppn.



20
21
22
# File 'lib/torque_rm/qsub.rb', line 20

def ppn
  @ppn
end

#procsObject

Returns the value of attribute procs.



20
21
22
# File 'lib/torque_rm/qsub.rb', line 20

def procs
  @procs
end

#qObject Also known as: queue

Returns the value of attribute q.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def q
  @q
end

#rObject Also known as: rerunnable

Returns the value of attribute r.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def r
  @r
end

#SObject Also known as: shell

Returns the value of attribute S.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def S
  @S
end

#scriptObject

Returns the value of attribute script.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def script
  @script
end

#tObject

Returns the value of attribute t.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def t
  @t
end

#uObject Also known as: user_list

Returns the value of attribute u.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def u
  @u
end

#vObject Also known as: variable_list

Returns the value of attribute v.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def v
  @v
end

#VObject Also known as: exports

Returns the value of attribute V.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def V
  @V
end

#WObject

Returns the value of attribute W.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def W
  @W
end

#walltimeObject

Returns the value of attribute walltime.



20
21
22
# File 'lib/torque_rm/qsub.rb', line 20

def walltime
  @walltime
end

#XObject Also known as: additional_attributes

Returns the value of attribute X.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def X
  @X
end

#zObject

Returns the value of attribute z.



19
20
21
# File 'lib/torque_rm/qsub.rb', line 19

def z
  @z
end

Instance Method Details

#config(&block) ⇒ Object

initialize



126
127
128
129
130
131
132
133
134
135
# 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

#rmObject

delete this job from the queue



196
197
198
199
200
201
202
# File 'lib/torque_rm/qsub.rb', line 196

def rm
  if id.nil? 
    warn("No job submitted")
  else
    TORQUE::Qdel.rm(id)
  end
end

#statObject

get the stats for this job



185
186
187
188
189
190
191
192
# File 'lib/torque_rm/qsub.rb', line 185

def stat
  if id.nil? 
    warn("No job submitted")
  else
    @qstat = @qstat || TORQUE::Qstat.new
    @qstat.query(job_id: id)
  end
end

#submit(opts = {dry: false}) ⇒ Object

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.


179
180
181
182
# File 'lib/torque_rm/qsub.rb', line 179

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

#to_sObject



162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/torque_rm/qsub.rb', line 162

def to_s
 pbs_script = ""
 [: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