rbbt-util 5.32.16 → 5.32.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/resource/path.rb +6 -6
- data/lib/rbbt/tsv/parallel/traverse.rb +1 -1
- data/lib/rbbt/util/log.rb +15 -4
- data/lib/rbbt/util/misc/inspect.rb +1 -1
- data/lib/rbbt/util/open.rb +1 -0
- data/lib/rbbt/workflow.rb +43 -1
- data/lib/rbbt/workflow/accessor.rb +15 -242
- data/lib/rbbt/workflow/definition.rb +1 -0
- data/lib/rbbt/workflow/dependencies.rb +195 -0
- data/lib/rbbt/workflow/step.rb +10 -158
- data/lib/rbbt/workflow/step/accessor.rb +1 -311
- data/lib/rbbt/workflow/step/dependencies.rb +43 -3
- data/lib/rbbt/workflow/step/info.rb +294 -0
- data/lib/rbbt/workflow/step/status.rb +146 -0
- data/lib/rbbt/workflow/usage.rb +4 -2
- data/lib/rbbt/workflow/util/orchestrator.rb +1 -1
- data/lib/rbbt/workflow/util/provenance.rb +16 -4
- data/share/rbbt_commands/system/clean +1 -0
- data/share/rbbt_commands/workflow/prov +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e7aa425415a69c6615edd3fd7f38ce4c0bba0b1a911e7f97e927bf433483401
|
4
|
+
data.tar.gz: d2e8045de7f45d961afd8671b694c4c92f629dbc41d96057c84b9e97fc8cf15c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4f577d5d647b6c9ce1226062e7f5a459e6dee13e151e782d5938494a3e061d4b3fcc41bd14a8276ea646e58b726571445a45db7f2fe03dc34f4ca28d94c2d9a
|
7
|
+
data.tar.gz: d8432ea0d5232ddd9ac89c9e9cf0880a677cf708772ea5d0a6b6e28bd2204831d676e613a218c616c950c509c381a0ab2cf1acf88b98a85e9d4f18c3480ef48c
|
data/lib/rbbt/resource/path.rb
CHANGED
@@ -159,6 +159,12 @@ module Path
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def find(where = nil, caller_lib = nil, paths = nil)
|
162
|
+
|
163
|
+
if located?
|
164
|
+
self.original ||= self
|
165
|
+
return self
|
166
|
+
end
|
167
|
+
|
162
168
|
@path ||= {}
|
163
169
|
rsearch_paths = (resource and resource.respond_to?(:search_paths)) ? resource.search_paths : nil
|
164
170
|
key_elems = [where, caller_lib, rsearch_paths, paths]
|
@@ -167,12 +173,6 @@ module Path
|
|
167
173
|
|
168
174
|
return @path[key] if @path[key]
|
169
175
|
|
170
|
-
if located?
|
171
|
-
@path[key] = self
|
172
|
-
self.original ||= self
|
173
|
-
return self
|
174
|
-
end
|
175
|
-
|
176
176
|
@path[key] ||= begin
|
177
177
|
paths = [paths, rsearch_paths, self.search_paths, SEARCH_PATHS].reverse.compact.inject({}){|acc,h| acc.merge! h; acc }
|
178
178
|
where = paths[:default] if where == :default
|
@@ -332,7 +332,7 @@ module TSV
|
|
332
332
|
Log.low{"Traversing #{name} #{Log.color :green, "->"} #{stream_name(options[:into])}"}
|
333
333
|
begin
|
334
334
|
case obj
|
335
|
-
when (defined? FastContainers
|
335
|
+
when (defined? FastContainers && FastContainers::PriorityQueue === obj)
|
336
336
|
traverse_priority_queue(obj, options, &block)
|
337
337
|
when TSV
|
338
338
|
traverse_tsv(obj, options, &block)
|
data/lib/rbbt/util/log.rb
CHANGED
@@ -322,8 +322,13 @@ module Log
|
|
322
322
|
|
323
323
|
def self.exception(e)
|
324
324
|
stack = caller
|
325
|
-
|
326
|
-
|
325
|
+
if ENV["RBBT_ORIGINAL_STACK"] == 'true'
|
326
|
+
error([e.class.to_s, e.message].compact * ": " )
|
327
|
+
error("BACKTRACE [#{Process.pid}]: " << Log.last_caller(stack) << "\n" + color_stack(e.backtrace)*"\n")
|
328
|
+
else
|
329
|
+
error("BACKTRACE [#{Process.pid}]: " << Log.last_caller(stack) << "\n" + color_stack(e.backtrace.reverse)*"\n")
|
330
|
+
error([e.class.to_s, e.message].compact * ": " )
|
331
|
+
end
|
327
332
|
end
|
328
333
|
|
329
334
|
def self.deprecated(m)
|
@@ -370,11 +375,17 @@ module Log
|
|
370
375
|
|
371
376
|
def self.stack(stack)
|
372
377
|
LOG_MUTEX.synchronize do
|
373
|
-
|
374
|
-
|
378
|
+
if ENV["RBBT_ORIGINAL_STACK"] == 'true'
|
379
|
+
STDERR.puts Log.color :magenta, "Stack trace [#{Process.pid}]: " << Log.last_caller(caller)
|
375
380
|
color_stack(stack).each do |line|
|
376
381
|
STDERR.puts line
|
377
382
|
end
|
383
|
+
else
|
384
|
+
STDERR.puts Log.color :magenta, "Stack trace [#{Process.pid}]: " << Log.last_caller(caller)
|
385
|
+
color_stack(stack.reverse).each do |line|
|
386
|
+
STDERR.puts line
|
387
|
+
end
|
388
|
+
end
|
378
389
|
end
|
379
390
|
end
|
380
391
|
|
@@ -320,7 +320,7 @@ module Misc
|
|
320
320
|
end
|
321
321
|
end
|
322
322
|
when String
|
323
|
-
if Misc.is_filename?(obj) and ! %w(. ..).include?(obj)
|
323
|
+
if Misc.is_filename?(obj, false) and ! %w(. ..).include?(obj) and ! Path === obj
|
324
324
|
obj2str Path.setup(obj.dup)
|
325
325
|
else
|
326
326
|
obj = obj.chomp if String === obj
|
data/lib/rbbt/util/open.rb
CHANGED
data/lib/rbbt/workflow.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rbbt/workflow/definition'
|
2
|
+
require 'rbbt/workflow/dependencies'
|
2
3
|
require 'rbbt/workflow/task'
|
3
4
|
require 'rbbt/workflow/step'
|
4
5
|
require 'rbbt/workflow/accessor'
|
@@ -228,6 +229,47 @@ module Workflow
|
|
228
229
|
end
|
229
230
|
end
|
230
231
|
|
232
|
+
TAG = ENV["RBBT_INPUT_JOBNAME"] == "true" ? :inputs : :hash
|
233
|
+
DEBUG_JOB_HASH = ENV["RBBT_DEBUG_JOB_HASH"] == 'true'
|
234
|
+
def step_path(taskname, jobname, inputs, dependencies, extension = nil)
|
235
|
+
raise "Jobname makes an invalid path: #{ jobname }" if jobname.include? '..'
|
236
|
+
if inputs.length > 0 or dependencies.any?
|
237
|
+
tagged_jobname = case TAG
|
238
|
+
when :hash
|
239
|
+
clean_inputs = Annotated.purge(inputs)
|
240
|
+
clean_inputs = clean_inputs.collect{|i| Symbol === i ? i.to_s : i }
|
241
|
+
deps_str = dependencies.collect{|d| (Step === d || (defined?(RemoteStep) && RemoteStep === Step)) ? "Step: " << (d.overriden? ? d.path : d.short_path) : d }
|
242
|
+
key_obj = {:inputs => clean_inputs, :dependencies => deps_str }
|
243
|
+
key_str = Misc.obj2str(key_obj)
|
244
|
+
hash_str = Misc.digest(key_str)
|
245
|
+
Log.debug "Hash for '#{[taskname, jobname] * "/"}' #{hash_str} for #{key_str}" if DEBUG_JOB_HASH
|
246
|
+
jobname + '_' << hash_str
|
247
|
+
when :inputs
|
248
|
+
all_inputs = {}
|
249
|
+
inputs.zip(self.task_info(taskname)[:inputs]) do |i,f|
|
250
|
+
all_inputs[f] = i
|
251
|
+
end
|
252
|
+
dependencies.each do |dep|
|
253
|
+
ri = dep.recursive_inputs
|
254
|
+
ri.zip(ri.fields).each do |i,f|
|
255
|
+
all_inputs[f] = i
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
all_inputs.any? ? jobname + '_' << Misc.obj2str(all_inputs) : jobname
|
260
|
+
else
|
261
|
+
jobname
|
262
|
+
end
|
263
|
+
else
|
264
|
+
tagged_jobname = jobname
|
265
|
+
end
|
266
|
+
|
267
|
+
if extension and not extension.empty?
|
268
|
+
tagged_jobname = tagged_jobname + ('.' << extension.to_s)
|
269
|
+
end
|
270
|
+
|
271
|
+
workdir[taskname][tagged_jobname].find
|
272
|
+
end
|
231
273
|
def import_task(workflow, orig, new)
|
232
274
|
orig_task = workflow.tasks[orig]
|
233
275
|
new_task = orig_task.dup
|
@@ -417,7 +459,7 @@ module Workflow
|
|
417
459
|
extension = nil
|
418
460
|
if dependencies.any?
|
419
461
|
dep_basename = File.basename(dependencies.last.path)
|
420
|
-
extension =
|
462
|
+
extension = dep_basename.split(".").last if dep_basename.include?('.')
|
421
463
|
end
|
422
464
|
end
|
423
465
|
|
@@ -7,7 +7,7 @@ module ComputeDependency
|
|
7
7
|
dep.extend ComputeDependency
|
8
8
|
dep.compute = value
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def canfail?
|
12
12
|
compute == :canfail || (Array === compute && compute.include?(:canfail))
|
13
13
|
end
|
@@ -72,83 +72,6 @@ module Workflow
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def rec_dependencies(taskname)
|
76
|
-
@rec_dependencies ||= {}
|
77
|
-
@rec_dependencies[taskname] ||= begin
|
78
|
-
if task_dependencies.include? taskname
|
79
|
-
|
80
|
-
deps = task_dependencies[taskname]
|
81
|
-
|
82
|
-
#all_deps = deps.select{|dep| String === dep or Symbol === dep or Array === dep}
|
83
|
-
|
84
|
-
all_deps = []
|
85
|
-
deps.each do |dep|
|
86
|
-
if DependencyBlock === dep
|
87
|
-
all_deps << dep.dependency if dep.dependency
|
88
|
-
else
|
89
|
-
all_deps << dep unless Proc === dep
|
90
|
-
end
|
91
|
-
|
92
|
-
begin
|
93
|
-
case dep
|
94
|
-
when Array
|
95
|
-
wf, t, o = dep
|
96
|
-
|
97
|
-
wf.rec_dependencies(t.to_sym).each do |d|
|
98
|
-
if Array === d
|
99
|
-
new = d.dup
|
100
|
-
else
|
101
|
-
new = [dep.first, d]
|
102
|
-
end
|
103
|
-
|
104
|
-
if Hash === o and not o.empty?
|
105
|
-
if Hash === new.last
|
106
|
-
hash = new.last.dup
|
107
|
-
o.each{|k,v| hash[k] ||= v}
|
108
|
-
new[new.length-1] = hash
|
109
|
-
else
|
110
|
-
new.push o.dup
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
all_deps << new
|
115
|
-
end if wf && t
|
116
|
-
|
117
|
-
when String, Symbol
|
118
|
-
rec_deps = rec_dependencies(dep.to_sym)
|
119
|
-
all_deps.concat rec_deps
|
120
|
-
when DependencyBlock
|
121
|
-
dep = dep.dependency
|
122
|
-
raise TryAgain
|
123
|
-
end
|
124
|
-
rescue TryAgain
|
125
|
-
retry
|
126
|
-
end
|
127
|
-
end
|
128
|
-
all_deps.uniq
|
129
|
-
else
|
130
|
-
[]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def task_from_dep(dep)
|
136
|
-
task = case dep
|
137
|
-
when Array
|
138
|
-
dep.first.tasks[dep[1]]
|
139
|
-
when String
|
140
|
-
tasks[dep.to_sym]
|
141
|
-
when Symbol
|
142
|
-
tasks[dep.to_sym]
|
143
|
-
end
|
144
|
-
raise "Unknown dependency: #{Misc.fingerprint dep}" if task.nil?
|
145
|
-
task
|
146
|
-
end
|
147
|
-
|
148
|
-
#def rec_inputs(taskname)
|
149
|
-
# [taskname].concat(rec_dependencies(taskname)).inject([]){|acc, tn| acc.concat(task_from_dep(tn).inputs) }.uniq
|
150
|
-
#end
|
151
|
-
|
152
75
|
def rec_inputs(taskname)
|
153
76
|
task = task_from_dep(taskname)
|
154
77
|
deps = rec_dependencies(taskname)
|
@@ -294,174 +217,24 @@ module Workflow
|
|
294
217
|
_inputs
|
295
218
|
end
|
296
219
|
|
297
|
-
def
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
override_dependencies
|
309
|
-
end
|
310
|
-
|
311
|
-
def setup_override_dependency(dep, workflow, task_name)
|
312
|
-
dep = Step === dep ? dep : Workflow.load_step(dep)
|
313
|
-
dep.workflow = workflow
|
314
|
-
dep.info[:name] = dep.name
|
315
|
-
dep.original_task_name ||= dep.task_name if dep.workflow
|
316
|
-
begin
|
317
|
-
workflow = Kernel.const_get workflow if String === workflow
|
318
|
-
dep.task = workflow.tasks[task_name] if dep.task.nil? && workflow.tasks.include?(task_name)
|
319
|
-
rescue
|
320
|
-
Log.exception $!
|
321
|
-
end
|
322
|
-
dep.task_name = task_name
|
323
|
-
dep.overriden = dep.original_task_name.to_sym
|
324
|
-
dep
|
325
|
-
end
|
326
|
-
|
327
|
-
def real_dependencies(task, orig_jobname, inputs, dependencies)
|
328
|
-
real_dependencies = []
|
329
|
-
path_deps = {}
|
330
|
-
|
331
|
-
override_dependencies = override_dependencies(inputs)
|
332
|
-
|
333
|
-
dependencies.each do |dependency|
|
334
|
-
_inputs = IndiferentHash.setup(inputs.dup)
|
335
|
-
jobname = orig_jobname
|
336
|
-
jobname = _inputs[:jobname] if _inputs.include? :jobname
|
337
|
-
|
338
|
-
real_dep = case dependency
|
339
|
-
when Array
|
340
|
-
workflow, dep_task, options = dependency
|
341
|
-
|
342
|
-
if override_dependencies[workflow.to_s] && value = override_dependencies[workflow.to_s][dep_task]
|
343
|
-
setup_override_dependency(value, workflow, dep_task)
|
344
|
-
else
|
345
|
-
|
346
|
-
compute = options[:compute] if options
|
347
|
-
|
348
|
-
all_d = (real_dependencies + real_dependencies.flatten.collect{|d| d.rec_dependencies} ).flatten.compact.uniq
|
349
|
-
|
350
|
-
_inputs = assign_dep_inputs(_inputs, options, all_d, workflow.task_info(dep_task))
|
351
|
-
jobname = _inputs.delete :jobname if _inputs.include? :jobname
|
352
|
-
|
353
|
-
job = workflow._job(dep_task, jobname, _inputs)
|
354
|
-
ComputeDependency.setup(job, compute) if compute
|
355
|
-
job
|
356
|
-
end
|
357
|
-
when Step
|
358
|
-
dependency
|
359
|
-
when Symbol
|
360
|
-
if override_dependencies[self.to_s] && value = override_dependencies[self.to_s][dependency]
|
361
|
-
setup_override_dependency(value, self, dependency)
|
362
|
-
else
|
363
|
-
_job(dependency, jobname, _inputs)
|
364
|
-
end
|
365
|
-
when Proc
|
366
|
-
if DependencyBlock === dependency
|
367
|
-
orig_dep = dependency.dependency
|
368
|
-
wf, task_name, options = orig_dep
|
369
|
-
|
370
|
-
options = {} if options.nil?
|
371
|
-
compute = options[:compute]
|
372
|
-
|
373
|
-
options = IndiferentHash.setup(options.dup)
|
374
|
-
dep = dependency.call jobname, _inputs.merge(options), real_dependencies
|
375
|
-
|
376
|
-
dep = [dep] unless Array === dep
|
377
|
-
|
378
|
-
new_=[]
|
379
|
-
dep.each{|d|
|
380
|
-
next if d.nil?
|
381
|
-
if Hash === d
|
382
|
-
d[:workflow] ||= wf
|
383
|
-
d[:task] ||= task_name
|
384
|
-
_override_dependencies = override_dependencies.merge(override_dependencies(d[:inputs] || {}))
|
385
|
-
d = if _override_dependencies[d[:workflow].to_s] && value = _override_dependencies[d[:workflow].to_s][d[:task]]
|
386
|
-
setup_override_dependency(value, d[:workflow], d[:task])
|
387
|
-
else
|
388
|
-
task_info = d[:workflow].task_info(d[:task])
|
389
|
-
|
390
|
-
_inputs = assign_dep_inputs({}, options.merge(d[:inputs] || {}), real_dependencies, task_info)
|
391
|
-
d[:workflow]._job(d[:task], d[:jobname], _inputs)
|
392
|
-
end
|
393
|
-
end
|
394
|
-
ComputeDependency.setup(d, compute) if compute
|
395
|
-
new_ << d
|
396
|
-
}
|
397
|
-
dep = new_
|
398
|
-
else
|
399
|
-
_inputs = IndiferentHash.setup(_inputs.dup)
|
400
|
-
dep = dependency.call jobname, _inputs, real_dependencies
|
401
|
-
if Hash === dep
|
402
|
-
dep[:workflow] ||= wf || self
|
403
|
-
_override_dependencies = override_dependencies.merge(override_dependencies(dep[:inputs] || {}))
|
404
|
-
if _override_dependencies[dep[:workflow].to_s] && value = _override_dependencies[dep[:workflow].to_s][dep[:task]]
|
405
|
-
setup_override_dependency(value, dep[:workflow], dep[:task])
|
406
|
-
else
|
407
|
-
task_info = (dep[:task] && dep[:workflow]) ? dep[:workflow].task_info(dep[:task]) : nil
|
408
|
-
_inputs = assign_dep_inputs({}, dep[:inputs], real_dependencies, task_info)
|
409
|
-
dep = dep[:workflow]._job(dep[:task], dep[:jobname], _inputs)
|
410
|
-
end
|
411
|
-
end
|
412
|
-
end
|
413
|
-
|
414
|
-
dep
|
415
|
-
else
|
416
|
-
raise "Dependency for #{task.name} not understood: #{Misc.fingerprint dependency}"
|
417
|
-
end
|
418
|
-
|
419
|
-
real_dependencies << real_dep
|
420
|
-
end
|
421
|
-
real_dependencies.flatten.compact
|
220
|
+
def task_from_dep(dep)
|
221
|
+
task = case dep
|
222
|
+
when Array
|
223
|
+
dep.first.tasks[dep[1]]
|
224
|
+
when String
|
225
|
+
tasks[dep.to_sym]
|
226
|
+
when Symbol
|
227
|
+
tasks[dep.to_sym]
|
228
|
+
end
|
229
|
+
raise "Unknown dependency: #{Misc.fingerprint dep}" if task.nil?
|
230
|
+
task
|
422
231
|
end
|
423
232
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
raise "Jobname makes an invalid path: #{ jobname }" if jobname.include? '..'
|
428
|
-
if inputs.length > 0 or dependencies.any?
|
429
|
-
tagged_jobname = case TAG
|
430
|
-
when :hash
|
431
|
-
clean_inputs = Annotated.purge(inputs)
|
432
|
-
clean_inputs = clean_inputs.collect{|i| Symbol === i ? i.to_s : i }
|
433
|
-
deps_str = dependencies.collect{|d| (Step === d || (defined?(RemoteStep) && RemoteStep === Step)) ? "Step: " << d.short_path : d }
|
434
|
-
key_obj = {:inputs => clean_inputs, :dependencies => deps_str }
|
435
|
-
key_str = Misc.obj2str(key_obj)
|
436
|
-
hash_str = Misc.digest(key_str)
|
437
|
-
Log.debug "Hash for '#{[taskname, jobname] * "/"}' #{hash_str} for #{key_str}" if DEBUG_JOB_HASH
|
438
|
-
jobname + '_' << hash_str
|
439
|
-
when :inputs
|
440
|
-
all_inputs = {}
|
441
|
-
inputs.zip(self.task_info(taskname)[:inputs]) do |i,f|
|
442
|
-
all_inputs[f] = i
|
443
|
-
end
|
444
|
-
dependencies.each do |dep|
|
445
|
-
ri = dep.recursive_inputs
|
446
|
-
ri.zip(ri.fields).each do |i,f|
|
447
|
-
all_inputs[f] = i
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
all_inputs.any? ? jobname + '_' << Misc.obj2str(all_inputs) : jobname
|
452
|
-
else
|
453
|
-
jobname
|
454
|
-
end
|
455
|
-
else
|
456
|
-
tagged_jobname = jobname
|
457
|
-
end
|
233
|
+
#def rec_inputs(taskname)
|
234
|
+
# [taskname].concat(rec_dependencies(taskname)).inject([]){|acc, tn| acc.concat(task_from_dep(tn).inputs) }.uniq
|
235
|
+
#end
|
458
236
|
|
459
|
-
if extension and not extension.empty?
|
460
|
-
tagged_jobname = tagged_jobname + ('.' << extension.to_s)
|
461
|
-
end
|
462
237
|
|
463
|
-
workdir[taskname][tagged_jobname].find
|
464
|
-
end
|
465
238
|
|
466
239
|
def id_for(path)
|
467
240
|
if workdir.respond_to? :find
|
@@ -77,6 +77,7 @@ module Workflow
|
|
77
77
|
returns workflow.tasks[oname].result_description if workflow.tasks.include?(oname) unless @result_description
|
78
78
|
task name do
|
79
79
|
raise RbbtException, "dependency not found in dep_task" if dependencies.empty?
|
80
|
+
Step.wait_for_jobs dependencies
|
80
81
|
dep = dependencies.last
|
81
82
|
dep.join
|
82
83
|
raise dep.get_exception if dep.error?
|