rbbt-util 5.32.7 → 5.32.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +1 -0
- data/lib/rbbt/hpc/batch.rb +23 -7
- data/lib/rbbt/hpc/slurm.rb +29 -10
- data/lib/rbbt/persist/tsv/adapter.rb +1 -5
- data/lib/rbbt/resource.rb +22 -9
- data/lib/rbbt/tsv/csv.rb +2 -2
- data/lib/rbbt/tsv/manipulate.rb +2 -0
- data/lib/rbbt/util/R.rb +2 -2
- data/lib/rbbt/util/cmd.rb +39 -18
- data/lib/rbbt/util/log/progress/report.rb +20 -17
- data/lib/rbbt/util/python.rb +24 -3
- data/lib/rbbt/util/simpleDSL.rb +4 -4
- data/lib/rbbt/workflow.rb +20 -2
- data/lib/rbbt/workflow/step.rb +37 -6
- data/lib/rbbt/workflow/step/accessor.rb +2 -2
- data/lib/rbbt/workflow/util/data.rb +31 -0
- data/lib/rbbt/workflow/util/trace.rb +2 -1
- data/python/rbbt.py +3 -0
- data/share/install/software/lib/install_helpers +1 -1
- data/share/rbbt_commands/hpc/list +11 -7
- data/share/rbbt_commands/hpc/orchestrate +6 -1
- data/share/rbbt_commands/hpc/task +6 -1
- data/share/rbbt_commands/lsf/clean +212 -0
- data/share/rbbt_commands/lsf/list +315 -0
- data/share/rbbt_commands/lsf/orchestrate +61 -0
- data/share/rbbt_commands/lsf/tail +55 -0
- data/share/rbbt_commands/lsf/task +60 -0
- data/share/rbbt_commands/slurm/clean +212 -0
- data/share/rbbt_commands/slurm/list +315 -0
- data/share/rbbt_commands/slurm/orchestrate +61 -0
- data/share/rbbt_commands/slurm/tail +55 -0
- data/share/rbbt_commands/slurm/task +60 -0
- data/share/rbbt_commands/workflow/forget_deps +5 -4
- data/test/rbbt/util/test_python.rb +3 -2
- data/test/rbbt/util/test_simpleDSL.rb +3 -3
- data/test/rbbt/workflow/util/test_data.rb +35 -0
- metadata +97 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c61ee9aa98e617b2cd43ea3c57b71439cbb5c2c65282ed7695fafd5c46ccbf3
|
4
|
+
data.tar.gz: e30e12b162f86ee74b4a4c33e44c7e976612a11e8219b2afd9c6cc0ea520fe24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abee1a9322982a9da1cca62f7c36e47a7517a6c8066177f5155f8bfc17e6bc19054bfc1b8068c67e58fb0bf4a1c7585c3d493c2ca70d600391348e03f61ebab6
|
7
|
+
data.tar.gz: 80e3f811802c5e33cefd1c7c9561a9bdfcc2cfbfa97f300babd3c095de1d5bfb14a88e2e52918c4be9e869f9bf2722df68a493895077101e42b2f4ee57e9427c
|
data/bin/rbbt
CHANGED
data/lib/rbbt/hpc/batch.rb
CHANGED
@@ -95,14 +95,15 @@ module HPC
|
|
95
95
|
|
96
96
|
task = Symbol === job.overriden ? job.overriden : job.task_name
|
97
97
|
|
98
|
-
if job.overriden
|
99
|
-
override_deps = job.rec_dependencies.
|
100
|
-
|
98
|
+
if job.overriden?
|
99
|
+
#override_deps = job.rec_dependencies.
|
100
|
+
# select{|dep| Symbol === dep.overriden }.
|
101
|
+
|
102
|
+
override_deps = job.overriden_deps.
|
101
103
|
collect do |dep|
|
102
|
-
|
103
104
|
name = [dep.workflow.to_s, dep.task_name] * "#"
|
104
105
|
[name, dep.path] * "="
|
105
|
-
end * ","
|
106
|
+
end.uniq * ","
|
106
107
|
|
107
108
|
options[:override_deps] = override_deps unless override_deps.empty?
|
108
109
|
end
|
@@ -156,10 +157,15 @@ EOF
|
|
156
157
|
:singularity_ruby_inline,
|
157
158
|
:sync,
|
158
159
|
:task_cpus,
|
160
|
+
:mem,
|
161
|
+
:mem_per_cpu,
|
162
|
+
:licenses,
|
163
|
+
:contraints,
|
159
164
|
:time,
|
160
165
|
:user_group,
|
161
166
|
:wipe_container,
|
162
167
|
:workdir,
|
168
|
+
:purge_deps
|
163
169
|
]
|
164
170
|
|
165
171
|
keys.each do |key|
|
@@ -378,9 +384,9 @@ echo "user_scratch: #{scratch_group_dir}/#{user}/{PKGDIR}/{TOPLEVEL}/{SUBPATH}"
|
|
378
384
|
end
|
379
385
|
|
380
386
|
def execute(options)
|
381
|
-
exec_cmd, job_cmd = options.values_at :exec_cmd, :rbbt_cmd
|
387
|
+
exec_cmd, job_cmd, task_cpus = options.values_at :exec_cmd, :rbbt_cmd, :task_cpus
|
382
388
|
|
383
|
-
|
389
|
+
script=<<-EOF
|
384
390
|
step_path=$(
|
385
391
|
#{exec_cmd} #{job_cmd} --printpath
|
386
392
|
)
|
@@ -388,7 +394,10 @@ exit_status=$?
|
|
388
394
|
|
389
395
|
[[ -z $BATCH_JOB_ID ]] || #{exec_cmd} workflow write_info --recursive --force=false --check_pid "$step_path" batch_job $BATCH_JOB_ID
|
390
396
|
[[ -z $BATCH_SYSTEM ]] || #{exec_cmd} workflow write_info --recursive --force=false --check_pid "$step_path" batch_system $BATCH_SYSTEM
|
397
|
+
#{exec_cmd} workflow write_info --recursive --force=false --check_pid "$step_path" batch_cpus #{task_cpus}
|
391
398
|
EOF
|
399
|
+
|
400
|
+
script
|
392
401
|
end
|
393
402
|
|
394
403
|
def sync_environment(options = {})
|
@@ -409,6 +418,13 @@ fi
|
|
409
418
|
|
410
419
|
def cleanup_environment(options = {})
|
411
420
|
cleanup_environment = ""
|
421
|
+
|
422
|
+
cleanup_environment +=<<-EOF if options[:purge_deps]
|
423
|
+
if [ $exit_status == '0' ]; then
|
424
|
+
#{options[:exec_cmd]} workflow forget_deps --purge --recursive_purge "$step_path" 2>1 >> '#{options[:fsync]}'
|
425
|
+
fi
|
426
|
+
EOF
|
427
|
+
|
412
428
|
if options[:sync]
|
413
429
|
if options[:wipe_container] == 'force'
|
414
430
|
cleanup_environment +=<<-EOF
|
data/lib/rbbt/hpc/slurm.rb
CHANGED
@@ -28,6 +28,11 @@ export BATCH_SYSTEM=SLURM
|
|
28
28
|
workdir = Misc.process_options options, :workdir
|
29
29
|
exclusive = Misc.process_options options, :exclusive
|
30
30
|
highmem = Misc.process_options options, :highmem
|
31
|
+
licenses = Misc.process_options options, :licenses
|
32
|
+
constraint = Misc.process_options options, :constraint
|
33
|
+
|
34
|
+
mem = Misc.process_options options, :mem
|
35
|
+
mem_per_cpu = Misc.process_options options, :mem_per_cpu
|
31
36
|
|
32
37
|
batch_dir = Misc.process_options options, :batch_dir
|
33
38
|
batch_name = Misc.process_options options, :batch_name
|
@@ -37,20 +42,34 @@ export BATCH_SYSTEM=SLURM
|
|
37
42
|
|
38
43
|
time = Misc.format_seconds Misc.timespan(time) unless time.include? ":"
|
39
44
|
|
45
|
+
sbatch_params = {"job-name" => batch_name,
|
46
|
+
"output" => fout,
|
47
|
+
"error" => ferr,
|
48
|
+
"cpus-per-task" => task_cpus,
|
49
|
+
"nodes" => nodes,
|
50
|
+
"time" => time,
|
51
|
+
"exclusive" => exclusive,
|
52
|
+
"licenses" => licenses,
|
53
|
+
"mem" => mem,
|
54
|
+
"mem-per-cpu" => mem_per_cpu,
|
55
|
+
}
|
56
|
+
|
40
57
|
header =<<-EOF
|
41
58
|
#!/bin/bash
|
42
|
-
#SBATCH --job-name="#{batch_name}"
|
43
|
-
#SBATCH --workdir="#{workdir}"
|
44
|
-
#SBATCH --output="#{fout}"
|
45
|
-
#SBATCH --error="#{ferr}"
|
46
|
-
#SBATCH --qos="#{queue}"
|
47
|
-
#SBATCH --cpus-per-task="#{task_cpus}"
|
48
|
-
#SBATCH --time="#{time}"
|
49
|
-
#SBATCH --nodes="#{nodes}"
|
50
59
|
EOF
|
51
60
|
|
52
|
-
|
53
|
-
|
61
|
+
sbatch_params.each do |name,value|
|
62
|
+
next if value.nil? || value == ""
|
63
|
+
if TrueClass === value
|
64
|
+
header << "#SBATCH --#{name}" << "\n"
|
65
|
+
elsif Array === value
|
66
|
+
value.each do |v|
|
67
|
+
header << "#SBATCH --#{name}=\"#{v}\"" << "\n"
|
68
|
+
end
|
69
|
+
else
|
70
|
+
header << "#SBATCH --#{name}=\"#{value}\"" << "\n"
|
71
|
+
end
|
72
|
+
end
|
54
73
|
|
55
74
|
header
|
56
75
|
end
|
data/lib/rbbt/resource.rb
CHANGED
@@ -4,10 +4,10 @@ require 'rbbt/resource/path'
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'set'
|
6
6
|
|
7
|
-
|
8
7
|
module Resource
|
9
8
|
class ResourceNotFound < RbbtException; end
|
10
9
|
|
10
|
+
|
11
11
|
class << self
|
12
12
|
attr_accessor :lock_dir
|
13
13
|
|
@@ -87,12 +87,21 @@ module Resource
|
|
87
87
|
lock_filename = nil # it seems like this was locked already.
|
88
88
|
|
89
89
|
Misc.lock lock_filename do
|
90
|
-
|
90
|
+
begin
|
91
|
+
uri = URI(url)
|
92
|
+
|
93
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
91
94
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
if uri.scheme == "https"
|
96
|
+
http.use_ssl = true
|
97
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
98
|
+
http.instance_variable_set("@ssl_options", OpenSSL::SSL::OP_NO_SSLv2 + OpenSSL::SSL::OP_NO_SSLv3 + OpenSSL::SSL::OP_NO_COMPRESSION)
|
99
|
+
end
|
100
|
+
|
101
|
+
timeout = 60 * 10
|
102
|
+
http.read_timeout = timeout
|
103
|
+
http.open_timeout = timeout
|
104
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
96
105
|
http.request request do |response|
|
97
106
|
filename = if response["Content-Disposition"]
|
98
107
|
response["Content-Disposition"].split(";").select{|f| f.include? "filename"}.collect{|f| f.split("=").last.gsub('"','')}.first
|
@@ -123,9 +132,11 @@ module Resource
|
|
123
132
|
FileUtils.mv tmp_dir, final_path
|
124
133
|
end
|
125
134
|
else
|
126
|
-
|
127
|
-
|
128
|
-
|
135
|
+
url = location
|
136
|
+
raise TryAgain
|
137
|
+
#Open.open(location, :nocache => true) do |s|
|
138
|
+
# Misc.sensiblewrite(final_path, s)
|
139
|
+
#end
|
129
140
|
end
|
130
141
|
when Net::HTTPInternalServerError
|
131
142
|
@server_missing_resource_cache << url
|
@@ -134,6 +145,8 @@ module Resource
|
|
134
145
|
raise "Response not understood: #{response.inspect}"
|
135
146
|
end
|
136
147
|
end
|
148
|
+
rescue TryAgain
|
149
|
+
retry
|
137
150
|
end
|
138
151
|
end
|
139
152
|
rescue
|
data/lib/rbbt/tsv/csv.rb
CHANGED
data/lib/rbbt/tsv/manipulate.rb
CHANGED
@@ -174,6 +174,8 @@ module TSV
|
|
174
174
|
if Hash === @monitor
|
175
175
|
desc = @monitor[:desc] if @monitor.include? :desc
|
176
176
|
step = @monitor[:step] if @monitor.include? :step
|
177
|
+
elsif String === @monitor
|
178
|
+
desc = @monitor
|
177
179
|
end
|
178
180
|
progress_monitor = Log::ProgressBar.new_bar(size, :desc => desc)
|
179
181
|
end
|
data/lib/rbbt/util/R.rb
CHANGED
@@ -41,7 +41,7 @@ source('#{UTIL}');
|
|
41
41
|
|
42
42
|
if monitor
|
43
43
|
#io = CMD.cmd('R --no-save --quiet', options.merge(:in => cmd, :pipe => true, :log => true))
|
44
|
-
io = CMD.cmd('R --no-save --quiet', options.merge(:in => cmd, :pipe => true, :log => true, :xvfb =>
|
44
|
+
io = CMD.cmd('R --no-save --quiet', options.merge(:in => cmd, :pipe => true, :log => true, :xvfb => options[:xvfb]))
|
45
45
|
while line = io.gets
|
46
46
|
case monitor
|
47
47
|
when Proc
|
@@ -52,7 +52,7 @@ source('#{UTIL}');
|
|
52
52
|
end
|
53
53
|
nil
|
54
54
|
else
|
55
|
-
CMD.cmd('R --no-save --slave --quiet', options.merge(:in => cmd, :xvfb =>
|
55
|
+
CMD.cmd('R --no-save --slave --quiet', options.merge(:in => cmd, :xvfb => options[:xvfb]))
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
data/lib/rbbt/util/cmd.rb
CHANGED
@@ -192,25 +192,47 @@ module CMD
|
|
192
192
|
|
193
193
|
ConcurrentStream.setup sout, :pids => pids, :autojoin => no_wait, :no_fail => no_fail
|
194
194
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
195
|
+
if (Integer === stderr and log) || bar
|
196
|
+
err_thread = Thread.new do
|
197
|
+
while line = serr.gets
|
198
|
+
bar.process(line) if bar
|
199
|
+
sout.log = line
|
200
|
+
Log.log "STDERR [#{pid}]: " + line, stderr if log
|
201
|
+
end
|
202
|
+
serr.close
|
203
|
+
end
|
204
|
+
else
|
205
|
+
err_thread = Misc.consume_stream(serr, true)
|
202
206
|
end
|
203
207
|
|
204
208
|
sout.threads = [in_thread, err_thread, wait_thr].compact
|
205
209
|
|
206
210
|
sout
|
207
211
|
else
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
+
|
213
|
+
if bar
|
214
|
+
err = ""
|
215
|
+
err_thread = Thread.new do
|
216
|
+
while not serr.eof?
|
217
|
+
line = serr.gets
|
218
|
+
bar.process(line)
|
219
|
+
err << line if Integer === stderr and log
|
220
|
+
end
|
221
|
+
serr.close
|
212
222
|
end
|
213
|
-
|
223
|
+
elsif log and Integer === stderr
|
224
|
+
err = ""
|
225
|
+
err_thread = Thread.new do
|
226
|
+
while not serr.eof?
|
227
|
+
err << serr.gets
|
228
|
+
end
|
229
|
+
serr.close
|
230
|
+
end
|
231
|
+
else
|
232
|
+
Misc.consume_stream(serr, true)
|
233
|
+
#serr.close
|
234
|
+
err_thread = nil
|
235
|
+
err = ""
|
214
236
|
end
|
215
237
|
|
216
238
|
ConcurrentStream.setup sout, :pids => pids, :threads => [in_thread, err_thread].compact, :autojoin => no_wait, :no_fail => no_fail
|
@@ -220,7 +242,11 @@ module CMD
|
|
220
242
|
|
221
243
|
status = wait_thr.value
|
222
244
|
if not status.success? and not no_fail
|
223
|
-
|
245
|
+
if !err.empty?
|
246
|
+
raise ProcessFailed.new "Command [#{pid}] #{cmd} failed with error status #{status.exitstatus}.\n#{err}"
|
247
|
+
else
|
248
|
+
raise ProcessFailed.new "Command [#{pid}] #{cmd} failed with error status #{status.exitstatus}"
|
249
|
+
end
|
224
250
|
else
|
225
251
|
Log.log err, stderr if Integer === stderr and log
|
226
252
|
end
|
@@ -263,11 +289,6 @@ module CMD
|
|
263
289
|
if c == "\n"
|
264
290
|
bar.process(line) if bar
|
265
291
|
starting = true
|
266
|
-
#if pid
|
267
|
-
# Log.logn "STDOUT [#{pid}]: ", level
|
268
|
-
#else
|
269
|
-
# Log.logn "STDOUT: ", level
|
270
|
-
#end
|
271
292
|
line = "" if bar
|
272
293
|
end
|
273
294
|
end
|
@@ -12,32 +12,35 @@ module Log
|
|
12
12
|
attr_accessor :history, :mean_max, :max_history
|
13
13
|
def thr_msg
|
14
14
|
if @history.nil?
|
15
|
-
@history ||= [[@ticks, Time.now] ]
|
15
|
+
@history ||= [[0, @start], [@ticks, Time.now] ]
|
16
16
|
elsif @last_ticks != @ticks
|
17
17
|
@history << [@ticks, Time.now]
|
18
|
-
max_history ||=
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
max_history ||= begin
|
19
|
+
max_history = case
|
20
|
+
when @ticks > 20
|
21
|
+
count = @ticks - @last_count
|
22
|
+
count = 1 if count == 0
|
23
|
+
if @max
|
24
|
+
times = @max / count
|
25
|
+
num = times / 20
|
26
|
+
num = 2 if num < 2
|
27
|
+
else
|
28
|
+
num = 10
|
29
|
+
end
|
30
|
+
count * num
|
31
|
+
else
|
32
|
+
20
|
33
|
+
end
|
34
|
+
max_history = 30 if max_history > 30
|
35
|
+
max_history
|
28
36
|
end
|
29
|
-
count * num
|
30
|
-
else
|
31
|
-
20
|
32
|
-
end
|
33
|
-
max_history = 30 if max_history > 30
|
34
37
|
@history.shift if @history.length > max_history
|
35
38
|
end
|
36
39
|
|
37
40
|
@last_ticks = @ticks
|
38
41
|
|
39
42
|
@mean_max ||= 0
|
40
|
-
if @history.length >
|
43
|
+
if @history.length > 3
|
41
44
|
|
42
45
|
sticks, stime = @history.first
|
43
46
|
ssticks, sstime = @history[-3]
|
data/lib/rbbt/util/python.rb
CHANGED
@@ -3,10 +3,17 @@ require 'pycall/import'
|
|
3
3
|
|
4
4
|
module RbbtPython
|
5
5
|
extend PyCall::Import
|
6
|
+
|
7
|
+
def self.exec(script)
|
8
|
+
PyCall.exec(script)
|
9
|
+
end
|
10
|
+
|
6
11
|
def self.run(mod = nil, imports = nil, &block)
|
7
12
|
if mod
|
8
|
-
if imports
|
13
|
+
if Array === imports
|
9
14
|
pyfrom mod, :import => imports
|
15
|
+
elsif Hash === imports
|
16
|
+
pyimport mod, imports
|
10
17
|
else
|
11
18
|
pyimport mod
|
12
19
|
end
|
@@ -17,8 +24,10 @@ module RbbtPython
|
|
17
24
|
|
18
25
|
def self.run_log(mod = nil, imports = nil, severity = 0, severity_err = nil, &block)
|
19
26
|
if mod
|
20
|
-
if imports
|
27
|
+
if Array === imports
|
21
28
|
pyfrom mod, :import => imports
|
29
|
+
elsif Hash === imports
|
30
|
+
pyimport mod, imports
|
22
31
|
else
|
23
32
|
pyimport mod
|
24
33
|
end
|
@@ -31,8 +40,10 @@ module RbbtPython
|
|
31
40
|
|
32
41
|
def self.run_log_stderr(mod = nil, imports = nil, severity = 0, &block)
|
33
42
|
if mod
|
34
|
-
if imports
|
43
|
+
if Array === imports
|
35
44
|
pyfrom mod, :import => imports
|
45
|
+
elsif Hash === imports
|
46
|
+
pyimport mod, imports
|
36
47
|
else
|
37
48
|
pyimport mod
|
38
49
|
end
|
@@ -49,4 +60,14 @@ module RbbtPython
|
|
49
60
|
end
|
50
61
|
end
|
51
62
|
|
63
|
+
def self.add_paths(paths)
|
64
|
+
self.run 'sys' do
|
65
|
+
paths.each do |path|
|
66
|
+
sys.path.append path
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
RbbtPython.add_paths Rbbt.python.find_all
|
72
|
+
RbbtPython.pyimport "rbbt"
|
52
73
|
end
|