rbbt-util 5.32.10 → 5.32.16
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 +29 -12
- data/lib/rbbt/resource.rb +51 -49
- data/lib/rbbt/tsv.rb +5 -0
- data/lib/rbbt/tsv/csv.rb +2 -2
- data/lib/rbbt/tsv/manipulate.rb +2 -0
- data/lib/rbbt/tsv/parallel/traverse.rb +8 -11
- 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 +32 -4
- data/lib/rbbt/workflow/definition.rb +1 -1
- 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/provenance.rb +26 -7
- 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 +7 -1
- data/share/rbbt_commands/hpc/task +5 -0
- data/share/rbbt_commands/lsf/list +11 -7
- data/share/rbbt_commands/lsf/orchestrate +7 -1
- data/share/rbbt_commands/lsf/task +5 -0
- data/share/rbbt_commands/slurm/list +11 -7
- data/share/rbbt_commands/slurm/orchestrate +7 -1
- data/share/rbbt_commands/slurm/task +5 -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 +48 -0
- metadata +86 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2898a052d60bd9d6c05e3d277482e2221d07c18067b592fe7b8fefd796e8a6a
|
4
|
+
data.tar.gz: 55bdd8b9a78d2d35a2c4c1574da11113c66b7621128076f29128941a5a0caf77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dd350c68a0c931da771f789aa934e3a94cf52be343101743a14eb2e049b782665db8f941da1f28e7503386af3f17c6ef4e53afa0ef388aecb65c9571ea974a5
|
7
|
+
data.tar.gz: 110a0a0eed2343835e3c4598f9c91c0280e28c64911a4fa18662c423d4f3d1774893b2e0ed848676a60878cae608a9b3d2e50de7c1c724935894971320628f2e
|
data/bin/rbbt
CHANGED
@@ -152,6 +152,7 @@ module Annotated
|
|
152
152
|
tsv = TSV.setup({}, :key_field => "List", :fields => fields, :type => :list, :unnamed => true)
|
153
153
|
|
154
154
|
annot_id = annotations.id
|
155
|
+
annot_id = annot_id * "," if Array === annot_id
|
155
156
|
tsv[annot_id] = annotations.tsv_values(*fields).dup
|
156
157
|
|
157
158
|
when Array === annotations
|
data/lib/rbbt/entity.rb
CHANGED
@@ -197,7 +197,7 @@ module Entity
|
|
197
197
|
if self.instance_variable_get("@multiple_result_" + name.to_s)
|
198
198
|
return self.instance_variable_get("@multiple_result_" + name.to_s)
|
199
199
|
end
|
200
|
-
raise MultipleEntity, "Entity #{name} runs with multiple entities"
|
200
|
+
raise MultipleEntity, "Entity property #{name} runs with multiple entities"
|
201
201
|
end
|
202
202
|
|
203
203
|
define_method name do |*args|
|
@@ -225,10 +225,12 @@ module Entity
|
|
225
225
|
case res
|
226
226
|
when Array
|
227
227
|
missing.zip(res).each do |o,res|
|
228
|
+
raise "Multiple function #{name} result nil for element #{o}" if res.nil?
|
228
229
|
o.instance_variable_set("@multiple_result_" + name.to_s, res)
|
229
230
|
end
|
230
231
|
when Hash
|
231
232
|
res.each do |o,res|
|
233
|
+
raise "Multiple function #{name} result nil for element #{o}" if res.nil?
|
232
234
|
o.instance_variable_set("@multiple_result_" + name.to_s, res)
|
233
235
|
end
|
234
236
|
end
|
@@ -254,7 +256,10 @@ module Entity
|
|
254
256
|
|
255
257
|
orig_method_name = method_name
|
256
258
|
multi_name = "_multiple_" + method_name.to_s
|
259
|
+
single_name = "_single_" + method_name.to_s
|
260
|
+
|
257
261
|
method_name = multi_name if self.instance_methods.include?(multi_name.to_sym)
|
262
|
+
method_name = single_name if self.instance_methods.include?(single_name.to_sym)
|
258
263
|
|
259
264
|
orig_name = UNPERSISTED_PREFIX + method_name.to_s
|
260
265
|
alias_method orig_name, method_name unless self.instance_methods.include? orig_name.to_sym
|
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
|
@@ -138,7 +139,7 @@ EOF
|
|
138
139
|
|
139
140
|
keys = [
|
140
141
|
:batch_dir,
|
141
|
-
:
|
142
|
+
:lua_modules,
|
142
143
|
:batch_name,
|
143
144
|
:contain,
|
144
145
|
:contain_and_sync,
|
@@ -156,10 +157,16 @@ EOF
|
|
156
157
|
:singularity_ruby_inline,
|
157
158
|
:sync,
|
158
159
|
:task_cpus,
|
160
|
+
:gres,
|
161
|
+
:mem,
|
162
|
+
:mem_per_cpu,
|
163
|
+
:licenses,
|
164
|
+
:contraints,
|
159
165
|
:time,
|
160
166
|
:user_group,
|
161
167
|
:wipe_container,
|
162
168
|
:workdir,
|
169
|
+
:purge_deps
|
163
170
|
]
|
164
171
|
|
165
172
|
keys.each do |key|
|
@@ -283,7 +290,7 @@ let MAX_MEMORY="$(grep MemTotal /proc/meminfo|grep -o "[[:digit:]]*") / 1024"
|
|
283
290
|
end
|
284
291
|
|
285
292
|
def prepare_environment(options = {})
|
286
|
-
modules = options[:
|
293
|
+
modules = options[:lua_modules]
|
287
294
|
|
288
295
|
prepare_environment = ""
|
289
296
|
|
@@ -378,9 +385,9 @@ echo "user_scratch: #{scratch_group_dir}/#{user}/{PKGDIR}/{TOPLEVEL}/{SUBPATH}"
|
|
378
385
|
end
|
379
386
|
|
380
387
|
def execute(options)
|
381
|
-
exec_cmd, job_cmd = options.values_at :exec_cmd, :rbbt_cmd
|
388
|
+
exec_cmd, job_cmd, task_cpus = options.values_at :exec_cmd, :rbbt_cmd, :task_cpus
|
382
389
|
|
383
|
-
|
390
|
+
script=<<-EOF
|
384
391
|
step_path=$(
|
385
392
|
#{exec_cmd} #{job_cmd} --printpath
|
386
393
|
)
|
@@ -388,7 +395,10 @@ exit_status=$?
|
|
388
395
|
|
389
396
|
[[ -z $BATCH_JOB_ID ]] || #{exec_cmd} workflow write_info --recursive --force=false --check_pid "$step_path" batch_job $BATCH_JOB_ID
|
390
397
|
[[ -z $BATCH_SYSTEM ]] || #{exec_cmd} workflow write_info --recursive --force=false --check_pid "$step_path" batch_system $BATCH_SYSTEM
|
398
|
+
#{exec_cmd} workflow write_info --recursive --force=false --check_pid "$step_path" batch_cpus #{task_cpus}
|
391
399
|
EOF
|
400
|
+
|
401
|
+
script
|
392
402
|
end
|
393
403
|
|
394
404
|
def sync_environment(options = {})
|
@@ -409,6 +419,13 @@ fi
|
|
409
419
|
|
410
420
|
def cleanup_environment(options = {})
|
411
421
|
cleanup_environment = ""
|
422
|
+
|
423
|
+
cleanup_environment +=<<-EOF if options[:purge_deps]
|
424
|
+
if [ $exit_status == '0' ]; then
|
425
|
+
#{options[:exec_cmd]} workflow forget_deps --purge --recursive_purge "$step_path" 2>1 >> '#{options[:fsync]}'
|
426
|
+
fi
|
427
|
+
EOF
|
428
|
+
|
412
429
|
if options[:sync]
|
413
430
|
if options[:wipe_container] == 'force'
|
414
431
|
cleanup_environment +=<<-EOF
|
data/lib/rbbt/hpc/orchestrate.rb
CHANGED
data/lib/rbbt/hpc/slurm.rb
CHANGED
@@ -30,6 +30,10 @@ export BATCH_SYSTEM=SLURM
|
|
30
30
|
highmem = Misc.process_options options, :highmem
|
31
31
|
licenses = Misc.process_options options, :licenses
|
32
32
|
constraint = Misc.process_options options, :constraint
|
33
|
+
gres = Misc.process_options options, :gres
|
34
|
+
|
35
|
+
mem = Misc.process_options options, :mem
|
36
|
+
mem_per_cpu = Misc.process_options options, :mem_per_cpu
|
33
37
|
|
34
38
|
batch_dir = Misc.process_options options, :batch_dir
|
35
39
|
batch_name = Misc.process_options options, :batch_name
|
@@ -39,22 +43,35 @@ export BATCH_SYSTEM=SLURM
|
|
39
43
|
|
40
44
|
time = Misc.format_seconds Misc.timespan(time) unless time.include? ":"
|
41
45
|
|
46
|
+
sbatch_params = {"job-name" => batch_name,
|
47
|
+
"output" => fout,
|
48
|
+
"error" => ferr,
|
49
|
+
"cpus-per-task" => task_cpus,
|
50
|
+
"nodes" => nodes,
|
51
|
+
"time" => time,
|
52
|
+
"exclusive" => exclusive,
|
53
|
+
"licenses" => licenses,
|
54
|
+
"gres" => gres,
|
55
|
+
"mem" => mem,
|
56
|
+
"mem-per-cpu" => mem_per_cpu,
|
57
|
+
}
|
58
|
+
|
42
59
|
header =<<-EOF
|
43
60
|
#!/bin/bash
|
44
|
-
#SBATCH --job-name="#{batch_name}"
|
45
|
-
#SBATCH --workdir="#{workdir}"
|
46
|
-
#SBATCH --output="#{fout}"
|
47
|
-
#SBATCH --error="#{ferr}"
|
48
|
-
#SBATCH --qos="#{queue}"
|
49
|
-
#SBATCH --cpus-per-task="#{task_cpus}"
|
50
|
-
#SBATCH --time="#{time}"
|
51
|
-
#SBATCH --nodes="#{nodes}"
|
52
61
|
EOF
|
53
62
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
63
|
+
sbatch_params.each do |name,value|
|
64
|
+
next if value.nil? || value == ""
|
65
|
+
if TrueClass === value
|
66
|
+
header << "#SBATCH --#{name}" << "\n"
|
67
|
+
elsif Array === value
|
68
|
+
value.each do |v|
|
69
|
+
header << "#SBATCH --#{name}=\"#{v}\"" << "\n"
|
70
|
+
end
|
71
|
+
else
|
72
|
+
header << "#SBATCH --#{name}=\"#{value}\"" << "\n"
|
73
|
+
end
|
74
|
+
end
|
58
75
|
|
59
76
|
header
|
60
77
|
end
|
data/lib/rbbt/resource.rb
CHANGED
@@ -87,65 +87,67 @@ module Resource
|
|
87
87
|
lock_filename = nil # it seems like this was locked already.
|
88
88
|
|
89
89
|
Misc.lock lock_filename do
|
90
|
-
|
91
|
-
|
92
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
93
|
-
|
94
|
-
if uri.scheme == "https"
|
95
|
-
http.use_ssl = true
|
96
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
97
|
-
http.instance_variable_set("@ssl_options", OpenSSL::SSL::OP_NO_SSLv2 + OpenSSL::SSL::OP_NO_SSLv3 + OpenSSL::SSL::OP_NO_COMPRESSION)
|
98
|
-
end
|
90
|
+
begin
|
91
|
+
uri = URI(url)
|
99
92
|
|
100
|
-
|
101
|
-
http.read_timeout = timeout
|
102
|
-
http.open_timeout = timeout
|
103
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
104
|
-
http.request request do |response|
|
105
|
-
filename = if response["Content-Disposition"]
|
106
|
-
response["Content-Disposition"].split(";").select{|f| f.include? "filename"}.collect{|f| f.split("=").last.gsub('"','')}.first
|
107
|
-
else
|
108
|
-
nil
|
109
|
-
end
|
93
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
110
94
|
|
111
|
-
if
|
112
|
-
|
113
|
-
|
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)
|
114
99
|
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
100
|
+
|
101
|
+
timeout = 60 * 10
|
102
|
+
http.read_timeout = timeout
|
103
|
+
http.open_timeout = timeout
|
104
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
105
|
+
http.request request do |response|
|
106
|
+
filename = if response["Content-Disposition"]
|
107
|
+
response["Content-Disposition"].split(";").select{|f| f.include? "filename"}.collect{|f| f.split("=").last.gsub('"','')}.first
|
108
|
+
else
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
|
112
|
+
if filename && filename =~ /\.b?gz$/ && final_path !~ /\.b?gz$/
|
113
|
+
extension = filename.split(".").last
|
114
|
+
final_path += '.' + extension
|
121
115
|
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
TmpFile.with_file do |tmp_dir|
|
128
|
-
Misc.in_dir tmp_dir do
|
129
|
-
CMD.cmd('tar xvfz -', :in => Open.open(location, :nocache => true))
|
116
|
+
case response
|
117
|
+
when Net::HTTPSuccess, Net::HTTPOK
|
118
|
+
Misc.sensiblewrite(final_path) do |file|
|
119
|
+
response.read_body do |chunk|
|
120
|
+
file.write chunk
|
130
121
|
end
|
131
|
-
FileUtils.mv tmp_dir, final_path
|
132
122
|
end
|
123
|
+
when Net::HTTPRedirection, Net::HTTPFound
|
124
|
+
location = response['location']
|
125
|
+
if location.include? 'get_directory'
|
126
|
+
Log.debug("Feching directory from: #{location}. Into: #{final_path}")
|
127
|
+
FileUtils.mkdir_p final_path unless File.exist? final_path
|
128
|
+
TmpFile.with_file do |tmp_dir|
|
129
|
+
Misc.in_dir tmp_dir do
|
130
|
+
CMD.cmd('tar xvfz -', :in => Open.open(location, :nocache => true))
|
131
|
+
end
|
132
|
+
FileUtils.mv tmp_dir, final_path
|
133
|
+
end
|
134
|
+
else
|
135
|
+
url = location
|
136
|
+
raise TryAgain
|
137
|
+
#Open.open(location, :nocache => true) do |s|
|
138
|
+
# Misc.sensiblewrite(final_path, s)
|
139
|
+
#end
|
140
|
+
end
|
141
|
+
when Net::HTTPInternalServerError
|
142
|
+
@server_missing_resource_cache << url
|
143
|
+
raise "Resource Not Found"
|
133
144
|
else
|
134
|
-
|
135
|
-
raise TryAgain
|
136
|
-
#Open.open(location, :nocache => true) do |s|
|
137
|
-
# Misc.sensiblewrite(final_path, s)
|
138
|
-
#end
|
145
|
+
raise "Response not understood: #{response.inspect}"
|
139
146
|
end
|
140
|
-
when Net::HTTPInternalServerError
|
141
|
-
@server_missing_resource_cache << url
|
142
|
-
raise "Resource Not Found"
|
143
|
-
else
|
144
|
-
raise "Response not understood: #{response.inspect}"
|
145
147
|
end
|
148
|
+
rescue TryAgain
|
149
|
+
retry
|
146
150
|
end
|
147
|
-
rescue TryAgain
|
148
|
-
retry
|
149
151
|
end
|
150
152
|
rescue
|
151
153
|
Log.warn "Could not retrieve (#{self.to_s}) #{ path } from #{ remote_server }"
|
data/lib/rbbt/tsv.rb
CHANGED
@@ -98,6 +98,11 @@ module TSV
|
|
98
98
|
stream = get_stream source, options.merge(open_options)
|
99
99
|
parse stream, data, options.merge(:tsv_grep => tsv_grep)
|
100
100
|
|
101
|
+
if ! open_options[:noclose]
|
102
|
+
stream.close unless stream.closed?
|
103
|
+
stream.join if stream.respond_to?(:join)
|
104
|
+
end
|
105
|
+
|
101
106
|
data.filename = filename.to_s unless filename.nil?
|
102
107
|
|
103
108
|
if data.identifiers.nil? and Path === filename and filename.identifier_file_path
|
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
|
@@ -97,12 +97,11 @@ module TSV
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
rescue
|
100
|
-
Log.exception $!
|
101
100
|
error = true
|
102
101
|
raise $!
|
103
102
|
ensure
|
104
103
|
join.call(error) if join
|
105
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
104
|
+
Log::ProgressBar.remove_bar(bar, error) if bar
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
@@ -138,7 +137,7 @@ module TSV
|
|
138
137
|
raise $!
|
139
138
|
ensure
|
140
139
|
join.call(error) if join
|
141
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
140
|
+
Log::ProgressBar.remove_bar(bar, error) if bar
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
@@ -178,7 +177,7 @@ module TSV
|
|
178
177
|
raise $!
|
179
178
|
ensure
|
180
179
|
join.call(error) if join
|
181
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
180
|
+
Log::ProgressBar.remove_bar(bar, error) if bar
|
182
181
|
end
|
183
182
|
end
|
184
183
|
|
@@ -220,7 +219,7 @@ module TSV
|
|
220
219
|
raise $!
|
221
220
|
ensure
|
222
221
|
join.call(error) if join
|
223
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
222
|
+
Log::ProgressBar.remove_bar(bar, error) if bar
|
224
223
|
end
|
225
224
|
end
|
226
225
|
|
@@ -274,7 +273,7 @@ module TSV
|
|
274
273
|
raise $!
|
275
274
|
ensure
|
276
275
|
join.call(error) if join
|
277
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
276
|
+
Log::ProgressBar.remove_bar(bar, error) if bar
|
278
277
|
end
|
279
278
|
end
|
280
279
|
|
@@ -319,7 +318,7 @@ module TSV
|
|
319
318
|
raise $!
|
320
319
|
ensure
|
321
320
|
join.call(error) if join
|
322
|
-
Log::ProgressBar.remove_bar(bar) if bar
|
321
|
+
Log::ProgressBar.remove_bar(bar, error) if bar
|
323
322
|
end
|
324
323
|
end
|
325
324
|
|
@@ -390,7 +389,7 @@ module TSV
|
|
390
389
|
when Set
|
391
390
|
traverse_array(obj.to_a, options, &block)
|
392
391
|
when String
|
393
|
-
if Open.remote?
|
392
|
+
if Open.remote?(obj) or Misc.is_filename?(obj)
|
394
393
|
Open.open(obj) do |s|
|
395
394
|
traverse_obj(s, options, &block)
|
396
395
|
end
|
@@ -491,9 +490,7 @@ module TSV
|
|
491
490
|
q.join
|
492
491
|
raise $!
|
493
492
|
ensure
|
494
|
-
if bar
|
495
|
-
Log::ProgressBar.remove_bar(bar, error)
|
496
|
-
end
|
493
|
+
Log::ProgressBar.remove_bar(bar, error) if bar
|
497
494
|
end
|
498
495
|
end
|
499
496
|
|