rbbt-util 5.14.12 → 5.14.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +4 -0
- data/lib/rbbt/annotations/annotated_array.rb +0 -22
- data/lib/rbbt/association/item.rb +37 -2
- data/lib/rbbt/persist.rb +4 -1
- data/lib/rbbt/resource/rake.rb +1 -2
- data/lib/rbbt/tsv/accessor.rb +17 -6
- data/lib/rbbt/tsv/parallel/traverse.rb +16 -6
- data/lib/rbbt/util/log.rb +2 -3
- data/lib/rbbt/workflow.rb +3 -1
- data/lib/rbbt/workflow/accessor.rb +7 -7
- data/lib/rbbt/workflow/definition.rb +5 -1
- data/lib/rbbt/workflow/step.rb +18 -7
- data/lib/rbbt/workflow/step/run.rb +4 -4
- data/share/rbbt_commands/workflow/knowledge_base +4 -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: 12a27683f6ea8562a740927dac6dca9e22854834
|
4
|
+
data.tar.gz: 6d69aab1d30fa8d56fc8b579a241779e3d84054c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e33da494e19497c5f1aaaca0a6bd35f32edf91d66dbbc2f6b7cfc9932e381bb4ca08ad703b85d5fde85d5c4cba483a48d2ea287ab5e83c5f4d4a82d4f174833
|
7
|
+
data.tar.gz: 8fafdc22a685ce746ceb13cf10c6162c27afbcc51478c241a2d10402d904655b1c2e348e636758ac29cdcb48a3bf7ce9f3c6f4b50fecb45d895780308b8ff172
|
data/bin/rbbt
CHANGED
@@ -205,6 +205,10 @@ rescue ParameterException
|
|
205
205
|
print_error($!.message, $!.backtrace)
|
206
206
|
puts
|
207
207
|
exit -1
|
208
|
+
rescue SystemExit
|
209
|
+
Log.exception $! unless $?.success?
|
210
|
+
rescue Exception
|
211
|
+
Log.exception $!
|
208
212
|
ensure
|
209
213
|
if options[:profile]
|
210
214
|
result = RubyProf.stop
|
@@ -90,28 +90,6 @@ module AnnotatedArray
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
def select(method = nil, *args)
|
94
|
-
|
95
|
-
if method
|
96
|
-
|
97
|
-
res = self.zip( self.send(method, *args) ).
|
98
|
-
select{|e,result| result }.
|
99
|
-
collect{|element,r| element }
|
100
|
-
else
|
101
|
-
|
102
|
-
return self unless block_given?
|
103
|
-
|
104
|
-
res = []
|
105
|
-
each do |value|
|
106
|
-
res << value if yield(value)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
annotate(res)
|
111
|
-
res.extend AnnotatedArray
|
112
|
-
|
113
|
-
res
|
114
|
-
end
|
115
93
|
|
116
94
|
def reject
|
117
95
|
res = []
|
@@ -62,11 +62,12 @@ module AssociationItem
|
|
62
62
|
end
|
63
63
|
|
64
64
|
property :tsv => :array do
|
65
|
-
|
65
|
+
info_fields = self.info_fields
|
66
|
+
fields = [self.source_type, self.target_type].concat info_fields
|
66
67
|
type = [self.source_type, self.target_type] * "~"
|
67
68
|
tsv = TSV.setup({}, :key_field => type, :fields => fields, :type => :list, :namespace => self.namespace)
|
68
69
|
self.each do |match|
|
69
|
-
tsv[match] = match.info.values_at
|
70
|
+
tsv[match] = [match.source, match.target].concat match.info.values_at(*info_fields)
|
70
71
|
end
|
71
72
|
tsv
|
72
73
|
end
|
@@ -94,4 +95,38 @@ module AssociationItem
|
|
94
95
|
|
95
96
|
defined?(TSV)? TSV.setup(matrix, :key_field => (key_field || "Source") , :fields => targets, :type => :list) : matrix
|
96
97
|
end
|
98
|
+
|
99
|
+
def self._select_match(orig, elem)
|
100
|
+
if Array === orig and Array === elem
|
101
|
+
(orig & elem).any?
|
102
|
+
elsif Array === orig
|
103
|
+
orig.include? elem
|
104
|
+
elsif Array === elem
|
105
|
+
elem.include? orig
|
106
|
+
else
|
107
|
+
elem === orif
|
108
|
+
end
|
109
|
+
false
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.select(list, method = nil, &block)
|
113
|
+
if method and method.any?
|
114
|
+
list.select do |item|
|
115
|
+
method.collect do |key,value|
|
116
|
+
case key
|
117
|
+
when :target
|
118
|
+
_select_match item.target, value
|
119
|
+
when :source
|
120
|
+
_select_match item.source, value
|
121
|
+
else
|
122
|
+
orig = item.info[key]
|
123
|
+
orig = orig.split(";;") if String orig
|
124
|
+
_select_match orig, value
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
else
|
129
|
+
list.select(&block)
|
130
|
+
end
|
131
|
+
end
|
97
132
|
end
|
data/lib/rbbt/persist.rb
CHANGED
@@ -38,7 +38,10 @@ module Persist
|
|
38
38
|
check = persist_options[:check]
|
39
39
|
if not check.nil?
|
40
40
|
if Array === check
|
41
|
-
|
41
|
+
if check.select{|file| newer? path, file}.any?
|
42
|
+
Log.medium "Persistence check for #{path} failed in: #{ check.select{|file| newer? path, file} * ", "}"
|
43
|
+
return false
|
44
|
+
end
|
42
45
|
else
|
43
46
|
return false if newer? path, check
|
44
47
|
end
|
data/lib/rbbt/resource/rake.rb
CHANGED
data/lib/rbbt/tsv/accessor.rb
CHANGED
@@ -235,14 +235,25 @@ module TSV
|
|
235
235
|
|
236
236
|
def zip_new(key, values)
|
237
237
|
values = [values] unless Array === values
|
238
|
-
|
239
|
-
|
240
|
-
self
|
241
|
-
new
|
238
|
+
case type
|
239
|
+
when :double
|
240
|
+
if self.include? key
|
241
|
+
new = []
|
242
|
+
self[key, true].each_with_index do |v,i|
|
243
|
+
new << (v << values[i])
|
244
|
+
end
|
245
|
+
self[key] == new
|
246
|
+
else
|
247
|
+
self[key] = values.collect{|v| [v] }
|
248
|
+
end
|
249
|
+
when :flat
|
250
|
+
if self.include? key
|
251
|
+
self[key] = (self[key] + values).uniq
|
252
|
+
else
|
253
|
+
self[key] = values
|
242
254
|
end
|
243
|
-
self[key] == new
|
244
255
|
else
|
245
|
-
|
256
|
+
raise "Cannot zip_new for type: #{type}"
|
246
257
|
end
|
247
258
|
end
|
248
259
|
|
@@ -294,12 +294,13 @@ module TSV
|
|
294
294
|
Log.medium{"Aborted traversing 2 #{stream_name(obj)}"}
|
295
295
|
rescue Exception
|
296
296
|
Log.medium{"Exception traversing #{stream_name(obj)}"}
|
297
|
-
Log.exception $!
|
298
297
|
begin
|
299
298
|
stream = obj_stream(obj)
|
300
299
|
stream.abort if stream and stream.respond_to? :abort
|
301
300
|
stream = obj_stream(options[:into])
|
302
301
|
stream.abort if stream.respond_to? :abort
|
302
|
+
rescue Exception
|
303
|
+
ensure
|
303
304
|
raise $!
|
304
305
|
end
|
305
306
|
end
|
@@ -378,19 +379,28 @@ module TSV
|
|
378
379
|
return
|
379
380
|
end
|
380
381
|
begin
|
382
|
+
return false if value.nil?
|
381
383
|
case store
|
382
|
-
when
|
383
|
-
|
384
|
-
|
385
|
-
|
384
|
+
when TSV
|
385
|
+
if store.type == :double or store.type == :flat
|
386
|
+
case value
|
387
|
+
when TSV, Hash
|
386
388
|
store.merge_zip value
|
387
389
|
else
|
388
|
-
store.
|
390
|
+
store.zip_new *value
|
389
391
|
end
|
390
392
|
else
|
391
393
|
k,v = value
|
392
394
|
store[k] = v
|
393
395
|
end
|
396
|
+
when Hash
|
397
|
+
case value
|
398
|
+
when TSV, Hash
|
399
|
+
store.merge! value
|
400
|
+
else
|
401
|
+
k,v = value
|
402
|
+
store[k] = v
|
403
|
+
end
|
394
404
|
when TSV::Dumper
|
395
405
|
return false if value.nil?
|
396
406
|
store.add *value
|
data/lib/rbbt/util/log.rb
CHANGED
@@ -213,9 +213,8 @@ module Log
|
|
213
213
|
|
214
214
|
def self.exception(e)
|
215
215
|
stack = caller
|
216
|
-
error(
|
217
|
-
error(
|
218
|
-
error("BACKTRACE:\n" + e.backtrace * "\n")
|
216
|
+
error([e.class.to_s, e.message].compact * ": " )
|
217
|
+
error("BACKTRACE: " << Log.last_caller(caller) << "\n" + color_stack(e.backtrace)*"\n")
|
219
218
|
end
|
220
219
|
|
221
220
|
def self.color_stack(stack)
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -297,7 +297,9 @@ module Workflow
|
|
297
297
|
step_path = step_path taskname, jobname, input_values, dependencies, task.extension
|
298
298
|
end
|
299
299
|
|
300
|
-
get_job_step step_path, task, input_values, dependencies
|
300
|
+
job = get_job_step step_path, task, input_values, dependencies
|
301
|
+
job.clean_name = jobname
|
302
|
+
job
|
301
303
|
end
|
302
304
|
|
303
305
|
def load_step(path)
|
@@ -54,10 +54,6 @@ class Step
|
|
54
54
|
path.sub(/.*\/#{Regexp.quote task.name.to_s}\/(.*)/, '\1')
|
55
55
|
end
|
56
56
|
|
57
|
-
def clean_name
|
58
|
-
name.sub(/(.*)_.*/, '\1')
|
59
|
-
end
|
60
|
-
|
61
57
|
def task_name
|
62
58
|
@task_name ||= task.name
|
63
59
|
end
|
@@ -505,13 +501,17 @@ module Workflow
|
|
505
501
|
case v
|
506
502
|
when Symbol
|
507
503
|
rec_dependency = real_dependencies.collect{|d| [d, d.dependencies].flatten}.flatten.select{|d| d.task.name == v }.first
|
508
|
-
|
509
|
-
|
504
|
+
if (dependency.first.tasks[dependency[1]].input_options[i] || {})[:stream]
|
505
|
+
inputs[i] = rec_dependency.run(true).grace.join.path
|
506
|
+
else
|
507
|
+
inputs[i] = rec_dependency.run(true).join.load
|
508
|
+
end
|
510
509
|
else
|
511
510
|
inputs[i] = v
|
512
511
|
end
|
513
512
|
} if options
|
514
|
-
dependency.first.job(dependency[1], jobname, inputs)
|
513
|
+
res = dependency.first.job(dependency[1], jobname, inputs)
|
514
|
+
res
|
515
515
|
when Step
|
516
516
|
dependency
|
517
517
|
when Symbol
|
@@ -40,7 +40,10 @@ module Workflow
|
|
40
40
|
@dependencies << dependency_list
|
41
41
|
else
|
42
42
|
@dependency_list ||= []
|
43
|
-
|
43
|
+
if block_given?
|
44
|
+
dependency_list.unshift self if dependency_list.length == 1
|
45
|
+
dependency_list << block
|
46
|
+
end
|
44
47
|
dependencies.concat dependency_list
|
45
48
|
end
|
46
49
|
end
|
@@ -48,6 +51,7 @@ module Workflow
|
|
48
51
|
def dep(*dependency, &block)
|
49
52
|
@dependencies ||= []
|
50
53
|
if block_given?
|
54
|
+
dependency.unshift self if dependency.length == 1
|
51
55
|
DependencyBlock.setup block, dependency if dependency.any?
|
52
56
|
@dependencies << block
|
53
57
|
else
|
data/lib/rbbt/workflow/step.rb
CHANGED
@@ -5,7 +5,7 @@ require 'rbbt/util/semaphore'
|
|
5
5
|
require 'rbbt/workflow/accessor'
|
6
6
|
|
7
7
|
class Step
|
8
|
-
attr_accessor :path, :task, :inputs, :dependencies, :bindings
|
8
|
+
attr_accessor :clean_name, :path, :task, :inputs, :dependencies, :bindings
|
9
9
|
attr_accessor :pid
|
10
10
|
attr_accessor :exec
|
11
11
|
attr_accessor :result, :mutex, :seen
|
@@ -22,9 +22,16 @@ class Step
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def clean_name
|
26
|
+
@clean_name ||= begin
|
27
|
+
info[:clean_name] || path.sub(/_[a-z0-9]{32}/, '')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(path, task = nil, inputs = nil, dependencies = nil, bindings = nil, clean_name = nil)
|
26
32
|
path = Path.setup(Misc.sanitize_filename(path)) if String === path
|
27
|
-
|
33
|
+
path = path.call if Proc === path
|
34
|
+
|
28
35
|
@path = path
|
29
36
|
@task = task
|
30
37
|
@bindings = bindings
|
@@ -39,7 +46,7 @@ class Step
|
|
39
46
|
@mutex = Mutex.new
|
40
47
|
@info_mutex = Mutex.new
|
41
48
|
@inputs = inputs || []
|
42
|
-
NamedArray.setup @inputs, task.inputs.collect{|s| s.to_s} if task and task.inputs
|
49
|
+
NamedArray.setup @inputs, task.inputs.collect{|s| s.to_s} if task and task.respond_to? :inputs and task.inputs
|
43
50
|
end
|
44
51
|
|
45
52
|
def inputs
|
@@ -204,9 +211,13 @@ class Step
|
|
204
211
|
|
205
212
|
def step(name)
|
206
213
|
@steps ||= {}
|
207
|
-
@steps[name] ||=
|
208
|
-
|
209
|
-
|
214
|
+
@steps[name] ||= begin
|
215
|
+
deps = rec_dependencies.select{|step|
|
216
|
+
step.task_name.to_sym == name.to_sym
|
217
|
+
}
|
218
|
+
deps.first
|
219
|
+
end
|
220
|
+
|
210
221
|
end
|
211
222
|
end
|
212
223
|
|
@@ -123,15 +123,14 @@ class Step
|
|
123
123
|
dependencies.uniq.each do |dependency|
|
124
124
|
next if seen.collect{|d| d.path}.include?(dependency.path)
|
125
125
|
dependency.seen = seen
|
126
|
-
@seen << dependency
|
127
126
|
@seen.concat dependency.rec_dependencies.collect{|d| d }
|
127
|
+
@seen << dependency
|
128
128
|
@seen.uniq!
|
129
129
|
end
|
130
130
|
|
131
131
|
@seen.each do |dependency|
|
132
132
|
next if dependency == self
|
133
133
|
next unless dependencies.include? dependency
|
134
|
-
#dependency.relay_log self
|
135
134
|
dependency.dup_inputs
|
136
135
|
end
|
137
136
|
|
@@ -147,8 +146,8 @@ class Step
|
|
147
146
|
dependency.clean if (dependency.error? or dependency.aborted? or dependency.status.nil? or not (dependency.done? or dependency.running?))
|
148
147
|
end
|
149
148
|
|
150
|
-
unless dependency.started?
|
151
|
-
dependency.run(true)
|
149
|
+
unless dependency.started?
|
150
|
+
dependency.run(true)
|
152
151
|
end
|
153
152
|
rescue Aborted
|
154
153
|
Log.error "Aborted dep. #{Log.color :red, dependency.task.name.to_s}"
|
@@ -183,6 +182,7 @@ class Step
|
|
183
182
|
:pid => Process.pid,
|
184
183
|
:issued => Time.now,
|
185
184
|
:name => name,
|
185
|
+
:clean_name => clean_name,
|
186
186
|
:dependencies => dependencies.collect{|dep| [dep.task_name, dep.name, dep.path]},
|
187
187
|
})
|
188
188
|
|
@@ -51,18 +51,17 @@ when :subset
|
|
51
51
|
source_entities = options[:source_entities] || :all
|
52
52
|
target_entities = options[:target_entities] || :all
|
53
53
|
|
54
|
-
source_entities = source_entities.split(
|
55
|
-
target_entities = target_entities.split(
|
54
|
+
source_entities = source_entities.split(/[,|]/) if String === source_entities
|
55
|
+
target_entities = target_entities.split(/[,|]/) if String === target_entities
|
56
56
|
|
57
57
|
if options[:identify]
|
58
|
-
source_entities = knowledge_base.
|
59
|
-
target_entities = knowledge_base.
|
58
|
+
source_entities = knowledge_base.identify_source(database, source_entities)
|
59
|
+
target_entities = knowledge_base.identify_target(database, target_entities)
|
60
60
|
end
|
61
61
|
entities = {source_format => source_entities, target_format => target_entities}
|
62
62
|
|
63
63
|
matches = knowledge_base.subset(database, entities)
|
64
64
|
|
65
|
-
|
66
65
|
if options[:tsv]
|
67
66
|
puts matches.tsv.to_s
|
68
67
|
else
|
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.14.
|
4
|
+
version: 5.14.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: 2014-
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|