rbbt-util 5.44.1 → 6.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rbbt +67 -90
  3. data/etc/app.d/base.rb +2 -2
  4. data/etc/app.d/semaphores.rb +3 -3
  5. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  6. data/lib/rbbt/annotations/refactor.rb +27 -0
  7. data/lib/rbbt/annotations/util.rb +282 -282
  8. data/lib/rbbt/annotations.rb +343 -320
  9. data/lib/rbbt/association/database.rb +200 -225
  10. data/lib/rbbt/association/index.rb +294 -291
  11. data/lib/rbbt/association/item.rb +227 -227
  12. data/lib/rbbt/association/open.rb +35 -34
  13. data/lib/rbbt/association/util.rb +0 -169
  14. data/lib/rbbt/association.rb +2 -4
  15. data/lib/rbbt/entity/identifiers.rb +119 -118
  16. data/lib/rbbt/entity/refactor.rb +12 -0
  17. data/lib/rbbt/entity.rb +319 -315
  18. data/lib/rbbt/hpc/batch.rb +72 -53
  19. data/lib/rbbt/hpc/lsf.rb +2 -2
  20. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  21. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  22. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  24. data/lib/rbbt/hpc/slurm.rb +18 -18
  25. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  26. data/lib/rbbt/knowledge_base/query.rb +2 -2
  27. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  28. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  29. data/lib/rbbt/knowledge_base.rb +1 -1
  30. data/lib/rbbt/monitor.rb +36 -25
  31. data/lib/rbbt/persist/refactor.rb +166 -0
  32. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  33. data/lib/rbbt/persist/tsv.rb +187 -185
  34. data/lib/rbbt/persist.rb +556 -551
  35. data/lib/rbbt/refactor.rb +20 -0
  36. data/lib/rbbt/resource/path/refactor.rb +178 -0
  37. data/lib/rbbt/resource/path.rb +317 -497
  38. data/lib/rbbt/resource/util.rb +0 -48
  39. data/lib/rbbt/resource.rb +3 -390
  40. data/lib/rbbt/tsv/accessor.rb +2 -838
  41. data/lib/rbbt/tsv/attach.rb +303 -299
  42. data/lib/rbbt/tsv/change_id.rb +244 -245
  43. data/lib/rbbt/tsv/csv.rb +87 -85
  44. data/lib/rbbt/tsv/dumper.rb +2 -100
  45. data/lib/rbbt/tsv/excel.rb +26 -24
  46. data/lib/rbbt/tsv/field_index.rb +4 -1
  47. data/lib/rbbt/tsv/filter.rb +3 -2
  48. data/lib/rbbt/tsv/index.rb +2 -284
  49. data/lib/rbbt/tsv/manipulate.rb +750 -747
  50. data/lib/rbbt/tsv/marshal.rb +3 -3
  51. data/lib/rbbt/tsv/matrix.rb +2 -2
  52. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  53. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  54. data/lib/rbbt/tsv/parser.rb +678 -678
  55. data/lib/rbbt/tsv/refactor.rb +195 -0
  56. data/lib/rbbt/tsv/stream.rb +253 -251
  57. data/lib/rbbt/tsv/util.rb +420 -420
  58. data/lib/rbbt/tsv.rb +210 -208
  59. data/lib/rbbt/util/R/eval.rb +4 -4
  60. data/lib/rbbt/util/R/plot.rb +62 -166
  61. data/lib/rbbt/util/R.rb +21 -18
  62. data/lib/rbbt/util/cmd.rb +2 -318
  63. data/lib/rbbt/util/color.rb +269 -269
  64. data/lib/rbbt/util/colorize.rb +89 -89
  65. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  66. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  67. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  68. data/lib/rbbt/util/config.rb +169 -167
  69. data/lib/rbbt/util/iruby.rb +20 -0
  70. data/lib/rbbt/util/log/progress/report.rb +241 -241
  71. data/lib/rbbt/util/log/progress/util.rb +99 -99
  72. data/lib/rbbt/util/log/progress.rb +102 -102
  73. data/lib/rbbt/util/log/refactor.rb +49 -0
  74. data/lib/rbbt/util/log.rb +486 -532
  75. data/lib/rbbt/util/migrate.rb +1 -1
  76. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  77. data/lib/rbbt/util/misc/development.rb +12 -11
  78. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  79. data/lib/rbbt/util/misc/format.rb +2 -230
  80. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  81. data/lib/rbbt/util/misc/inspect.rb +2 -476
  82. data/lib/rbbt/util/misc/lock.rb +109 -106
  83. data/lib/rbbt/util/misc/omics.rb +9 -1
  84. data/lib/rbbt/util/misc/pipes.rb +765 -793
  85. data/lib/rbbt/util/misc/refactor.rb +20 -0
  86. data/lib/rbbt/util/misc/ssw.rb +27 -17
  87. data/lib/rbbt/util/misc/system.rb +0 -15
  88. data/lib/rbbt/util/misc.rb +39 -20
  89. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  90. data/lib/rbbt/util/named_array.rb +3 -220
  91. data/lib/rbbt/util/open/refactor.rb +7 -0
  92. data/lib/rbbt/util/open.rb +3 -857
  93. data/lib/rbbt/util/procpath.rb +6 -6
  94. data/lib/rbbt/util/python/paths.rb +27 -0
  95. data/lib/rbbt/util/python/run.rb +115 -0
  96. data/lib/rbbt/util/python/script.rb +110 -0
  97. data/lib/rbbt/util/python/util.rb +3 -3
  98. data/lib/rbbt/util/python.rb +22 -81
  99. data/lib/rbbt/util/semaphore.rb +152 -148
  100. data/lib/rbbt/util/simpleopt.rb +9 -8
  101. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  102. data/lib/rbbt/util/ssh.rb +122 -118
  103. data/lib/rbbt/util/tar.rb +117 -115
  104. data/lib/rbbt/util/tmpfile.rb +69 -67
  105. data/lib/rbbt/util/version.rb +2 -0
  106. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  107. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  108. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  109. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  110. data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
  111. data/lib/rbbt/workflow/refactor.rb +153 -0
  112. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  113. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  114. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  115. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  116. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  117. data/lib/rbbt/workflow/step/run.rb +766 -766
  118. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  119. data/lib/rbbt/workflow/step.rb +2 -362
  120. data/lib/rbbt/workflow/task.rb +118 -118
  121. data/lib/rbbt/workflow/usage.rb +289 -287
  122. data/lib/rbbt/workflow/util/archive.rb +6 -5
  123. data/lib/rbbt/workflow/util/data.rb +1 -1
  124. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  125. data/lib/rbbt/workflow/util/trace.rb +79 -44
  126. data/lib/rbbt/workflow.rb +4 -882
  127. data/lib/rbbt-util.rb +21 -13
  128. data/lib/rbbt.rb +16 -3
  129. data/python/rbbt/__init__.py +19 -1
  130. data/share/Rlib/plot.R +37 -37
  131. data/share/Rlib/svg.R +22 -5
  132. data/share/install/software/lib/install_helpers +1 -1
  133. data/share/rbbt_commands/hpc/list +2 -3
  134. data/share/rbbt_commands/hpc/orchestrate +4 -4
  135. data/share/rbbt_commands/hpc/tail +2 -0
  136. data/share/rbbt_commands/hpc/task +10 -7
  137. data/share/rbbt_commands/lsf/list +2 -3
  138. data/share/rbbt_commands/lsf/orchestrate +4 -4
  139. data/share/rbbt_commands/lsf/tail +2 -0
  140. data/share/rbbt_commands/lsf/task +10 -7
  141. data/share/rbbt_commands/migrate +1 -1
  142. data/share/rbbt_commands/pbs/list +2 -3
  143. data/share/rbbt_commands/pbs/orchestrate +4 -4
  144. data/share/rbbt_commands/pbs/tail +2 -0
  145. data/share/rbbt_commands/pbs/task +10 -7
  146. data/share/rbbt_commands/resource/produce +8 -1
  147. data/share/rbbt_commands/slurm/list +2 -3
  148. data/share/rbbt_commands/slurm/orchestrate +4 -4
  149. data/share/rbbt_commands/slurm/tail +2 -0
  150. data/share/rbbt_commands/slurm/task +10 -7
  151. data/share/rbbt_commands/system/clean +5 -5
  152. data/share/rbbt_commands/system/status +5 -5
  153. data/share/rbbt_commands/tsv/get +2 -3
  154. data/share/rbbt_commands/tsv/info +10 -13
  155. data/share/rbbt_commands/tsv/keys +18 -14
  156. data/share/rbbt_commands/tsv/slice +2 -2
  157. data/share/rbbt_commands/tsv/transpose +6 -2
  158. data/share/rbbt_commands/workflow/info +20 -24
  159. data/share/rbbt_commands/workflow/list +1 -1
  160. data/share/rbbt_commands/workflow/prov +20 -13
  161. data/share/rbbt_commands/workflow/server +11 -1
  162. data/share/rbbt_commands/workflow/task +76 -71
  163. data/share/rbbt_commands/workflow/write_info +26 -9
  164. data/share/software/opt/ssw/ssw.c +861 -0
  165. data/share/software/opt/ssw/ssw.h +130 -0
  166. data/share/workflow_config.ru +3 -3
  167. metadata +40 -2
data/lib/rbbt/util/tar.rb CHANGED
@@ -1,117 +1,119 @@
1
- require 'rubygems/package'
2
- require 'zlib'
3
- require 'fileutils'
4
-
5
- # SOURCE: https://gist.github.com/sinisterchipmunk/1335041
6
- # Adapted for Rbbt
7
-
8
- module Misc
9
- # Creates a tar file in memory recursively
10
- # from the given path.
11
- #
12
- # Returns a StringIO whose underlying String
13
- # is the contents of the tar file.
14
- def self.tar(path, tarfile = nil)
15
- tarfile ||= StringIO.new("")
16
-
17
- Gem::Package::TarWriter.new(tarfile) do |tar|
18
- Dir[File.join(path, "**/*")].each do |file|
19
- mode = File.stat(file).mode
20
- relative_file = file.sub /^#{Regexp::escape path}\/?/, ''
21
-
22
- if File.directory?(file)
23
- tar.mkdir relative_file, mode
24
- else
25
- tar.add_file relative_file, mode do |tf|
26
- File.open(file, "rb") { |f| tf.write f.read }
27
- end
28
- end
29
- end
30
- end
31
-
32
- tarfile.rewind
33
-
34
- tarfile
35
- end
36
-
37
- def self.tarize(path, gz = nil)
38
- gz ||= StringIO.new('wb')
39
-
40
- tar = Misc.in_dir(path) do self.tar('.') end
41
-
42
- tar.rewind
43
-
44
- string = tar.string
45
-
46
- z = Zlib::GzipWriter.new(gz)
47
- z.write string
48
- z.close
49
-
50
- gz.reopen('read')
51
- gz.rewind
52
-
53
-
54
- gz
55
- end
56
-
57
- def self.tarize(path)
58
- Misc.in_dir(path) do
59
- CMD.cmd("tar cvfz - '.'", :pipe => true)
60
- end
61
- end
62
-
63
- # gzips the underlying string in the given StringIO,
64
- # returning a new StringIO representing the
65
- # compressed file.
66
- def self.gzip(tarfile)
67
- gz = StringIO.new("")
68
- z = Zlib::GzipWriter.new(gz)
69
- z.write tarfile.string
70
- z.close # this is necessary!
71
-
72
- # z was closed to write the gzip footer, so
73
- # now we need a new StringIO
74
- StringIO.new gz.string
75
- end
76
-
77
- # un-gzips the given IO, returning the
78
- # decompressed version as a StringIO
79
- def self.ungzip(tarfile)
80
- z = Zlib::GzipReader.new(tarfile)
81
- unzipped = StringIO.new(z.read)
82
- z.close
83
- unzipped
84
- end
85
-
86
- def self._untar_cmd(io, destination)
87
- FileUtils.mkdir_p destination unless File.exist? destination
88
- CMD.cmd_log("tar xvf - -C '#{destination}'", :in => io)
89
- nil
90
- end
91
-
92
- # untars the given IO into the specified
93
- # directory
94
- def self.untar(io, destination)
95
- io = io.find if Path === io
96
- if String === io and File.exist?(io)
97
- Open.open(io) do |f|
98
- untar(f, destination)
99
- end
100
- else
101
- return _untar_cmd(io, destination)
102
- end
103
- end
104
- end
105
-
106
-
107
- ### Usage Example: ###
108
- #
109
- # include Util::Tar
1
+ require_relative '../refactor'
2
+ Rbbt.require_instead 'scout/misc/filesystem'
3
+ #require 'rubygems/package'
4
+ #require 'zlib'
5
+ #require 'fileutils'
110
6
  #
111
- # io = tar("./Desktop") # io is a TAR of files
112
- # gz = gzip(io) # gz is a TGZ
113
- #
114
- # io = ungzip(gz) # io is a TAR
115
- # untar(io, "./untarred") # files are untarred
7
+ ## SOURCE: https://gist.github.com/sinisterchipmunk/1335041
8
+ ## Adapted for Rbbt
9
+ #
10
+ #module Misc
11
+ # # Creates a tar file in memory recursively
12
+ # # from the given path.
13
+ # #
14
+ # # Returns a StringIO whose underlying String
15
+ # # is the contents of the tar file.
16
+ # def self.tar(path, tarfile = nil)
17
+ # tarfile ||= StringIO.new("")
18
+ #
19
+ # Gem::Package::TarWriter.new(tarfile) do |tar|
20
+ # Dir[File.join(path, "**/*")].each do |file|
21
+ # mode = File.stat(file).mode
22
+ # relative_file = file.sub /^#{Regexp::escape path}\/?/, ''
23
+ #
24
+ # if File.directory?(file)
25
+ # tar.mkdir relative_file, mode
26
+ # else
27
+ # tar.add_file relative_file, mode do |tf|
28
+ # File.open(file, "rb") { |f| tf.write f.read }
29
+ # end
30
+ # end
31
+ # end
32
+ # end
33
+ #
34
+ # tarfile.rewind
35
+ #
36
+ # tarfile
37
+ # end
38
+ #
39
+ # def self.tarize(path, gz = nil)
40
+ # gz ||= StringIO.new('wb')
41
+ #
42
+ # tar = Misc.in_dir(path) do self.tar('.') end
43
+ #
44
+ # tar.rewind
45
+ #
46
+ # string = tar.string
47
+ #
48
+ # z = Zlib::GzipWriter.new(gz)
49
+ # z.write string
50
+ # z.close
51
+ #
52
+ # gz.reopen('read')
53
+ # gz.rewind
54
+ #
55
+ #
56
+ # gz
57
+ # end
58
+ #
59
+ # def self.tarize(path)
60
+ # Misc.in_dir(path) do
61
+ # CMD.cmd("tar cvfz - '.'", :pipe => true)
62
+ # end
63
+ # end
64
+ #
65
+ # # gzips the underlying string in the given StringIO,
66
+ # # returning a new StringIO representing the
67
+ # # compressed file.
68
+ # def self.gzip(tarfile)
69
+ # gz = StringIO.new("")
70
+ # z = Zlib::GzipWriter.new(gz)
71
+ # z.write tarfile.string
72
+ # z.close # this is necessary!
73
+ #
74
+ # # z was closed to write the gzip footer, so
75
+ # # now we need a new StringIO
76
+ # StringIO.new gz.string
77
+ # end
78
+ #
79
+ # # un-gzips the given IO, returning the
80
+ # # decompressed version as a StringIO
81
+ # def self.ungzip(tarfile)
82
+ # z = Zlib::GzipReader.new(tarfile)
83
+ # unzipped = StringIO.new(z.read)
84
+ # z.close
85
+ # unzipped
86
+ # end
87
+ #
88
+ # def self._untar_cmd(io, destination)
89
+ # FileUtils.mkdir_p destination unless File.exist? destination
90
+ # CMD.cmd_log("tar xvf - -C '#{destination}'", :in => io)
91
+ # nil
92
+ # end
93
+ #
94
+ # # untars the given IO into the specified
95
+ # # directory
96
+ # def self.untar(io, destination)
97
+ # io = io.find if Path === io
98
+ # if String === io and File.exist?(io)
99
+ # Open.open(io) do |f|
100
+ # untar(f, destination)
101
+ # end
102
+ # else
103
+ # return _untar_cmd(io, destination)
104
+ # end
105
+ # end
106
+ #end
107
+ #
108
+ #
109
+ #### Usage Example: ###
110
+ ##
111
+ ## include Util::Tar
112
+ ##
113
+ ## io = tar("./Desktop") # io is a TAR of files
114
+ ## gz = gzip(io) # gz is a TGZ
115
+ ##
116
+ ## io = ungzip(gz) # io is a TAR
117
+ ## untar(io, "./untarred") # files are untarred
118
+ ##
116
119
  #
117
-
@@ -1,67 +1,69 @@
1
- require 'fileutils'
2
-
3
- module TmpFile
4
-
5
- TMPDIR = "/tmp/#{ENV['USER']}/tmpfiles"
6
- FileUtils.mkdir_p TMPDIR unless File.exist? TMPDIR
7
-
8
- def self.tmpdir=(tmpdir)
9
- TMPDIR.replace tmpdir
10
- FileUtils.mkdir_p TMPDIR unless File.exist? TMPDIR
11
- end
12
-
13
- def self.tmpdir
14
- TMPDIR
15
- end
16
-
17
-
18
- # Creates a random file name, with the given suffix and a random number
19
- # up to +max+
20
- def self.random_name(s = "tmp-", max = 1_000_000_000)
21
- n = rand(max)
22
- s + n.to_s
23
- end
24
-
25
- # Creates a random filename in the temporary directory
26
- def self.tmp_file(s = "tmp-", max=1_000_000_000, dir = TMPDIR)
27
- File.expand_path(File.join(dir, random_name(s, max)))
28
- end
29
-
30
- def self.with_file(content = nil, erase = true, options = {})
31
- options, content, erase = content, nil, true if Hash === content
32
- options, erase = erase, true if Hash === erase
33
-
34
- prefix = options[:prefix] || "tmp-"
35
- tmpdir = options[:tmpdir] || TMPDIR
36
- max = options[:max] || 1_000_000_000
37
- tmpfile = tmp_file prefix, max, tmpdir
38
- if options[:extension]
39
- tmpfile += ".#{options[:extension]}"
40
- end
41
-
42
- if IO === content
43
- Misc.consume_stream(content, false, tmpfile)
44
- else
45
- File.open(tmpfile, 'w') do |f| f.write content end if content != nil
46
- end
47
-
48
- result = yield(tmpfile)
49
-
50
- FileUtils.rm_rf tmpfile if File.exist?(tmpfile) and erase
51
-
52
- result
53
- end
54
-
55
- def self.with_dir(erase = true, options = {})
56
- prefix = options[:prefix] || "tmpdir-"
57
- tmpdir = tmp_file prefix
58
-
59
- FileUtils.mkdir_p tmpdir
60
-
61
- result = yield(tmpdir)
62
-
63
- FileUtils.rm_rf tmpdir if File.exist?(tmpdir) and erase
64
-
65
- result
66
- end
67
- end
1
+ require_relative '../refactor'
2
+ Rbbt.require_instead 'scout/tmpfile'
3
+ #require 'fileutils'
4
+ #
5
+ #module TmpFile
6
+ #
7
+ # TMPDIR = "/tmp/#{ENV['USER']}/tmpfiles"
8
+ # FileUtils.mkdir_p TMPDIR unless File.exist? TMPDIR
9
+ #
10
+ # def self.tmpdir=(tmpdir)
11
+ # TMPDIR.replace tmpdir
12
+ # FileUtils.mkdir_p TMPDIR unless File.exist? TMPDIR
13
+ # end
14
+ #
15
+ # def self.tmpdir
16
+ # TMPDIR
17
+ # end
18
+ #
19
+ #
20
+ # # Creates a random file name, with the given suffix and a random number
21
+ # # up to +max+
22
+ # def self.random_name(s = "tmp-", max = 1_000_000_000)
23
+ # n = rand(max)
24
+ # s + n.to_s
25
+ # end
26
+ #
27
+ # # Creates a random filename in the temporary directory
28
+ # def self.tmp_file(s = "tmp-", max=1_000_000_000, dir = TMPDIR)
29
+ # File.expand_path(File.join(dir, random_name(s, max)))
30
+ # end
31
+ #
32
+ # def self.with_file(content = nil, erase = true, options = {})
33
+ # options, content, erase = content, nil, true if Hash === content
34
+ # options, erase = erase, true if Hash === erase
35
+ #
36
+ # prefix = options[:prefix] || "tmp-"
37
+ # tmpdir = options[:tmpdir] || TMPDIR
38
+ # max = options[:max] || 1_000_000_000
39
+ # tmpfile = tmp_file prefix, max, tmpdir
40
+ # if options[:extension]
41
+ # tmpfile += ".#{options[:extension]}"
42
+ # end
43
+ #
44
+ # if IO === content
45
+ # Misc.consume_stream(content, false, tmpfile)
46
+ # else
47
+ # File.open(tmpfile, 'w') do |f| f.write content end if content != nil
48
+ # end
49
+ #
50
+ # result = yield(tmpfile)
51
+ #
52
+ # FileUtils.rm_rf tmpfile if File.exist?(tmpfile) and erase
53
+ #
54
+ # result
55
+ # end
56
+ #
57
+ # def self.with_dir(erase = true, options = {})
58
+ # prefix = options[:prefix] || "tmpdir-"
59
+ # tmpdir = tmp_file prefix
60
+ #
61
+ # FileUtils.mkdir_p tmpdir
62
+ #
63
+ # result = yield(tmpdir)
64
+ #
65
+ # FileUtils.rm_rf tmpdir if File.exist?(tmpdir) and erase
66
+ #
67
+ # result
68
+ # end
69
+ #end
@@ -1,3 +1,5 @@
1
+ require 'scout/path'
2
+ require 'scout/indiferent_hash'
1
3
  module Rbbt
2
4
  VERSIONS = IndiferentHash.setup({})
3
5
 
@@ -0,0 +1,11 @@
1
+ module TSV
2
+ annotation :entity_options, :entity_templates
3
+
4
+ def entity_options
5
+ @entity_options ||= {}
6
+ end
7
+
8
+ def entity_templates
9
+ @entity_templates ||= {}
10
+ end
11
+ end
@@ -0,0 +1,66 @@
1
+ module Workflow
2
+
3
+ annotation :asynchronous_exports, :synchronous_exports, :exec_exports, :stream_exports
4
+
5
+ def asynchronous_exports
6
+ @asynchronous_exports ||= []
7
+ end
8
+
9
+ def synchronous_exports
10
+ @synchronous_exports ||= []
11
+ end
12
+
13
+ def exec_exports
14
+ @exec_exports ||= []
15
+ end
16
+
17
+ def stream_exports
18
+ @exec_exports ||= []
19
+ end
20
+
21
+
22
+ def all_exports
23
+ asynchronous_exports + synchronous_exports + exec_exports + stream_exports
24
+ end
25
+
26
+ alias task_exports all_exports
27
+
28
+ def unexport(*names)
29
+ names = names.collect{|n| n.to_s} + names.collect{|n| n.to_sym}
30
+ names.uniq!
31
+ exec_exports.replace exec_exports - names if exec_exports
32
+ synchronous_exports.replace synchronous_exports - names if synchronous_exports
33
+ asynchronous_exports.replace asynchronous_exports - names if asynchronous_exports
34
+ stream_exports.replace stream_exports - names if stream_exports
35
+ end
36
+
37
+ def export_exec(*names)
38
+ unexport *names
39
+ exec_exports.concat names
40
+ exec_exports.uniq!
41
+ exec_exports
42
+ end
43
+
44
+ def export_synchronous(*names)
45
+ unexport *names
46
+ synchronous_exports.concat names
47
+ synchronous_exports.uniq!
48
+ synchronous_exports
49
+ end
50
+
51
+ def export_asynchronous(*names)
52
+ unexport *names
53
+ asynchronous_exports.concat names
54
+ asynchronous_exports.uniq!
55
+ asynchronous_exports
56
+ end
57
+
58
+ def export_stream(*names)
59
+ unexport *names
60
+ stream_exports.concat names
61
+ stream_exports.uniq!
62
+ stream_exports
63
+ end
64
+
65
+ alias export export_asynchronous
66
+ end
@@ -0,0 +1,24 @@
1
+ class Step
2
+ def self.save_inputs(inputs, input_types, dir)
3
+ inputs.collect do |name,value|
4
+ next if value.nil?
5
+ type = input_types[name]
6
+ type = type.to_s if type
7
+
8
+ Task.save_input(dir, name, type, value)
9
+ name
10
+ end.compact.any?
11
+ end
12
+ end
13
+
14
+ module Workflow
15
+ def self.load_inputs(dir, names, types)
16
+ inputs = IndiferentHash.setup({})
17
+ names.zip(types) do |name, type|
18
+ filename = File.join(directory, name.to_s)
19
+ value = Task.load_input_from_file(filename, name, type)
20
+ inputs[name] = value unless value.nil?
21
+ end
22
+ inputs
23
+ end
24
+ end
@@ -0,0 +1,64 @@
1
+ module Workflow
2
+ def rec_inputs(task_name)
3
+ tasks[task_name].recursive_inputs.collect{|name, _| name }
4
+ end
5
+
6
+ def rec_input_types(task_name)
7
+ tasks[task_name].recursive_inputs.inject({}) do |acc,l|
8
+ name, type, desc, default, options = l
9
+ acc.merge!(name => type) unless acc.include?(name)
10
+ acc
11
+ end
12
+ end
13
+
14
+
15
+ def rec_input_descriptions(task_name)
16
+ tasks[task_name].recursive_inputs.inject({}) do |acc,l|
17
+ name, type, desc, default, options = l
18
+ acc.merge!(name => desc) unless desc.nil? || acc.include?(name)
19
+ acc
20
+ end
21
+ end
22
+
23
+ def rec_input_defaults(task_name)
24
+ tasks[task_name].recursive_inputs.inject({}) do |acc,l|
25
+ name, type, desc, default, options = l
26
+ acc.merge!(name => default) unless default.nil? || acc.include?(name)
27
+ acc
28
+ end
29
+ end
30
+
31
+ def rec_input_options(task_name)
32
+ tasks[task_name].recursive_inputs.inject({}) do |acc,l|
33
+ name, type, desc, default, options = l
34
+ acc.merge!(name => options) unless options.nil? unless acc.include?(name)
35
+ acc
36
+ end
37
+ end
38
+
39
+
40
+ def rec_input_use(task_name)
41
+ input_use = {}
42
+ task = self.tasks[task_name]
43
+ task.inputs.each do |name,_|
44
+ input_use[name] ||= {}
45
+ input_use[name][self] ||= []
46
+ input_use[name][self] << task_name
47
+ end
48
+
49
+ task.deps.inject(input_use) do |acc,p|
50
+ workflow, task_name = p
51
+ next if task_name.nil?
52
+ workflow.rec_input_use(task_name).each do |name,uses|
53
+ acc[name] ||= {}
54
+ uses.each do |workflow, task_names|
55
+ acc[name][workflow] ||= []
56
+ acc[name][workflow].concat(task_names)
57
+ end
58
+ end
59
+ acc
60
+ end if task.deps
61
+
62
+ input_use
63
+ end
64
+ end
@@ -0,0 +1,65 @@
1
+ require_relative 'export'
2
+ require_relative 'recursive'
3
+ module Workflow
4
+ def task_info(name)
5
+ name = name.to_sym
6
+ task = tasks[name]
7
+ raise "No '#{name}' task in '#{self.to_s}' Workflow" if task.nil?
8
+ id = File.join(self.to_s, name.to_s)
9
+ @task_info ||= {}
10
+ @task_info[id] ||= begin
11
+ description = task.description
12
+ result_description = task.result_description
13
+ result_type = task.result_type
14
+
15
+ inputs = rec_inputs(name).uniq
16
+ input_types = rec_input_types(name)
17
+ input_descriptions = rec_input_descriptions(name)
18
+ input_use = rec_input_use(name)
19
+ input_defaults = rec_input_defaults(name)
20
+ input_options = rec_input_options(name)
21
+ extension = task.extension
22
+ export = case
23
+ when (synchronous_exports.include?(name.to_sym) or synchronous_exports.include?(name.to_s))
24
+ :synchronous
25
+ when (asynchronous_exports.include?(name.to_sym) or asynchronous_exports.include?(name.to_s))
26
+ :asynchronous
27
+ when (exec_exports.include?(name.to_sym) or exec_exports.include?(name.to_s))
28
+ :exec
29
+ when (stream_exports.include?(name.to_sym) or stream_exports.include?(name.to_s))
30
+ :stream
31
+ else
32
+ :none
33
+ end
34
+
35
+ dependencies = tasks[name].deps
36
+ { :id => id,
37
+ :description => description,
38
+ :export => export,
39
+ :inputs => inputs,
40
+ :input_types => input_types,
41
+ :input_descriptions => input_descriptions,
42
+ :input_defaults => input_defaults,
43
+ :input_options => input_options,
44
+ :input_use => input_use,
45
+ :result_type => result_type,
46
+ :result_description => result_description,
47
+ :dependencies => dependencies,
48
+ :extension => extension
49
+ }
50
+ end
51
+ end
52
+ end
53
+
54
+ module Task
55
+ def result_description
56
+ ""
57
+ end
58
+
59
+ def result_type
60
+ @returns
61
+ end
62
+
63
+ end
64
+
65
+