rbbt-util 5.20.4 → 5.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 940e4cab3bc56e4713e30e94d79ef0e087fe2e3e
4
- data.tar.gz: 9faaf4ade7833732f581edee900cf9f81df53b41
3
+ metadata.gz: 732f48d509a3d1292ceecf5001206984b5681829
4
+ data.tar.gz: 54bad659a94eefc173f4c6d306f4bd78aca37ea9
5
5
  SHA512:
6
- metadata.gz: 684c46a31c7050ac87ad83a9877d3051c5bbfac2558da5a9f71f806d01a646fff2126dc110f1f98b796a39b1873c49df6750a1465c53de2d296a631488cfc7c0
7
- data.tar.gz: 1a55b1f2ff541b29448a85267ef635deb282e92e9c4f5511254df4b287d74f4ce62ee877eaf018c0a643cf3983798ba617947ac04fd141344071c19e9d9b196f
6
+ metadata.gz: b8ec9e618e757d8d308e2218c8dab1399bbe2dff8574d48063f07ce3391882b1fa95d78bbf84734b4e29122bda7a1868c650506e2ffe6c02e2e75e89de8254f2
7
+ data.tar.gz: 06c02c802611a555db90e5bf6402aaec68c3a49b85aa8de3032b30b6e1cb9cea8936b0ba033a52c55e40784b6c2aabfcb487a14908f628519f86c69019458e02
@@ -79,7 +79,6 @@ module Misc
79
79
  Log.medium "Aborted open_pipe: #{$!.message}"
80
80
  rescue Exception
81
81
  Log.medium "Exception in open_pipe: #{$!.message}"
82
- Log.exception $!
83
82
  parent.raise $!
84
83
  raise $!
85
84
  end
@@ -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].input_types
569
+ new = tn.first.tasks[tn[1].to_sym].input_defaults
570
570
  elsif Symbol === tn
571
- new = tasks[tn.to_sym].input_types
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].input_types
601
+ new = tn.first.tasks[tn[1].to_sym].input_descriptions
602
602
  elsif Symbol === tn
603
- new = tasks[tn.to_sym].input_types
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].input_types
617
+ new = tn.first.tasks[tn[1].to_sym].input_options
618
618
  elsif Symbol === tn
619
- new = tasks[tn.to_sym].input_types
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
- ##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
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
- ## when Step
41
- ## job = current
42
- ## current = job.result
43
- ## new = Misc.dup_stream(current)
44
- ## job.result = current
45
- ## Log.medium "Duplicating step #{stream_key} #{current.inspect} => #{Misc.fingerprint(new)}"
46
- ## new
47
- ## else
48
- ## new = Misc.dup_stream(current)
49
- ## Log.medium "Duplicating stream #{stream_key} #{ Misc.fingerprint(stream) } => #{Misc.fingerprint(new)}"
50
- ## new
51
- ## end
52
- ## end
53
- ## when TSV::Dumper#, TSV::Parser
54
- ## stream = stream.stream
55
- ## return stream if stream.closed?
56
-
57
- ## STREAM_CACHE_MUTEX.synchronize do
58
- ## if STREAM_CACHE[stream].nil?
59
- ## Log.high "Not duplicating dumper #{ stream.inspect }"
60
- ## STREAM_CACHE[stream] = stream
61
- ## else
62
- ## new = Misc.dup_stream(STREAM_CACHE[stream])
63
- ## Log.high "Duplicating dumper #{ stream.inspect } into #{new.inspect}"
64
- ## new
65
- ## end
66
- ## end
67
- ## else
68
- ## stream
69
- ## end
70
- ##end
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 dup_inputs
156
- # return if true or @dupped or ENV["RBBT_NO_STREAM"] == 'true'
157
- # Log.low "Dupping inputs for #{path}"
158
- # dupped_inputs = @inputs.collect do |input|
159
- # Step.dup_stream input
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
- # @inputs.replace dupped_inputs
162
- # @dupped = true
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 = ! step.result
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
- if Step === i
25
- step = true
26
- if i.done?
27
- i.load
28
- elsif i.streaming?
29
- TSV.get_stream i
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.join
32
- i.load
45
+ i
33
46
  end
34
- else
35
- i
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
- #dup_inputs
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
- #Step.purge_stream_cache
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
- #Step.purge_stream_cache
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
- #Step.purge_stream_cache
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
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-05-30 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake