rbbt-util 5.32.9 → 5.32.15
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/annotations/util.rb +1 -0
- data/lib/rbbt/entity.rb +6 -1
- data/lib/rbbt/hpc/batch.rb +26 -9
- data/lib/rbbt/hpc/orchestrate.rb +1 -0
- data/lib/rbbt/hpc/slurm.rb +31 -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/tsv/parallel/traverse.rb +7 -10
- 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/log/progress/util.rb +2 -1
- data/lib/rbbt/util/misc/omics.rb +2 -2
- data/lib/rbbt/util/misc/system.rb +2 -2
- data/lib/rbbt/util/python.rb +63 -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 +35 -0
- data/lib/rbbt/workflow/util/trace.rb +2 -1
- data/python/rbbt.py +7 -0
- data/share/install/software/lib/install_helpers +1 -1
- data/share/rbbt_commands/hpc/list +11 -7
- data/share/rbbt_commands/hpc/orchestrate +10 -2
- data/share/rbbt_commands/hpc/task +8 -1
- data/share/rbbt_commands/lsf/list +11 -7
- data/share/rbbt_commands/lsf/orchestrate +10 -2
- data/share/rbbt_commands/lsf/task +8 -1
- data/share/rbbt_commands/slurm/list +11 -7
- data/share/rbbt_commands/slurm/orchestrate +10 -2
- data/share/rbbt_commands/slurm/task +8 -1
- 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 +48 -0
- metadata +86 -83
@@ -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/misc/omics.rb
CHANGED
@@ -511,9 +511,9 @@ module Misc
|
|
511
511
|
|
512
512
|
case chr_prefix.to_s.downcase
|
513
513
|
when "remove"
|
514
|
-
sort_order = sort_order.collect{|chr| "chr" + chr } unless sort_order.first.include?('chr')
|
515
|
-
when "true", "add"
|
516
514
|
sort_order = sort_order.collect{|chr| chr.sub('chr', '') } if sort_order.first.include?('chr')
|
515
|
+
when "true", "add"
|
516
|
+
sort_order = sort_order.collect{|chr| "chr" + chr } unless sort_order.first.include?('chr')
|
517
517
|
end
|
518
518
|
|
519
519
|
sort_genomic_locations_by_contig(mutations, sort_order)
|
@@ -112,10 +112,10 @@ end
|
|
112
112
|
res
|
113
113
|
end
|
114
114
|
|
115
|
-
def self.is_filename?(string)
|
115
|
+
def self.is_filename?(string, need_to_exists = true)
|
116
116
|
return true if defined? Path and Path === string
|
117
117
|
return true if string.respond_to? :exists
|
118
|
-
return true if String === string and string.length < 265 and File.exist?(string)
|
118
|
+
return true if String === string and string.length < 265 and (File.exist?(string) || ! need_to_exists)
|
119
119
|
return false
|
120
120
|
end
|
121
121
|
|
data/lib/rbbt/util/python.rb
CHANGED
@@ -3,10 +3,56 @@ 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
|
+
|
11
|
+
def self.iterate(iterator, options = {})
|
12
|
+
bar = options[:bar]
|
13
|
+
|
14
|
+
case bar
|
15
|
+
when TrueClass
|
16
|
+
bar = Log::ProgressBar.new nil, :desc => "RbbtPython iterate"
|
17
|
+
when String
|
18
|
+
bar = Log::ProgressBar.new nil, :desc => bar
|
19
|
+
end
|
20
|
+
|
21
|
+
while true
|
22
|
+
begin
|
23
|
+
yield iterator.__next__
|
24
|
+
bar.tick if bar
|
25
|
+
rescue PyCall::PyError
|
26
|
+
if $!.type.to_s == "<class 'StopIteration'>"
|
27
|
+
break
|
28
|
+
else
|
29
|
+
raise $!
|
30
|
+
end
|
31
|
+
rescue
|
32
|
+
bar.error if bar
|
33
|
+
raise $!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Log::ProgressBar.remove_bar bar if bar
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.collect(iterator, options = {}, &block)
|
42
|
+
acc = []
|
43
|
+
self.iterate(iterator, options) do |elem|
|
44
|
+
res = block.call elem
|
45
|
+
acc << res
|
46
|
+
end
|
47
|
+
acc
|
48
|
+
end
|
49
|
+
|
6
50
|
def self.run(mod = nil, imports = nil, &block)
|
7
51
|
if mod
|
8
|
-
if imports
|
52
|
+
if Array === imports
|
9
53
|
pyfrom mod, :import => imports
|
54
|
+
elsif Hash === imports
|
55
|
+
pyimport mod, imports
|
10
56
|
else
|
11
57
|
pyimport mod
|
12
58
|
end
|
@@ -17,8 +63,10 @@ module RbbtPython
|
|
17
63
|
|
18
64
|
def self.run_log(mod = nil, imports = nil, severity = 0, severity_err = nil, &block)
|
19
65
|
if mod
|
20
|
-
if imports
|
66
|
+
if Array === imports
|
21
67
|
pyfrom mod, :import => imports
|
68
|
+
elsif Hash === imports
|
69
|
+
pyimport mod, imports
|
22
70
|
else
|
23
71
|
pyimport mod
|
24
72
|
end
|
@@ -31,8 +79,10 @@ module RbbtPython
|
|
31
79
|
|
32
80
|
def self.run_log_stderr(mod = nil, imports = nil, severity = 0, &block)
|
33
81
|
if mod
|
34
|
-
if imports
|
82
|
+
if Array === imports
|
35
83
|
pyfrom mod, :import => imports
|
84
|
+
elsif Hash === imports
|
85
|
+
pyimport mod, imports
|
36
86
|
else
|
37
87
|
pyimport mod
|
38
88
|
end
|
@@ -49,4 +99,14 @@ module RbbtPython
|
|
49
99
|
end
|
50
100
|
end
|
51
101
|
|
102
|
+
def self.add_paths(paths)
|
103
|
+
self.run 'sys' do
|
104
|
+
paths.each do |path|
|
105
|
+
sys.path.append path
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
RbbtPython.add_paths Rbbt.python.find_all
|
111
|
+
RbbtPython.pyimport "rbbt"
|
52
112
|
end
|
data/lib/rbbt/util/simpleDSL.rb
CHANGED
@@ -38,13 +38,13 @@ module SimpleDSL
|
|
38
38
|
hook_method(method)
|
39
39
|
|
40
40
|
# Execute
|
41
|
+
@config ||= {}
|
41
42
|
if actions.is_a? Proc
|
42
43
|
begin
|
43
|
-
require '
|
44
|
-
|
45
|
-
require 'ruby2ruby'
|
46
|
-
@config[@@method_name] = actions.to_ruby.collect[1..-2].join
|
44
|
+
require 'method_source'
|
45
|
+
@config[@@method_name] = actions.source.split("\n")[1..-2] * "\n"
|
47
46
|
rescue Exception
|
47
|
+
Log.exception $!
|
48
48
|
@config[@@method_name] = NoRuby2Ruby.new "The gem ruby2ruby is not installed. It will not work on ruby 1.9."
|
49
49
|
end
|
50
50
|
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -347,6 +347,11 @@ module Workflow
|
|
347
347
|
|
348
348
|
inputs = IndiferentHash.setup(inputs)
|
349
349
|
|
350
|
+
not_overriden = inputs.delete :not_overriden
|
351
|
+
if not_overriden
|
352
|
+
inputs[:not_overriden] = :not_overriden_dep
|
353
|
+
end
|
354
|
+
|
350
355
|
Workflow.resolve_locals(inputs)
|
351
356
|
|
352
357
|
task_info = task_info(taskname)
|
@@ -400,7 +405,11 @@ module Workflow
|
|
400
405
|
jobname = DEFAULT_NAME if jobname.nil? or jobname.empty?
|
401
406
|
|
402
407
|
dependencies = real_dependencies(task, jobname, defaults.merge(inputs), task_dependencies[taskname] || [])
|
403
|
-
|
408
|
+
|
409
|
+
overriden_deps = dependencies.select{|d| d.overriden }
|
410
|
+
true_overriden_deps = overriden_deps.select{|d| TrueClass === d.overriden }
|
411
|
+
|
412
|
+
overriden = has_overriden_inputs || overriden_deps.any?
|
404
413
|
|
405
414
|
if real_inputs.empty? && Workflow::TAG != :inputs && ! overriden
|
406
415
|
step_path = step_path taskname, jobname, [], [], task.extension
|
@@ -413,7 +422,16 @@ module Workflow
|
|
413
422
|
job = get_job_step step_path, task, input_values, dependencies
|
414
423
|
job.workflow = self
|
415
424
|
job.clean_name = jobname
|
416
|
-
|
425
|
+
|
426
|
+
case not_overriden
|
427
|
+
when TrueClass
|
428
|
+
job.overriden = has_overriden_inputs || true_overriden_deps.any?
|
429
|
+
when :not_overriden_dep
|
430
|
+
job.overriden = true if has_overriden_inputs || true_overriden_deps.any?
|
431
|
+
else
|
432
|
+
job.overriden = true if has_overriden_inputs || overriden_deps.any?
|
433
|
+
end
|
434
|
+
|
417
435
|
job.real_inputs = real_inputs.keys
|
418
436
|
job
|
419
437
|
end
|
data/lib/rbbt/workflow/step.rb
CHANGED
@@ -34,13 +34,40 @@ class Step
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
|
38
|
+
def overriden?
|
39
|
+
return true if @overriden
|
40
|
+
return true if dependencies.select{|dep| dep.overriden? }.any?
|
41
|
+
info[:archived_info].each do |f,i|
|
42
|
+
return true if i[:overriden] || i["overriden"]
|
43
|
+
end if info[:archived_info]
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
|
37
47
|
def overriden
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
48
|
+
@overriden
|
49
|
+
#if @overriden.nil?
|
50
|
+
# return false if dependencies.nil?
|
51
|
+
# dependencies.select{|dep| dep.overriden? }.any?
|
52
|
+
#else
|
53
|
+
# @overriden
|
54
|
+
#end
|
55
|
+
end
|
56
|
+
|
57
|
+
def overriden_deps
|
58
|
+
ord = []
|
59
|
+
deps = dependencies.dup
|
60
|
+
while dep = deps.shift
|
61
|
+
case dep.overriden
|
62
|
+
when FalseClass
|
63
|
+
next
|
64
|
+
when Symbol
|
65
|
+
ord << dep
|
66
|
+
else
|
67
|
+
deps += dep.dependencies
|
68
|
+
end
|
43
69
|
end
|
70
|
+
ord
|
44
71
|
end
|
45
72
|
|
46
73
|
def initialize(path, task = nil, inputs = nil, dependencies = nil, bindings = nil, clean_name = nil)
|
@@ -134,7 +161,11 @@ class Step
|
|
134
161
|
|
135
162
|
archived_info = {}
|
136
163
|
dependencies.each do |dep|
|
137
|
-
|
164
|
+
if Symbol === dep.overriden && ! Open.exists?(dep.info_file)
|
165
|
+
archived_info[dep.path] = dep.overriden
|
166
|
+
else
|
167
|
+
archived_info[dep.path] = dep.info
|
168
|
+
end
|
138
169
|
archived_info.merge!(dep.archived_info)
|
139
170
|
end if dependencies
|
140
171
|
|
@@ -248,7 +248,7 @@ class Step
|
|
248
248
|
def init_info(force = false)
|
249
249
|
return nil if @exec || info_file.nil? || (Open.exists?(info_file) && ! force)
|
250
250
|
Open.lock(info_file, :lock => info_lock) do
|
251
|
-
i = {:status => :waiting, :pid => Process.pid, :path => path, :real_inputs => real_inputs}
|
251
|
+
i = {:status => :waiting, :pid => Process.pid, :path => path, :real_inputs => real_inputs, :overriden => overriden}
|
252
252
|
i[:dependencies] = dependencies.collect{|dep| [dep.task_name, dep.name, dep.path]} if dependencies
|
253
253
|
Misc.sensiblewrite(info_file, Step.serialize_info(i), :force => true, :lock => false)
|
254
254
|
@info_cache = IndiferentHash.setup(i)
|
@@ -551,7 +551,7 @@ class Step
|
|
551
551
|
|
552
552
|
def aborted?
|
553
553
|
status = self.status
|
554
|
-
status == :aborted || ((status != :dependencies && status != :cleaned && status != :noinfo && status != :setup && status != :noinfo) && nopid?)
|
554
|
+
status == :aborted || ((status != :ending && status != :dependencies && status != :cleaned && status != :noinfo && status != :setup && status != :noinfo) && nopid?)
|
555
555
|
end
|
556
556
|
|
557
557
|
# {{{ INFO
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rbbt/workflow'
|
2
|
+
require 'rbbt/workflow/examples'
|
3
|
+
|
4
|
+
module Workflow
|
5
|
+
module Data
|
6
|
+
def data(directory)
|
7
|
+
@@data_directory = directory
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_datadir(clean_name)
|
11
|
+
data_dir = File.join(@@data_directory, clean_name)
|
12
|
+
raise "Data dir not found #{data_dir}" unless File.directory?(data_dir)
|
13
|
+
if Path === @@data_directory
|
14
|
+
@@data_directory.annotate data_dir
|
15
|
+
else
|
16
|
+
Path.setup(data_dir)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def data_task(name, workflow, oname, *rest, &block)
|
21
|
+
dep_task(name, workflow, oname, *rest) do |jobname, options|
|
22
|
+
data_dir = self.get_datadir(jobname)
|
23
|
+
task_info = workflow.task_info(oname)
|
24
|
+
dir_options = Workflow.load_inputs(data_dir.options, task_info[:inputs], task_info[:input_types])
|
25
|
+
data_options = block.call data_dir, dir_options, task_info
|
26
|
+
if data_options.include?(:inputs)
|
27
|
+
data_options
|
28
|
+
else
|
29
|
+
{:inputs => data_options.merge(options)}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -188,6 +188,7 @@ rbbt.png_plot('#{plot}', 'plot(timeline)', width=#{width}, height=#{height}, poi
|
|
188
188
|
seed_jobs.each do |step|
|
189
189
|
jobs += step.rec_dependencies + [step]
|
190
190
|
step.info[:archived_info].each do |path,ainfo|
|
191
|
+
next unless Hash === ainfo
|
191
192
|
archived_step = Step.new path
|
192
193
|
|
193
194
|
archived_step.define_singleton_method :info do
|
@@ -205,7 +206,7 @@ rbbt.png_plot('#{plot}', 'plot(timeline)', width=#{width}, height=#{height}, poi
|
|
205
206
|
|
206
207
|
end
|
207
208
|
|
208
|
-
jobs = jobs.uniq.sort_by{|job| t = job.info[:started] || Open.mtime(job.path) || Time.now; Time === t ? t : Time.parse(t) }
|
209
|
+
jobs = jobs.uniq.sort_by{|job| [job, job.info]; t = job.info[:started] || Open.mtime(job.path) || Time.now; Time === t ? t : Time.parse(t) }
|
209
210
|
|
210
211
|
data = trace_job_times(jobs, options[:fix_gap])
|
211
212
|
|
data/python/rbbt.py
ADDED
@@ -499,7 +499,7 @@ install_jar(){
|
|
499
499
|
local url="$2"
|
500
500
|
|
501
501
|
[ -d "$OPT_DIR/$name/" ] || mkdir -p "$OPT_DIR/$name/"
|
502
|
-
wget "$url" -O "$OPT_DIR
|
502
|
+
wget "$url" -O "$OPT_DIR/$name/$name.jar" || wget "$url" -O "$OPT_DIR/$name/$name.jar" --no-check-certificate || (rm "$OPT_DIR/$name/$name.jar"; exit -1)
|
503
503
|
link "$OPT_DIR/$name/$name.jar" "$OPT_JAR_DIR/$name.jar"
|
504
504
|
}
|
505
505
|
|
@@ -173,7 +173,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
173
173
|
select = true if queued && deps && (running_jobs & deps).any? || queued && is_running && nodes.empty?
|
174
174
|
select = true if running && nodes.any? && (exit_status.nil? && running_jobs.include?(id)) && (!deps || (running_jobs & deps).empty?)
|
175
175
|
select = true if jobid && jobid.split(",").include?(id)
|
176
|
-
select = select &&
|
176
|
+
select = select && step_path.match(/#{search}/) if search
|
177
177
|
next unless select
|
178
178
|
elsif search
|
179
179
|
select = false
|
@@ -206,9 +206,9 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
206
206
|
puts Log.color(:magenta, "BATCH parameters: ")
|
207
207
|
case job_batch_system
|
208
208
|
when 'slurm'
|
209
|
-
text = CMD.cmd('grep "^#SBATCH"
|
209
|
+
text = CMD.cmd('grep "^#SBATCH" ', :in => Open.read(fcmd)).read.strip
|
210
210
|
when 'lsf'
|
211
|
-
text = CMD.cmd('grep "^#BSUB"
|
211
|
+
text = CMD.cmd('grep "^#BSUB" ', :in => Open.read(fcmd)).read.strip
|
212
212
|
else
|
213
213
|
text = ""
|
214
214
|
end
|
@@ -292,13 +292,17 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
292
292
|
step_path = step_line.split(": ").last.strip
|
293
293
|
step = Step.new step_path
|
294
294
|
step.load_dependencies_from_info
|
295
|
+
has_bar = false
|
295
296
|
(step.rec_dependencies + [step]).reverse.each do |j|
|
296
297
|
next if j.done?
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
298
|
+
if j.file(:progress).exists?
|
299
|
+
bar = Log::ProgressBar.new
|
300
|
+
bar.load(j.file(:progress).yaml)
|
301
|
+
puts Log.color(:magenta, "Progress: ") + bar.report_msg + " " + Log.color(:yellow, j.task_signature)
|
302
|
+
has_bar = true
|
303
|
+
end
|
301
304
|
end
|
305
|
+
puts Log.color(:magenta, "Progress: ") + Log.color(:yellow, step.task_signature) + " #{step.status}" unless has_bar
|
302
306
|
end
|
303
307
|
end
|
304
308
|
|