Class: OodCore::Job::Adapters::Lsf
- Inherits:
-
OodCore::Job::Adapter
- Object
- OodCore::Job::Adapter
- OodCore::Job::Adapters::Lsf
- Defined in:
- lib/ood_core/job/adapters/lsf.rb
Overview
The adapter class for the LSF scheduler.
Defined Under Namespace
Constant Summary collapse
- STATE_MAP =
{ 'RUN' => :running, 'PEND' => :queued, 'DONE' => :completed, 'EXIT' => :completed, 'PSUSP' => :queued_held, # supsended before job started, resumable via bresume 'USUSP' => :suspended, # suspended after job started, resumable via bresume 'SSUSP' => :suspended, 'WAIT' => :queued, # FIXME: not sure what else to do here 'ZOMBI' => :undetermined, 'UNKWN' => :undetermined }
Instance Attribute Summary collapse
- #batch ⇒ Object readonly private
- #helper ⇒ Object readonly private
Instance Method Summary collapse
-
#delete(id) ⇒ void
Delete the submitted job.
- #directive_prefix ⇒ Object
-
#hold(id) ⇒ void
Put the submitted job on hold.
-
#info(id) ⇒ Info
Retrieve job info from the resource manager.
-
#info_all(attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs from the resource manager.
-
#info_where_owner(owner, attrs: nil) ⇒ Array<Info>
Retrieve info for all of the owner’s jobs from the resource manager.
-
#initialize(batch:) ⇒ Lsf
constructor
private
A new instance of Lsf.
-
#release(id) ⇒ void
Release the job that is on hold.
-
#status(id) ⇒ Status
Retrieve job status from resource manager.
-
#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String
Submit a job with the attributes defined in the job template instance.
Methods inherited from OodCore::Job::Adapter
#accounts, #cluster_info, #info_all_each, #info_where_owner_each, #job_name_illegal_chars, #nodes, #queues, #sanitize_job_name, #supports_job_arrays?
Constructor Details
#initialize(batch:) ⇒ Lsf
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Lsf.
56 57 58 59 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 56 def initialize(batch:) @batch = batch @helper = Lsf::Helper.new end |
Instance Attribute Details
#batch ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 31 def batch @batch end |
#helper ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 31 def helper @helper end |
Instance Method Details
#delete(id) ⇒ void
This method returns an undefined value.
Delete the submitted job
167 168 169 170 171 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 167 def delete(id) batch.delete_job(id.to_s) rescue Batch::Error => e raise JobAdapterError, e. end |
#directive_prefix ⇒ Object
173 174 175 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 173 def directive_prefix '#BSUB' end |
#hold(id) ⇒ void
This method returns an undefined value.
Put the submitted job on hold
145 146 147 148 149 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 145 def hold(id) batch.hold_job(id.to_s) rescue Batch::Error => e raise JobAdapterError, e. end |
#info(id) ⇒ Info
Retrieve job info from the resource manager
95 96 97 98 99 100 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 95 def info(id) info_ary = batch.get_job(id: id).map{|v| info_for_batch_hash(v)} handle_job_array(info_ary, id) rescue Batch::Error => e raise JobAdapterError, e. end |
#info_all(attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs from the resource manager
106 107 108 109 110 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 106 def info_all(attrs: nil) batch.get_jobs.map { |v| info_for_batch_hash(v) } rescue Batch::Error => e raise JobAdapterError, e. end |
#info_where_owner(owner, attrs: nil) ⇒ Array<Info>
Retrieve info for all of the owner’s jobs from the resource manager
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 116 def info_where_owner(owner, attrs: nil) owners = Array.wrap(owner).map(&:to_s) if owners.count > 1 super elsif owners.count == 0 [] else batch.get_jobs_for_user(owners.first).map { |v| info_for_batch_hash(v) } end rescue Batch::Error => e raise JobAdapterError, e. end |
#release(id) ⇒ void
This method returns an undefined value.
Release the job that is on hold
156 157 158 159 160 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 156 def release(id) batch.release_job(id.to_s) rescue Batch::Error => e raise JobAdapterError, e. end |
#status(id) ⇒ Status
Retrieve job status from resource manager
134 135 136 137 138 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 134 def status(id) info(id).status rescue Batch::Error => e raise JobAdapterError, e. end |
#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String
Submit a job with the attributes defined in the job template instance
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ood_core/job/adapters/lsf.rb', line 76 def submit(script, after: [], afterok: [], afternotok: [], afterany: []) # ensure dependencies are array of ids after = Array(after).map(&:to_s) afterok = Array(afterok).map(&:to_s) afternotok = Array(afternotok).map(&:to_s) afterany = Array(afterany).map(&:to_s) kwargs = helper.batch_submit_args(script, after: after, afterok: afterok, afternotok: afternotok, afterany: afterany) batch.submit_string(script.content, **kwargs) rescue Batch::Error => e raise JobAdapterError, e. end |