rbbt-util 5.27.10 → 5.28.1

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: 98ed2ecc6b1230c582607dde6d9bdc14a5909fffcf17e8b3f297acc9e5e3829d
4
- data.tar.gz: 1b0b841bf558da4befbbf4dd778ce504ac63b0e2c880ae69c3cf239ed1d0d456
3
+ metadata.gz: 49e2972467a5efda29a81c562f96a69f190415a9226c4e8e9e5e776bc1e44f33
4
+ data.tar.gz: 047125157bbeb36260736630c091dda1243a7856f88b01553c6ecec5177c1795
5
5
  SHA512:
6
- metadata.gz: 8a8d228215a750c1d8f5726d28c2260f16f98d1d9546f9b151f2cc9d9886e2cc5922b43353acc497e618332a8836cb0bd0425140ebdf3d030dbfc47fcd5c45d7
7
- data.tar.gz: 999e589c2eb52cbd205682a835ead3838930c8e61c3fee2e76966da10cd13d484ad20a00865e12f5e6456eca060440066c1e6d34026881ac9ac4c97faefed191
6
+ metadata.gz: ddd94924f8cdbbe8b9219d64a8261e484e0f7c1c34ee6b4b6a745e9dca2e9f51524f6d1d45471cd2ce229661500fa8052515ce5835fb0061f1ef07021b5eb37f
7
+ data.tar.gz: c5f52161994f7d6de86aba05544f05dfbe1fff765c587220adca9a917c6f7ebe410cfeae601996eaa790f9587468508a8750618a5c126b1ad5e07238bc4e34e1
@@ -74,7 +74,7 @@ module Annotated
74
74
 
75
75
  object = case
76
76
  when literal_pos
77
- values[literal_pos]
77
+ values[literal_pos].tap{|o| o.force_encoding(Encoding.default_external)}
78
78
  else
79
79
  id.dup
80
80
  end
@@ -119,7 +119,7 @@ module Annotated
119
119
  fields = AnnotatedArray === annotations ? annotations.annotations : annotations.compact.first.annotations
120
120
  fields << :annotation_types
121
121
 
122
- when (fields == [:literal] and not annotations.compact.empty?)
122
+ when (fields == [:literal] and ! annotations.compact.empty?)
123
123
  fields << :literal
124
124
 
125
125
  when (fields == [:all] && Annotated === annotations)
@@ -13,7 +13,7 @@ module Path
13
13
  string.resource = resource
14
14
  string.search_paths = search_paths
15
15
  string.search_order = search_order
16
- string.libdir = libdir || Path.caller_lib_dir
16
+ string.libdir = libdir || Path.caller_lib_dir
17
17
  string
18
18
  end
19
19
 
@@ -52,11 +52,11 @@ module Path
52
52
  def join(name)
53
53
  raise "Invalid path: #{ self }" if self.nil?
54
54
  new = if self.empty?
55
- self.annotate name.to_s.dup
55
+ self.annotate name.to_s.dup.chomp
56
56
  else
57
- self.annotate File.join(self, name.to_s)
57
+ self.annotate File.join(self, name.to_s.chomp)
58
58
  end
59
- new.original = File.join(self.original, name.to_s) if self.original
59
+ new.original = File.join(self.original, name.to_s.chomp) if self.original
60
60
  new
61
61
  end
62
62
 
@@ -76,7 +76,7 @@ module Path
76
76
  return [] unless self.exists?
77
77
  found = self.find
78
78
  exp = File.join(found, pattern)
79
- paths = Dir.glob(exp).collect{|f| Path.setup(f, self.resource, self.pkgdir)}
79
+ paths = Dir.glob(exp).collect{|f| self.annotate(f) }
80
80
 
81
81
  paths.each do |p|
82
82
  p.original = File.join(found.original, p.sub(/^#{found}/, ''))
@@ -1,6 +1,6 @@
1
1
  module Path
2
2
 
3
- def self.caller_lib_dir(file = nil, relative_to = 'lib')
3
+ def self.caller_lib_dir(file = nil, relative_to = ['lib', 'bin'])
4
4
  file = caller.reject{|l|
5
5
  l =~ /rbbt\/(?:resource\.rb|workflow\.rb)/ or
6
6
  l =~ /rbbt\/resource\/path\.rb/ or
@@ -9,13 +9,14 @@ module Path
9
9
  l =~ /progress-monitor\.rb/
10
10
  }.first.sub(/\.rb[^\w].*/,'.rb') if file.nil?
11
11
 
12
+ relative_to = [relative_to] unless Array === relative_to
12
13
  file = File.expand_path(file)
13
- return Path.setup(file) if File.exist? File.join(file, relative_to)
14
+ return Path.setup(file) if relative_to.select{|d| File.exist? File.join(file, d)}.any?
14
15
 
15
16
  while file != '/'
16
17
  dir = File.dirname file
17
18
 
18
- return dir if File.exist? File.join(dir, relative_to)
19
+ return dir if relative_to.select{|d| File.exist? File.join(dir, d)}.any?
19
20
 
20
21
  file = File.dirname file
21
22
  end
@@ -727,6 +727,8 @@ module TSV
727
727
  Log.exception $!
728
728
  abort_stream(into, $!)
729
729
  raise $!
730
+ ensure
731
+ Log::ProgressBar.remove_bar(bar) if bar
730
732
  end
731
733
 
732
734
  into
@@ -2,6 +2,7 @@ require 'lockfile'
2
2
  require 'digest/md5'
3
3
  require 'cgi'
4
4
  require 'zlib'
5
+ require 'etc'
5
6
  require 'rubygems/package'
6
7
 
7
8
  require 'rbbt/util/tar'
@@ -292,14 +292,21 @@ def self.add_libdir(dir=nil)
292
292
  end
293
293
  end
294
294
 
295
- def self.bootstrap(elems, num = :current, options = {}, &block)
295
+ def self.bootstrap(elems, num = nil, options = {}, &block)
296
296
  IndiferentHash.setup options
297
+
298
+ num = Rbbt::Config.get :cpus, :default_bootstrap_cpus, :bootstrap_cpus if num == :current || num == nil if defined?(Rbbt::Config)
297
299
  num = :current if num.nil?
298
300
  cpus = case num
299
301
  when :current
300
- n = 10
301
- n = elems.length / 2 if n > elems.length/2
302
- n
302
+ n = Etc.nprocessors
303
+ n = elems.length / 2 if n > elems.length/2
304
+
305
+ if $BOOTSTRAPPED_CURRENT && $BOOTSTRAPPED_CURRENT + n > Etc.nprocessors
306
+ 1
307
+ else
308
+ n
309
+ end
303
310
  when String
304
311
  num.to_i
305
312
  when Integer
@@ -318,7 +325,12 @@ def self.add_libdir(dir=nil)
318
325
  respawn = options[:respawn] and options[:cpus] and options[:cpus].to_i > 1
319
326
 
320
327
  index = (0..elems.length-1).to_a.collect{|v| v.to_s }
328
+
321
329
  TSV.traverse index, options do |pos|
330
+ if num == :current
331
+ $BOOTSTRAPPED_CURRENT ||= n
332
+ $BOOTSTRAPPED_CURRENT += 0
333
+ end
322
334
  elem = elems[pos.to_i]
323
335
  elems.annotate elem if elems.respond_to? :annotate
324
336
  res = begin
@@ -290,7 +290,7 @@ module Misc
290
290
  if obj.exists?
291
291
  if obj.directory?
292
292
  files = obj.glob("**/*")
293
- "directory: #{files}"
293
+ "directory: #{Misc.fingerprint(files)}"
294
294
  else
295
295
  "file: " << obj << "--" << mtime_str(obj)
296
296
  end
@@ -401,7 +401,7 @@ module Misc
401
401
 
402
402
  def self.scan_version_text(text, cmd = nil)
403
403
  cmd = "NOCMDGIVE" if cmd.nil? || cmd.empty?
404
- m = text.match(/(?:version.*?|#{cmd}.*?|v)((?:\d+\.)*\d+(?:-[a-z_]+)?)/i)
404
+ m = text.match(/(?:version.*?|#{cmd}.*?|#{cmd.split(/[-_.]/).first}.*?|v)((?:\d+\.)*\d+(?:-[a-z_]+)?)/i)
405
405
  return nil if m.nil?
406
406
  m[1]
407
407
  end
@@ -94,7 +94,8 @@ module Open
94
94
  end
95
95
 
96
96
  begin
97
- wget_options = options.merge( '-O' => '-')
97
+ wget_options = options.dup
98
+ wget_options = wget_options.merge( '-O' => '-') unless options.include?('--output-document')
98
99
  wget_options[:pipe] = pipe unless pipe.nil?
99
100
  wget_options[:stderr] = stderr unless stderr.nil?
100
101
 
@@ -824,4 +825,8 @@ module Open
824
825
  def self.broken_link?(path)
825
826
  File.symlink?(path) && ! File.exists?(File.readlink(path))
826
827
  end
828
+
829
+ def self.download(url, path)
830
+ Open.wget(url, "--output-document" => path)
831
+ end
827
832
  end
@@ -340,6 +340,11 @@ class RemoteStep < Step
340
340
  @inputs = new_inputs
341
341
  @info = nil
342
342
  end
343
+
344
+ def init_info(*args)
345
+ i = {:status => :waiting, :pid => Process.pid, :path => path}
346
+ i[:dependencies] = dependencies.collect{|dep| [dep.task_name, dep.name, dep.path]} if dependencies
347
+ end
343
348
  end
344
349
 
345
350
  require 'rbbt/workflow/remote_workflow/remote_step/rest'
@@ -15,6 +15,7 @@ $ rbbt app start [options] <app_name>
15
15
  -Ho--Host* Host name
16
16
  -B--Bind* Bind IP
17
17
  -p--port* TCP port
18
+ -w--workers* Number of workers for cluster mode (puma)
18
19
  -s--server* Server type: thin, webrick, unicorn, etc
19
20
  -f--finder Start server with finder functionality
20
21
  -fs--file_server Activate file serving for resources
@@ -88,6 +89,8 @@ Misc.in_dir(app_dir) do
88
89
  options.each do |k,v| fixed_options[k.to_sym] = v end
89
90
  options = fixed_options
90
91
 
92
+ options[:workers] = options[:workers].to_i if options[:workers]
93
+
91
94
  case server
92
95
  when 'passenger'
93
96
  system ENV, "env RBBT_LOG=0 passenger start -R '#{config_ru_file}' -p #{options[:Port] || "2887"}"
@@ -95,6 +98,7 @@ Misc.in_dir(app_dir) do
95
98
  system ENV, "puma '#{config_ru_file}' -p #{options[:Port] || "2887"} -w 3 -t 8:32 --preload"
96
99
  else
97
100
  options[:config] = config_ru_file
101
+ options[:threads] = "8:8"
98
102
  Rack::Server.start(options)
99
103
  end
100
104
  end
@@ -25,5 +25,4 @@ file = STDIN if file == '-'
25
25
 
26
26
  tsv = TSV.open file, :merge => true, :type => :double
27
27
 
28
-
29
28
  puts tsv.to_unmerged_expanded_s
@@ -43,7 +43,11 @@ etc_dir = Rbbt.etc
43
43
  load_file etc_dir['app.d/pre.rb'].find
44
44
 
45
45
  app.get '/' do
46
- redirect to(File.join('/', wf.to_s))
46
+ begin
47
+ template_render('main', params, 'main', :cache_type => :asynchronous)
48
+ rescue TemplateMissing
49
+ redirect to(File.join('/', wf.to_s))
50
+ end
47
51
  end
48
52
 
49
53
  #{{{ BASE
@@ -69,11 +69,11 @@ class TestTSV < Test::Unit::TestCase
69
69
  end
70
70
 
71
71
  def test_libdir
72
- assert File.exist? TestResource[].share.Rlib["util.R"].find :lib
73
- assert File.exist? TestResource[].share.Rlib["util.R"].find
72
+ assert File.exist?(TestResource[].share.Rlib["util.R"].find(:lib))
73
+ assert File.exist?(TestResource[].share.Rlib["util.R"].find)
74
74
  end
75
75
 
76
- def test_server
76
+ def __test_server
77
77
  require 'rbbt/sources/organism'
78
78
  TmpFile.with_file :extension => 'gz' do |tmp|
79
79
  Organism.get_from_server("Hsa/b37/known_sites/dbsnp_138.vcf.gz", tmp, 'http://rbbt.bsc.es')
@@ -690,5 +690,30 @@ Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tre
690
690
  EOF
691
691
  assert_equal "3.1", Misc.scan_version_text(txt, "grep")
692
692
  end
693
+
694
+ def test_bootstrap_current_only_once
695
+
696
+
697
+ max = Etc.nprocessors * 10
698
+ TmpFile.with_file do |f|
699
+ RbbtSemaphore.with_semaphore(1) do |sem|
700
+ Misc.bootstrap (1..max).to_a do
701
+ Open.open(f, :mode => 'a') do |sin|
702
+ sin.puts Process.pid.to_s
703
+ end
704
+ Misc.bootstrap (1..10).to_a do
705
+ RbbtSemaphore.synchronize(sem) do
706
+ Open.open(f, :mode => 'a') do |sin|
707
+ sin.puts [Process.ppid.to_s, Process.pid.to_s] * ":"
708
+ end
709
+ end
710
+ end
711
+ end
712
+ end
713
+ assert_equal max * 10 + max, Open.read(f).split("\n").length
714
+ assert_equal Etc.nprocessors * 2, Open.read(f).split("\n").uniq.length
715
+ end
716
+
717
+ end
693
718
  end
694
719
 
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.27.10
4
+ version: 5.28.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-10 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake