rbbt-util 5.31.9 → 5.31.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9627d833faf734e912d68d60714081cd8179b8f65de153842c2a77bc356e58ab
4
- data.tar.gz: 4d75542d741d61732ddead0ab6295e97461e5cd4aa7b8baeb4436f78f875465d
3
+ metadata.gz: 99337ec5d1fb8c3dbc9d1b8f89bc2965dc659c3e6043defe718b0007ba00456b
4
+ data.tar.gz: c61228a72814e48ff2c7bf90a0e44ace075f6f4c1e29cfb7f36e6a182896f7b6
5
5
  SHA512:
6
- metadata.gz: 7105097e07ee1da675b2ee4cc5fa7f7be61bd49051553a28ca39a829105fda3e08e684ea804928000863d83d67bdad3d462121ab23a379a5ba76d3ce4c74ccc5
7
- data.tar.gz: ba67880edc6ecad00c8a06fa802fc56a035524a321ab31abe8d4cae07ea521ce641abd948731cd7da8f0582b8d5ea9cdea8bca3e9152acb070f379b35fd0a40d
6
+ metadata.gz: eeb8b9d43a4199cbea11693f7028ba6216507bb3c1cc149e30d30070652ddfd15f7660db2df1435a2ed108354d6ce261bfc23907d5cc6866c2561f2eac9285eb
7
+ data.tar.gz: 405081e84408572eb3a78cda085dba453c44b5583bc93e35287f9feb8d7693912710a1946b30e7ab931517da592f5a469cc66c4c923cf126070e7c01edbff134
@@ -121,6 +121,9 @@ EOF
121
121
  :nodes,
122
122
  :queue,
123
123
  :singularity,
124
+ :singularity_img,
125
+ :singularity_opt_dir,
126
+ :singularity_ruby_inline,
124
127
  :sync,
125
128
  :task_cpus,
126
129
  :time,
@@ -163,6 +166,8 @@ EOF
163
166
  batch_options[:scratch_group_dir] = File.join('/gpfs/scratch/', group)
164
167
  batch_options[:projects_group_dir] = File.join('/gpfs/projects/', group)
165
168
 
169
+ batch_options[:singularity] = true if batch_options[:singularity_img]
170
+
166
171
  if batch_options[:contain_and_sync]
167
172
  if batch_options[:contain].nil?
168
173
  contain_base = Rbbt::Config.get(:contain_base_dir, :batch_contain, :batch, :default => "/scratch/tmp/rbbt-[USER]")
@@ -23,6 +23,7 @@ BATCH_SYSTEM=SLURM
23
23
  nodes = Misc.process_options options, :nodes
24
24
  workdir = Misc.process_options options, :workdir
25
25
  exclusive = Misc.process_options options, :exclusive
26
+ highmem = Misc.process_options options, :highmem
26
27
 
27
28
  batch_dir = Misc.process_options options, :batch_dir
28
29
  batch_name = Misc.process_options options, :batch_name
@@ -45,6 +46,7 @@ BATCH_SYSTEM=SLURM
45
46
  EOF
46
47
 
47
48
  header << "#SBATCH --exclusive" << "\n" if exclusive
49
+ header << "#SBATCH --constraint=highmem" << "\n" if highmem
48
50
 
49
51
  header
50
52
  end
@@ -189,6 +189,7 @@ module TSV
189
189
  other.each do |k,v|
190
190
  self.zip_new k, v
191
191
  end
192
+ self
192
193
  end
193
194
 
194
195
 
data/lib/rbbt/util/cmd.rb CHANGED
@@ -10,6 +10,14 @@ module CMD
10
10
  TOOLS[tool] = [claim, test, block, cmd]
11
11
  end
12
12
 
13
+ def self.conda(tool, env = nil, channel = 'bioconda')
14
+ if env
15
+ CMD.cmd("bash -l -c '(conda activate #{env} && conda install #{tool} -c #{channel})'")
16
+ else
17
+ CMD.cmd("bash -l -c 'conda install #{tool} -c #{channel}'")
18
+ end
19
+ end
20
+
13
21
  def self.get_tool(tool)
14
22
  return tool.to_s unless TOOLS[tool]
15
23
 
@@ -30,16 +38,17 @@ module CMD
30
38
  end
31
39
  end
32
40
  version_txt = ""
33
- %w(--version -version --help).each do |f|
41
+ version = nil
42
+ ["--version", "-version", "--help", ""].each do |f|
34
43
  begin
35
- version_txt += CMD.cmd("#{tool} #{f}").read
36
- break
44
+ version_txt += CMD.cmd("#{tool} #{f} 2>&1", :nofail => true).read
45
+ version = Misc.scan_version_text(version_txt, tool)
46
+ break if version
37
47
  rescue
48
+ Log.exception $!
38
49
  end
39
50
  end
40
51
 
41
- version = Misc.scan_version_text(version_txt, tool)
42
-
43
52
  @@init_cmd_tool[tool] = version || true
44
53
 
45
54
  return cmd if cmd
@@ -67,7 +76,8 @@ module CMD
67
76
  string = ""
68
77
  options.each do |option, value|
69
78
  raise "Invalid option key: #{option.inspect}" if option.to_s !~ /^[a-z_0-9\-=]+$/i
70
- raise "Invalid option value: #{value.inspect}" if value.to_s.include? "'"
79
+ #raise "Invalid option value: #{value.inspect}" if value.to_s.include? "'"
80
+ value = value.gsub("'","\\'") if value.to_s.include? "'"
71
81
 
72
82
  option = "--" << option.to_s if add_dashes and option.to_s[0] != '-'
73
83
 
@@ -431,8 +431,20 @@ module Misc
431
431
 
432
432
  def self.scan_version_text(text, cmd = nil)
433
433
  cmd = "NOCMDGIVE" if cmd.nil? || cmd.empty?
434
+ text.split("\n").each do |line|
435
+ next unless line =~ /\W#{cmd}\W/i
436
+ m = line.match(/(v(?:\d+\.)*\d+(?:-[a-z_]+)?)/i)
437
+ return m[1] if m
438
+ m = line.match(/((?:\d+\.)*\d+(?:-[a-z_]+)?v)/i)
439
+ return m[1] if m
440
+ next unless line =~ /\Wversion\W/i
441
+ m = line.match(/((?:\d+\.)*\d+(?:-[a-z_]+)?)/i)
442
+ return m[1] if m
443
+ end
434
444
  m = text.match(/(?:version.*?|#{cmd}.*?|#{cmd.to_s.split(/[-_.]/).first}.*?|v)((?:\d+\.)*\d+(?:-[a-z_]+)?)/i)
435
- return nil if m.nil?
436
- m[1]
445
+ return m[1] if m
446
+ m = text.match(/(?:#{cmd}.*(v.*|.*v))/i)
447
+ return m[1] if m
448
+ nil
437
449
  end
438
450
  end
@@ -46,8 +46,8 @@ module Misc
46
46
  def self.hash2string(hash)
47
47
  hash.sort_by{|k,v| k.to_s}.collect{|k,v|
48
48
  next unless %w(Symbol String Float Fixnum Integer Numeric TrueClass FalseClass Module Class Object).include? v.class.to_s
49
- [ Symbol === k ? ":" << k.to_s : k,
50
- Symbol === v ? ":" << v.to_s : v] * "="
49
+ [ Symbol === k ? ":" << k.to_s : k.to_s.chomp,
50
+ Symbol === v ? ":" << v.to_s : v.to_s.chomp] * "="
51
51
  }.compact * "#"
52
52
  end
53
53
 
@@ -35,10 +35,11 @@ module Misc
35
35
  res
36
36
  end
37
37
 
38
- def self.with_fifo(path = nil, &block)
38
+ def self.with_fifo(path = nil, clean = true, &block)
39
39
  begin
40
40
  erase = path.nil?
41
41
  path = TmpFile.tmp_file if path.nil?
42
+ File.rm path if clean && File.exists?(path)
42
43
  File.mkfifo path
43
44
  yield path
44
45
  ensure
@@ -11,7 +11,7 @@ module Open
11
11
  class OpenGzipError < StandardError; end
12
12
 
13
13
  REMOTE_CACHEDIR = File.join(ENV["HOME"], "/tmp/open_cache")
14
- FileUtils.mkdir_p REMOTE_CACHEDIR unless File.exist? REMOTE_CACHEDIR
14
+ #FileUtils.mkdir_p REMOTE_CACHEDIR unless File.exist? REMOTE_CACHEDIR
15
15
 
16
16
  GREP_CMD = begin
17
17
  if ENV["GREP_CMD"]
@@ -346,15 +346,18 @@ module Open
346
346
  target = File.join(target, File.basename(source)) if File.directory? target
347
347
  FileUtils.mkdir_p File.dirname(target) unless File.exist?(File.dirname(target))
348
348
  FileUtils.rm target if File.exist?(target)
349
+ FileUtils.rm target if File.symlink?(target)
349
350
  FileUtils.ln_s source, target
350
351
  end
351
352
 
352
353
  def self.ln(source, target, options = {})
353
354
  source = source.find if Path === source
354
355
  target = target.find if Path === target
356
+ source = File.realpath(source) if File.symlink?(source)
355
357
 
356
358
  FileUtils.mkdir_p File.dirname(target) unless File.exist?(File.dirname(target))
357
359
  FileUtils.rm target if File.exist?(target)
360
+ FileUtils.rm target if File.symlink?(target)
358
361
  FileUtils.ln source, target
359
362
  end
360
363
 
@@ -76,8 +76,10 @@ module Workflow
76
76
  extension workflow.tasks[oname].extension if workflow.tasks.include?(oname) unless @extension
77
77
  task name do
78
78
  raise RbbtException, "dependency not found in dep_task" if dependencies.empty?
79
- dep = dependencies.last.join
79
+ dep = dependencies.last
80
+ dep.join
80
81
  raise dep.get_exception if dep.error?
82
+ raise Aborted, "Aborted dependency #{dep.path}" if dep.aborted?
81
83
  set_info :result_type, dep.info[:result_type]
82
84
  forget = config :forget_dep_tasks, "forget_dep_tasks", "key:forget_dep_tasks", :default => FORGET_DEP_TASKS
83
85
  if forget
@@ -103,7 +105,11 @@ module Workflow
103
105
  Open.rm_rf self.files_dir
104
106
  Open.link dep.files_dir, self.files_dir
105
107
  end
106
- Open.link dep.path, self.path
108
+ if defined?(RemoteStep) && RemoteStep === dep
109
+ Open.write(self.tmp_path, Open.read(dep.path))
110
+ else
111
+ Open.link dep.path, self.path
112
+ end
107
113
  end
108
114
  nil
109
115
  end
@@ -54,7 +54,8 @@ module Workflow
54
54
  inputs[input.to_sym] = YAML.load(Open.read(file))
55
55
  else
56
56
  if File.symlink?(file)
57
- inputs[input.to_sym] = File.readlink(file)
57
+ link_target = File.expand_path(File.readlink(file), File.dirname(file))
58
+ inputs[input.to_sym] = link_target
58
59
  else
59
60
  inputs[input.to_sym] = Open.realpath(file)
60
61
  end
@@ -20,7 +20,7 @@ class RemoteWorkflow
20
20
 
21
21
  def self.encode(url)
22
22
  begin
23
- URI.encode(url)
23
+ URI::DEFAULT_PARSER.escape(url)
24
24
  rescue
25
25
  Log.warn $!.message
26
26
  url
@@ -368,7 +368,7 @@ class Step
368
368
  end
369
369
 
370
370
  def self.log_progress(status, options = {}, path = nil, &block)
371
- options = Misc.add_defaults options, :severity => Log::INFO, :file => path
371
+ options = Misc.add_defaults options, :severity => Log::INFO, :file => (@exec ? nil : path)
372
372
  max = Misc.process_options options, :max
373
373
  Log::ProgressBar.with_bar(max, options) do |bar|
374
374
  begin
@@ -394,7 +394,7 @@ class Step
394
394
  options = {} if options.nil?
395
395
 
396
396
  max = options[:max]
397
- Log::ProgressBar.new_bar(max, {:desc => msg, :file => file(:progress)}.merge(options))
397
+ Log::ProgressBar.new_bar(max, {:desc => msg, :file => (@exec ? nil : file(:progress))}.merge(options))
398
398
  end
399
399
 
400
400
  def self.log(status, message, path, &block)
@@ -215,7 +215,7 @@ module Workflow
215
215
 
216
216
  dep_tree = {[self, task_name] => dep_tree(task_name)}
217
217
  prov_tree = prov_tree(dep_tree)
218
- if prov_tree && ! prov_tree.empty?
218
+ if prov_tree && ! prov_tree.empty? && prov_tree.split("\n").length > 2
219
219
 
220
220
  puts Log.color :magenta, "## DEPENDENCY GRAPH (abridged)"
221
221
  puts
@@ -12,6 +12,7 @@ $slurm_options = SOPT.get <<EOF
12
12
  -cj--clean_job Clean job
13
13
  --drbbt* Use development version of rbbt
14
14
  -sing--singularity Use Singularity
15
+ -si--singularity_img* 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
@@ -11,6 +11,7 @@ $slurm_options = SOPT.get <<EOF
11
11
  -cj--clean_job Clean job
12
12
  --drbbt* Use development version of rbbt
13
13
  -sing--singularity Use Singularity
14
+ -si--singularity_img* Singularity image to use
14
15
  -ug--user_group* Use alternative user group for group project directory
15
16
  -c--contain* Contain in directory (using Singularity)
16
17
  -s--sync* Contain in directory and sync jobs
@@ -31,7 +31,9 @@ if ARGV.empty?
31
31
  puts Rbbt.etc.log_severity.find + ' does not exist'
32
32
  end
33
33
  else
34
- Open.write(Rbbt.etc.log_severity, ARGV[0].upcase)
34
+ level = ARGV[0]
35
+ level = %w(DEBUG LOW MEDIUM HIGH INFO WARN ERROR NONE)[level.to_i] if level =~ /^\d+$/
36
+ Open.write(Rbbt.etc.log_severity, level.upcase)
35
37
  end
36
38
 
37
39
 
@@ -23,7 +23,7 @@ $ rbbt workflow trace <job-result>
23
23
  -h--help Help
24
24
  -w--width* Image Width
25
25
  -h--height* Image Height
26
- -p--plot Plot file
26
+ -p--plot* Plot file
27
27
  -s--size* Image Size (Height and Width)
28
28
  -fg--fix_gap Remove execution gaps
29
29
  -pd--plot_data Print plot data
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.31.9
4
+ version: 5.31.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: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake