rbbt-util 5.34.12 → 5.34.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d36e35e1495c3c319e8aa0485851b870e985bc34ea282f21c8e744adc302f50
4
- data.tar.gz: e4df8738231ce9e1f8ebf70090595413fef4555ad9bedde4b52b36ebc219e39e
3
+ metadata.gz: b2e50428f936aab209874c5f26e7504aa14da9a30bc7e2b13575432527a5b6a4
4
+ data.tar.gz: e522b76bb910b477e303e2cfc323c8708fa4d3bbecc0a7c46de473fe81f1ef6a
5
5
  SHA512:
6
- metadata.gz: 3ebc6c5ea53567b06a58854ab0b58c83777d939bb67a80cc28dbe7ebaa992269f59c20c2dba28d799402bfded6cbd9771ad1036e31ebbb365e3995500cd37f44
7
- data.tar.gz: 2d3870b76a07c096ee1df74593b6bd641c0f1f8aab68c09827bae57cf64ee97e237b22ee6d16edb81ddcc83b7d8b6f4cb6298da8d203c63f8cdebc408b44fb84
6
+ metadata.gz: e73a4ceda5eca11497ea4f0fe91fda7275375aaf8aeb6f9f70a45a46d4c71022527d7cd32c0cb30700a6bc2724bd1e2d2e0bd808a553ee3c8d6e729baa1dc2c0
7
+ data.tar.gz: a050c5defff3e3d36fe5682c117802d54cfeb930e3e61ff96da29e326719bf97af6fe85b5c30812dd91c5c6a447201164c15a3e1714aa1226690a0c49782ba9a
@@ -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
- singularity_cmd = %(singularity exec -e -B #{singularity_opt_dir}:/singularity_opt/ -B "#{singularity_ruby_inline}":"/.singularity_ruby_inline":rw )
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
@@ -25,7 +25,9 @@ module TSV
25
25
  when Path
26
26
  CSV.read obj.find.open, options
27
27
  when String
28
- if Misc.is_filename?(obj)
28
+ if Open.remote?(obj)
29
+ CSV.read Open.open(obj), options
30
+ elsif Misc.is_filename?(obj)
29
31
  CSV.read obj, options
30
32
  else
31
33
  CSV.new obj, **options
@@ -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)
@@ -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 * 30),
92
+ "mo" => (60 * 60 * 24 * 31),
90
93
  "y" => (60 * 60 * 24 * 365),
91
94
  }
92
95
 
@@ -640,7 +640,7 @@ module Open
640
640
  io
641
641
  end
642
642
 
643
- def self.download(url, file)
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|
@@ -203,7 +203,7 @@ class Step
203
203
  files
204
204
  end
205
205
 
206
- def file(name)
206
+ def file(name=nil)
207
207
  Path.setup(File.join(files_dir, name.to_s), workflow, self)
208
208
  end
209
209
 
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
@@ -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.12
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-08-23 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake