pbs 2.0.4 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +22 -3
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/pbs/batch.rb +43 -4
- data/lib/pbs/torque.rb +20 -11
- data/lib/pbs/version.rb +1 -1
- data/pbs.gemspec +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a57e8e24fb6fba02e681f2d9dd2ada214d09f3
|
4
|
+
data.tar.gz: 04edfbd44cc1fbf2558f0c26ce6677e8d4fa8fef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5a98efcdb34c5679c078fbf6a151d9babb108ff3090b5517295b5d0a8c8f6f8676bbed1c2808c5e0369cb308f6b3013f87289822ae35e539509df9f8191583d
|
7
|
+
data.tar.gz: 0f32ca27b52b5afc182df01cb9a7d23581bbe69cb2e28eb096426b5a49f6d0db20209fd15d3c9af9ed74c15d2736f1b0557eab39d29b8c964c62688f95b8442d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -34,7 +34,7 @@ oakley = PBS::Batch.new(
|
|
34
34
|
)
|
35
35
|
|
36
36
|
# Get status information for this batch server
|
37
|
-
# see
|
37
|
+
# see https://linux.die.net/man/7/pbs_server_attributes
|
38
38
|
oakley.get_status
|
39
39
|
#=>
|
40
40
|
#{
|
@@ -84,7 +84,7 @@ b.get_node("n0003")
|
|
84
84
|
#=> { ... }
|
85
85
|
|
86
86
|
# Get list of queues from batch server
|
87
|
-
# see
|
87
|
+
# see https://linux.die.net/man/7/pbs_queue_attributes
|
88
88
|
b.get_queues
|
89
89
|
#=>
|
90
90
|
#{
|
@@ -107,7 +107,7 @@ b.get_queue("serial")
|
|
107
107
|
#=> { ... }
|
108
108
|
|
109
109
|
# Get list of jobs from batch server
|
110
|
-
# see
|
110
|
+
# see https://linux.die.net/man/7/pbs_job_attributes
|
111
111
|
b.get_jobs
|
112
112
|
#=>
|
113
113
|
#{
|
@@ -128,6 +128,25 @@ b.get_jobs
|
|
128
128
|
# To get info about a single job
|
129
129
|
b.get_job("6621251.oak-batch.osc.edu")
|
130
130
|
#=> { ... }
|
131
|
+
|
132
|
+
# Get selected list of jobs from batch server
|
133
|
+
# see https://linux.die.net/man/3/pbs_selstat
|
134
|
+
b.select_jobs(attribs: [{name: "User_List", value: "bob", op: :eq}])
|
135
|
+
#=>
|
136
|
+
#{
|
137
|
+
# "6621261.oak-batch.osc.edu" => {
|
138
|
+
# :Job_Name => "FEA_solver_1",
|
139
|
+
# :Job_Owner => "bob@oakley01.osc.edu",
|
140
|
+
# :job_state => "R",
|
141
|
+
# ...
|
142
|
+
# },
|
143
|
+
# "6621262.oak-batch.osc.edu" => {
|
144
|
+
# :Job_Name => "FEA_solver_2",
|
145
|
+
# :Job_Owner => "bob@oakley01.osc.edu",
|
146
|
+
# :job_state => "Q",
|
147
|
+
# ...
|
148
|
+
# }, ...
|
149
|
+
#}
|
131
150
|
```
|
132
151
|
|
133
152
|
### Simple Job Submission
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pbs"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
data/lib/pbs/batch.rb
CHANGED
@@ -179,6 +179,35 @@ module PBS
|
|
179
179
|
get_nodes(id: id, **kwargs)
|
180
180
|
end
|
181
181
|
|
182
|
+
# Get a list of hashes of the selected jobs on the batch server
|
183
|
+
# @example Status info for jobs owned by Bob
|
184
|
+
# my_conn.select_jobs(attribs: [{name: "User_List", value: "bob", op: :eq}])
|
185
|
+
# #=>
|
186
|
+
# #{
|
187
|
+
# # "10219837.oak-batch.osc.edu" => {
|
188
|
+
# # :Job_Owner => "bob@oakley02.osc.edu",
|
189
|
+
# # :Job_Name => "CFD_Solver",
|
190
|
+
# # ...
|
191
|
+
# # },
|
192
|
+
# # "10219839.oak-batch.osc.edu" => {
|
193
|
+
# # :Job_Owner => "bob@oakley02.osc.edu",
|
194
|
+
# # :Job_Name => "CFD_Solver2",
|
195
|
+
# # ...
|
196
|
+
# # },
|
197
|
+
# # ...
|
198
|
+
# #}
|
199
|
+
# @param attribs [Array<#to_h>] list of hashes describing attributes to
|
200
|
+
# select on
|
201
|
+
# @return [Hash] hash of details of selected jobs
|
202
|
+
#
|
203
|
+
def select_jobs(attribs: [])
|
204
|
+
connect do |cid|
|
205
|
+
attribs = PBS::Torque::Attropl.from_list(attribs.map(&:to_h))
|
206
|
+
batch_status = Torque.pbs_selstat cid, attribs, nil
|
207
|
+
batch_status.to_h.tap { Torque.pbs_statfree batch_status }
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
182
211
|
# Get a list of hashes of the jobs on the batch server
|
183
212
|
# @example Status info for OSC Oakley jobs
|
184
213
|
# my_conn.get_jobs
|
@@ -309,12 +338,22 @@ module PBS
|
|
309
338
|
private
|
310
339
|
# Submit a script using Torque library
|
311
340
|
def pbs_submit(script, queue, headers, resources, envvars)
|
312
|
-
attribs =
|
313
|
-
|
314
|
-
|
341
|
+
attribs = []
|
342
|
+
headers.each do |name, value|
|
343
|
+
attribs << { name: name, value: value }
|
344
|
+
end
|
345
|
+
resources.each do |rsc, value|
|
346
|
+
attribs << { name: :Resource_List, resource: rsc, value: value }
|
347
|
+
end
|
348
|
+
unless envvars.empty?
|
349
|
+
attribs << {
|
350
|
+
name: :Variable_List,
|
351
|
+
value: envvars.map {|k,v| "#{k}=#{v}"}.join(",")
|
352
|
+
}
|
353
|
+
end
|
315
354
|
|
316
355
|
connect do |cid|
|
317
|
-
attropl = Torque::Attropl.
|
356
|
+
attropl = Torque::Attropl.from_list attribs
|
318
357
|
Torque.pbs_submit cid, attropl, script, queue, nil
|
319
358
|
end
|
320
359
|
end
|
data/lib/pbs/torque.rb
CHANGED
@@ -119,6 +119,16 @@ module PBS
|
|
119
119
|
# @return [BatchStatus] c-linked list of batch status objects
|
120
120
|
# @note It is up to the user to free the space of the batch status objects
|
121
121
|
|
122
|
+
# @!method self.pbs_selstat(connect, attrib, extend)
|
123
|
+
# Obtain status of selected PBS batch jobs
|
124
|
+
# batch_status * pbs_selstat(int connect, struct attropl *sel_list, char *extend)
|
125
|
+
# @see http://linux.die.net/man/3/pbs_selstat
|
126
|
+
# @param connect [Fixnum] connection identifier
|
127
|
+
# @param attrib [Attropl] the attribute operation c-linked list object
|
128
|
+
# @param extend [String] implementation defined extensions
|
129
|
+
# @return [BatchStatus] c-linked list of batch status objects
|
130
|
+
# @note It is up to the user to free the space of the batch status objects
|
131
|
+
|
122
132
|
# @!method self.pbs_submit(connect, attrib, script, destination, extend)
|
123
133
|
# Submit a PBS batch job
|
124
134
|
# char *pbs_submit(int connect, struct attropl *attrib, char *script, char *destination, char *extend)
|
@@ -159,6 +169,7 @@ module PBS
|
|
159
169
|
attach_function :pbs_statnode, [ :int, :string, Attrl.ptr, :string ], BatchStatus.ptr
|
160
170
|
attach_function :pbs_statque, [ :int, :string, Attrl.ptr, :string ], BatchStatus.ptr
|
161
171
|
attach_function :pbs_statserver, [ :int, Attrl.ptr, :string ], BatchStatus.ptr
|
172
|
+
attach_function :pbs_selstat, [ :int, Attropl.ptr, :string ], BatchStatus.ptr
|
162
173
|
|
163
174
|
# FIXME: The space for the job_identifier string is allocated by
|
164
175
|
# pbs_submit() and should be released via a call to free() when no longer
|
@@ -236,21 +247,19 @@ module PBS
|
|
236
247
|
:value, :pointer, # string for value of attribute
|
237
248
|
:op, BatchOp # operation to perform for this attribute
|
238
249
|
|
239
|
-
# Convert to C-linked list of structs from
|
240
|
-
# @param
|
250
|
+
# Convert to C-linked list of structs from list of hashes
|
251
|
+
# @param list [Array<#to_h>] list of hashes describing attribute
|
241
252
|
# @return [Attropl] generated attribute operation c-linked list object
|
242
|
-
def self.
|
243
|
-
|
244
|
-
# Format: {name: value, name: {resource: value, resource: value}}
|
245
|
-
# {a: 1, b: {c: 2, d: 3}} => [[:a,1],[:b,2,:c],[:b,3,:d]]
|
246
|
-
ary = hash.map{|k,v| [*v].map{|v2| [k,*[*v2].reverse]}}.flatten(1)
|
253
|
+
def self.from_list(list)
|
254
|
+
list = list.map(&:to_h)
|
247
255
|
attropl = nil
|
248
256
|
prev = Attropl.new(FFI::Pointer::NULL)
|
249
|
-
|
257
|
+
list.each do |attrib|
|
250
258
|
attropl = Attropl.new
|
251
|
-
attropl[:name] = FFI::MemoryPointer.from_string attrib[
|
252
|
-
attropl[:value] = FFI::MemoryPointer.from_string attrib[
|
253
|
-
attropl[:resource] = FFI::MemoryPointer.from_string attrib[
|
259
|
+
attropl[:name] = FFI::MemoryPointer.from_string attrib[:name].to_s
|
260
|
+
attropl[:value] = FFI::MemoryPointer.from_string attrib[:value].to_s
|
261
|
+
attropl[:resource] = FFI::MemoryPointer.from_string attrib[:resource].to_s
|
262
|
+
attropl[:op] = (attrib[:op] || :eq).to_sym
|
254
263
|
attropl[:next] = prev
|
255
264
|
prev = attropl
|
256
265
|
end
|
data/lib/pbs/version.rb
CHANGED
data/pbs.gemspec
CHANGED
@@ -15,7 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files`.split($/)
|
18
|
-
spec.
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
21
|
spec.require_paths = ["lib"]
|
21
22
|
spec.required_ruby_version = '>= 2.2.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Nicklas
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -86,6 +86,8 @@ files:
|
|
86
86
|
- LICENSE.txt
|
87
87
|
- README.md
|
88
88
|
- Rakefile
|
89
|
+
- bin/console
|
90
|
+
- bin/setup
|
89
91
|
- lib/pbs.rb
|
90
92
|
- lib/pbs/attributes.rb
|
91
93
|
- lib/pbs/batch.rb
|