ood_core 0.2.1 → 0.3.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 +15 -1
- data/lib/ood_core/batch_connect/template.rb +16 -2
- data/lib/ood_core/job/adapters/lsf.rb +1 -0
- data/lib/ood_core/job/adapters/lsf/batch.rb +12 -3
- data/lib/ood_core/job/adapters/lsf/helper.rb +2 -1
- data/lib/ood_core/job/adapters/pbspro.rb +1 -0
- data/lib/ood_core/job/adapters/slurm.rb +8 -1
- data/lib/ood_core/job/adapters/torque.rb +1 -0
- data/lib/ood_core/job/info.rb +5 -5
- data/lib/ood_core/job/node_info.rb +2 -2
- data/lib/ood_core/job/script.rb +15 -7
- data/lib/ood_core/job/status.rb +1 -1
- data/lib/ood_core/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc6dd320e10be434a6689cf286a0250e639ae82a
|
4
|
+
data.tar.gz: cfaa8e4bad41f728f6bf08e6db0bea634dca9e4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60f7e34ded14e2ed6aba02a850d2157c90b73347e1846c69e18a663dde3992e80a71d90be7a1c1dac4b895c007b1d5cf062f54a08913e18bd67de864088278db
|
7
|
+
data.tar.gz: c2927b9f0342ec93462e74f04d806b9359780949bb99f6af8e304e3c1da5c72fe27d77ebfdb575686012f04067c8d927e6914bf452d3fc5c7fffb6736f774a19
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [0.3.0] - 2018-04-05
|
11
|
+
### Added
|
12
|
+
- Basic multi-cluster support for LSF by specifying name of cluster for -m
|
13
|
+
argument. [#24](https://github.com/OSC/ood_core/issues/24)
|
14
|
+
- Added `OodCore::Job::Script#shell_path` as an option to all adapters.
|
15
|
+
[#82](https://github.com/OSC/ood_core/issues/82)
|
16
|
+
- Added `header` and `footer` options to a Batch Connect template.
|
17
|
+
[#64](https://github.com/OSC/ood_core/issues/64)
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- Replaced `Fixnum` code comments with `Integer`.
|
21
|
+
[#67](https://github.com/OSC/ood_core/issues/67)
|
22
|
+
|
10
23
|
## [0.2.1] - 2018-01-26
|
11
24
|
### Changed
|
12
25
|
- Updated the date in the `LICENSE.txt` file.
|
@@ -99,7 +112,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
99
112
|
### Added
|
100
113
|
- Initial release!
|
101
114
|
|
102
|
-
[Unreleased]: https://github.com/OSC/ood_core/compare/v0.
|
115
|
+
[Unreleased]: https://github.com/OSC/ood_core/compare/v0.3.0...HEAD
|
116
|
+
[0.3.0]: https://github.com/OSC/ood_core/compare/v0.2.1...v0.3.0
|
103
117
|
[0.2.1]: https://github.com/OSC/ood_core/compare/v0.2.0...v0.2.1
|
104
118
|
[0.2.0]: https://github.com/OSC/ood_core/compare/v0.1.1...v0.2.0
|
105
119
|
[0.1.1]: https://github.com/OSC/ood_core/compare/v0.1.0...v0.1.1
|
@@ -26,6 +26,10 @@ module OodCore
|
|
26
26
|
# looking for available port
|
27
27
|
# @option context [#to_i] :passwd_size (32) Length of randomly generated
|
28
28
|
# password
|
29
|
+
# @option context [#to_s] :header ("") Shell code prepended at the top of
|
30
|
+
# the script body
|
31
|
+
# @option context [#to_s] :footer ("") Shell code appended at the bottom
|
32
|
+
# of the script body
|
29
33
|
# @option context [#to_s] :script_wrapper ("%s") Bash code that wraps
|
30
34
|
# around the body of the template script (use `%s` to interpolate the
|
31
35
|
# body)
|
@@ -58,9 +62,9 @@ module OodCore
|
|
58
62
|
# @return [String] rendered template
|
59
63
|
def to_s
|
60
64
|
<<-EOT.gsub(/^ {10}/, '')
|
61
|
-
|
62
|
-
|
65
|
+
#{header}
|
63
66
|
#{script_wrapper}
|
67
|
+
#{footer}
|
64
68
|
EOT
|
65
69
|
end
|
66
70
|
|
@@ -148,6 +152,16 @@ module OodCore
|
|
148
152
|
end.to_s
|
149
153
|
end
|
150
154
|
|
155
|
+
# Shell code that is prepended at the top of the script body
|
156
|
+
def header
|
157
|
+
context.fetch(:header, "").to_s
|
158
|
+
end
|
159
|
+
|
160
|
+
# Shell code that is appended at the bottom of the script body
|
161
|
+
def footer
|
162
|
+
context.fetch(:footer, "").to_s
|
163
|
+
end
|
164
|
+
|
151
165
|
# Bash code that wraps around the body of the template script (use `%s`
|
152
166
|
# to interpolate the body)
|
153
167
|
def script_wrapper
|
@@ -11,6 +11,7 @@ module OodCore
|
|
11
11
|
# @option config [#to_s] :libdir ('') Path to lsf client lib dir
|
12
12
|
# @option config [#to_s] :envdir ('') Path to lsf client conf dir
|
13
13
|
# @option config [#to_s] :serverdir ('') Path to lsf client etc dir
|
14
|
+
# @option config [#to_s] :cluster ('') name of cluster, if in multi-cluster mode
|
14
15
|
def self.build_lsf(config)
|
15
16
|
batch = Adapters::Lsf::Batch.new(config.to_h.symbolize_keys)
|
16
17
|
Adapters::Lsf.new(batch: batch)
|
@@ -2,19 +2,20 @@
|
|
2
2
|
#
|
3
3
|
# @api private
|
4
4
|
class OodCore::Job::Adapters::Lsf::Batch
|
5
|
-
attr_reader :bindir, :libdir, :envdir, :serverdir
|
5
|
+
attr_reader :bindir, :libdir, :envdir, :serverdir, :cluster
|
6
6
|
|
7
7
|
# The root exception class that all LSF-specific exceptions inherit
|
8
8
|
# from
|
9
9
|
class Error < StandardError; end
|
10
10
|
|
11
11
|
# @param bin [#to_s] path to LSF installation binaries
|
12
|
-
def initialize(bindir: "", envdir: "", libdir: "", serverdir: "", **_)
|
12
|
+
def initialize(bindir: "", envdir: "", libdir: "", serverdir: "", cluster: "", **_)
|
13
13
|
@bindir = Pathname.new(bindir.to_s)
|
14
14
|
|
15
15
|
@envdir = Pathname.new(envdir.to_s)
|
16
16
|
@libdir = Pathname.new(libdir.to_s)
|
17
17
|
@serverdir = Pathname.new(serverdir.to_s)
|
18
|
+
@cluster = cluster.to_s
|
18
19
|
end
|
19
20
|
|
20
21
|
def default_env
|
@@ -127,11 +128,19 @@ class OodCore::Job::Adapters::Lsf::Batch
|
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
131
|
+
def cluster_args
|
132
|
+
if cluster.nil? || cluster.strip.empty?
|
133
|
+
[]
|
134
|
+
else
|
135
|
+
["-m", cluster]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
130
139
|
private
|
131
140
|
# Call a forked Lsf command for a given cluster
|
132
141
|
def call(cmd, *args, env: {}, stdin: "")
|
133
142
|
cmd = bindir.join(cmd.to_s).to_s
|
134
|
-
|
143
|
+
args = cluster_args + args
|
135
144
|
env = default_env.merge(env.to_h)
|
136
145
|
o, e, s = Open3.capture3(env, cmd, *(args.map(&:to_s)), stdin_data: stdin.to_s)
|
137
146
|
s.success? ? o : raise(Error, e)
|
@@ -68,7 +68,7 @@ class OodCore::Job::Adapters::Lsf::Helper
|
|
68
68
|
#
|
69
69
|
# my guess is: hours:minutes:seconds.????
|
70
70
|
#
|
71
|
-
# @return [
|
71
|
+
# @return [Integer, nil] cpu used as seconds
|
72
72
|
def parse_cpu_used(cpu_used)
|
73
73
|
if cpu_used =~ /^(\d+):(\d+):(\d+)\..*$/
|
74
74
|
$1.to_i*3600 + $2.to_i*60 + $3.to_i
|
@@ -88,6 +88,7 @@ class OodCore::Job::Adapters::Lsf::Helper
|
|
88
88
|
args += (script.rerunnable ? ["-r"] : ["-rn"]) unless script.rerunnable.nil?
|
89
89
|
args += ["-b", script.start_time.localtime.strftime("%Y:%m:%d:%H:%M")] unless script.start_time.nil?
|
90
90
|
args += ["-W", (script.wall_time / 60).to_i] unless script.wall_time.nil?
|
91
|
+
args += ["-L", script.shell_path.to_s] unless script.shell_path.nil?
|
91
92
|
|
92
93
|
# input and output files
|
93
94
|
args += ["-i", script.input_path] unless script.input_path.nil?
|
@@ -227,6 +227,7 @@ module OodCore
|
|
227
227
|
args += ["-m", "e"]
|
228
228
|
end
|
229
229
|
args += ["-N", script.job_name] unless script.job_name.nil?
|
230
|
+
args += ["-S", script.shell_path] unless script.shell_path.nil?
|
230
231
|
# ignore input_path (not defined in PBS Pro)
|
231
232
|
args += ["-o", script.output_path] unless script.output_path.nil?
|
232
233
|
args += ["-e", script.error_path] unless script.error_path.nil?
|
@@ -298,8 +298,15 @@ module OodCore
|
|
298
298
|
# Set native options
|
299
299
|
args += script.native if script.native
|
300
300
|
|
301
|
+
# Set content
|
302
|
+
content = if script.shell_path.nil?
|
303
|
+
script.content
|
304
|
+
else
|
305
|
+
"#!#{script.shell_path}\n#{script.content}"
|
306
|
+
end
|
307
|
+
|
301
308
|
# Submit job
|
302
|
-
@slurm.submit_string(
|
309
|
+
@slurm.submit_string(content, args: args, env: env)
|
303
310
|
rescue Batch::Error => e
|
304
311
|
raise JobAdapterError, e.message
|
305
312
|
end
|
@@ -83,6 +83,7 @@ module OodCore
|
|
83
83
|
mail_points += 'e' if script.email_on_terminated
|
84
84
|
headers.merge!(Mail_Points: mail_points) unless mail_points.empty?
|
85
85
|
headers.merge!(Job_Name: script.job_name) unless script.job_name.nil?
|
86
|
+
headers.merge!(Shell_Path_List: script.shell_path) unless script.shell_path.nil?
|
86
87
|
# ignore input_path (not defined in Torque)
|
87
88
|
headers.merge!(Output_Path: script.output_path) unless script.output_path.nil?
|
88
89
|
headers.merge!(Error_Path: script.error_path) unless script.error_path.nil?
|
data/lib/ood_core/job/info.rb
CHANGED
@@ -33,7 +33,7 @@ module OodCore
|
|
33
33
|
attr_reader :accounting_id
|
34
34
|
|
35
35
|
# Number of procs allocated for job
|
36
|
-
# @return [
|
36
|
+
# @return [Integer, nil] allocated total number of procs
|
37
37
|
attr_reader :procs
|
38
38
|
|
39
39
|
# Name of the queue in which the job was queued or started
|
@@ -41,15 +41,15 @@ module OodCore
|
|
41
41
|
attr_reader :queue_name
|
42
42
|
|
43
43
|
# The accumulated wall clock time in seconds
|
44
|
-
# @return [
|
44
|
+
# @return [Integer, nil] wallclock time
|
45
45
|
attr_reader :wallclock_time
|
46
46
|
|
47
47
|
# The total wall clock time limit in seconds
|
48
|
-
# @return [
|
48
|
+
# @return [Integer, nil] wallclock time limit
|
49
49
|
attr_reader :wallclock_limit
|
50
50
|
|
51
51
|
# The accumulated CPU time in seconds
|
52
|
-
# @return [
|
52
|
+
# @return [Integer, nil] cpu time
|
53
53
|
attr_reader :cpu_time
|
54
54
|
|
55
55
|
# The time at which the job was submitted
|
@@ -139,7 +139,7 @@ module OodCore
|
|
139
139
|
end
|
140
140
|
|
141
141
|
# Generate a hash value for this object
|
142
|
-
# @return [
|
142
|
+
# @return [Integer] hash value of object
|
143
143
|
def hash
|
144
144
|
[self.class, to_h].hash
|
145
145
|
end
|
@@ -7,7 +7,7 @@ module OodCore
|
|
7
7
|
attr_reader :name
|
8
8
|
|
9
9
|
# The number of procs reserved on the given machine
|
10
|
-
# @return [
|
10
|
+
# @return [Integer, nil] number of procs
|
11
11
|
attr_reader :procs
|
12
12
|
|
13
13
|
# @param name [#to_s] node name
|
@@ -38,7 +38,7 @@ module OodCore
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Generate a hash value for this object
|
41
|
-
# @return [
|
41
|
+
# @return [Integer] hash value of object
|
42
42
|
def hash
|
43
43
|
[self.class, to_h].hash
|
44
44
|
end
|
data/lib/ood_core/job/script.rb
CHANGED
@@ -54,6 +54,10 @@ module OodCore
|
|
54
54
|
# @return [String, nil] name of job
|
55
55
|
attr_reader :job_name
|
56
56
|
|
57
|
+
# Path to file specifying the login shell of the job
|
58
|
+
# @return [Pathname, nil] file path specifying login shell
|
59
|
+
attr_reader :shell_path
|
60
|
+
|
57
61
|
# Path to file specifying the input stream of the job
|
58
62
|
# @return [Pathname, nil] file path specifying input stream
|
59
63
|
attr_reader :input_path
|
@@ -75,7 +79,7 @@ module OodCore
|
|
75
79
|
attr_reader :queue_name
|
76
80
|
|
77
81
|
# The scheduling priority for the job
|
78
|
-
# @return [
|
82
|
+
# @return [Integer, nil] scheduling priority
|
79
83
|
attr_reader :priority
|
80
84
|
|
81
85
|
# The earliest time when the job may be eligible to run
|
@@ -84,7 +88,7 @@ module OodCore
|
|
84
88
|
|
85
89
|
# The maximum amount of real time during which the job can be running in
|
86
90
|
# seconds
|
87
|
-
# @return [
|
91
|
+
# @return [Integer, nil] max real time
|
88
92
|
attr_reader :wall_time
|
89
93
|
|
90
94
|
# The attribute used for job accounting purposes
|
@@ -106,6 +110,8 @@ module OodCore
|
|
106
110
|
# @param email_on_started [Boolean, nil] whether email when job starts
|
107
111
|
# @param email_on_terminated [Boolean, nil] whether email when job ends
|
108
112
|
# @param job_name [#to_s, nil] name of job
|
113
|
+
# @param shell_path [#to_s, nil] file path specifying login shell
|
114
|
+
# @param error_path [#to_s, nil] file path specifying error stream
|
109
115
|
# @param input_path [#to_s, nil] file path specifying input stream
|
110
116
|
# @param output_path [#to_s, nil] file path specifying output stream
|
111
117
|
# @param error_path [#to_s, nil] file path specifying error stream
|
@@ -119,10 +125,10 @@ module OodCore
|
|
119
125
|
def initialize(content:, args: nil, submit_as_hold: nil, rerunnable: nil,
|
120
126
|
job_environment: nil, workdir: nil, email: nil,
|
121
127
|
email_on_started: nil, email_on_terminated: nil,
|
122
|
-
job_name: nil,
|
123
|
-
|
124
|
-
|
125
|
-
accounting_id: nil, native: nil, **_)
|
128
|
+
job_name: nil, shell_path: nil, input_path: nil,
|
129
|
+
output_path: nil, error_path: nil, reservation_id: nil,
|
130
|
+
queue_name: nil, priority: nil, start_time: nil,
|
131
|
+
wall_time: nil, accounting_id: nil, native: nil, **_)
|
126
132
|
@content = content.to_s
|
127
133
|
|
128
134
|
@submit_as_hold = submit_as_hold
|
@@ -135,6 +141,7 @@ module OodCore
|
|
135
141
|
@workdir = workdir && Pathname.new(workdir.to_s)
|
136
142
|
@email = email && Array.wrap(email).map(&:to_s)
|
137
143
|
@job_name = job_name && job_name.to_s
|
144
|
+
@shell_path = shell_path && Pathname.new(shell_path.to_s)
|
138
145
|
@input_path = input_path && Pathname.new(input_path.to_s)
|
139
146
|
@output_path = output_path && Pathname.new(output_path.to_s)
|
140
147
|
@error_path = error_path && Pathname.new(error_path.to_s)
|
@@ -161,6 +168,7 @@ module OodCore
|
|
161
168
|
email_on_started: email_on_started,
|
162
169
|
email_on_terminated: email_on_terminated,
|
163
170
|
job_name: job_name,
|
171
|
+
shell_path: shell_path,
|
164
172
|
input_path: input_path,
|
165
173
|
output_path: output_path,
|
166
174
|
error_path: error_path,
|
@@ -189,7 +197,7 @@ module OodCore
|
|
189
197
|
end
|
190
198
|
|
191
199
|
# Generate a hash value for this object
|
192
|
-
# @return [
|
200
|
+
# @return [Integer] hash value of object
|
193
201
|
def hash
|
194
202
|
[self.class, to_h].hash
|
195
203
|
end
|
data/lib/ood_core/job/status.rb
CHANGED
data/lib/ood_core/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ood_support
|
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: '0'
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
|
-
rubygems_version: 2.4.5
|
182
|
+
rubygems_version: 2.4.5.4
|
183
183
|
signing_key:
|
184
184
|
specification_version: 4
|
185
185
|
summary: Open OnDemand core library
|