Class: TORQUE::Qstat::Job
- Inherits:
-
EnanchedOpenStruct
- Object
- OpenStruct
- EnanchedOpenStruct
- TORQUE::Qstat::Job
- Defined in:
- lib/torque_rm/qstat.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fields ⇒ Object
-
#initialize(*args) ⇒ Job
constructor
A new instance of Job.
- #is_completed? ⇒ Boolean (also: #completed?)
- #is_exited? ⇒ Boolean (also: #exited?)
- #is_queued? ⇒ Boolean (also: #queued?, #is_in_queue?)
- #is_runnig? ⇒ Boolean (also: #running?)
- #memory ⇒ Object
- #node ⇒ Object
- #procs ⇒ Object
- #rm ⇒ Object (also: #del, #delete)
- #time ⇒ Object
- #to_json(*a) ⇒ Object
-
#to_map ⇒ Object
alias to_hash to_h.
Constructor Details
#initialize(*args) ⇒ Job
Returns a new instance of Job.
73 74 75 76 77 78 |
# File 'lib/torque_rm/qstat.rb', line 73 def initialize(*args) super(*args) class_eval do alias_method :id, :job_id end end |
Class Method Details
.fields ⇒ Object
127 128 129 |
# File 'lib/torque_rm/qstat.rb', line 127 def self.fields FIELDS + %w( is_runnig? is_queued? is_exited? is_completed? time memory node ) end |
.json_load(json) ⇒ Object
143 144 145 |
# File 'lib/torque_rm/qstat.rb', line 143 def self.json_load(json) JSON.load(json) end |
Instance Method Details
#fields ⇒ Object
123 124 125 |
# File 'lib/torque_rm/qstat.rb', line 123 def fields FIELDS + %w( is_runnig? is_queued? is_exited? is_completed? time memory node ) end |
#is_completed? ⇒ Boolean Also known as: completed?
85 86 87 |
# File 'lib/torque_rm/qstat.rb', line 85 def is_completed? job_state == 'C' end |
#is_exited? ⇒ Boolean Also known as: exited?
90 91 92 |
# File 'lib/torque_rm/qstat.rb', line 90 def is_exited? job_state == 'E' end |
#is_queued? ⇒ Boolean Also known as: queued?, is_in_queue?
95 96 97 |
# File 'lib/torque_rm/qstat.rb', line 95 def is_queued? job_state == 'Q' end |
#is_runnig? ⇒ Boolean Also known as: running?
80 81 82 |
# File 'lib/torque_rm/qstat.rb', line 80 def is_runnig? job_state == 'R' end |
#memory ⇒ Object
105 106 107 |
# File 'lib/torque_rm/qstat.rb', line 105 def memory (resources_used && resources_used.mem) ? (resources_used.mem.split("kb").first.to_f/1000).round(1) : "0" end |
#node ⇒ Object
109 110 111 |
# File 'lib/torque_rm/qstat.rb', line 109 def node exec_host ? exec_host.split("+").map {|n| n.split(".").first}.uniq.join(",") : "-" end |
#procs ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/torque_rm/qstat.rb', line 113 def procs if resource_list.ncpus return resource_list.ncpus elsif resource_list.nodes return resource_list.nodes.split("ppn=")[-1] else return "-" end end |
#rm ⇒ Object Also known as: del, delete
147 148 149 |
# File 'lib/torque_rm/qstat.rb', line 147 def rm Qdel.rm(job_id) end |
#time ⇒ Object
101 102 103 |
# File 'lib/torque_rm/qstat.rb', line 101 def time return (resources_used && resources_used.walltime) ? resources_used.walltime[:diff] : "-" #using time_diff it prints a nice report in case of more than 1 day end |
#to_json(*a) ⇒ Object
139 140 141 |
# File 'lib/torque_rm/qstat.rb', line 139 def to_json(*a) to_map.to_json(*a) end |
#to_map ⇒ Object
alias to_hash to_h
133 134 135 136 137 |
# File 'lib/torque_rm/qstat.rb', line 133 def to_map map = Hash.new self.members.each { |m| map[m] = self[m] } map end |