ood_core 0.10.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,68 +10,33 @@
10
10
  module OodCore
11
11
  module Job
12
12
  class ArrayIds
13
- class Error < StandardError ; end
13
+ attr_reader :spec_string
14
14
 
15
- attr_reader :ids
16
15
  def initialize(spec_string)
17
- @ids = []
18
- begin
19
- parse_spec_string(spec_string) if spec_string
20
- rescue Error
21
- end
22
- end
23
-
24
- protected
25
- def parse_spec_string(spec_string)
26
- @ids = get_components(spec_string).map{
27
- |component| process_component(component)
28
- }.reduce(:+).sort
16
+ @spec_string = spec_string
29
17
  end
30
18
 
31
- def get_components(spec_string)
32
- base = discard_percent_modifier(spec_string)
33
- raise Error unless base
34
- base.split(',')
19
+ def ids
20
+ @ids ||= parse_spec_string(spec_string)
35
21
  end
36
22
 
37
- # A few adapters use percent to define an arrays maximum number of
38
- # simultaneous tasks. The percent is expected to come at the end.
39
- def discard_percent_modifier(spec_string)
40
- spec_string.split('%').first
41
- end
23
+ protected
42
24
 
43
- def process_component(component)
44
- if is_range?(component)
45
- get_range(component)
46
- elsif numbers_valid?([component])
47
- [ component.to_i ]
48
- else
49
- raise Error
25
+ def parse_spec_string(spec_string)
26
+ return [] unless spec_string
27
+
28
+ rx = /^(\d+)-?(\d+)?:?(\d+)?%?\d*$/
29
+ spec_string.split(',').reduce([]) do |ids, spec|
30
+ if rx =~ spec
31
+ start = ($1 || 1).to_i
32
+ finish = ($2 || start).to_i
33
+ step = ($3 || 1).to_i
34
+ ids.concat (start..finish).step(step).to_a
35
+ end
36
+
37
+ ids
50
38
  end
51
39
  end
52
-
53
- def get_range(component)
54
- raw_range, raw_step = component.split(':')
55
- start, stop = raw_range.split('-')
56
- raise Error unless numbers_valid?(
57
- # Only include Step if it is not nil
58
- [start, stop].tap { |a| a << raw_step if raw_step }
59
- )
60
- range = Range.new(start.to_i, stop.to_i)
61
- step = raw_step.to_i
62
- step = 1 if step == 0
63
-
64
- range.step(step).to_a
65
- end
66
-
67
- def is_range?(component)
68
- component.include?('-')
69
- end
70
-
71
- # Protect against Ruby's String#to_i returning 0 for arbitrary strings
72
- def numbers_valid?(numbers)
73
- numbers.all? { |str| /^[0-9]+$/ =~ str }
74
- end
75
40
  end
76
41
  end
77
42
  end
@@ -99,11 +99,20 @@ module OodCore
99
99
  # @return [String, nil] job array request
100
100
  attr_reader :job_array_request
101
101
 
102
+ # The qos selected for the job
103
+ # @return [String, nil] qos
104
+ attr_reader :qos
105
+
102
106
  # Object detailing any native specifications that are implementation specific
103
107
  # @note Should not be used at all costs.
104
108
  # @return [Object, nil] native specifications
105
109
  attr_reader :native
106
110
 
111
+ # Flag whether the job should contain a copy of its calling environment
112
+ # @return [Boolean] copy environment
113
+ attr_reader :copy_environment
114
+ alias_method :copy_environment?, :copy_environment
115
+
107
116
  # @param content [#to_s] the script content
108
117
  # @param args [Array<#to_s>, nil] arguments supplied to script
109
118
  # @param submit_as_hold [Boolean, nil] whether job is held after submit
@@ -125,14 +134,18 @@ module OodCore
125
134
  # @param start_time [#to_i, nil] eligible start time
126
135
  # @param wall_time [#to_i, nil] max real time
127
136
  # @param accounting_id [#to_s, nil] accounting id
137
+ # @param job_array_request [#to_s, nil] job array request
138
+ # @param qos [#to_s, nil] qos
128
139
  # @param native [Object, nil] native specifications
140
+ # @param copy_environment [Boolean, nil] copy the environment
129
141
  def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
130
142
  job_environment: nil, workdir: nil, email: nil,
131
143
  email_on_started: nil, email_on_terminated: nil,
132
144
  job_name: nil, shell_path: nil, input_path: nil,
133
145
  output_path: nil, error_path: nil, reservation_id: nil,
134
146
  queue_name: nil, priority: nil, start_time: nil,
135
- wall_time: nil, accounting_id: nil, job_array_request: nil, native: nil, **_)
147
+ wall_time: nil, accounting_id: nil, job_array_request: nil,
148
+ qos: nil, native: nil, copy_environment: nil, **_)
136
149
  @content = content.to_s
137
150
 
138
151
  @submit_as_hold = submit_as_hold
@@ -156,7 +169,9 @@ module OodCore
156
169
  @wall_time = wall_time && wall_time.to_i
157
170
  @accounting_id = accounting_id && accounting_id.to_s
158
171
  @job_array_request = job_array_request && job_array_request.to_s
172
+ @qos = qos && qos.to_s
159
173
  @native = native
174
+ @copy_environment = (copy_environment.nil?) ? nil : !! copy_environment
160
175
  end
161
176
 
162
177
  # Convert object to hash
@@ -184,7 +199,9 @@ module OodCore
184
199
  wall_time: wall_time,
185
200
  accounting_id: accounting_id,
186
201
  job_array_request: job_array_request,
187
- native: native
202
+ qos: qos,
203
+ native: native,
204
+ copy_environment: copy_environment
188
205
  }
189
206
  end
190
207
 
@@ -1,4 +1,4 @@
1
1
  module OodCore
2
2
  # The current version of {OodCore}
3
- VERSION = "0.10.0"
3
+ VERSION = "0.12.0"
4
4
  end
@@ -25,8 +25,9 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency "ood_support", "~> 0.0.2"
26
26
  spec.add_runtime_dependency "ffi", "~> 1.9", ">= 1.9.6"
27
27
  spec.add_development_dependency "bundler", "~> 1.7"
28
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rake", "~> 13.0.1"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  spec.add_development_dependency "pry", "~> 0.10"
31
31
  spec.add_development_dependency "timecop", "~> 0.8"
32
+ spec.add_development_dependency "climate_control", "~> 0.2.0"
32
33
  end
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.10.0
4
+ version: 0.12.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: 2019-11-05 00:00:00.000000000 Z
13
+ date: 2020-08-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ood_support
@@ -66,14 +66,14 @@ dependencies:
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '10.0'
69
+ version: 13.0.1
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '10.0'
76
+ version: 13.0.1
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: rspec
79
79
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +116,20 @@ dependencies:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0.8'
119
+ - !ruby/object:Gem::Dependency
120
+ name: climate_control
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: 0.2.0
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: 0.2.0
119
133
  description: Open OnDemand core library that provides support for an HPC Center to
120
134
  globally define HPC services that web applications can then take advantage of.
121
135
  email:
@@ -147,6 +161,7 @@ files:
147
161
  - lib/ood_core/cluster.rb
148
162
  - lib/ood_core/clusters.rb
149
163
  - lib/ood_core/errors.rb
164
+ - lib/ood_core/invalid_cluster.rb
150
165
  - lib/ood_core/job/adapter.rb
151
166
  - lib/ood_core/job/adapters/drmaa.rb
152
167
  - lib/ood_core/job/adapters/helper.rb
@@ -200,8 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
215
  - !ruby/object:Gem::Version
201
216
  version: '0'
202
217
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.6.11
218
+ rubygems_version: 3.0.3
205
219
  signing_key:
206
220
  specification_version: 4
207
221
  summary: Open OnDemand core library