ood_core 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -455,6 +455,13 @@ module OodCore
455
455
  # Parse hash describing Slurm job status
456
456
  def parse_job_info(v)
457
457
  allocated_nodes = parse_nodes(v[:node_list])
458
+ if allocated_nodes.empty?
459
+ if v[:scheduled_nodes] && v[:scheduled_nodes] != "(null)"
460
+ allocated_nodes = parse_nodes(v[:scheduled_nodes])
461
+ else
462
+ allocated_nodes = [ { name: nil } ] * v[:nodes].to_i
463
+ end
464
+ end
458
465
  Info.new(
459
466
  id: v[:job_id],
460
467
  status: get_state(v[:state_compact]),
@@ -466,6 +473,7 @@ module OodCore
466
473
  procs: v[:cpus],
467
474
  queue_name: v[:partition],
468
475
  wallclock_time: duration_in_seconds(v[:time_used]),
476
+ wallclock_limit: duration_in_seconds(v[:time_limit]),
469
477
  cpu_time: nil,
470
478
  submission_time: Time.parse(v[:submit_time]),
471
479
  dispatch_time: v[:start_time] == "N/A" ? nil : Time.parse(v[:start_time]),
@@ -1,6 +1,6 @@
1
1
  require "ood_core/refinements/hash_extensions"
2
2
 
3
- gem "pbs", "~> 2.0"
3
+ gem "pbs", "~> 2.1"
4
4
  require "pbs"
5
5
 
6
6
  module OodCore
@@ -27,6 +27,7 @@ module OodCore
27
27
  # An adapter object that describes the communication with a Torque resource
28
28
  # manager for job management.
29
29
  class Torque < Adapter
30
+ using Refinements::ArrayExtensions
30
31
  using Refinements::HashExtensions
31
32
 
32
33
  # Mapping of state characters for PBS
@@ -133,6 +134,24 @@ module OodCore
133
134
  raise JobAdapterError, e.message
134
135
  end
135
136
 
137
+ # Retrieve info for all jobs for a given owner or owners from the
138
+ # resource manager
139
+ # @param owner [#to_s, Array<#to_s>] the owner(s) of the jobs
140
+ # @raise [JobAdapterError] if something goes wrong getting job info
141
+ # @return [Array<Info>] information describing submitted jobs
142
+ def info_where_owner(owner)
143
+ owner = Array.wrap(owner).map(&:to_s)
144
+ @pbs.select_jobs(
145
+ attribs: [
146
+ { name: "User_List", value: owner.join(","), op: :eq }
147
+ ]
148
+ ).map do |k, v|
149
+ parse_job_info(k, v)
150
+ end
151
+ rescue PBS::Error => e
152
+ raise JobAdapterError, e.message
153
+ end
154
+
136
155
  # Retrieve job info from the resource manager
137
156
  # @param id [#to_s] the id of the job
138
157
  # @raise [JobAdapterError] if something goes wrong getting job info
@@ -238,6 +257,16 @@ module OodCore
238
257
  def parse_job_info(k, v)
239
258
  /^(?<job_owner>[\w-]+)@/ =~ v[:Job_Owner]
240
259
  allocated_nodes = parse_nodes(v[:exec_host] || "")
260
+ procs = allocated_nodes.inject(0) { |sum, x| sum + x[:procs] }
261
+ if allocated_nodes.empty?
262
+ allocated_nodes = [ { name: nil } ] * v.fetch(:Resource_List, {})[:nodect].to_i
263
+ # Only cover the simplest of cases where there is a single
264
+ # `ppn=##` and ignore otherwise
265
+ ppn_list = v.fetch(:Resource_List, {})[:nodes].to_s.scan(/ppn=(\d+)/)
266
+ if ppn_list.size == 1
267
+ procs = allocated_nodes.size * ppn_list.first.first.to_i
268
+ end
269
+ end
241
270
  Info.new(
242
271
  id: k,
243
272
  status: STATE_MAP.fetch(v[:job_state], :undetermined),
@@ -246,9 +275,10 @@ module OodCore
246
275
  job_name: v[:Job_Name],
247
276
  job_owner: job_owner,
248
277
  accounting_id: v[:Account_Name],
249
- procs: allocated_nodes.inject(0) { |sum, x| sum + x[:procs] },
278
+ procs: procs,
250
279
  queue_name: v[:queue],
251
280
  wallclock_time: duration_in_seconds(v.fetch(:resources_used, {})[:walltime]),
281
+ wallclock_limit: duration_in_seconds(v.fetch(:Resource_List, {})[:walltime]),
252
282
  cpu_time: duration_in_seconds(v.fetch(:resources_used, {})[:cput]),
253
283
  submission_time: v[:ctime],
254
284
  dispatch_time: v[:start_time],
@@ -44,6 +44,10 @@ module OodCore
44
44
  # @return [Fixnum, nil] wallclock time
45
45
  attr_reader :wallclock_time
46
46
 
47
+ # The total wall clock time limit in seconds
48
+ # @return [Fixnum, nil] wallclock time limit
49
+ attr_reader :wallclock_limit
50
+
47
51
  # The accumulated CPU time in seconds
48
52
  # @return [Fixnum, nil] cpu time
49
53
  attr_reader :cpu_time
@@ -71,6 +75,7 @@ module OodCore
71
75
  # @param procs [#to_i, nil] allocated total number of procs
72
76
  # @param queue_name [#to_s, nil] queue name
73
77
  # @param wallclock_time [#to_i, nil] wallclock time
78
+ # @param wallclock_limit [#to_i, nil] wallclock time limit
74
79
  # @param cpu_time [#to_i, nil] cpu time
75
80
  # @param submission_time [#to_i, nil] submission time
76
81
  # @param dispatch_time [#to_i, nil] dispatch time
@@ -78,8 +83,8 @@ module OodCore
78
83
  def initialize(id:, status:, allocated_nodes: [], submit_host: nil,
79
84
  job_name: nil, job_owner: nil, accounting_id: nil,
80
85
  procs: nil, queue_name: nil, wallclock_time: nil,
81
- cpu_time: nil, submission_time: nil, dispatch_time: nil,
82
- native: nil, **_)
86
+ wallclock_limit: nil, cpu_time: nil, submission_time: nil,
87
+ dispatch_time: nil, native: nil, **_)
83
88
  @id = id.to_s
84
89
  @status = Status.new(state: status.to_sym)
85
90
  @allocated_nodes = allocated_nodes.map { |n| NodeInfo.new(n.to_h) }
@@ -90,6 +95,7 @@ module OodCore
90
95
  @procs = procs && procs.to_i
91
96
  @queue_name = queue_name && queue_name.to_s
92
97
  @wallclock_time = wallclock_time && wallclock_time.to_i
98
+ @wallclock_limit = wallclock_limit && wallclock_limit.to_i
93
99
  @cpu_time = cpu_time && cpu_time.to_i
94
100
  @submission_time = submission_time && Time.at(submission_time.to_i)
95
101
  @dispatch_time = dispatch_time && Time.at(dispatch_time.to_i)
@@ -110,6 +116,7 @@ module OodCore
110
116
  procs: procs,
111
117
  queue_name: queue_name,
112
118
  wallclock_time: wallclock_time,
119
+ wallclock_limit: wallclock_limit,
113
120
  cpu_time: cpu_time,
114
121
  submission_time: submission_time,
115
122
  dispatch_time: dispatch_time,
@@ -19,6 +19,15 @@ module OodCore
19
19
  keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
20
20
  keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if has_key?(k) }
21
21
  end
22
+
23
+ # Return a hash with non `nil` values
24
+ # @example
25
+ # { a: 1, b: nil, c: 3, d: nil }.compact
26
+ # # => {:a=>1, :c=>3}
27
+ # @see https://apidock.com/rails/Hash/compact
28
+ def compact
29
+ self.select { |_, value| !value.nil? }
30
+ end
22
31
  end
23
32
  end
24
33
  end
@@ -1,4 +1,4 @@
1
1
  module OodCore
2
2
  # The current version of {OodCore}
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
data/ood_core.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = ">= 2.2.0"
24
24
 
25
25
  spec.add_runtime_dependency "ood_support", "~> 0.0.2"
26
- spec.add_development_dependency "pbs", "~> 2.0", ">= 2.0.3"
26
+ spec.add_development_dependency "pbs", "~> 2.1", ">= 2.1.0"
27
27
  spec.add_development_dependency "bundler", "~> 1.7"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ood_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Nicklas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ood_support
@@ -30,20 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '2.1'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 2.0.3
36
+ version: 2.1.0
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '2.0'
43
+ version: '2.1'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.0.3
46
+ version: 2.1.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +136,10 @@ files:
136
136
  - lib/ood_core/acl/adapter.rb
137
137
  - lib/ood_core/acl/adapters/group.rb
138
138
  - lib/ood_core/acl/factory.rb
139
+ - lib/ood_core/batch_connect/factory.rb
140
+ - lib/ood_core/batch_connect/template.rb
141
+ - lib/ood_core/batch_connect/templates/basic.rb
142
+ - lib/ood_core/batch_connect/templates/vnc.rb
139
143
  - lib/ood_core/cluster.rb
140
144
  - lib/ood_core/clusters.rb
141
145
  - lib/ood_core/errors.rb
@@ -143,6 +147,7 @@ files:
143
147
  - lib/ood_core/job/adapters/lsf.rb
144
148
  - lib/ood_core/job/adapters/lsf/batch.rb
145
149
  - lib/ood_core/job/adapters/lsf/helper.rb
150
+ - lib/ood_core/job/adapters/pbspro.rb
146
151
  - lib/ood_core/job/adapters/slurm.rb
147
152
  - lib/ood_core/job/adapters/torque.rb
148
153
  - lib/ood_core/job/factory.rb