rbbt-util 5.44.1 → 6.0.4

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.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/bin/rbbt +67 -90
  4. data/bin/rbbt_exec.rb +2 -2
  5. data/etc/app.d/base.rb +2 -2
  6. data/etc/app.d/semaphores.rb +3 -3
  7. data/lib/rbbt/annotations/annotated_array.rb +207 -207
  8. data/lib/rbbt/annotations/refactor.rb +27 -0
  9. data/lib/rbbt/annotations/util.rb +282 -282
  10. data/lib/rbbt/annotations.rb +343 -320
  11. data/lib/rbbt/association/database.rb +200 -225
  12. data/lib/rbbt/association/index.rb +294 -291
  13. data/lib/rbbt/association/item.rb +227 -227
  14. data/lib/rbbt/association/open.rb +35 -34
  15. data/lib/rbbt/association/util.rb +0 -169
  16. data/lib/rbbt/association.rb +2 -4
  17. data/lib/rbbt/entity/identifiers.rb +119 -118
  18. data/lib/rbbt/entity/refactor.rb +12 -0
  19. data/lib/rbbt/entity.rb +319 -315
  20. data/lib/rbbt/hpc/batch.rb +72 -53
  21. data/lib/rbbt/hpc/lsf.rb +2 -2
  22. data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
  23. data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
  24. data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
  25. data/lib/rbbt/hpc/orchestrate.rb +19 -13
  26. data/lib/rbbt/hpc/slurm.rb +18 -18
  27. data/lib/rbbt/knowledge_base/entity.rb +13 -5
  28. data/lib/rbbt/knowledge_base/query.rb +2 -2
  29. data/lib/rbbt/knowledge_base/registry.rb +32 -31
  30. data/lib/rbbt/knowledge_base/traverse.rb +1 -1
  31. data/lib/rbbt/knowledge_base.rb +1 -1
  32. data/lib/rbbt/monitor.rb +36 -25
  33. data/lib/rbbt/persist/refactor.rb +166 -0
  34. data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
  35. data/lib/rbbt/persist/tsv.rb +187 -185
  36. data/lib/rbbt/persist.rb +556 -551
  37. data/lib/rbbt/refactor.rb +20 -0
  38. data/lib/rbbt/resource/path/refactor.rb +178 -0
  39. data/lib/rbbt/resource/path.rb +317 -497
  40. data/lib/rbbt/resource/util.rb +0 -48
  41. data/lib/rbbt/resource.rb +3 -390
  42. data/lib/rbbt/tsv/accessor.rb +2 -838
  43. data/lib/rbbt/tsv/attach.rb +303 -299
  44. data/lib/rbbt/tsv/change_id.rb +244 -245
  45. data/lib/rbbt/tsv/csv.rb +87 -85
  46. data/lib/rbbt/tsv/dumper.rb +2 -100
  47. data/lib/rbbt/tsv/excel.rb +26 -24
  48. data/lib/rbbt/tsv/field_index.rb +4 -1
  49. data/lib/rbbt/tsv/filter.rb +3 -2
  50. data/lib/rbbt/tsv/index.rb +2 -284
  51. data/lib/rbbt/tsv/manipulate.rb +750 -747
  52. data/lib/rbbt/tsv/marshal.rb +3 -3
  53. data/lib/rbbt/tsv/matrix.rb +2 -2
  54. data/lib/rbbt/tsv/parallel/through.rb +2 -1
  55. data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
  56. data/lib/rbbt/tsv/parser.rb +678 -678
  57. data/lib/rbbt/tsv/refactor.rb +195 -0
  58. data/lib/rbbt/tsv/stream.rb +253 -251
  59. data/lib/rbbt/tsv/util.rb +420 -420
  60. data/lib/rbbt/tsv.rb +210 -208
  61. data/lib/rbbt/util/R/eval.rb +4 -4
  62. data/lib/rbbt/util/R/plot.rb +62 -166
  63. data/lib/rbbt/util/R.rb +21 -18
  64. data/lib/rbbt/util/cmd.rb +2 -318
  65. data/lib/rbbt/util/color.rb +269 -269
  66. data/lib/rbbt/util/colorize.rb +89 -89
  67. data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
  68. data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
  69. data/lib/rbbt/util/concurrency/processes.rb +389 -386
  70. data/lib/rbbt/util/config.rb +169 -167
  71. data/lib/rbbt/util/filecache.rb +1 -1
  72. data/lib/rbbt/util/iruby.rb +20 -0
  73. data/lib/rbbt/util/log/progress/report.rb +241 -241
  74. data/lib/rbbt/util/log/progress/util.rb +99 -99
  75. data/lib/rbbt/util/log/progress.rb +102 -102
  76. data/lib/rbbt/util/log/refactor.rb +49 -0
  77. data/lib/rbbt/util/log.rb +486 -532
  78. data/lib/rbbt/util/migrate.rb +2 -2
  79. data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
  80. data/lib/rbbt/util/misc/development.rb +12 -11
  81. data/lib/rbbt/util/misc/exceptions.rb +117 -112
  82. data/lib/rbbt/util/misc/format.rb +2 -230
  83. data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
  84. data/lib/rbbt/util/misc/inspect.rb +2 -476
  85. data/lib/rbbt/util/misc/lock.rb +109 -106
  86. data/lib/rbbt/util/misc/omics.rb +9 -1
  87. data/lib/rbbt/util/misc/pipes.rb +765 -793
  88. data/lib/rbbt/util/misc/refactor.rb +20 -0
  89. data/lib/rbbt/util/misc/ssw.rb +27 -17
  90. data/lib/rbbt/util/misc/system.rb +92 -105
  91. data/lib/rbbt/util/misc.rb +39 -20
  92. data/lib/rbbt/util/named_array/refactor.rb +4 -0
  93. data/lib/rbbt/util/named_array.rb +3 -220
  94. data/lib/rbbt/util/open/refactor.rb +7 -0
  95. data/lib/rbbt/util/open.rb +3 -857
  96. data/lib/rbbt/util/procpath.rb +6 -6
  97. data/lib/rbbt/util/python/paths.rb +27 -0
  98. data/lib/rbbt/util/python/run.rb +115 -0
  99. data/lib/rbbt/util/python/script.rb +110 -0
  100. data/lib/rbbt/util/python/util.rb +3 -3
  101. data/lib/rbbt/util/python.rb +22 -81
  102. data/lib/rbbt/util/semaphore.rb +152 -148
  103. data/lib/rbbt/util/simpleopt.rb +9 -8
  104. data/lib/rbbt/util/ssh/refactor.rb +19 -0
  105. data/lib/rbbt/util/ssh.rb +122 -118
  106. data/lib/rbbt/util/tar.rb +117 -115
  107. data/lib/rbbt/util/tmpfile.rb +69 -67
  108. data/lib/rbbt/util/version.rb +2 -0
  109. data/lib/rbbt/workflow/refactor/entity.rb +11 -0
  110. data/lib/rbbt/workflow/refactor/export.rb +66 -0
  111. data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
  112. data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
  113. data/lib/rbbt/workflow/refactor/task_info.rb +66 -0
  114. data/lib/rbbt/workflow/refactor.rb +150 -0
  115. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +1 -2
  116. data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
  117. data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
  118. data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
  119. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
  120. data/lib/rbbt/workflow/remote_workflow.rb +6 -1
  121. data/lib/rbbt/workflow/step/run.rb +766 -766
  122. data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
  123. data/lib/rbbt/workflow/step.rb +2 -362
  124. data/lib/rbbt/workflow/task.rb +118 -118
  125. data/lib/rbbt/workflow/usage.rb +289 -287
  126. data/lib/rbbt/workflow/util/archive.rb +6 -5
  127. data/lib/rbbt/workflow/util/data.rb +1 -1
  128. data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
  129. data/lib/rbbt/workflow/util/trace.rb +79 -44
  130. data/lib/rbbt/workflow.rb +4 -882
  131. data/lib/rbbt-util.rb +21 -13
  132. data/lib/rbbt.rb +16 -3
  133. data/python/rbbt/__init__.py +96 -4
  134. data/python/rbbt/workflow/remote.py +104 -0
  135. data/python/rbbt/workflow.py +64 -0
  136. data/python/test.py +10 -0
  137. data/share/Rlib/plot.R +37 -37
  138. data/share/Rlib/svg.R +22 -5
  139. data/share/install/software/lib/install_helpers +1 -1
  140. data/share/rbbt_commands/hpc/list +2 -3
  141. data/share/rbbt_commands/hpc/orchestrate +4 -4
  142. data/share/rbbt_commands/hpc/tail +2 -0
  143. data/share/rbbt_commands/hpc/task +10 -7
  144. data/share/rbbt_commands/lsf/list +2 -3
  145. data/share/rbbt_commands/lsf/orchestrate +4 -4
  146. data/share/rbbt_commands/lsf/tail +2 -0
  147. data/share/rbbt_commands/lsf/task +10 -7
  148. data/share/rbbt_commands/migrate +1 -1
  149. data/share/rbbt_commands/pbs/list +2 -3
  150. data/share/rbbt_commands/pbs/orchestrate +4 -4
  151. data/share/rbbt_commands/pbs/tail +2 -0
  152. data/share/rbbt_commands/pbs/task +10 -7
  153. data/share/rbbt_commands/resource/produce +8 -1
  154. data/share/rbbt_commands/slurm/list +2 -3
  155. data/share/rbbt_commands/slurm/orchestrate +4 -4
  156. data/share/rbbt_commands/slurm/tail +2 -0
  157. data/share/rbbt_commands/slurm/task +10 -7
  158. data/share/rbbt_commands/system/clean +5 -5
  159. data/share/rbbt_commands/system/status +5 -5
  160. data/share/rbbt_commands/tsv/get +2 -3
  161. data/share/rbbt_commands/tsv/info +10 -13
  162. data/share/rbbt_commands/tsv/keys +18 -14
  163. data/share/rbbt_commands/tsv/slice +2 -2
  164. data/share/rbbt_commands/tsv/transpose +6 -2
  165. data/share/rbbt_commands/workflow/info +20 -24
  166. data/share/rbbt_commands/workflow/list +1 -1
  167. data/share/rbbt_commands/workflow/prov +20 -13
  168. data/share/rbbt_commands/workflow/retry +43 -0
  169. data/share/rbbt_commands/workflow/server +12 -2
  170. data/share/rbbt_commands/workflow/task +80 -73
  171. data/share/rbbt_commands/workflow/write_info +26 -9
  172. data/share/software/opt/ssw/ssw.c +861 -0
  173. data/share/software/opt/ssw/ssw.h +130 -0
  174. data/share/workflow_config.ru +3 -3
  175. metadata +45 -6
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,66 @@
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
+ # returns = task.returns
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
+ # :returns => returns,
46
+ # #:result_type => result_type,
47
+ # #:result_description => result_description,
48
+ # :dependencies => dependencies,
49
+ # :extension => extension
50
+ # }
51
+ # end
52
+ # end
53
+ #end
54
+ #
55
+ #module Task
56
+ # def result_description
57
+ # ""
58
+ # end
59
+ #
60
+ # def result_type
61
+ # @returns
62
+ # end
63
+ #
64
+ #end
65
+ #
66
+ #