rbbt-util 5.20.4 → 5.20.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/util/misc/pipes.rb +0 -1
- data/lib/rbbt/workflow/accessor.rb +6 -6
- data/lib/rbbt/workflow/step/dependencies.rb +93 -87
- data/lib/rbbt/workflow/step/run.rb +27 -14
- 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: 732f48d509a3d1292ceecf5001206984b5681829
|
4
|
+
data.tar.gz: 54bad659a94eefc173f4c6d306f4bd78aca37ea9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ec9e618e757d8d308e2218c8dab1399bbe2dff8574d48063f07ce3391882b1fa95d78bbf84734b4e29122bda7a1868c650506e2ffe6c02e2e75e89de8254f2
|
7
|
+
data.tar.gz: 06c02c802611a555db90e5bf6402aaec68c3a49b85aa8de3032b30b6e1cb9cea8936b0ba033a52c55e40784b6c2aabfcb487a14908f628519f86c69019458e02
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -566,9 +566,9 @@ module Workflow
|
|
566
566
|
rec_inputs = rec_inputs(taskname)
|
567
567
|
[taskname].concat(rec_dependencies(taskname)).inject(IndiferentHash.setup({})){|acc, tn|
|
568
568
|
if Array === tn and tn.first
|
569
|
-
new = tn.first.tasks[tn[1].to_sym].
|
569
|
+
new = tn.first.tasks[tn[1].to_sym].input_defaults
|
570
570
|
elsif Symbol === tn
|
571
|
-
new = tasks[tn.to_sym].
|
571
|
+
new = tasks[tn.to_sym].input_defaults
|
572
572
|
else
|
573
573
|
next acc
|
574
574
|
end
|
@@ -598,9 +598,9 @@ module Workflow
|
|
598
598
|
rec_inputs = rec_inputs(taskname)
|
599
599
|
[taskname].concat(rec_dependencies(taskname)).inject({}){|acc, tn|
|
600
600
|
if Array === tn and tn.first
|
601
|
-
new = tn.first.tasks[tn[1].to_sym].
|
601
|
+
new = tn.first.tasks[tn[1].to_sym].input_descriptions
|
602
602
|
elsif Symbol === tn
|
603
|
-
new = tasks[tn.to_sym].
|
603
|
+
new = tasks[tn.to_sym].input_descriptions
|
604
604
|
else
|
605
605
|
next acc
|
606
606
|
end
|
@@ -614,9 +614,9 @@ module Workflow
|
|
614
614
|
rec_inputs = rec_inputs(taskname)
|
615
615
|
[taskname].concat(rec_dependencies(taskname)).inject({}){|acc, tn|
|
616
616
|
if Array === tn and tn.first
|
617
|
-
new = tn.first.tasks[tn[1].to_sym].
|
617
|
+
new = tn.first.tasks[tn[1].to_sym].input_options
|
618
618
|
elsif Symbol === tn
|
619
|
-
new = tasks[tn.to_sym].
|
619
|
+
new = tasks[tn.to_sym].input_options
|
620
620
|
else
|
621
621
|
next acc
|
622
622
|
end
|
@@ -1,73 +1,76 @@
|
|
1
1
|
|
2
2
|
class Step
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
4
|
+
STREAM_CACHE = {}
|
5
|
+
STREAM_CACHE_MUTEX = Mutex.new
|
6
|
+
def self.purge_stream_cache
|
7
|
+
Log.medium "Purging dup. stream cache"
|
8
|
+
STREAM_CACHE_MUTEX.synchronize do
|
9
|
+
#STREAM_CACHE.collect{|k,s|
|
10
|
+
# Thread.new do
|
11
|
+
# Misc.consume_stream s
|
12
|
+
# end
|
13
|
+
#}
|
14
|
+
STREAM_CACHE.clear
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.dup_stream(stream)
|
19
|
+
case stream
|
20
|
+
when IO, File, Step
|
21
|
+
return stream if stream.respond_to?(:closed?) and stream.closed?
|
22
|
+
return stream if stream.respond_to?(:done?) and stream.done?
|
23
|
+
|
24
|
+
STREAM_CACHE_MUTEX.synchronize do
|
25
|
+
stream_key = Misc.fingerprint(stream)
|
26
|
+
current = STREAM_CACHE[stream_key]
|
27
|
+
case current
|
28
|
+
when nil, Step
|
29
|
+
Log.medium "Not duplicating stream #{stream_key}"
|
30
|
+
STREAM_CACHE[stream_key] = stream
|
31
|
+
when File
|
32
|
+
if Open.exists? current.path
|
33
|
+
Log.medium "Reopening file #{stream_key}"
|
34
|
+
Open.open(current.path)
|
35
|
+
else
|
36
|
+
new = Misc.dup_stream(current)
|
37
|
+
Log.medium "Duplicating file #{stream_key} #{current.inspect} => #{Misc.fingerprint(new)}"
|
38
|
+
new
|
39
|
+
end
|
40
|
+
else
|
41
|
+
new = Misc.dup_stream(current)
|
42
|
+
Log.medium "Duplicating stream #{stream_key} #{ Misc.fingerprint(stream) } => #{Misc.fingerprint(new)}"
|
43
|
+
new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
when TSV::Dumper#, TSV::Parser
|
47
|
+
stream = stream.stream
|
48
|
+
return stream if stream.closed?
|
49
|
+
|
50
|
+
STREAM_CACHE_MUTEX.synchronize do
|
51
|
+
if STREAM_CACHE[stream].nil?
|
52
|
+
Log.high "Not duplicating dumper #{ stream.inspect }"
|
53
|
+
STREAM_CACHE[stream] = stream
|
54
|
+
else
|
55
|
+
new = Misc.dup_stream(STREAM_CACHE[stream])
|
56
|
+
Log.high "Duplicating dumper #{ stream.inspect } into #{new.inspect}"
|
57
|
+
new
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
stream
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def dup_inputs
|
66
|
+
return if @dupped or ENV["RBBT_NO_STREAM"] == 'true'
|
67
|
+
Log.low "Dupping inputs for #{path}"
|
68
|
+
dupped_inputs = @inputs.collect do |input|
|
69
|
+
Step.dup_stream input
|
70
|
+
end
|
71
|
+
@inputs.replace dupped_inputs
|
72
|
+
@dupped = true
|
73
|
+
end
|
71
74
|
|
72
75
|
def self.prepare_for_execution(job)
|
73
76
|
return if (job.done? and not job.dirty?) or
|
@@ -76,6 +79,8 @@ class Step
|
|
76
79
|
|
77
80
|
job.clean if job.error? or job.aborted? or (job.started? and not job.running? and not job.error?)
|
78
81
|
|
82
|
+
job.dup_inputs
|
83
|
+
|
79
84
|
raise DependencyError, job if job.error?
|
80
85
|
end
|
81
86
|
|
@@ -152,27 +157,17 @@ class Step
|
|
152
157
|
end
|
153
158
|
end
|
154
159
|
|
155
|
-
#def
|
156
|
-
# return if
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
+
#def consolidate_dependencies(path_deps = {})
|
161
|
+
# return false if @consolidated or dependencies.nil? or dependencies.empty?
|
162
|
+
# consolidated_deps = dependencies.collect do |dep|
|
163
|
+
# dep.consolidate_dependencies(path_deps)
|
164
|
+
# path = dep.path
|
165
|
+
# path_deps[path] ||= dep
|
160
166
|
# end
|
161
|
-
#
|
162
|
-
# @
|
167
|
+
# dependencies.replace consolidated_deps
|
168
|
+
# @consolidated = true
|
163
169
|
#end
|
164
170
|
|
165
|
-
def consolidate_dependencies(path_deps = {})
|
166
|
-
return false if @consolidated or dependencies.nil? or dependencies.empty?
|
167
|
-
consolidated_deps = dependencies.collect do |dep|
|
168
|
-
dep.consolidate_dependencies(path_deps)
|
169
|
-
path = dep.path
|
170
|
-
path_deps[path] ||= dep
|
171
|
-
end
|
172
|
-
dependencies.replace consolidated_deps
|
173
|
-
@consolidated = true
|
174
|
-
end
|
175
|
-
|
176
171
|
#def prepare_dependencies
|
177
172
|
# dep_step = {}
|
178
173
|
|
@@ -210,9 +205,9 @@ class Step
|
|
210
205
|
#end
|
211
206
|
|
212
207
|
def execute_and_dup(step, dep_step, log = true)
|
213
|
-
dup =
|
208
|
+
dup = step.result.nil?
|
214
209
|
execute_dependency(step, log)
|
215
|
-
if dup and step.streaming? and step.result
|
210
|
+
if dup and step.streaming? and not step.result.nil?
|
216
211
|
if dep_step[step.path] and dep_step[step.path].length > 1
|
217
212
|
stream = step.result
|
218
213
|
other_steps = dep_step[step.path] - [step]
|
@@ -255,6 +250,10 @@ class Step
|
|
255
250
|
def run_dependencies
|
256
251
|
dep_step = {}
|
257
252
|
|
253
|
+
rec_dependencies = self.rec_dependencies
|
254
|
+
|
255
|
+
return if rec_dependencies.empty?
|
256
|
+
|
258
257
|
all_deps = rec_dependencies + [self]
|
259
258
|
|
260
259
|
dependencies.each do |dep|
|
@@ -282,6 +281,8 @@ class Step
|
|
282
281
|
end
|
283
282
|
end
|
284
283
|
|
284
|
+
self.dup_inputs
|
285
|
+
|
285
286
|
required_dep_paths = []
|
286
287
|
dep_step.each do |path,list|
|
287
288
|
required_dep_paths << path if list.length > 1
|
@@ -289,6 +290,7 @@ class Step
|
|
289
290
|
|
290
291
|
required_dep_paths.concat dependencies.collect{|dep| dep.path }
|
291
292
|
|
293
|
+
|
292
294
|
log :dependencies, "Dependencies for step #{Log.color :yellow, task.name.to_s || ""}"
|
293
295
|
|
294
296
|
pre_deps = []
|
@@ -317,20 +319,24 @@ class Step
|
|
317
319
|
end
|
318
320
|
end
|
319
321
|
|
322
|
+
Log.medium "Processing pre dependencies: #{Misc.fingerprint(pre_deps)} - #{Log.color :blue, self.path}" if pre_deps.any?
|
320
323
|
pre_deps.each do |step|
|
321
324
|
next if compute_deps.include? step
|
322
325
|
execute_and_dup(step, dep_step, false)
|
323
326
|
end
|
324
327
|
|
328
|
+
Log.medium "Computing pre dependencies: #{Misc.fingerprint(compute_pre_deps)} - #{Log.color :blue, self.path}" if pre_deps.any?
|
325
329
|
compute_pre_deps.each do |type,list|
|
326
330
|
run_compute_dependencies(type, list, dep_step)
|
327
331
|
end
|
328
332
|
|
333
|
+
Log.medium "Processing last dependencies: #{Misc.fingerprint(last_deps)} - #{Log.color :blue, self.path}" if pre_deps.any?
|
329
334
|
last_deps.each do |step|
|
330
335
|
next if compute_deps.include? step
|
331
336
|
execute_and_dup(step, dep_step)
|
332
337
|
end
|
333
338
|
|
339
|
+
Log.medium "Computing last dependencies: #{Misc.fingerprint(compute_last_deps)} - #{Log.color :blue, self.path}" if pre_deps.any?
|
334
340
|
compute_last_deps.each do |type,list|
|
335
341
|
run_compute_dependencies(type, list, dep_step)
|
336
342
|
end
|
@@ -20,19 +20,32 @@ class Step
|
|
20
20
|
|
21
21
|
def resolve_input_steps
|
22
22
|
step = false
|
23
|
+
pos = 0
|
23
24
|
new_inputs = @inputs.collect do |i|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
i.
|
28
|
-
|
29
|
-
|
25
|
+
begin
|
26
|
+
if Step === i
|
27
|
+
step = true
|
28
|
+
if i.done?
|
29
|
+
if (task.input_options[task.inputs[pos]] || {})[:stream]
|
30
|
+
TSV.get_stream i
|
31
|
+
else
|
32
|
+
i.load
|
33
|
+
end
|
34
|
+
elsif i.streaming?
|
35
|
+
TSV.get_stream i
|
36
|
+
else
|
37
|
+
i.join
|
38
|
+
if (task.input_options[task.inputs[pos]] || {})[:stream]
|
39
|
+
TSV.get_stream i
|
40
|
+
else
|
41
|
+
i.load
|
42
|
+
end
|
43
|
+
end
|
30
44
|
else
|
31
|
-
i
|
32
|
-
i.load
|
45
|
+
i
|
33
46
|
end
|
34
|
-
|
35
|
-
|
47
|
+
ensure
|
48
|
+
pos += 1
|
36
49
|
end
|
37
50
|
end
|
38
51
|
@inputs.replace new_inputs if step
|
@@ -100,7 +113,7 @@ class Step
|
|
100
113
|
:clean_name => clean_name,
|
101
114
|
})
|
102
115
|
|
103
|
-
|
116
|
+
dup_inputs
|
104
117
|
begin
|
105
118
|
run_dependencies
|
106
119
|
rescue Exception
|
@@ -161,7 +174,7 @@ class Step
|
|
161
174
|
Log.exception $!
|
162
175
|
ensure
|
163
176
|
join
|
164
|
-
|
177
|
+
Step.purge_stream_cache
|
165
178
|
FileUtils.rm pid_file if File.exists?(pid_file)
|
166
179
|
end
|
167
180
|
end
|
@@ -179,7 +192,7 @@ class Step
|
|
179
192
|
set_info :total_time_elapsed, (total_time_elapsed = done_time - issue_time)
|
180
193
|
set_info :time_elapsed, (time_elapsed = done_time - start_time)
|
181
194
|
log :done, "Completed step #{Log.color :yellow, task.name.to_s || ""} in #{time_elapsed.to_i}+#{(total_time_elapsed - time_elapsed).to_i} sec."
|
182
|
-
|
195
|
+
Step.purge_stream_cache
|
183
196
|
FileUtils.rm pid_file if File.exists?(pid_file)
|
184
197
|
end
|
185
198
|
|
@@ -190,7 +203,7 @@ class Step
|
|
190
203
|
@result ||= result
|
191
204
|
self
|
192
205
|
else
|
193
|
-
|
206
|
+
Step.purge_stream_cache
|
194
207
|
@result = prepare_result result, @task.result_description
|
195
208
|
end
|
196
209
|
end
|
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.20.
|
4
|
+
version: 5.20.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: 2016-
|
11
|
+
date: 2016-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|