rbbt-util 5.34.12 → 5.34.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/hpc/batch.rb +27 -3
- data/lib/rbbt/resource.rb +4 -0
- data/lib/rbbt/tsv/csv.rb +3 -1
- data/lib/rbbt/tsv/excel.rb +2 -2
- data/lib/rbbt/util/misc/development.rb +10 -0
- data/lib/rbbt/util/misc.rb +4 -1
- data/lib/rbbt/util/open.rb +5 -4
- data/lib/rbbt/util/python/util.rb +2 -1
- data/lib/rbbt/workflow/step/accessor.rb +1 -1
- data/share/Rlib/plot.R +6 -0
- data/share/Rlib/util.R +1 -1
- data/share/rbbt_commands/hpc/clean +1 -1
- data/share/rbbt_commands/hpc/orchestrate +3 -1
- data/share/rbbt_commands/hpc/task +3 -1
- data/share/rbbt_commands/lsf/clean +1 -1
- data/share/rbbt_commands/lsf/orchestrate +3 -1
- data/share/rbbt_commands/lsf/task +3 -1
- data/share/rbbt_commands/slurm/clean +1 -1
- data/share/rbbt_commands/slurm/orchestrate +3 -1
- data/share/rbbt_commands/slurm/task +3 -1
- data/test/rbbt/util/test_misc.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e50428f936aab209874c5f26e7504aa14da9a30bc7e2b13575432527a5b6a4
|
4
|
+
data.tar.gz: e522b76bb910b477e303e2cfc323c8708fa4d3bbecc0a7c46de473fe81f1ef6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e73a4ceda5eca11497ea4f0fe91fda7275375aaf8aeb6f9f70a45a46d4c71022527d7cd32c0cb30700a6bc2724bd1e2d2e0bd808a553ee3c8d6e729baa1dc2c0
|
7
|
+
data.tar.gz: a050c5defff3e3d36fe5682c117802d54cfeb930e3e61ff96da29e326719bf97af6fe85b5c30812dd91c5c6a447201164c15a3e1714aa1226690a0c49782ba9a
|
data/lib/rbbt/hpc/batch.rb
CHANGED
@@ -51,9 +51,15 @@ module HPC
|
|
51
51
|
|
52
52
|
group, user, user_group, scratch_group_dir, projects_group_dir = options.values_at :group, :user, :user_group, :scratch_group_dir, :projects_group_dir
|
53
53
|
|
54
|
-
singularity_img, singularity_opt_dir, singularity_ruby_inline = options.values_at :singularity_img, :singularity_opt_dir, :singularity_ruby_inline
|
54
|
+
singularity_img, singularity_opt_dir, singularity_ruby_inline, singularity_mounts = options.values_at :singularity_img, :singularity_opt_dir, :singularity_ruby_inline, :singularity_mounts
|
55
|
+
|
56
|
+
singularity_cmd = %(singularity exec -e -B "#{File.expand_path singularity_opt_dir}":/singularity_opt/ -B "#{File.expand_path singularity_ruby_inline}":"/.singularity_ruby_inline":rw )
|
55
57
|
|
56
|
-
|
58
|
+
if singularity_mounts
|
59
|
+
singularity_mounts.split(",").each do |mount|
|
60
|
+
singularity_cmd += "-B #{ mount } "
|
61
|
+
end
|
62
|
+
end
|
57
63
|
|
58
64
|
if contain && options[:hardened]
|
59
65
|
singularity_cmd << %( -C -H "#{contain}" \
|
@@ -150,6 +156,7 @@ EOF
|
|
150
156
|
:mem_per_cpu,
|
151
157
|
:gres,
|
152
158
|
:lua_modules,
|
159
|
+
:conda,
|
153
160
|
:contraints,
|
154
161
|
:licenses,
|
155
162
|
:batch_dir,
|
@@ -167,6 +174,7 @@ EOF
|
|
167
174
|
:purge_deps,
|
168
175
|
:singularity,
|
169
176
|
:singularity_img,
|
177
|
+
:singularity_mounts,
|
170
178
|
:singularity_opt_dir,
|
171
179
|
:singularity_ruby_inline
|
172
180
|
]
|
@@ -188,6 +196,7 @@ EOF
|
|
188
196
|
:env_cmd,
|
189
197
|
:user_group,
|
190
198
|
:singularity_img,
|
199
|
+
:singularity_mounts,
|
191
200
|
:singularity_opt_dir,
|
192
201
|
:singularity_ruby_inline,
|
193
202
|
:singularity
|
@@ -284,6 +293,20 @@ EOF
|
|
284
293
|
str
|
285
294
|
end
|
286
295
|
|
296
|
+
def load_conda(env = nil)
|
297
|
+
return "" if env.nil? || env.empty?
|
298
|
+
|
299
|
+
<<-EOF
|
300
|
+
if ! type conda | grep function &> /dev/null; then
|
301
|
+
if [ ! -z $CONDA_EXE ]; then
|
302
|
+
source "$(dirname $(dirname $CONDA_EXE))/etc/profile.d/conda.sh" &> /dev/null
|
303
|
+
fi
|
304
|
+
fi
|
305
|
+
conda activate #{ env }
|
306
|
+
EOF
|
307
|
+
end
|
308
|
+
|
309
|
+
|
287
310
|
def batch_system_variables
|
288
311
|
<<-EOF
|
289
312
|
let MAX_MEMORY="$(grep MemTotal /proc/meminfo|grep -o "[[:digit:]]*") / 1024"
|
@@ -292,6 +315,7 @@ let MAX_MEMORY="$(grep MemTotal /proc/meminfo|grep -o "[[:digit:]]*") / 1024"
|
|
292
315
|
|
293
316
|
def prepare_environment(options = {})
|
294
317
|
modules = options[:lua_modules]
|
318
|
+
conda = options[:conda]
|
295
319
|
|
296
320
|
prepare_environment = ""
|
297
321
|
|
@@ -382,7 +406,7 @@ echo "user_scratch: #{scratch_group_dir}/#{user}/{PKGDIR}/{TOPLEVEL}/{SUBPATH}"
|
|
382
406
|
end
|
383
407
|
end
|
384
408
|
|
385
|
-
batch_system_variables + load_modules(modules) + "\n" + functions + "\n" + prepare_environment
|
409
|
+
batch_system_variables + load_modules(modules) + "\n" + load_conda(conda) + "\n" + functions + "\n" + prepare_environment
|
386
410
|
end
|
387
411
|
|
388
412
|
def execute(options)
|
data/lib/rbbt/resource.rb
CHANGED
@@ -204,6 +204,10 @@ module Resource
|
|
204
204
|
case type
|
205
205
|
when :string
|
206
206
|
Misc.sensiblewrite(final_path, content)
|
207
|
+
when :csv
|
208
|
+
require 'rbbt/tsv/csv'
|
209
|
+
tsv = TSV.csv Open.open(content)
|
210
|
+
Misc.sensiblewrite(final_path, tsv.to_s)
|
207
211
|
when :url
|
208
212
|
options = {}
|
209
213
|
options[:noz] = true if Open.gzip?(final_path) || Open.bgzip?(final_path) || Open.zip?(final_path)
|
data/lib/rbbt/tsv/csv.rb
CHANGED
data/lib/rbbt/tsv/excel.rb
CHANGED
@@ -266,7 +266,7 @@ module TSV
|
|
266
266
|
|
267
267
|
def self.xls(filename, options ={})
|
268
268
|
if Open.remote? filename
|
269
|
-
TmpFile.with_file do |tmp|
|
269
|
+
TmpFile.with_file nil, :extension => 'xls' do |tmp|
|
270
270
|
Open.download(filename, tmp)
|
271
271
|
TSV::XLS.read(tmp, options)
|
272
272
|
end
|
@@ -278,7 +278,7 @@ module TSV
|
|
278
278
|
def self.xlsx(filename, options ={})
|
279
279
|
if Open.remote? filename
|
280
280
|
|
281
|
-
TmpFile.with_file do |tmp|
|
281
|
+
TmpFile.with_file nil, :extension => 'xlsx' do |tmp|
|
282
282
|
Open.download(filename, tmp)
|
283
283
|
TSV::XLSX.read(tmp, options)
|
284
284
|
end
|
@@ -193,6 +193,16 @@ def self.add_libdir(dir=nil)
|
|
193
193
|
insist(3, &block)
|
194
194
|
end
|
195
195
|
|
196
|
+
def self.chunk(array, num)
|
197
|
+
total = array.length
|
198
|
+
current = 0
|
199
|
+
while current < total
|
200
|
+
last = current + num - 1
|
201
|
+
yield array[current..last]
|
202
|
+
current = last + 1
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
196
206
|
# Divides the array into +num+ chunks of the same size by placing one
|
197
207
|
# element in each chunk iteratively.
|
198
208
|
def self.divide(array, num)
|
data/lib/rbbt/util/misc.rb
CHANGED
@@ -71,6 +71,9 @@ module Misc
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.timespan(str, default = "s")
|
74
|
+
|
75
|
+
return - timespan(str[1..-1], default) if str[0] == "-"
|
76
|
+
|
74
77
|
if str.include?(":")
|
75
78
|
seconds, minutes, hours = str.split(":").reverse
|
76
79
|
return seconds.to_i + minutes.to_i * 60 + hours.to_i * 60 * 60
|
@@ -86,7 +89,7 @@ module Misc
|
|
86
89
|
"h" => (60 * 60),
|
87
90
|
"d" => (60 * 60 * 24),
|
88
91
|
"w" => (60 * 60 * 24 * 7),
|
89
|
-
"mo" => (60 * 60 * 24 *
|
92
|
+
"mo" => (60 * 60 * 24 * 31),
|
90
93
|
"y" => (60 * 60 * 24 * 365),
|
91
94
|
}
|
92
95
|
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -640,7 +640,7 @@ module Open
|
|
640
640
|
io
|
641
641
|
end
|
642
642
|
|
643
|
-
def self.
|
643
|
+
def self.download_old(url, file)
|
644
644
|
Open.open(url, :mode => 'rb', :noz => true) do |sin|
|
645
645
|
Open.open(file, :mode => 'wb') do |sout|
|
646
646
|
Misc.consume_stream(sin, false, sout)
|
@@ -648,6 +648,10 @@ module Open
|
|
648
648
|
end
|
649
649
|
end
|
650
650
|
|
651
|
+
def self.download(url, path)
|
652
|
+
Open.wget(url, "--output-document" => path, :pipe => false)
|
653
|
+
end
|
654
|
+
|
651
655
|
def self.can_open?(file)
|
652
656
|
String === file and (Open.exist?(file) or remote?(file))
|
653
657
|
end
|
@@ -841,7 +845,4 @@ module Open
|
|
841
845
|
File.symlink?(path) && ! File.exist?(File.readlink(path))
|
842
846
|
end
|
843
847
|
|
844
|
-
def self.download(url, path)
|
845
|
-
Open.wget(url, "--output-document" => path)
|
846
|
-
end
|
847
848
|
end
|
@@ -19,8 +19,9 @@ module RbbtPython
|
|
19
19
|
|
20
20
|
def self.df2tsv(tuple, options = {})
|
21
21
|
options = Misc.add_defaults options, :type => :list
|
22
|
+
IndiferentHash.setup options
|
22
23
|
tsv = TSV.setup({}, options)
|
23
|
-
tsv.key_field = tuple.columns.name
|
24
|
+
tsv.key_field = options[:key_field] || tuple.columns.name
|
24
25
|
tsv.fields = py2ruby_a(tuple.columns.values)
|
25
26
|
keys = tuple.index.values
|
26
27
|
PyCall.len(tuple.index).times do |i|
|
data/share/Rlib/plot.R
CHANGED
@@ -39,3 +39,9 @@ geom_entity <- function (real.geom = NULL, mapping = NULL, data = NULL, stat = "
|
|
39
39
|
}
|
40
40
|
|
41
41
|
rbbt.ggplot2.rotate_x_labels <- function(){ theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) }
|
42
|
+
|
43
|
+
rbbt.ggplot2.theme <- function(plot){
|
44
|
+
|
45
|
+
plot + theme_classic() + scale_y_continuous(labels=scales::comma) + scale_x_continuous(labels=scales::comma) + rbbt.ggplot2.rotate_x_labels()
|
46
|
+
|
47
|
+
}
|
data/share/Rlib/util.R
CHANGED
@@ -812,7 +812,7 @@ rbbt.plot.text_scatter <- function(formula, data) {
|
|
812
812
|
rbbt.install.CRAN <- function(pkg){
|
813
813
|
cat("Try CRAN install:", pkg, "\n")
|
814
814
|
res = FALSE
|
815
|
-
tryCatch({ install.packages(pkg); library(pkg); res = TRUE; }, error = function(e){ str(e); warning(paste("Could not install CRAN ", pkg)); res = FALSE })
|
815
|
+
tryCatch({ install.packages(pkg); library(pkg, character.only=T); res = TRUE; }, error = function(e){ str(e); warning(paste("Could not install CRAN ", pkg)); res = FALSE })
|
816
816
|
return(res)
|
817
817
|
}
|
818
818
|
|
@@ -138,7 +138,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
138
138
|
fcadep = File.join(dir, 'canfail_dependencies.list')
|
139
139
|
cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
|
140
140
|
|
141
|
-
aborted = error = true if aborted.nil? && error.nil?
|
141
|
+
aborted = error = true if ! done && aborted.nil? && error.nil?
|
142
142
|
#if done || error || aborted || running || queued || jobid || search
|
143
143
|
# select = false
|
144
144
|
# select = true if done && exit_status && exit_status.to_i == 0
|
@@ -13,6 +13,7 @@ $slurm_options = SOPT.get <<EOF
|
|
13
13
|
--drbbt* Use development version of rbbt
|
14
14
|
-sing--singularity Use Singularity
|
15
15
|
-si--singularity_img* Singularity image to use
|
16
|
+
-sm--singularity_mounts* Singularity image to use
|
16
17
|
-ug--user_group* Use alternative user group for group project directory
|
17
18
|
-c--contain* Contain in directory (using Singularity)
|
18
19
|
-s--sync* Contain in directory and sync jobs
|
@@ -36,8 +37,9 @@ $slurm_options = SOPT.get <<EOF
|
|
36
37
|
-cons--constraint* SLURM constraint
|
37
38
|
-W--workflows* Additional workflows
|
38
39
|
-rmb--remove_batch_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
|
39
|
-
-lmod--lua_modules* Lua Modules to load
|
40
40
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
41
|
+
-lmod--lua_modules* Lua Modules to load
|
42
|
+
-co--conda* Conda environment to use
|
41
43
|
-OR--orchestration_rules* Orchestration rules
|
42
44
|
EOF
|
43
45
|
|
@@ -12,6 +12,7 @@ $slurm_options = SOPT.get <<EOF
|
|
12
12
|
--drbbt* Use development version of rbbt
|
13
13
|
-sing--singularity Use Singularity
|
14
14
|
-si--singularity_img* Singularity image to use
|
15
|
+
-sm--singularity_mounts* Singularity image to use
|
15
16
|
-ug--user_group* Use alternative user group for group project directory
|
16
17
|
-c--contain* Contain in directory (using Singularity)
|
17
18
|
-s--sync* Contain in directory and sync jobs
|
@@ -35,8 +36,9 @@ $slurm_options = SOPT.get <<EOF
|
|
35
36
|
-cons--constraint* SLURM constraint
|
36
37
|
-W--workflows* Additional workflows
|
37
38
|
-rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
|
38
|
-
-lmod--lua_modules* Lua Modules to load
|
39
39
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
40
|
+
-lmod--lua_modules* Lua Modules to load
|
41
|
+
-co--conda* Conda environment to use
|
40
42
|
EOF
|
41
43
|
|
42
44
|
batch_system = $slurm_options.delete :batch_system
|
@@ -138,7 +138,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
138
138
|
fcadep = File.join(dir, 'canfail_dependencies.list')
|
139
139
|
cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
|
140
140
|
|
141
|
-
aborted = error = true if aborted.nil? && error.nil?
|
141
|
+
aborted = error = true if ! done && aborted.nil? && error.nil?
|
142
142
|
#if done || error || aborted || running || queued || jobid || search
|
143
143
|
# select = false
|
144
144
|
# select = true if done && exit_status && exit_status.to_i == 0
|
@@ -13,6 +13,7 @@ $slurm_options = SOPT.get <<EOF
|
|
13
13
|
--drbbt* Use development version of rbbt
|
14
14
|
-sing--singularity Use Singularity
|
15
15
|
-si--singularity_img* Singularity image to use
|
16
|
+
-sm--singularity_mounts* Singularity image to use
|
16
17
|
-ug--user_group* Use alternative user group for group project directory
|
17
18
|
-c--contain* Contain in directory (using Singularity)
|
18
19
|
-s--sync* Contain in directory and sync jobs
|
@@ -36,8 +37,9 @@ $slurm_options = SOPT.get <<EOF
|
|
36
37
|
-cons--constraint* SLURM constraint
|
37
38
|
-W--workflows* Additional workflows
|
38
39
|
-rmb--remove_batch_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
|
39
|
-
-lmod--lua_modules* Lua Modules to load
|
40
40
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
41
|
+
-lmod--lua_modules* Lua Modules to load
|
42
|
+
-co--conda* Conda environment to use
|
41
43
|
-OR--orchestration_rules* Orchestration rules
|
42
44
|
EOF
|
43
45
|
|
@@ -12,6 +12,7 @@ $slurm_options = SOPT.get <<EOF
|
|
12
12
|
--drbbt* Use development version of rbbt
|
13
13
|
-sing--singularity Use Singularity
|
14
14
|
-si--singularity_img* Singularity image to use
|
15
|
+
-sm--singularity_mounts* Singularity image to use
|
15
16
|
-ug--user_group* Use alternative user group for group project directory
|
16
17
|
-c--contain* Contain in directory (using Singularity)
|
17
18
|
-s--sync* Contain in directory and sync jobs
|
@@ -35,8 +36,9 @@ $slurm_options = SOPT.get <<EOF
|
|
35
36
|
-cons--constraint* SLURM constraint
|
36
37
|
-W--workflows* Additional workflows
|
37
38
|
-rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
|
38
|
-
-lmod--lua_modules* Lua Modules to load
|
39
39
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
40
|
+
-lmod--lua_modules* Lua Modules to load
|
41
|
+
-co--conda* Conda environment to use
|
40
42
|
EOF
|
41
43
|
|
42
44
|
batch_system = $slurm_options.delete :batch_system
|
@@ -138,7 +138,7 @@ workdir.glob("**/command.batch").sort_by{|f| File.mtime(f)}.each do |fcmd|
|
|
138
138
|
fcadep = File.join(dir, 'canfail_dependencies.list')
|
139
139
|
cadeps = Open.read(fcadep).split("\n") if File.exist?(fcadep)
|
140
140
|
|
141
|
-
aborted = error = true if aborted.nil? && error.nil?
|
141
|
+
aborted = error = true if ! done && aborted.nil? && error.nil?
|
142
142
|
#if done || error || aborted || running || queued || jobid || search
|
143
143
|
# select = false
|
144
144
|
# select = true if done && exit_status && exit_status.to_i == 0
|
@@ -13,6 +13,7 @@ $slurm_options = SOPT.get <<EOF
|
|
13
13
|
--drbbt* Use development version of rbbt
|
14
14
|
-sing--singularity Use Singularity
|
15
15
|
-si--singularity_img* Singularity image to use
|
16
|
+
-sm--singularity_mounts* Singularity image to use
|
16
17
|
-ug--user_group* Use alternative user group for group project directory
|
17
18
|
-c--contain* Contain in directory (using Singularity)
|
18
19
|
-s--sync* Contain in directory and sync jobs
|
@@ -36,8 +37,9 @@ $slurm_options = SOPT.get <<EOF
|
|
36
37
|
-cons--constraint* SLURM constraint
|
37
38
|
-W--workflows* Additional workflows
|
38
39
|
-rmb--remove_batch_basedir Remove the SLURM working directory (command, STDIN, exit status, ...)
|
39
|
-
-lmod--lua_modules* Lua Modules to load
|
40
40
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
41
|
+
-lmod--lua_modules* Lua Modules to load
|
42
|
+
-co--conda* Conda environment to use
|
41
43
|
-OR--orchestration_rules* Orchestration rules
|
42
44
|
EOF
|
43
45
|
|
@@ -12,6 +12,7 @@ $slurm_options = SOPT.get <<EOF
|
|
12
12
|
--drbbt* Use development version of rbbt
|
13
13
|
-sing--singularity Use Singularity
|
14
14
|
-si--singularity_img* Singularity image to use
|
15
|
+
-sm--singularity_mounts* Singularity image to use
|
15
16
|
-ug--user_group* Use alternative user group for group project directory
|
16
17
|
-c--contain* Contain in directory (using Singularity)
|
17
18
|
-s--sync* Contain in directory and sync jobs
|
@@ -35,8 +36,9 @@ $slurm_options = SOPT.get <<EOF
|
|
35
36
|
-cons--constraint* SLURM constraint
|
36
37
|
-W--workflows* Additional workflows
|
37
38
|
-rmb--remove_batch_dir Remove the batch working directory (command, STDIN, exit status, ...)
|
38
|
-
-lmod--lua_modules* Lua Modules to load
|
39
39
|
-bs--batch_system* Batch system to use: auto, lsf, slurm (default is auto-detect)
|
40
|
+
-lmod--lua_modules* Lua Modules to load
|
41
|
+
-co--conda* Conda environment to use
|
40
42
|
EOF
|
41
43
|
|
42
44
|
batch_system = $slurm_options.delete :batch_system
|
data/test/rbbt/util/test_misc.rb
CHANGED
@@ -610,6 +610,8 @@ EOF
|
|
610
610
|
assert_equal 60*60*24, Misc.timespan('1d')
|
611
611
|
assert_equal 60*60*24, Misc.timespan('1d')
|
612
612
|
assert_equal 60*60*24, Misc.timespan('24:00:00')
|
613
|
+
|
614
|
+
assert_equal Misc.timespan('1min'), - Misc.timespan('-1min')
|
613
615
|
end
|
614
616
|
|
615
617
|
def test_remove_long_items
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.34.
|
4
|
+
version: 5.34.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|