Class: Comana::GridEngine
- Inherits:
-
Object
- Object
- Comana::GridEngine
- Defined in:
- lib/comana/gridengine.rb
Class Method Summary collapse
-
.guess_end_time(nj:, nh:, bench:) ⇒ Object
nj: number of jobs nh: number of hosts bench: benchmark time.
- .qstat_f(io = IO.popen("qstat -f -xml", "r+")) ⇒ Object
- .qstat_u(io = IO.popen("qstat -u '*' -xml", "r+")) ⇒ Object
- .queue_alive_hosts(io = IO.popen("qstat -f -xml", "r+")) ⇒ Object
- .queue_alive_nums(io = IO.popen("qstat -f -xml", "r+")) ⇒ Object
-
.queue_jobs(qname, io = nil) ⇒ Object
def self.queue_jobs(qname, str = ‘qconf -sql`).
-
.queues(str = `qconf -sql`) ⇒ Object
def self.qconf_sql(str = ‘qconf -sql`).
- .write_qsub_script(q_name:, pe_name:, ppn:, ld_library_path:, command:, io:) ⇒ Object
Class Method Details
.guess_end_time(nj:, nh:, bench:) ⇒ Object
nj: number of jobs nh: number of hosts bench: benchmark time
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/comana/gridengine.rb', line 162 def self.guess_end_time(nj:, nh:, bench:) nj = nj.to_f nh = nh.to_f if nj < nh start = 0 else start = nj/nh end (start + 1) * bench end |
.qstat_f(io = IO.popen("qstat -f -xml", "r+")) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/comana/gridengine.rb', line 27 def self.qstat_f(io = IO.popen("qstat -f -xml", "r+")) qs = Nokogiri::XML(io) results = qs.xpath("/job_info/queue_info/Queue-List").map do |queue| hash = {} queue.children.each do |j| next if j.name == 'text' key = j.name val = j.children.to_s val = val.to_i if val.integer? hash[key] = val end hash end results end |
.qstat_u(io = IO.popen("qstat -u '*' -xml", "r+")) ⇒ Object
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/comana/gridengine.rb', line 66 def self.qstat_u(io = IO.popen("qstat -u '*' -xml", "r+")) qs = Nokogiri::XML(io) results = [] qs.xpath("/job_info/queue_info/job_list").each do |queue| hash = {} value = queue.attributes.values[0].to_s hash['job_list_state'] = value queue.children.each do |j| next if j.name == 'text' key = j.name val = j.children.to_s if val.integer? val = val.to_i elsif val.float? val = val.to_f end hash[key] = val end results << hash end qs.xpath("/job_info/job_info/job_list").each do |queue| hash = {} value = queue.attributes.values[0].to_s hash['job_list_state'] = value queue.children.each do |j| next if j.name == 'text' key = j.name val = j.children.to_s if val.integer? val = val.to_i elsif val.float? val = val.to_f end hash[key] = val end results << hash end results end |
.queue_alive_hosts(io = IO.popen("qstat -f -xml", "r+")) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/comana/gridengine.rb', line 43 def self.queue_alive_hosts(io = IO.popen("qstat -f -xml", "r+")) qs = self.qstat_f(io) results = {} qs.each do |q| next if q['state'] == 'au' /(.*)\@(.*)/ =~ q["name"] q = $1 host = $2 results[q] ||= [] results[q] << host end results end |
.queue_alive_nums(io = IO.popen("qstat -f -xml", "r+")) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/comana/gridengine.rb', line 57 def self.queue_alive_nums(io = IO.popen("qstat -f -xml", "r+")) qs = self.queue_alive_hosts(io) results = {} qs.each do |key,val| results[key] = val.size end results end |
.queue_jobs(qname, io = nil) ⇒ Object
def self.queue_jobs(qname, str = ‘qconf -sql`)
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/comana/gridengine.rb', line 115 def self.queue_jobs(qname, io = nil) io ||= IO.popen("qstat -q #{qname} -u '*' -xml", "r+") results = [] qs = Nokogiri::XML(io) qs.xpath("/job_info/queue_info/job_list").each do |queue| hash = {} value = queue.attributes.values[0].to_s hash['job_list_state'] = value queue.children.each do |j| next if j.name == 'text' key = j.name val = j.children.to_s if val.integer? val = val.to_i elsif val.float? val = val.to_f end hash[key] = val end results << hash end qs.xpath("/job_info/job_info/job_list").each do |queue| hash = {} value = queue.attributes.values[0].to_s hash['job_list_state'] = value queue.children.each do |j| next if j.name == 'text' key = j.name val = j.children.to_s if val.integer? val = val.to_i elsif val.float? val = val.to_f end hash[key] = val end results << hash end results #qs.xpath("/job_info/job_info/job_list").each do |queue| end |
.queues(str = `qconf -sql`) ⇒ Object
def self.qconf_sql(str = ‘qconf -sql`)
109 110 111 |
# File 'lib/comana/gridengine.rb', line 109 def self.queues(str = `qconf -sql`) str.strip.split("\n") end |
.write_qsub_script(q_name:, pe_name:, ppn:, ld_library_path:, command:, io:) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/comana/gridengine.rb', line 9 def self.write_qsub_script(q_name:, pe_name:, ppn:, ld_library_path: , command:, io:) io.puts "#! /bin/sh" io.puts "#$ -S /bin/sh" io.puts "#$ -cwd" io.puts "#$ -o stdout" io.puts "#$ -e stderr" io.puts "#$ -q #{q_name}" io.puts "#$ -pe #{pe_name} #{ppn}" io.puts "MACHINE_FILE='machines'" io.puts "LD_LIBRARY_PATH=#{ld_library_path}" if ld_library_path io.puts "export LD_LIBRARY_PATH" if ld_library_path io.puts "cd $SGE_O_WORKDIR" io.puts "printenv | sort > printenv.log" io.puts "cut -d ' ' -f 1,2 $PE_HOSTFILE | sed 's/ / cpu=/' > $MACHINE_FILE" io.puts "#{command}" #{__FILE__} execute end |