torque_rm 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/lib/torque_rm.rb +1 -0
- data/lib/torque_rm/qstat.rb +223 -159
- data/torque_rm.gemspec +5 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e16eae105bf6988ad355b72030b9aa28571c9e
|
4
|
+
data.tar.gz: 57adda4ebf39189379a2ffbe10f7832d957875c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b71f85629a720d80667f6449be6d2b1b528dd36ac284524ee9b23b9ff1035bc6af2d75274d9c60caf34f364ba9133182101abfeb7eb5ff1b49db134a92101bf7
|
7
|
+
data.tar.gz: ef01213ebcc576eba3a8175f38347df1aa8be41c4f2e8b0bd6fc07e0fcab506d62a5eb4f3ed82e31015c5369205d8e920f581f2e4cc91c31218d01ff52e86a71
|
data/Gemfile
CHANGED
@@ -11,6 +11,7 @@ gem 'sinatra-contrib'
|
|
11
11
|
gem 'shotgun'
|
12
12
|
gem 'haml'
|
13
13
|
gem 'sinatra-twitter-bootstrap', :require => 'sinatra/twitter-bootstrap'
|
14
|
+
gem 'activesupport'
|
14
15
|
# gem "awesome_print"
|
15
16
|
# gem 'sinatra-twitter-bootstrap', :require => 'sinatra/twitter-bootstrap'
|
16
17
|
# Add dependencies to develop your gem here.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/torque_rm.rb
CHANGED
data/lib/torque_rm/qstat.rb
CHANGED
@@ -1,25 +1,78 @@
|
|
1
1
|
require 'date'
|
2
|
+
require 'time'
|
2
3
|
require 'json'
|
3
4
|
require 'json/add/core'
|
5
|
+
require 'ostruct'
|
6
|
+
|
4
7
|
module TORQUE
|
5
8
|
class Qstat
|
6
|
-
FIELDS = %w(job_id job_name job_owner resources_used_cput resources_used_mem resources_used_vmem
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Job = Struct.new(:job_id, :job_name, :job_owner, :resources_used_cput, :resources_used_mem, :resources_used_vmem,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
#DEPRECATED # FIELDS = %w(job_id job_name job_owner resources_used_cput resources_used_mem resources_used_vmem
|
10
|
+
# resources_used_walltime job_state substate queue server checkpoint ctime error_path exec_host
|
11
|
+
# exec_port hold_types join_path keep_files mail_points mail_users mtime output_path
|
12
|
+
# priority qtime rerunable resource_list session_id shell_path_list variable_list
|
13
|
+
# euser egroup hashname queue_rank queue_type comment etime
|
14
|
+
# exit_status submit_args walltime_remaining start_time start_count fault_tolerant comp_time job_radix total_runtime
|
15
|
+
# submit_host nppcu)
|
16
|
+
# Job = Struct.new(:job_id, :job_name, :job_owner, :resources_used_cput, :resources_used_mem, :resources_used_vmem,
|
17
|
+
# :resources_used_walltime, :job_state, :substate, :queue, :server, :checkpoint, :ctime, :error_path, :exec_host,
|
18
|
+
# :exec_port, :hold_types, :join_path, :keep_files, :mail_points, :mail_users, :mtime, :output_path,
|
19
|
+
# :priority, :qtime, :rerunable, :resource_list, :session_id,
|
20
|
+
# :shell_path_list, :variable_list, :euser, :egroup, :hashname, :queue_rank, :queue_type, :comment,
|
21
|
+
# :etime, :exit_status, :submit_args, :walltime_remaining, :start_time,
|
22
|
+
# :start_count, :fault_tolerant, :comp_time, :job_radix, :total_runtime, :submit_host, :nppcu) do
|
23
|
+
class EnanchedOpenStruct < OpenStruct
|
24
|
+
def initialize(*args)
|
25
|
+
super(*args)
|
26
|
+
casting
|
27
|
+
alias_case_insensitive_methods
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Cast generic types from string to most near type selected by pattern matching
|
33
|
+
def casting
|
34
|
+
each_pair do |k,v| #converting
|
35
|
+
if v =~ (/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]/)
|
36
|
+
send "#{k}=", Time.parse(v)
|
37
|
+
elsif k.to_s =~ /time/ && v.is_a?(String) && v =~ (/^[0-9]+$/)
|
38
|
+
send "#{k}=", Time.at(v.to_i).to_datetime
|
39
|
+
elsif v =~ (/(true)$/i)
|
40
|
+
send "#{k}=", true
|
41
|
+
elsif v =~ (/(false)$/i)
|
42
|
+
send "#{k}=", false
|
43
|
+
elsif v =~ (/^[0-9]+$/)
|
44
|
+
send "#{k}=", v.to_i
|
45
|
+
elsif v.is_a? Hash
|
46
|
+
send "#{k}=", EnanchedOpenStruct.new(v)
|
47
|
+
end
|
48
|
+
end #each pair
|
49
|
+
end #casting
|
50
|
+
|
51
|
+
def alias_case_insensitive_methods
|
52
|
+
each_pair do |k,v| #adding methods
|
53
|
+
unless k == k.downcase
|
54
|
+
original=k.to_sym
|
55
|
+
newer=k.downcase.to_sym
|
56
|
+
class_eval do
|
57
|
+
alias_method newer, original
|
58
|
+
alias_method "#{newer}=", "#{original}="
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
class Job < EnanchedOpenStruct
|
20
67
|
#add here your custom method for Qstat::Job
|
21
68
|
|
22
|
-
|
69
|
+
|
70
|
+
def initialize(*args)
|
71
|
+
super(*args)
|
72
|
+
class_eval do
|
73
|
+
alias_method :id, :job_id
|
74
|
+
end
|
75
|
+
end
|
23
76
|
|
24
77
|
def is_runnig?
|
25
78
|
job_state == 'R'
|
@@ -43,11 +96,11 @@ module TORQUE
|
|
43
96
|
alias is_in_queue? is_queued?
|
44
97
|
|
45
98
|
def time
|
46
|
-
return (
|
99
|
+
return (resources_used.walltime) ? resources_used.walltime : "-"
|
47
100
|
end
|
48
101
|
|
49
102
|
def memory
|
50
|
-
|
103
|
+
resources_used.mem ? (resources_used.mem.split("kb").first.to_f/1000).round(1) : "0"
|
51
104
|
end
|
52
105
|
|
53
106
|
def node
|
@@ -55,15 +108,13 @@ module TORQUE
|
|
55
108
|
end
|
56
109
|
|
57
110
|
def procs
|
58
|
-
resource_list.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
return "-"
|
111
|
+
if resource_list.ncpus
|
112
|
+
return resource_list.ncpus
|
113
|
+
elsif resource_list.nodes
|
114
|
+
return resource_list.nodes.split("ppn=")[-1]
|
115
|
+
else
|
116
|
+
return "-"
|
117
|
+
end
|
67
118
|
end
|
68
119
|
|
69
120
|
def fields
|
@@ -98,108 +149,108 @@ module TORQUE
|
|
98
149
|
|
99
150
|
end # Job
|
100
151
|
|
101
|
-
class Parser < Parslet::Parser
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
# a lot of maybe, maybe everything
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
end #Parser
|
191
|
-
|
192
|
-
class Trans < Parslet::Transform
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
end #Trans
|
152
|
+
# class Parser < Parslet::Parser
|
153
|
+
# rule(:newline) { match('\n').repeat(1) }
|
154
|
+
# rule(:space) { match('\s').repeat }
|
155
|
+
# rule(:space?) { space.maybe }
|
156
|
+
# rule(:tab) { match('\t').repeat(1) }
|
157
|
+
# rule(:newline?) { newline.maybe }
|
158
|
+
# rule(:value) { match('[a-zA-Z0-9\.\_\@\/\+ \,\-:=]').repeat }
|
159
|
+
# rule(:qstat) { job_id.repeat }
|
160
|
+
# rule(:resource_list_name) { str("Resource_List") >> str(".") >> (match('[a-zA-Z]').repeat(1).as(:string)).as(:name) }
|
161
|
+
# rule(:split_assignment) { (space >> str("=") >> space).repeat(1) }
|
162
|
+
# root(:qstat)
|
163
|
+
|
164
|
+
# rule(:variable_item){ tab >> value >> newline }
|
165
|
+
# rule(:variable_items) { variable_item.repeat }
|
166
|
+
# rule(:variable_list_items) { value >> newline >> variable_items.maybe}
|
167
|
+
|
168
|
+
|
169
|
+
# rule(:job_id) {(str("Job Id:") >> space >> value.as(:string)).as(:job_id) >> newline? >> fields.maybe >> newline? }
|
170
|
+
# rule(:job_name) {(space >> str("Job_Name = ") >> value.as(:string) >> newline).as(:job_name)}
|
171
|
+
# rule(:job_owner) {(space >> str("Job_Owner = ") >> value.as(:string) >> newline).as(:job_owner)}
|
172
|
+
# rule(:resources_used_cput) {(space >> str("resources_used.cput = ") >> value.as(:string) >> newline).as(:resources_used_cput)}
|
173
|
+
# rule(:resources_used_mem) {(space >> str("resources_used.mem = ") >> value.as(:string) >> newline).as(:resources_used_mem)}
|
174
|
+
# rule(:resources_used_vmem) {(space >> str("resources_used.vmem = ") >> value.as(:string) >> newline).as(:resources_used_vmem)}
|
175
|
+
# rule(:resources_used_walltime) {(space >> str("resources_used.walltime = ") >> value.as(:string) >> newline).as(:resources_used_walltime)}
|
176
|
+
# rule(:job_state) {(space >> str("job_state = ") >> value.as(:string) >> newline).as(:job_state)}
|
177
|
+
# rule(:queue) {(space >> str("queue = ") >> value.as(:string) >> newline).as(:queue)}
|
178
|
+
# rule(:server) {(space >> str("server = ") >> value.as(:string) >> newline).as(:server)}
|
179
|
+
# rule(:checkpoint) {(space >> str("Checkpoint = ") >> value.as(:string) >> newline).as(:checkpoint)}
|
180
|
+
# rule(:ctime) {(space >> str("ctime = ") >> value.as(:datetime) >> newline).as(:ctime)}
|
181
|
+
# rule(:error_path) {(space >> str("Error_Path = ") >> value.as(:string) >> newline).as(:error_path)}
|
182
|
+
# rule(:exec_host) {(space >> str("exec_host = ") >> value.as(:string) >> newline).as(:exec_host)}
|
183
|
+
# rule(:exec_port) {(space >> str("exec_port = ") >> value.as(:string) >> newline).as(:exec_port)}
|
184
|
+
# rule(:hold_types) {(space >> str("Hold_Types = ") >> value.as(:string) >> newline).as(:hold_types)}
|
185
|
+
# rule(:join_path) {(space >> str("Join_Path = ") >> value.as(:string) >> newline).as(:join_path)}
|
186
|
+
# rule(:keep_files) {(space >> str("Keep_Files = ") >> value.as(:string) >> newline).as(:keep_files)}
|
187
|
+
# rule(:mail_points) {(space >> str("Mail_Points = ") >> value.as(:string) >> newline).as(:mail_points)}
|
188
|
+
# rule(:mail_users) {(space >> str("Mail_Users = ") >> value.as(:string) >> newline).as(:mail_users)}
|
189
|
+
# rule(:mail_users?) {mail_users.maybe }
|
190
|
+
# rule(:mtime) {(space >> str("mtime = ") >> value.as(:datetime) >> newline).as(:mtime)}
|
191
|
+
# rule(:output_path) {(space >> str("Output_Path = ") >> value.as(:string) >> newline).as(:output_path)}
|
192
|
+
# rule(:priority) {(space >> str("Priority = ") >> value.as(:integer) >> newline).as(:priority)}
|
193
|
+
# rule(:qtime) {(space >> str("qtime = ") >> value.as(:datetime) >> newline).as(:qtime)}
|
194
|
+
# rule(:rerunable) {(space >> str("Rerunable = ") >> value.as(:boolean) >> newline).as(:rerunable)}
|
195
|
+
|
196
|
+
# rule(:resource) {(space >> resource_list_name >> str(" = ") >> (value.as(:string)).as(:value) >> newline).as(:resource)}
|
197
|
+
# rule(:resource_list) { resource.repeat.as(:resource_list)}
|
198
|
+
|
199
|
+
# rule(:session_id) {(space >> str("session_id = ") >> value.as(:integer) >> newline?).as(:session_id)}
|
200
|
+
# rule(:substate) {(space >> str("substate = ") >> value.as(:integer) >> newline?).as(:substate)} # Torque 2.4.16
|
201
|
+
# rule(:shell_path_list) {(space >> str("Shell_Path_List = ") >> value.as(:string) >> newline?).as(:shell_path_list)}
|
202
|
+
# rule(:variable_list) {(space >> str("Variable_List = ") >> variable_list_items.as(:string) >> newline?).as(:variable_list)}
|
203
|
+
# rule(:euser) {(space >> str("euser = ") >> value.as(:string) >> newline?).as(:euser)} # Torque 2.4.16
|
204
|
+
# rule(:egroup) {(space >> str("egroup = ") >> value.as(:string) >> newline?).as(:egroup)} # Torque 2.4.16
|
205
|
+
# rule(:hashname) {(space >> str("hashname = ") >> value.as(:string) >> newline?).as(:hashname)} # Torque 2.4.16
|
206
|
+
# rule(:queue_rank) {(space >> str("queue_rank = ") >> value.as(:string) >> newline?).as(:queue_rank)} # Torque 2.4.16
|
207
|
+
# rule(:queue_type) {(space >> str("queue_type = ") >> value.as(:string) >> newline?).as(:queue_type)} # Torque 2.4.16
|
208
|
+
# rule(:comment) {(space >> str("comment = ") >> value.as(:string) >> newline?).as(:comment)} # Torque 2.4.16
|
209
|
+
# rule(:etime) {(space >> str("etime = ") >> value.as(:datetime) >> newline?).as(:etime)}
|
210
|
+
# rule(:exit_status) {(space >> str("exit_status = ") >> value.as(:string) >> newline?).as(:exit_status)}
|
211
|
+
# rule(:submit_args) {(space >> str("submit_args = ") >> value.as(:string) >> newline?).as(:submit_args)}
|
212
|
+
# rule(:start_time) {(space >> str("start_time = ") >> value.as(:datetime) >> newline?).as(:start_time)}
|
213
|
+
# rule(:walltime_remaining) {(space >> str("Walltime.Remaining = ") >> value.as(:integer) >> newline?).as(:walltime_remaining)} # Torque 2.4.16
|
214
|
+
# rule(:start_count) {(space >> str("start_count = ") >> value.as(:integer) >> newline?).as(:start_count)}
|
215
|
+
# rule(:fault_tolerant) {(space >> str("fault_tolerant = ") >> value.as(:boolean) >> newline?).as(:fault_tolerant)}
|
216
|
+
# rule(:comp_time) {(space >> str("comp_time = ") >> value.as(:datetime) >> newline?).as(:comp_time)}
|
217
|
+
# rule(:job_radix) {(space >> str("job_radix = ") >> value.as(:string) >> newline?).as(:job_radix)}
|
218
|
+
# rule(:total_runtime) {(space >> str("total_runtime = ") >> value.as(:string) >> newline?).as(:total_runtime)}
|
219
|
+
# rule(:submit_host) {(space >> str("submit_host = ") >> value.as(:string) >> newline?).as(:submit_host)}
|
220
|
+
# rule(:nppcu) {(space >> str("nppcu = ") >> value.as(:integer) >> newline?).as(:nppcu)} #Torque 4.2.5 / Maui 3.3.1
|
221
|
+
|
222
|
+
# # a lot of maybe, maybe everything
|
223
|
+
|
224
|
+
# rule(:fields) { job_name.maybe >> job_owner.maybe >> resources_used_cput.maybe >> resources_used_mem.maybe >>
|
225
|
+
# resources_used_vmem.maybe >> resources_used_walltime.maybe >> job_state.maybe >> queue.maybe >> server.maybe >>
|
226
|
+
# checkpoint.maybe >> ctime.maybe >> error_path.maybe >> exec_host.maybe >> exec_port.maybe >> hold_types.maybe >>
|
227
|
+
# join_path.maybe >> keep_files.maybe >> mail_points.maybe >> mail_users.maybe >> mtime.maybe >> output_path.maybe >>
|
228
|
+
# tab.maybe >> newline? >> priority.maybe >> qtime.maybe >> rerunable.maybe >>
|
229
|
+
# resource_list.maybe >> session_id.maybe >> substate.maybe >> shell_path_list.maybe >>
|
230
|
+
# variable_list.maybe >>
|
231
|
+
# euser.maybe >> egroup.maybe >> hashname.maybe >>
|
232
|
+
# queue_rank.maybe >> queue_type.maybe >>
|
233
|
+
# comment.maybe >> etime.maybe >> exit_status.maybe >>
|
234
|
+
# submit_args.maybe >> start_time .maybe >>
|
235
|
+
# walltime_remaining.maybe >> start_count.maybe >> fault_tolerant.maybe >> comp_time.maybe >> job_radix.maybe >> total_runtime.maybe >>
|
236
|
+
# submit_host.maybe >> nppcu.maybe >>
|
237
|
+
# newline?
|
238
|
+
# }
|
239
|
+
|
240
|
+
|
241
|
+
# end #Parser
|
242
|
+
|
243
|
+
# class Trans < Parslet::Transform
|
244
|
+
# rule(:datetime => simple(:datetime)) {DateTime.parse(datetime)}
|
245
|
+
# rule(:string => simple(:string)) {String(string)}
|
246
|
+
# rule(:integer => simple(:integer)) {Integer(integer)}
|
247
|
+
# rule(:boolean => simple(:boolean)) {String(boolean) == "True"}
|
248
|
+
# end #Trans
|
198
249
|
|
199
250
|
|
200
251
|
def initialize
|
201
|
-
@parser = Parser.new
|
202
|
-
@transformer = Trans.new
|
252
|
+
# @parser = Parser.new #DEPRECATED
|
253
|
+
# @transformer = Trans.new #DEPRECATED
|
203
254
|
@last_query = nil #cache last query, it can be useful to generate some kind of statistics ?
|
204
255
|
end #initialize
|
205
256
|
|
@@ -210,45 +261,56 @@ module TORQUE
|
|
210
261
|
def fields
|
211
262
|
FIELDS
|
212
263
|
end
|
264
|
+
|
213
265
|
# hash can contain keys:
|
214
266
|
# type = :raw just print a string
|
215
267
|
# job_id = job.id it will print info only about the specified job
|
216
268
|
# job_ids = ["1.server", "2.server", "3.server"] get an array for requested jobs
|
269
|
+
# returns results which is an Array of Job
|
217
270
|
def query(hash={})
|
218
|
-
result = TORQUE.server.qstat(
|
219
|
-
results = nil
|
271
|
+
# result = TORQUE.server.qstat('-f')
|
220
272
|
if hash[:type] == :raw
|
221
|
-
|
273
|
+
TORQUE.server.qstat('-f').to_s #returns
|
274
|
+
elsif hash[:type] == :xml
|
275
|
+
TORQUE.server.qstat('-f','-x') #returns
|
222
276
|
else
|
277
|
+
# begin
|
278
|
+
data_xml = Hash.from_xml(TORQUE.server.qstat('-f','-x').to_s)
|
279
|
+
@last_query = if data_xml.nil?
|
280
|
+
[] #returns
|
281
|
+
else
|
282
|
+
data_array = data_xml["Data"]["Job"].is_a?(Hash) ? [data_xml["Data"]["Job"]] : data_xml["Data"]["Job"]
|
283
|
+
jobs = data_array.map do |job_xml|
|
284
|
+
Job.new job_xml
|
285
|
+
end # do
|
286
|
+
if hash.key? :job_id
|
287
|
+
# if hash[:job_id]..is_a? String
|
288
|
+
jobs.select! {|job| (hash[:job_id].to_s == job.job_id || hash[:job_id].to_s == job.job_id.split(".").first)}
|
289
|
+
# else
|
290
|
+
# warn "You gave me #{hash[:job_id].class}, only String is supported."
|
291
|
+
# end
|
292
|
+
elsif hash.key? :job_ids
|
293
|
+
if hash[:job_ids].is_a? Array
|
294
|
+
jobs.select! {|job| (hash[:job_ids].include?(job.job_id) || hash[:job_ids].include?(job.job_id.split(".").first))}
|
295
|
+
elsif hash[:job_ids].is_a? String
|
296
|
+
warn "To be implemented for String object."
|
297
|
+
else
|
298
|
+
warm "To be implemented for #{hash[:job_ids].class}"
|
299
|
+
end
|
300
|
+
else
|
301
|
+
jobs
|
302
|
+
end
|
303
|
+
end # else
|
223
304
|
|
224
|
-
begin
|
225
305
|
# puts result.to_s.inspect
|
226
306
|
# puts result.to_s.gsub(/\n\t/,'').inspect
|
227
|
-
results = @transformer.apply(@parser.parse(result.to_s.gsub(/\n\t/,'')))
|
228
|
-
rescue Parslet::ParseFailed => failure
|
229
|
-
|
230
|
-
end
|
307
|
+
# results = @transformer.apply(@parser.parse(result.to_s.gsub(/\n\t/,'')))
|
308
|
+
# rescue Parslet::ParseFailed => failure
|
309
|
+
# puts failure.cause.ascii_tree
|
310
|
+
# end
|
231
311
|
|
232
|
-
results = [] if results.is_a?(String) && results.empty?
|
233
|
-
|
234
|
-
# if hash[:job_id]..is_a? String
|
235
|
-
|
236
|
-
results.select! {|j| (hash[:job_id].to_s == j[:job_id] || hash[:job_id].to_s == j[:job_id].to_s.split(".").first)}
|
237
|
-
# else
|
238
|
-
# warn "You gave me #{hash[:job_id].class}, only String is supported."
|
239
|
-
# end
|
240
|
-
elsif hash.key? :job_ids
|
241
|
-
if hash[:job_ids].is_a? Array
|
242
|
-
results.select! {|j| (hash[:job_ids].include?(j[:job_id].to_s) || hash[:job_ids].include?(j[:job_id].to_s.split(".").first))}
|
243
|
-
elsif hash[:job_ids].is_a? String
|
244
|
-
warn "To be implemented for String object."
|
245
|
-
else
|
246
|
-
warm "To be implemented for #{hash[:job_ids].class}"
|
247
|
-
end
|
248
|
-
else
|
249
|
-
results
|
250
|
-
end
|
251
|
-
@last_query = from_parselet_to_jobs(results)
|
312
|
+
# results = [] if results.is_a?(String) && results.empty?
|
313
|
+
# @last_query = from_parselet_to_jobs(results)
|
252
314
|
end
|
253
315
|
end #query
|
254
316
|
|
@@ -284,19 +346,21 @@ private
|
|
284
346
|
else
|
285
347
|
jobs_info.each do |job|
|
286
348
|
line = [job.job_id.split(".").first,job.job_name,job.node,job.procs,"#{job.memory} mb","#{job.time}",job.queue,job.job_state]
|
349
|
+
# puts line.inspect
|
350
|
+
# puts line[-1]
|
287
351
|
if job.completed?
|
288
|
-
line[-1] = "Completed"; rows << line.map {|l| l.underline}
|
352
|
+
line[-1] = "Completed"; rows << line.map {|l| l.to_s.underline}
|
289
353
|
elsif job.queued?
|
290
|
-
line[-1] = "Queued"; rows << line.map {|l| l.light_blue}
|
354
|
+
line[-1] = "Queued"; rows << line.map {|l| l.to_s.light_blue}
|
291
355
|
elsif job.running?
|
292
|
-
line[-1] = "Running"; rows << line.map {|l| l.green}
|
356
|
+
line[-1] = "Running"; rows << line.map {|l| l.to_s.green}
|
293
357
|
elsif job.exited?
|
294
|
-
line[-1] = "Exiting"; rows << line.map {|l| l.green.blink}
|
358
|
+
line[-1] = "Exiting"; rows << line.map {|l| l.to_s.green.blink}
|
295
359
|
else
|
296
|
-
rows << line.map {|l| l.red.blink}
|
360
|
+
rows << line.map {|l| l.to_s.red.blink}
|
297
361
|
end
|
298
362
|
end
|
299
|
-
print "\nSummary of submitted jobs for user: ".light_blue+"#{jobs_info.first
|
363
|
+
print "\nSummary of submitted jobs for user: ".light_blue+"#{jobs_info.first.job_owner.split("@").first.green}\n\n"
|
300
364
|
table = Terminal::Table.new :headings => headings, :rows => rows
|
301
365
|
Range.new(0,table.number_of_columns-1).to_a.each {|c| table.align_column(c,:center) } # set all columns alignment to :center
|
302
366
|
puts table
|
data/torque_rm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "torque_rm"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Raoul Jean Pierre Bonnal"]
|
12
|
-
s.date = "2013-09-
|
12
|
+
s.date = "2013-09-17"
|
13
13
|
s.description = "TORQUE Resource Manager for Ruby. Submit, check and control your job directly from Ruby."
|
14
14
|
s.email = "ilpuccio.febo@gmail.com"
|
15
15
|
s.executables = ["torque_rm_rest"]
|
@@ -65,6 +65,7 @@ Gem::Specification.new do |s|
|
|
65
65
|
s.add_runtime_dependency(%q<shotgun>, [">= 0"])
|
66
66
|
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
67
67
|
s.add_runtime_dependency(%q<sinatra-twitter-bootstrap>, [">= 0"])
|
68
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
68
69
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
69
70
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
70
71
|
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
@@ -80,6 +81,7 @@ Gem::Specification.new do |s|
|
|
80
81
|
s.add_dependency(%q<shotgun>, [">= 0"])
|
81
82
|
s.add_dependency(%q<haml>, [">= 0"])
|
82
83
|
s.add_dependency(%q<sinatra-twitter-bootstrap>, [">= 0"])
|
84
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
83
85
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
84
86
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
85
87
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
@@ -96,6 +98,7 @@ Gem::Specification.new do |s|
|
|
96
98
|
s.add_dependency(%q<shotgun>, [">= 0"])
|
97
99
|
s.add_dependency(%q<haml>, [">= 0"])
|
98
100
|
s.add_dependency(%q<sinatra-twitter-bootstrap>, [">= 0"])
|
101
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
99
102
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
100
103
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
101
104
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torque_rm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raoul Jean Pierre Bonnal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rye
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: activesupport
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: rspec
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|