/
auto_queues.rb
47 lines (40 loc) · 1.21 KB
/
auto_queues.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true
module SmartAttributes
class AttributeFactory
extend AccountCache
# Build this attribute object. No 'options' are used as this Attribute
# is meant to be dynamically generated from the users' available accounts
# from a given scheduler.
#
# @param opts [Hash] attribute's options
# @return [Attributes::AutoQueues] the attribute object
def self.build_auto_queues(opts = {})
static_opts = {
options: queues
}.merge(opts.without(:options).to_h)
Attributes::AutoQueues.new('auto_queues', static_opts)
end
end
module Attributes
class AutoQueues < Attribute
def widget
'select'
end
def label(fmt: nil)
str = opts[:label] || case fmt
when 'slurm'
'Partition'
else
'Queue'
end
str.to_s
end
# Submission hash describing how to submit this attribute
# @param fmt [String, nil] formatting of hash
# @return [Hash] submission hash
def submit(*)
{ script: { queue_name: value } }
end
end
end
end