rbbt-util 5.20.9 → 5.20.10
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/bin/rbbt +1 -1
- data/bin/rbbt_query.rb +1 -1
- data/lib/rbbt/association/index.rb +3 -3
- data/lib/rbbt/fix_width_table.rb +4 -4
- data/lib/rbbt/persist/tsv.rb +4 -4
- data/lib/rbbt/persist/tsv/cdb.rb +3 -3
- data/lib/rbbt/persist/tsv/fix_width_table.rb +2 -2
- data/lib/rbbt/persist/tsv/kyotocabinet.rb +2 -2
- data/lib/rbbt/persist/tsv/leveldb.rb +2 -2
- data/lib/rbbt/persist/tsv/lmdb.rb +2 -2
- data/lib/rbbt/persist/tsv/packed_index.rb +2 -2
- data/lib/rbbt/persist/tsv/sharder.rb +4 -4
- data/lib/rbbt/persist/tsv/tokyocabinet.rb +2 -2
- data/lib/rbbt/resource.rb +6 -6
- data/lib/rbbt/resource/path.rb +7 -7
- data/lib/rbbt/resource/util.rb +9 -9
- data/lib/rbbt/rest/client/step.rb +8 -4
- data/lib/rbbt/tsv/attach.rb +21 -19
- data/lib/rbbt/tsv/parallel/traverse.rb +2 -2
- data/lib/rbbt/tsv/util.rb +1 -1
- data/lib/rbbt/util/R.rb +1 -1
- data/lib/rbbt/util/R/eval.rb +10 -10
- data/lib/rbbt/util/R/model.rb +2 -2
- data/lib/rbbt/util/docker.rb +3 -3
- data/lib/rbbt/util/filecache.rb +2 -2
- data/lib/rbbt/util/misc/development.rb +6 -4
- data/lib/rbbt/util/misc/lock.rb +1 -1
- data/lib/rbbt/util/misc/multipart_payload.rb +1 -1
- data/lib/rbbt/util/misc/pipes.rb +8 -8
- data/lib/rbbt/util/misc/system.rb +3 -3
- data/lib/rbbt/util/open.rb +9 -9
- data/lib/rbbt/util/simpleDSL.rb +2 -2
- data/lib/rbbt/util/tar.rb +1 -1
- data/lib/rbbt/util/tmpfile.rb +2 -2
- data/lib/rbbt/workflow.rb +26 -12
- data/lib/rbbt/workflow/accessor.rb +4 -4
- data/lib/rbbt/workflow/step/dependencies.rb +1 -1
- data/lib/rbbt/workflow/step/run.rb +6 -6
- data/share/rbbt_commands/app/install +2 -2
- data/share/rbbt_commands/app/start +1 -1
- data/share/rbbt_commands/log +5 -1
- data/share/rbbt_commands/resource/exists +1 -1
- data/share/rbbt_commands/study/task +3 -3
- data/share/rbbt_commands/system/clean +2 -2
- data/share/rbbt_commands/system/deleted_files +1 -1
- data/share/rbbt_commands/system/status +3 -3
- data/share/rbbt_commands/tsv/info +1 -1
- data/share/rbbt_commands/tsv/subset +1 -1
- data/share/rbbt_commands/workflow/example +1 -1
- data/share/rbbt_commands/workflow/install +3 -3
- data/share/rbbt_commands/workflow/monitor +6 -6
- data/share/rbbt_commands/workflow/prov +2 -2
- data/share/rbbt_commands/workflow/server +2 -2
- data/share/rbbt_commands/workflow/task +3 -3
- data/test/rbbt/test_resource.rb +2 -2
- data/test/rbbt/workflow/test_step.rb +3 -6
- metadata +2 -3
- data/lib/rbbt/util/misc/progress.rb +0 -0
@@ -22,7 +22,7 @@ module TSV
|
|
22
22
|
if obj.done?
|
23
23
|
path = obj.path
|
24
24
|
path = path.find if path.respond_to? :find
|
25
|
-
if File.
|
25
|
+
if File.exist? path
|
26
26
|
CMD.cmd("wc -l '#{path}'").read.to_i
|
27
27
|
else
|
28
28
|
nil
|
@@ -39,7 +39,7 @@ module TSV
|
|
39
39
|
CMD.cmd("wc -l '#{obj.path}'").read.to_i
|
40
40
|
when Path, String
|
41
41
|
obj = obj.find if Path === obj
|
42
|
-
if File.
|
42
|
+
if File.exist? obj
|
43
43
|
return nil if Open.gzip?(obj) or Open.bgzip?(obj)
|
44
44
|
CMD.cmd("wc -l '#{obj}'").read.to_i
|
45
45
|
else
|
data/lib/rbbt/tsv/util.rb
CHANGED
data/lib/rbbt/util/R.rb
CHANGED
data/lib/rbbt/util/R/eval.rb
CHANGED
@@ -5,7 +5,7 @@ require 'rserve'
|
|
5
5
|
module Rserve
|
6
6
|
module TCPSocket
|
7
7
|
def self.new(hostname, port_number)
|
8
|
-
raise "Socket at #{hostname} not found" unless File.
|
8
|
+
raise "Socket at #{hostname} not found" unless File.exist? hostname
|
9
9
|
@s = Socket.unix hostname
|
10
10
|
end
|
11
11
|
end
|
@@ -50,16 +50,16 @@ module R
|
|
50
50
|
Log.warn "Error killing Rserve (#{@@instance_process}): #{$!.message}"
|
51
51
|
end
|
52
52
|
end
|
53
|
-
FileUtils.rm_rf pid_file if File.
|
54
|
-
FileUtils.rm_rf socket_file if File.
|
55
|
-
FileUtils.rm_rf lockfile if File.
|
56
|
-
FileUtils.rm_rf workdir if File.
|
53
|
+
FileUtils.rm_rf pid_file if File.exist? pid_file
|
54
|
+
FileUtils.rm_rf socket_file if File.exist? socket_file
|
55
|
+
FileUtils.rm_rf lockfile if File.exist? lockfile
|
56
|
+
FileUtils.rm_rf workdir if File.exist? workdir
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.instance
|
60
60
|
@@instance ||= begin
|
61
61
|
|
62
|
-
clear if File.
|
62
|
+
clear if File.exist? pid_file and ! Misc.pid_exists?(Open.read(pid_file).strip.to_i)
|
63
63
|
|
64
64
|
FileUtils.mkdir_p File.dirname(socket_file) unless File.directory?(File.dirname(socket_file))
|
65
65
|
FileUtils.mkdir_p workdir unless File.directory? workdir
|
@@ -70,7 +70,7 @@ module R
|
|
70
70
|
|
71
71
|
begin
|
72
72
|
|
73
|
-
if not File.
|
73
|
+
if not File.exist? socket_file
|
74
74
|
|
75
75
|
sh_pid = Process.fork do
|
76
76
|
#args = %w(CMD Rserve --vanilla --quiet --RS-socket)
|
@@ -90,7 +90,7 @@ module R
|
|
90
90
|
$stdout.reopen File.new('/dev/null', 'w')
|
91
91
|
exec(ENV, cmd)
|
92
92
|
end
|
93
|
-
while not File.
|
93
|
+
while not File.exist? pid_file
|
94
94
|
sleep 0.5
|
95
95
|
end
|
96
96
|
@@instance_process = Open.read(pid_file).to_i
|
@@ -100,7 +100,7 @@ module R
|
|
100
100
|
i = Rserve::Connection.new :hostname => socket_file
|
101
101
|
|
102
102
|
begin
|
103
|
-
FileUtils.mkdir workdir unless File.
|
103
|
+
FileUtils.mkdir workdir unless File.exist? workdir
|
104
104
|
i.eval "setwd('#{workdir}');"
|
105
105
|
i.eval "source('#{UTIL}');"
|
106
106
|
i
|
@@ -111,7 +111,7 @@ module R
|
|
111
111
|
rescue Exception
|
112
112
|
Log.exception $!
|
113
113
|
Process.kill :INT, @@instance_process if defined? @@instance_process and @@instance_process
|
114
|
-
FileUtils.rm socket_file if File.
|
114
|
+
FileUtils.rm socket_file if File.exist? socket_file
|
115
115
|
retry if TryAgain === $!
|
116
116
|
raise $!
|
117
117
|
end
|
data/lib/rbbt/util/R/model.rb
CHANGED
@@ -122,7 +122,7 @@ predict(model, data.frame(#{field} = #{R.ruby2R tsv}));
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def exists?
|
125
|
-
File.
|
125
|
+
File.exist? model_file
|
126
126
|
end
|
127
127
|
|
128
128
|
def fit(tsv, method='lm', args = {})
|
@@ -132,7 +132,7 @@ predict(model, data.frame(#{field} = #{R.ruby2R tsv}));
|
|
132
132
|
|
133
133
|
tsv = Model.groom(tsv, formula)
|
134
134
|
|
135
|
-
FileUtils.mkdir_p File.dirname(model_file) unless File.
|
135
|
+
FileUtils.mkdir_p File.dirname(model_file) unless File.exist?(File.dirname(model_file))
|
136
136
|
roptions = r_options(tsv)
|
137
137
|
tsv.R <<-EOF, roptions
|
138
138
|
model = rbbt.model.fit(data, #{formula}, method=#{method}#{args_str})
|
data/lib/rbbt/util/docker.rb
CHANGED
@@ -3,7 +3,7 @@ module Docker
|
|
3
3
|
mounts, job_inputs, directory, pipe = Misc.process_options options, :mounts, :job_inputs, :directory, :pipe
|
4
4
|
|
5
5
|
if mounts
|
6
|
-
mounts.each{|t,s| FileUtils.mkdir_p s unless File.
|
6
|
+
mounts.each{|t,s| FileUtils.mkdir_p s unless File.exist? s}
|
7
7
|
mount_cmd = mounts.sort.collect{|t,s| "-v " + ["'" + s + "'", "'" + t + "'"] * ":" } * " "
|
8
8
|
else
|
9
9
|
mount_cmd = ""
|
@@ -26,7 +26,7 @@ module Docker
|
|
26
26
|
obj.join if obj.respond_to?(:join) and not obj.joined?
|
27
27
|
end
|
28
28
|
when String
|
29
|
-
if obj.length < 256 and File.
|
29
|
+
if obj.length < 256 and File.exist?(obj)
|
30
30
|
FileUtils.cp obj, directory[name]
|
31
31
|
else
|
32
32
|
Open.write(directory[name], obj)
|
@@ -49,7 +49,7 @@ module Docker
|
|
49
49
|
obj.join if obj.respond_to?(:join) and not obj.joined?
|
50
50
|
end
|
51
51
|
when String
|
52
|
-
if obj.length < 256 and File.
|
52
|
+
if obj.length < 256 and File.exist?(obj)
|
53
53
|
FileUtils.cp obj, tmpfile[name]
|
54
54
|
else
|
55
55
|
Open.write(tmpfile[name], obj)
|
data/lib/rbbt/util/filecache.rb
CHANGED
@@ -39,13 +39,13 @@ module FileCache
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.found(filename)
|
42
|
-
File.
|
42
|
+
File.exist? FileCache.path(filename)
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.get(filename)
|
46
46
|
path = path(filename)
|
47
47
|
|
48
|
-
return nil if ! File.
|
48
|
+
return nil if ! File.exist? path
|
49
49
|
|
50
50
|
File.open(path)
|
51
51
|
end
|
@@ -63,7 +63,7 @@ module Misc
|
|
63
63
|
result = RubyProf.stop
|
64
64
|
printer = RubyProf::MultiPrinter.new(result)
|
65
65
|
TmpFile.with_file do |dir|
|
66
|
-
FileUtils.mkdir_p dir unless File.
|
66
|
+
FileUtils.mkdir_p dir unless File.exist? dir
|
67
67
|
printer.print(:path => dir, :profile => 'profile')
|
68
68
|
CMD.cmd("firefox -no-remote '#{ dir }'")
|
69
69
|
end
|
@@ -284,7 +284,9 @@ module Misc
|
|
284
284
|
num = :current if num.nil?
|
285
285
|
cpus = case num
|
286
286
|
when :current
|
287
|
-
10
|
287
|
+
n = 10
|
288
|
+
n = elems.length / 2 if n > elems.length/2
|
289
|
+
n
|
288
290
|
when String
|
289
291
|
num.to_i
|
290
292
|
when Integer
|
@@ -363,7 +365,7 @@ module Misc
|
|
363
365
|
ENV["PUSHBULLET_KEY"]
|
364
366
|
else
|
365
367
|
config_api = File.join(ENV['HOME'], 'config/apps/pushbullet/apikey')
|
366
|
-
if File.
|
368
|
+
if File.exist? config_api
|
367
369
|
File.read(config_api).strip
|
368
370
|
else
|
369
371
|
nil
|
@@ -386,7 +388,7 @@ module Misc
|
|
386
388
|
end
|
387
389
|
|
388
390
|
def self.unzip_in_dir(file, dir)
|
389
|
-
raise "Target is not a directory: #{file}" if File.
|
391
|
+
raise "Target is not a directory: #{file}" if File.exist?(dir) and not File.directory?(dir)
|
390
392
|
if Open.remote? file
|
391
393
|
file = file.find if Path === file
|
392
394
|
Open.open(file) do |stream|
|
data/lib/rbbt/util/misc/lock.rb
CHANGED
@@ -23,7 +23,7 @@ module Misc
|
|
23
23
|
return yield if file.nil? and not Lockfile === options[:lock]
|
24
24
|
|
25
25
|
file = file.find if Path === file
|
26
|
-
FileUtils.mkdir_p File.dirname(File.expand_path(file)) unless File.
|
26
|
+
FileUtils.mkdir_p File.dirname(File.expand_path(file)) unless File.exist? File.dirname(File.expand_path(file))
|
27
27
|
|
28
28
|
|
29
29
|
case options[:lock]
|
@@ -69,7 +69,7 @@ module RbbtMutiplartPayload
|
|
69
69
|
next if stream_input and input == stream_input.to_s
|
70
70
|
content_str = case content
|
71
71
|
when String
|
72
|
-
if Misc.is_filename?(content) and File.
|
72
|
+
if Misc.is_filename?(content) and File.exist?(content)
|
73
73
|
File.read(content)
|
74
74
|
else
|
75
75
|
content
|
data/lib/rbbt/util/misc/pipes.rb
CHANGED
@@ -331,7 +331,7 @@ module Misc
|
|
331
331
|
Misc.consume_stream content
|
332
332
|
else
|
333
333
|
FileUtils.mkdir_p File.dirname(tmp_path) unless File.directory? File.dirname(tmp_path)
|
334
|
-
FileUtils.rm_f tmp_path if File.
|
334
|
+
FileUtils.rm_f tmp_path if File.exist? tmp_path
|
335
335
|
begin
|
336
336
|
case
|
337
337
|
when block_given?
|
@@ -355,7 +355,7 @@ module Misc
|
|
355
355
|
Open.mv tmp_path, path, lock_options
|
356
356
|
end
|
357
357
|
rescue Exception
|
358
|
-
raise $! unless File.
|
358
|
+
raise $! unless File.exist? path
|
359
359
|
end
|
360
360
|
|
361
361
|
content.join if content.respond_to? :join and not content.joined?
|
@@ -363,23 +363,23 @@ module Misc
|
|
363
363
|
if Lockfile === lock_options[:lock] and lock_options[:lock].locked?
|
364
364
|
lock_options[:lock].unlock
|
365
365
|
end
|
366
|
-
FileUtils.touch path if File.
|
366
|
+
FileUtils.touch path if File.exist? path
|
367
367
|
Open.notify_write(path)
|
368
368
|
rescue Aborted
|
369
369
|
Log.medium "Aborted sensiblewrite -- #{ Log.reset << Log.color(:blue, path) }"
|
370
370
|
content.abort if content.respond_to? :abort
|
371
|
-
Open.rm path if File.
|
371
|
+
Open.rm path if File.exist? path
|
372
372
|
rescue Exception
|
373
373
|
Log.medium "Exception in sensiblewrite: [#{Process.pid}] #{$!.message} -- #{ Log.color :blue, path }"
|
374
374
|
Log.exception $!
|
375
375
|
content.abort if content.respond_to? :abort
|
376
|
-
Open.rm path if File.
|
376
|
+
Open.rm path if File.exist? path
|
377
377
|
raise $!
|
378
378
|
rescue
|
379
379
|
Log.exception $!
|
380
380
|
raise $!
|
381
381
|
ensure
|
382
|
-
FileUtils.rm_f tmp_path if File.
|
382
|
+
FileUtils.rm_f tmp_path if File.exist? tmp_path
|
383
383
|
end
|
384
384
|
end
|
385
385
|
end
|
@@ -607,7 +607,7 @@ module Misc
|
|
607
607
|
else
|
608
608
|
erase = []
|
609
609
|
|
610
|
-
if Path === stream1 or (String === stream1 and File.
|
610
|
+
if Path === stream1 or (String === stream1 and File.exist? stream1)
|
611
611
|
file1 = stream1
|
612
612
|
else
|
613
613
|
file1 = TmpFile.tmp_file
|
@@ -615,7 +615,7 @@ module Misc
|
|
615
615
|
Open.write(file1, TSV.get_stream(stream1))
|
616
616
|
end
|
617
617
|
|
618
|
-
if Path === stream2 or (String === stream2 and File.
|
618
|
+
if Path === stream2 or (String === stream2 and File.exist? stream2)
|
619
619
|
file2 = stream2
|
620
620
|
else
|
621
621
|
file2 = TmpFile.tmp_file
|
@@ -78,7 +78,7 @@ end
|
|
78
78
|
old_pwd = FileUtils.pwd
|
79
79
|
res = nil
|
80
80
|
begin
|
81
|
-
FileUtils.mkdir_p dir unless File.
|
81
|
+
FileUtils.mkdir_p dir unless File.exist? dir
|
82
82
|
FileUtils.cd dir
|
83
83
|
res = yield
|
84
84
|
ensure
|
@@ -88,12 +88,12 @@ end
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def self.filename?(string)
|
91
|
-
String === string and string.length > 0 and string.length < 250 and File.
|
91
|
+
String === string and string.length > 0 and string.length < 250 and File.exist?(string)
|
92
92
|
end
|
93
93
|
|
94
94
|
def self.is_filename?(string)
|
95
95
|
return true if string.respond_to? :exists
|
96
|
-
return true if String === string and string.length < 265 and File.
|
96
|
+
return true if String === string and string.length < 265 and File.exist? string
|
97
97
|
return false
|
98
98
|
end
|
99
99
|
|
data/lib/rbbt/util/open.rb
CHANGED
@@ -17,7 +17,7 @@ module Open
|
|
17
17
|
|
18
18
|
def repository_dirs
|
19
19
|
@repository_dirs ||= begin
|
20
|
-
File.
|
20
|
+
File.exist?(Rbbt.etc.repository_dirs.find) ?
|
21
21
|
File.read(Rbbt.etc.repository_dirs.find).split("\n") :
|
22
22
|
[]
|
23
23
|
rescue
|
@@ -100,7 +100,7 @@ module Open
|
|
100
100
|
#
|
101
101
|
def self.in_cache(url, options = {})
|
102
102
|
filename = File.join(REMOTE_CACHEDIR, digest_url(url, options))
|
103
|
-
if File.
|
103
|
+
if File.exist? filename
|
104
104
|
return filename
|
105
105
|
else
|
106
106
|
nil
|
@@ -111,7 +111,7 @@ module Open
|
|
111
111
|
digest = Misc.digest([url, options.values_at("--post-data", "--post-data="), (options.include?("--post-file")? Open.read(options["--post-file"]) : "")].inspect)
|
112
112
|
|
113
113
|
filename = File.join(REMOTE_CACHEDIR, digest)
|
114
|
-
if File.
|
114
|
+
if File.exist? filename
|
115
115
|
FileUtils.rm filename
|
116
116
|
else
|
117
117
|
nil
|
@@ -239,7 +239,7 @@ module Open
|
|
239
239
|
dir_sub_path_target = find_repo_dir(target)
|
240
240
|
|
241
241
|
if dir_sub_path_source.nil? and dir_sub_path_target.nil?
|
242
|
-
FileUtils.mkdir_p File.dirname(target) unless File.
|
242
|
+
FileUtils.mkdir_p File.dirname(target) unless File.exist? File.dirname(target)
|
243
243
|
return FileUtils.mv source, target
|
244
244
|
end
|
245
245
|
|
@@ -271,7 +271,7 @@ module Open
|
|
271
271
|
exists_in_repo(*dir_sub_path)
|
272
272
|
else
|
273
273
|
file = file.find if Path === file
|
274
|
-
File.
|
274
|
+
File.exist? file
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
@@ -409,7 +409,7 @@ module Open
|
|
409
409
|
end
|
410
410
|
|
411
411
|
def self.can_open?(file)
|
412
|
-
String === file and (File.
|
412
|
+
String === file and (File.exist?(file) or remote?(file))
|
413
413
|
end
|
414
414
|
|
415
415
|
def self.read(file, options = {}, &block)
|
@@ -431,7 +431,7 @@ module Open
|
|
431
431
|
def self.notify_write(file)
|
432
432
|
begin
|
433
433
|
notification_file = file + '.notify'
|
434
|
-
if File.
|
434
|
+
if File.exist? notification_file
|
435
435
|
key = Open.read(notification_file).strip
|
436
436
|
key = nil if key.empty?
|
437
437
|
Misc.notify("Wrote " << file, nil, key)
|
@@ -456,7 +456,7 @@ module Open
|
|
456
456
|
yield f
|
457
457
|
end
|
458
458
|
rescue Exception
|
459
|
-
FileUtils.rm file if File.
|
459
|
+
FileUtils.rm file if File.exist? file
|
460
460
|
raise $!
|
461
461
|
end
|
462
462
|
when content.nil?
|
@@ -473,7 +473,7 @@ module Open
|
|
473
473
|
f.flock(File::LOCK_UN)
|
474
474
|
end
|
475
475
|
rescue Exception
|
476
|
-
FileUtils.rm_rf file if File.
|
476
|
+
FileUtils.rm_rf file if File.exist? file
|
477
477
|
raise $!
|
478
478
|
end
|
479
479
|
content.close
|
data/lib/rbbt/util/simpleDSL.rb
CHANGED
@@ -49,7 +49,7 @@ module SimpleDSL
|
|
49
49
|
end
|
50
50
|
|
51
51
|
instance_eval &actions
|
52
|
-
elsif File.
|
52
|
+
elsif File.exist?(actions)
|
53
53
|
|
54
54
|
@config[@@method_name] = File.open(actions).read
|
55
55
|
|
@@ -67,7 +67,7 @@ module SimpleDSL
|
|
67
67
|
def load_config(method = nil, file = nil, &block)
|
68
68
|
@config = {}
|
69
69
|
if file
|
70
|
-
raise ConfigFileMissingError.new "Config file '#{ file }' is missing" unless File.
|
70
|
+
raise ConfigFileMissingError.new "Config file '#{ file }' is missing" unless File.exist? file
|
71
71
|
parse(method, file)
|
72
72
|
end
|
73
73
|
|
data/lib/rbbt/util/tar.rb
CHANGED
data/lib/rbbt/util/tmpfile.rb
CHANGED
@@ -42,7 +42,7 @@ module TmpFile
|
|
42
42
|
|
43
43
|
result = yield(tmpfile)
|
44
44
|
|
45
|
-
FileUtils.rm_rf tmpfile if File.
|
45
|
+
FileUtils.rm_rf tmpfile if File.exist?(tmpfile) and erase
|
46
46
|
|
47
47
|
result
|
48
48
|
end
|
@@ -54,7 +54,7 @@ module TmpFile
|
|
54
54
|
|
55
55
|
result = yield(tmpdir)
|
56
56
|
|
57
|
-
FileUtils.rm_rf tmpdir if File.
|
57
|
+
FileUtils.rm_rf tmpdir if File.exist?(tmpdir) and erase
|
58
58
|
|
59
59
|
result
|
60
60
|
end
|
data/lib/rbbt/workflow.rb
CHANGED
@@ -39,14 +39,18 @@ module Workflow
|
|
39
39
|
eval "Object::#{wf_name} = WorkflowRESTClient.new '#{ url }', '#{wf_name}'"
|
40
40
|
end
|
41
41
|
|
42
|
+
def self.load_workflow_libdir(filename)
|
43
|
+
workflow_lib_dir = File.join(File.dirname(File.expand_path(filename)), 'lib')
|
44
|
+
if File.directory? workflow_lib_dir
|
45
|
+
Log.debug "Adding workflow lib directory to LOAD_PATH: #{workflow_lib_dir}"
|
46
|
+
$LOAD_PATH.unshift(workflow_lib_dir)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
def self.load_workflow_file(filename)
|
43
51
|
begin
|
44
|
-
|
45
|
-
|
46
|
-
if File.directory? workflow_lib_dir
|
47
|
-
Log.debug "Adding workflow lib directory to LOAD_PATH: #{workflow_lib_dir}"
|
48
|
-
$LOAD_PATH.unshift(workflow_lib_dir)
|
49
|
-
end
|
52
|
+
|
53
|
+
load_workflow_libdir(filename)
|
50
54
|
|
51
55
|
filename = File.expand_path(filename)
|
52
56
|
|
@@ -81,29 +85,40 @@ module Workflow
|
|
81
85
|
end
|
82
86
|
end
|
83
87
|
|
84
|
-
def self.
|
88
|
+
def self.local_workflow_filename(wf_name)
|
85
89
|
filename = nil
|
86
90
|
|
87
91
|
if Path === wf_name
|
88
92
|
case
|
89
93
|
# Points to workflow file
|
90
|
-
when ((File.
|
94
|
+
when ((File.exist?(wf_name.find) and not File.directory?(wf_name.find)) or File.exist?(wf_name.find + '.rb'))
|
91
95
|
filename = wf_name.find
|
92
96
|
|
93
97
|
# Points to workflow dir
|
94
|
-
when (File.
|
98
|
+
when (File.exist?(wf_name.find) and File.directory?(wf_name.find) and File.exist?(File.join(wf_name.find, 'workflow.rb')))
|
95
99
|
filename = wf_name['workflow.rb'].find
|
96
100
|
end
|
97
101
|
|
98
102
|
else
|
99
|
-
if ((File.
|
103
|
+
if ((File.exist?(wf_name) and not File.directory?(wf_name)) or File.exist?(wf_name + '.rb'))
|
100
104
|
filename = (wf_name =~ /\.?\//) ? wf_name : "./" << wf_name
|
101
105
|
else
|
102
106
|
filename = workflow_dir[wf_name]['workflow.rb'].find
|
103
107
|
end
|
104
108
|
end
|
105
109
|
|
106
|
-
if filename
|
110
|
+
if filename.nil? or not File.exist?(filename)
|
111
|
+
wf_name_snake = Misc.snake_case(wf_name)
|
112
|
+
return local_workflow_filename(wf_name_snake) if wf_name_snake != wf_name
|
113
|
+
end
|
114
|
+
|
115
|
+
filename
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.require_local_workflow(wf_name)
|
119
|
+
filename = local_workflow_filename(wf_name)
|
120
|
+
|
121
|
+
if filename and File.exist? filename
|
107
122
|
load_workflow_file filename
|
108
123
|
else
|
109
124
|
return false
|
@@ -153,7 +168,6 @@ module Workflow
|
|
153
168
|
|
154
169
|
Log.info{"Loading workflow #{wf_name}"}
|
155
170
|
require_local_workflow(wf_name) or
|
156
|
-
require_local_workflow(Misc.snake_case(wf_name)) or
|
157
171
|
(Workflow.autoinstall and `rbbt workflow install #{Misc.snake_case(wf_name)}` and require_local_workflow(Misc.snake_case(wf_name))) or
|
158
172
|
raise("Workflow not found or could not be loaded: #{ wf_name }")
|
159
173
|
begin
|