rbbt-util 5.13.4 → 5.13.5
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 +4 -4
- data/lib/rbbt/persist.rb +5 -2
- data/lib/rbbt/tsv/accessor.rb +2 -2
- data/lib/rbbt/tsv/dumper.rb +1 -2
- data/lib/rbbt/tsv/parallel/traverse.rb +2 -2
- data/lib/rbbt/util/concurrency/threads.rb +2 -4
- data/lib/rbbt/util/misc/concurrent_stream.rb +5 -4
- data/lib/rbbt/util/misc/lock.rb +1 -1
- data/lib/rbbt/util/misc/pipes.rb +15 -8
- data/lib/rbbt/workflow.rb +1 -1
- data/share/rbbt_commands/workflow/example +3 -2
- data/test/rbbt/tsv/parallel/test_traverse.rb +28 -32
- data/test/rbbt/tsv/test_filter.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 419096bee8e448dd3c606c3c9770d76f347ede9b
|
4
|
+
data.tar.gz: 85c4317ea460338198ee814424988f0a12026dd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b9cb44704148225709dc3ba2e8aaac7b586829849700347d7152e78ecc3bc2d55f73eb44429eb24038495109ea49a65154050a33f427245352de6feee9513c6
|
7
|
+
data.tar.gz: 9baaffb5b6eacc7781b503969098ff53bbfa4052deb846f2fbc4f592fc69e3932cc6290f39f754fd15a95f083883aaf80c5f8280c70cdcbd172bc4abbadb9101
|
data/lib/rbbt/persist.rb
CHANGED
@@ -202,10 +202,12 @@ module Persist
|
|
202
202
|
rescue Aborted
|
203
203
|
Log.warn "Persist stream thread aborted: #{ Log.color :blue, path }"
|
204
204
|
file.abort if file.respond_to? :abort
|
205
|
+
raise $!
|
205
206
|
rescue Exception
|
206
207
|
Log.warn "Persist stream thread exception: #{ Log.color :blue, path }"
|
207
208
|
file.abort if file.respond_to? :abort
|
208
209
|
parent.raise $!
|
210
|
+
raise $!
|
209
211
|
end
|
210
212
|
end
|
211
213
|
ConcurrentStream.setup(out, :threads => saver_thread, :filename => path)
|
@@ -233,7 +235,8 @@ module Persist
|
|
233
235
|
Log.warn "Persist stream pipe exception: #{ Log.color :blue, path }"
|
234
236
|
Log.exception $!
|
235
237
|
stream.abort if stream.respond_to? :abort
|
236
|
-
|
238
|
+
stream.join if stream.respond_to? :join
|
239
|
+
raise $!
|
237
240
|
end
|
238
241
|
end
|
239
242
|
|
@@ -250,7 +253,7 @@ module Persist
|
|
250
253
|
sin.abort if sin.respond_to? :abort
|
251
254
|
sout.abort if sout.respond_to? :abort
|
252
255
|
Log.exception $!
|
253
|
-
|
256
|
+
raise $!
|
254
257
|
ensure
|
255
258
|
sin.close unless sin.closed?
|
256
259
|
end
|
data/lib/rbbt/tsv/accessor.rb
CHANGED
data/lib/rbbt/tsv/dumper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module TSV
|
2
2
|
def self.obj_stream(obj)
|
3
3
|
case obj
|
4
|
-
when Step
|
4
|
+
when (defined? Step and Step)
|
5
5
|
obj.result
|
6
6
|
when IO, File
|
7
7
|
obj
|
@@ -430,7 +430,7 @@ module TSV
|
|
430
430
|
stream.abort if stream and stream.respond_to? :abort
|
431
431
|
stream = obj_stream(into)
|
432
432
|
stream.abort if stream and stream.respond_to? :abort
|
433
|
-
|
433
|
+
raise $!
|
434
434
|
end
|
435
435
|
end
|
436
436
|
ConcurrentStream.setup(obj_stream(into), :threads => thread)
|
@@ -10,9 +10,8 @@ class RbbtThreadQueue
|
|
10
10
|
p = queue.pop
|
11
11
|
block.call *p
|
12
12
|
end
|
13
|
-
rescue Aborted
|
14
13
|
rescue Exception
|
15
|
-
|
14
|
+
raise $!
|
16
15
|
end
|
17
16
|
end
|
18
17
|
else
|
@@ -23,9 +22,8 @@ class RbbtThreadQueue
|
|
23
22
|
p = Array === p ? p << mutex : [p,mutex]
|
24
23
|
block.call *p
|
25
24
|
end
|
26
|
-
rescue Aborted
|
27
25
|
rescue Exception
|
28
|
-
|
26
|
+
raise $!
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
@@ -53,10 +53,11 @@ module ConcurrentStream
|
|
53
53
|
def join_threads
|
54
54
|
if @threads and @threads.any?
|
55
55
|
@threads.each do |t|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
t.join unless t == Thread.current
|
57
|
+
#begin
|
58
|
+
#ensure
|
59
|
+
# t.join unless t == Thread.current
|
60
|
+
#end
|
60
61
|
end
|
61
62
|
@threads = []
|
62
63
|
end
|
data/lib/rbbt/util/misc/lock.rb
CHANGED
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -64,8 +64,9 @@ module Misc
|
|
64
64
|
begin
|
65
65
|
yield sin
|
66
66
|
sin.close if close and not sin.closed?
|
67
|
-
rescue
|
68
|
-
|
67
|
+
rescue Exception
|
68
|
+
Log.warn "Exception in open_pipe: #{$!.message}"
|
69
|
+
raise $!
|
69
70
|
end
|
70
71
|
end
|
71
72
|
ConcurrentStream.setup sout, :threads => [thread]
|
@@ -104,10 +105,14 @@ module Misc
|
|
104
105
|
stream.abort if stream.respond_to? :abort
|
105
106
|
stream_out1.abort if stream_out1.respond_to? :abort
|
106
107
|
stream_out2.abort if stream_out2.respond_to? :abort
|
107
|
-
|
108
|
+
Log.warn "tee_stream_thread aborted: #{$!.message}"
|
108
109
|
rescue Exception
|
109
110
|
stream.abort if stream.respond_to? :abort
|
110
|
-
|
111
|
+
stream_out1.abort if stream_out1.respond_to? :abort
|
112
|
+
stream_out2.abort if stream_out2.respond_to? :abort
|
113
|
+
stream.join
|
114
|
+
Log.warn "Exception in tee_stream_thread: #{$!.message}"
|
115
|
+
raise $!
|
111
116
|
end
|
112
117
|
end
|
113
118
|
|
@@ -156,8 +161,6 @@ module Misc
|
|
156
161
|
else
|
157
162
|
begin
|
158
163
|
while block = io.read(2048)
|
159
|
-
#return if io.eof?
|
160
|
-
#Thread.pass
|
161
164
|
end
|
162
165
|
io.join if io.respond_to? :join
|
163
166
|
rescue Aborted
|
@@ -166,6 +169,7 @@ module Misc
|
|
166
169
|
rescue Exception
|
167
170
|
Log.warn "Exception consuming stream: #{Misc.fingerprint io}: #{$!.message}"
|
168
171
|
io.abort if io.respond_to? :abort
|
172
|
+
io.join
|
169
173
|
raise $!
|
170
174
|
end
|
171
175
|
end
|
@@ -392,9 +396,12 @@ module Misc
|
|
392
396
|
Thread.new(Thread.current) do |parent|
|
393
397
|
begin
|
394
398
|
Misc.sensiblewrite(file, save)
|
395
|
-
rescue
|
399
|
+
rescue Exception
|
396
400
|
save.abort if save.respond_to? :abort
|
397
|
-
|
401
|
+
stream.abort if stream.respond_to? :abort
|
402
|
+
stream.join
|
403
|
+
Log.warn "Exception in save_stream: #{$!.message}"
|
404
|
+
raise $!
|
398
405
|
end
|
399
406
|
end
|
400
407
|
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -236,7 +236,7 @@ module Workflow
|
|
236
236
|
def get_job_step(step_path, task = nil, input_values = nil, dependencies = nil)
|
237
237
|
step_path = step_path.call if Proc === step_path
|
238
238
|
persist = input_values.nil? ? false : true
|
239
|
-
|
239
|
+
persist = false
|
240
240
|
key = Path === step_path ? step_path.find : step_path
|
241
241
|
step = Persist.memory("Step", :key => key, :repo => step_cache, :persist => persist) do
|
242
242
|
step = Step.new step_path, task, input_values, dependencies
|
@@ -35,6 +35,7 @@ def run_task(workflow, task, name)
|
|
35
35
|
success = true
|
36
36
|
end
|
37
37
|
end
|
38
|
+
sleep 0.5
|
38
39
|
path = Open.read(res).strip if File.exists? res
|
39
40
|
end
|
40
41
|
path = "NO RESULT" if path.nil? or path.empty?
|
@@ -82,11 +83,11 @@ task_result.each do |code,res|
|
|
82
83
|
if orig_name
|
83
84
|
puts Open.read(path)
|
84
85
|
else
|
85
|
-
puts "#{Log.color :green, "SUCCESS"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
86
|
+
STDERR.puts "#{Log.color :green, "SUCCESS"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
86
87
|
puts path
|
87
88
|
end
|
88
89
|
else
|
89
|
-
puts "#{Log.color :red, "ERROR"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
90
|
+
STDERR.puts "#{Log.color :red, "ERROR"} #{Log.color :magenta, workflow.to_s}##{Log.color :yellow, task} -- #{Log.color :cyan, name}"
|
90
91
|
puts path
|
91
92
|
end
|
92
93
|
end
|
@@ -6,7 +6,7 @@ class StopException < StandardError; end
|
|
6
6
|
|
7
7
|
class TestTSVParallelThrough < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_traverse_tsv
|
10
10
|
require 'rbbt/sources/organism'
|
11
11
|
|
12
12
|
head = 100
|
@@ -25,7 +25,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
25
25
|
assert_equal head, res.keys.compact.sort.length
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def test_traverse_tsv_cpus
|
29
29
|
require 'rbbt/sources/organism'
|
30
30
|
|
31
31
|
head = 100
|
@@ -47,7 +47,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
47
47
|
assert res.values.compact.flatten.uniq.length > 0
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def test_traverse_stream
|
51
51
|
require 'rbbt/sources/organism'
|
52
52
|
|
53
53
|
head = 1000
|
@@ -61,7 +61,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
61
61
|
assert_equal head, res.keys.compact.sort.length
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def test_traverse_stream_cpus
|
65
65
|
require 'rbbt/sources/organism'
|
66
66
|
|
67
67
|
head = 1000
|
@@ -75,7 +75,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
75
75
|
assert_equal head, res.keys.compact.sort.length
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
78
|
+
def test_traverse_stream_keys
|
79
79
|
require 'rbbt/sources/organism'
|
80
80
|
|
81
81
|
head = 1000
|
@@ -99,7 +99,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
99
99
|
assert_equal res.sort, Organism.identifiers("Hsa").tsv(:head => head).keys.sort
|
100
100
|
end
|
101
101
|
|
102
|
-
def
|
102
|
+
def test_traverse_array
|
103
103
|
require 'rbbt/sources/organism'
|
104
104
|
|
105
105
|
array = []
|
@@ -121,7 +121,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
121
121
|
assert_equal array, res
|
122
122
|
end
|
123
123
|
|
124
|
-
def
|
124
|
+
def test_traverse_array_threads
|
125
125
|
require 'rbbt/sources/organism'
|
126
126
|
|
127
127
|
array = []
|
@@ -142,7 +142,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
142
142
|
assert_equal array.sort, res.sort
|
143
143
|
end
|
144
144
|
|
145
|
-
def
|
145
|
+
def test_traverse_array_cpus
|
146
146
|
require 'rbbt/sources/organism'
|
147
147
|
|
148
148
|
array = []
|
@@ -157,7 +157,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
157
157
|
assert_equal array.sort, res.sort
|
158
158
|
end
|
159
159
|
|
160
|
-
def
|
160
|
+
def test_traverse_benchmark
|
161
161
|
require 'rbbt/sources/organism'
|
162
162
|
|
163
163
|
head = 2_000
|
@@ -179,7 +179,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
-
def
|
182
|
+
def test_traverse_into_dumper
|
183
183
|
require 'rbbt/sources/organism'
|
184
184
|
|
185
185
|
head = 2_000
|
@@ -197,7 +197,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
197
197
|
assert_equal head, res.size
|
198
198
|
end
|
199
199
|
|
200
|
-
def
|
200
|
+
def test_traverse_into_dumper_threads
|
201
201
|
require 'rbbt/sources/organism'
|
202
202
|
|
203
203
|
head = 2_000
|
@@ -217,7 +217,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
217
217
|
assert_equal head, res.size
|
218
218
|
end
|
219
219
|
|
220
|
-
def
|
220
|
+
def test_traverse_into_dumper_cpus
|
221
221
|
require 'rbbt/sources/organism'
|
222
222
|
|
223
223
|
head = 2_000
|
@@ -238,7 +238,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
238
238
|
|
239
239
|
#{{{ TRAVERSE DUMPER
|
240
240
|
|
241
|
-
def
|
241
|
+
def test_traverse_dumper
|
242
242
|
require 'rbbt/sources/organism'
|
243
243
|
|
244
244
|
head = 2_000
|
@@ -259,7 +259,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
259
259
|
assert_equal head, res.size
|
260
260
|
end
|
261
261
|
|
262
|
-
def
|
262
|
+
def test_traverse_dumper_threads
|
263
263
|
require 'rbbt/sources/organism'
|
264
264
|
|
265
265
|
head = 2_000
|
@@ -281,7 +281,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
281
281
|
assert_equal head, res.size
|
282
282
|
end
|
283
283
|
|
284
|
-
def
|
284
|
+
def test_traverse_dumper_cpus
|
285
285
|
require 'rbbt/sources/organism'
|
286
286
|
|
287
287
|
head = 10_000
|
@@ -309,26 +309,22 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
309
309
|
head = 2_000
|
310
310
|
cpus = 2
|
311
311
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
[k,v]
|
323
|
-
end
|
324
|
-
stream = dumper.stream
|
325
|
-
stream.read
|
326
|
-
stream.join
|
312
|
+
Log.info Log.color :red, "TRAVERSE EXCEPTION"
|
313
|
+
stream = Organism.identifiers("Hsa/jun2011").open
|
314
|
+
dumper = TSV::Dumper.new Organism.identifiers("Hsa/jun2011").tsv_options
|
315
|
+
dumper.init
|
316
|
+
|
317
|
+
assert_raise StopException do
|
318
|
+
TSV.traverse stream, :head => head, :_cpus => cpus, :into => dumper do |k,v|
|
319
|
+
k = k.first
|
320
|
+
raise StopException if rand(100) < 1
|
321
|
+
[k,v]
|
327
322
|
end
|
323
|
+
Misc.consume_stream dumper.stream
|
328
324
|
end
|
329
325
|
end
|
330
326
|
|
331
|
-
def
|
327
|
+
def test_traverse_into_stream
|
332
328
|
size = 100
|
333
329
|
array = (1..size).to_a.collect{|n| n.to_s}
|
334
330
|
stream = TSV.traverse array, :into => :stream do |e|
|
@@ -337,7 +333,7 @@ class TestTSVParallelThrough < Test::Unit::TestCase
|
|
337
333
|
assert_equal size, stream.read.split("\n").length
|
338
334
|
end
|
339
335
|
|
340
|
-
def
|
336
|
+
def test_traverse_progress
|
341
337
|
size = 1000
|
342
338
|
array = (1..size).to_a.collect{|n| n.to_s}
|
343
339
|
stream = TSV.traverse array, :bar => {:max => size, :desc => "Array"}, :cpus => 5, :into => :stream do |e|
|
@@ -3,7 +3,7 @@ require 'rbbt/tsv'
|
|
3
3
|
require 'rbbt/tsv/filter'
|
4
4
|
|
5
5
|
class TestTSVFilters < Test::Unit::TestCase
|
6
|
-
def
|
6
|
+
def test_collect
|
7
7
|
content1 =<<-EOF
|
8
8
|
#: :sep=/\\s+/#:case_insensitive=false
|
9
9
|
#Id ValueA ValueB
|
@@ -19,7 +19,7 @@ row2 A B
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def test_through
|
23
23
|
content1 =<<-EOF
|
24
24
|
#: :sep=/\\s+/#:case_insensitive=false
|
25
25
|
#Id ValueA ValueB
|
@@ -37,7 +37,7 @@ row2 A B
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def test_2_filters
|
41
41
|
content1 =<<-EOF
|
42
42
|
#: :sep=/\\s+/#:case_insensitive=false
|
43
43
|
#Id ValueA ValueB
|
@@ -64,7 +64,7 @@ row3 A C
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def test_filter_persistence
|
68
68
|
content1 =<<-EOF
|
69
69
|
#: :sep=/\\s+/#:case_insensitive=false
|
70
70
|
#Id ValueA ValueB
|
@@ -165,7 +165,7 @@ row2 A B C
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
def
|
168
|
+
def test_filename
|
169
169
|
content1 =<<-EOF
|
170
170
|
#: :sep=/\\s+/#:case_insensitive=false
|
171
171
|
#Id ValueA ValueB
|
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.13.
|
4
|
+
version: 5.13.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|