ood_core 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8700bb802df78b66c3bb58ec5464a7f5e54a4dc3ebdc978f9816b8b5e5f7373
4
- data.tar.gz: 1e2b4ca05369c8072afe8d1069679a8f2744cdcb3ed766924a778e78af65afa2
3
+ metadata.gz: 379d230153e94bdbeca027f601afc89a525b328d8e200cc1a6a18754b3370b88
4
+ data.tar.gz: 5544e85c81b6e955a63144a056eee24d6bd5ec062de4d17a535d9df78eb5a817
5
5
  SHA512:
6
- metadata.gz: a40fc234d2be728b697b9b68884b2286ac68e63ed36eeaa4a48487af99c262fdc1f9b3010554f9e369555734c6d2c0693ca54bc2308c5817f424ec4032759563
7
- data.tar.gz: 5215f5c924002bfdc40576560898cae49b9a9750ff8d11c87d1e43cd43d0e86327a511ee97eea765a20f8ce6d6903acfaece7b26ad8e7733fd1d3f985b8a97e2
6
+ metadata.gz: 972cabe2a634f50b730e29d31a54e34c2784ea707fd562b867c8f8731e4d612bd39fd8bcacb84b49585a08131d4f9e3770195f2c1c6036fde52ff4e3d4f7124c
7
+ data.tar.gz: 4a0997de2400017ad8a921358b76341706cd4e58034c881dd8b9dfe63e9d9b7c559c42ed711a13051cd5168dde6703164714d22ee1e8ae2d7980fa33d2da3e4c
data/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.23.0] - 01-17-2023
11
+
12
+ ### Added
13
+
14
+ - [787](https://github.com/OSC/ood_core/pull/787) added the `queues` API to the adapter class with
15
+ support for Slurm.
16
+ - [783](https://github.com/OSC/ood_core/pull/783) added the `accounts` API to the adapter class with
17
+ support for Slurm.
18
+
19
+ ### Fixed
20
+
21
+ - The linux host adapter now supports apptainer in [788](https://github.com/OSC/ood_core/pull/788).
22
+
23
+
10
24
  ## [0.22.0] - 10-31-2022
11
25
 
12
26
  ### Added
@@ -455,7 +469,8 @@ Functionally the same as [0.17.3] but with some CI updates.
455
469
  ### Added
456
470
  - Initial release!
457
471
 
458
- [Unreleased]: https://github.com/OSC/ood_core/compare/v0.22.0...HEAD
472
+ [Unreleased]: https://github.com/OSC/ood_core/compare/v0.23.0...HEAD
473
+ [0.23.0]: https://github.com/OSC/ood_core/compare/v0.22.0...v0.23.0
459
474
  [0.22.0]: https://github.com/OSC/ood_core/compare/v0.21.0...v0.22.0
460
475
  [0.21.0]: https://github.com/OSC/ood_core/compare/v0.20.2...v0.21.0
461
476
  [0.20.2]: https://github.com/OSC/ood_core/compare/v0.20.1...v0.20.2
@@ -0,0 +1,36 @@
1
+ module OodCore
2
+ module Job
3
+
4
+ class AccountInfo
5
+
6
+ # The name of the account.
7
+ attr_reader :name
8
+ alias to_s name
9
+
10
+ # The QoS values this account can use.
11
+ attr_reader :qos
12
+
13
+ # The cluster this account is associated with.
14
+ attr_reader :cluster
15
+
16
+ # The queue this account can use. nil means there is no queue info
17
+ # for this account.
18
+ attr_reader :queue
19
+
20
+ def initialize(**opts)
21
+ orig_name = opts.fetch(:name, 'unknown')
22
+ @name = OodCore::Job::Adapters::Helper.upcase_accounts? ? orig_name.upcase : orig_name
23
+ @qos = opts.fetch(:qos, [])
24
+ @cluster = opts.fetch(:cluster, nil)
25
+ @queue = opts.fetch(:queue, nil)
26
+ end
27
+
28
+ def to_h
29
+ instance_variables.map do |var|
30
+ name = var.to_s.gsub('@', '').to_sym
31
+ [name, send(name)]
32
+ end.to_h
33
+ end
34
+ end
35
+ end
36
+ end
@@ -197,6 +197,22 @@ module OodCore
197
197
  def job_name_illegal_chars
198
198
  ENV["OOD_JOB_NAME_ILLEGAL_CHARS"].to_s
199
199
  end
200
+
201
+ # Retrieve the accounts available to use for the current user.
202
+ #
203
+ # Subclasses that do not implement this will return empty arrays.
204
+ # @return [Array<AccountInfo>] the accounts available to the user.
205
+ def accounts
206
+ []
207
+ end
208
+
209
+ # Return the list of queues for this scheduler.
210
+ #
211
+ # Subclasses that do not implement this will return empty arrays.
212
+ # @return [Array<QueueInfo>]
213
+ def queues
214
+ []
215
+ end
200
216
  end
201
217
  end
202
218
  end
@@ -31,6 +31,17 @@ module OodCore
31
31
 
32
32
  return 'ssh', args + [cmd] + cmd_args
33
33
  end
34
+
35
+ # Determine whether to upcase account strings when returning adapter#accounts
36
+ def self.upcase_accounts?
37
+ env_var = ENV['OOD_UPCASE_ACCOUNTS']
38
+
39
+ if env_var.nil? || env_var.to_s.downcase == 'false'
40
+ false
41
+ else
42
+ true
43
+ end
44
+ end
34
45
  end
35
46
  end
36
47
  end
@@ -73,7 +73,7 @@ class OodCore::Job::Adapters::LinuxHost::Launcher
73
73
  # Get the tmux pane PID for the target session
74
74
  pane_pid=$(tmux list-panes -aF '\#{session_name} \#{pane_pid}' | grep '#{session_name}' | cut -f 2 -d ' ')
75
75
  # Find the Singularity sinit PID child of the pane process
76
- pane_sinit_pid=$(pstree -p -l "$pane_pid" | egrep -o 'sinit[(][[:digit:]]*|shim-init[(][[:digit:]]*' | grep -o '[[:digit:]]*')
76
+ pane_sinit_pid=$(pstree -p -l "$pane_pid" | egrep -o 'sinit[(][[:digit:]]*|shim-init[(][[:digit:]]|appinit[(][[:digit:]]' | grep -o '[[:digit:]]*')
77
77
  # Kill sinit which stops both Singularity-based processes and the tmux session
78
78
  kill "$pane_sinit_pid"
79
79
  SCRIPT
@@ -1,4 +1,5 @@
1
1
  require "time"
2
+ require 'etc'
2
3
  require "ood_core/refinements/hash_extensions"
3
4
  require "ood_core/refinements/array_extensions"
4
5
  require "ood_core/job/adapters/helper"
@@ -178,6 +179,27 @@ module OodCore
178
179
  return [{ id: id, state: 'undetermined' }]
179
180
  end
180
181
 
182
+ def accounts
183
+ user = Etc.getlogin
184
+ args = ['-nP', 'show', 'users', 'withassoc', 'format=account,cluster,partition,qos', 'where', "user=#{user}"]
185
+
186
+ [].tap do |accts|
187
+ call('sacctmgr', *args).each_line do |line|
188
+ acct, cluster, queue, qos = line.split('|')
189
+ next if acct.nil?
190
+
191
+ args = {
192
+ name: acct,
193
+ qos: qos.to_s.chomp.split(','),
194
+ cluster: cluster,
195
+ queue: queue.empty? ? nil : queue
196
+ }
197
+ info = OodCore::Job::AccountInfo.new(**args) unless acct.nil?
198
+ accts << info unless acct.nil?
199
+ end
200
+ end
201
+ end
202
+
181
203
  def squeue_fields(attrs)
182
204
  if attrs.nil?
183
205
  all_squeue_fields
@@ -300,7 +322,37 @@ module OodCore
300
322
  }
301
323
  end
302
324
 
325
+ def queues
326
+ info_raw = call('scontrol', 'show', 'part', '-o')
327
+
328
+ [].tap do |ret_arr|
329
+ info_raw.each_line do |line|
330
+ ret_arr << str_to_acct_info(line)
331
+ end
332
+ end
333
+ end
334
+
303
335
  private
336
+ def str_to_acct_info(line)
337
+ hsh = line.split(' ').map do |token|
338
+ m = token.match(/^(?<key>\w+)=(?<value>.+)$/)
339
+ [m[:key], m[:value]]
340
+ end.to_h.symbolize_keys
341
+
342
+ hsh[:name] = hsh[:PartitionName]
343
+ hsh[:qos] = hsh[:QoS].to_s == 'N/A' ? [] : hsh[:QoS].to_s.split(',')
344
+ hsh[:allow_accounts] = if hsh[:AllowAccounts].nil? || hsh[:AllowAccounts].to_s == 'ALL'
345
+ nil
346
+ else
347
+ hsh[:AllowAccounts].to_s.split(',')
348
+ end
349
+
350
+
351
+ hsh[:deny_accounts] = hsh[:DenyAccounts].nil? ? [] : hsh[:DenyAccounts].to_s.split(',')
352
+
353
+ OodCore::Job::QueueInfo.new(**hsh)
354
+ end
355
+
304
356
  # Modify the StringIO instance by advancing past the squeue header
305
357
  #
306
358
  # The first two "records" should always be discarded. Consider the
@@ -325,7 +377,7 @@ module OodCore
325
377
  cmd = OodCore::Job::Adapters::Helper.bin_path(cmd, bin, bin_overrides)
326
378
 
327
379
  args = args.map(&:to_s)
328
- args.concat ["-M", cluster] if cluster
380
+ args.concat ["-M", cluster] if cluster && cmd != 'sacctmgr'
329
381
 
330
382
  env = env.to_h
331
383
  env["SLURM_CONF"] = conf.to_s if conf
@@ -483,6 +535,13 @@ module OodCore
483
535
  @slurm.get_cluster_info
484
536
  end
485
537
 
538
+ # Retrieve the accounts available to use for the current user.
539
+ #
540
+ # @return [Array<String>] the accounts available to the user.
541
+ def accounts
542
+ @slurm.accounts
543
+ end
544
+
486
545
  # Retrieve info for all jobs from the resource manager
487
546
  # @raise [JobAdapterError] if something goes wrong getting job info
488
547
  # @return [Array<Info>] information describing submitted jobs
@@ -605,6 +664,10 @@ module OodCore
605
664
  '#SBATCH'
606
665
  end
607
666
 
667
+ def queues
668
+ @slurm.queues
669
+ end
670
+
608
671
  private
609
672
  # Convert duration to seconds
610
673
  def duration_in_seconds(time)
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # QueueInfo is information about a given queue on a scheduler.
4
+ class OodCore::Job::QueueInfo
5
+ # The name of the queue.
6
+ attr_reader :name
7
+ alias to_s name
8
+
9
+ # The QoSes associated with this queue
10
+ attr_reader :qos
11
+
12
+ # The accounts that are allowed to use this queue.
13
+ #
14
+ # nil means ALL accounts are allowed.
15
+ attr_reader :allow_accounts
16
+
17
+ # The accounts that are not allowed to use this queue.
18
+ attr_reader :deny_accounts
19
+
20
+ def initialize(**opts)
21
+ @name = opts.fetch(:name, 'unknown')
22
+ @qos = opts.fetch(:qos, [])
23
+ @allow_accounts = opts.fetch(:allow_accounts, nil)
24
+ @deny_accounts = opts.fetch(:deny_accounts, [])
25
+ end
26
+
27
+ def to_h
28
+ instance_variables.map do |var|
29
+ name = var.to_s.gsub('@', '').to_sym
30
+ [name, send(name)]
31
+ end.to_h
32
+ end
33
+ end
@@ -1,4 +1,4 @@
1
1
  module OodCore
2
2
  # The current version of {OodCore}
3
- VERSION = "0.22.0"
3
+ VERSION = "0.23.0"
4
4
  end
data/lib/ood_core.rb CHANGED
@@ -12,6 +12,8 @@ module OodCore
12
12
  require "ood_core/job/script"
13
13
  require "ood_core/job/info"
14
14
  require "ood_core/job/cluster_info"
15
+ require "ood_core/job/account_info"
16
+ require "ood_core/job/queue_info"
15
17
  require "ood_core/job/status"
16
18
  require "ood_core/job/adapter"
17
19
  require "ood_core/job/factory"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ood_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Franz
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-10-31 00:00:00.000000000 Z
13
+ date: 2023-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ood_support
@@ -178,6 +178,7 @@ files:
178
178
  - lib/ood_core/clusters.rb
179
179
  - lib/ood_core/errors.rb
180
180
  - lib/ood_core/invalid_cluster.rb
181
+ - lib/ood_core/job/account_info.rb
181
182
  - lib/ood_core/job/adapter.rb
182
183
  - lib/ood_core/job/adapters/ccq.rb
183
184
  - lib/ood_core/job/adapters/drmaa.rb
@@ -217,6 +218,7 @@ files:
217
218
  - lib/ood_core/job/factory.rb
218
219
  - lib/ood_core/job/info.rb
219
220
  - lib/ood_core/job/node_info.rb
221
+ - lib/ood_core/job/queue_info.rb
220
222
  - lib/ood_core/job/script.rb
221
223
  - lib/ood_core/job/status.rb
222
224
  - lib/ood_core/job/task.rb