Class: PBS::Job
- Inherits:
-
Object
- Object
- PBS::Job
- Defined in:
- lib/pbs/job.rb
Constant Summary collapse
- HOSTNAME =
Socket.gethostname
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
-
#delete(args = {}) ⇒ Object
Delete job.
-
#hold(args = {}) ⇒ Object
Put job on hold.
-
#initialize(args = {}) ⇒ Job
constructor
Needs a connection object and headers Examples of headers found in ‘headers.rb’.
-
#release(args = {}) ⇒ Object
Release job from hold.
-
#status(args = {}) ⇒ Object
Get status of job by creating a Query object.
-
#submit(args) ⇒ Object
Can submit a script as a file or string.
Constructor Details
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
10 11 12 |
# File 'lib/pbs/job.rb', line 10 def conn @conn end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/pbs/job.rb', line 9 def id @id end |
Instance Method Details
#delete(args = {}) ⇒ Object
Delete job
47 48 49 |
# File 'lib/pbs/job.rb', line 47 def delete(args = {}) _pbs_delete() end |
#hold(args = {}) ⇒ Object
Put job on hold
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pbs/job.rb', line 21 def hold(args = {}) # hold_type:: # The parameter, hold_type, contains the type of hold to be applied. The possible values are (default is 'u'): # "u" : Available to the owner of the job, the batch operator and the batch administrator. # "o" : Available to the batch operator and the batch administrator. # "s" : Available only to the batch administrator. hold_type = args[:hold_type] || "u" _pbs_hold(hold_type) self end |
#release(args = {}) ⇒ Object
Release job from hold
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pbs/job.rb', line 34 def release(args = {}) # hold_type:: # The parameter, hold_type, contains the type of hold to be applied. The possible values are (default is 'u'): # "u" : Available to the owner of the job, the batch operator and the batch administrator. # "o" : Available to the batch operator and the batch administrator. # "s" : Available only to the batch administrator. hold_type = args[:hold_type] || "u" _pbs_release(hold_type) self end |
#status(args = {}) ⇒ Object
Get status of job by creating a Query object
52 53 54 55 |
# File 'lib/pbs/job.rb', line 52 def status(args = {}) q = Query.new(type: :job, conn: conn) q.find(args.merge(id: id))[0] end |
#submit(args) ⇒ Object
Can submit a script as a file or string
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pbs/job.rb', line 66 def submit(args) string = args.fetch(:string) { File.open(args[:file]).read } queue = args.fetch(:queue, nil) qsub = args.fetch(:qsub, true) headers = args.fetch(:headers, {}) resources = args.fetch(:resources, {}) envvars = args.fetch(:envvars, {}) # Create batch script in tmp file, submit, remove tmp file script = Tempfile.new('qsub.') begin script.write string script.close if qsub _qsub_submit(script.path, queue, headers, resources, envvars) else _pbs_submit(script.path, queue, headers, resources, envvars) end ensure script.unlink # deletes the temp file end self end |