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
@@ -1,254 +1,254 @@
1
- module Workflow
2
-
3
- def self.load_inputs(dir, input_names, input_types)
4
- inputs = {}
5
- if File.exist?(dir) && ! File.directory?(dir)
6
- Log.debug "Loading inputs from #{dir}, not a directory trying as tar.gz"
7
- tarfile = dir
8
- digest = CMD.cmd("md5sum '#{tarfile}'").read.split(" ").first
9
- tmpdir = Rbbt.tmp.input_bundle[digest].find
10
- Misc.untar(tarfile, tmpdir) unless File.exist? tmpdir
11
- files = tmpdir.glob("*")
12
- if files.length == 1 && File.directory?(files.first)
13
- tmpdir = files.first
14
- end
15
- load_inputs(tmpdir, input_names, input_types)
16
- else
17
- dir = Path.setup(dir.dup)
18
- input_names.each do |input|
19
- file = dir[input].find
20
- file = dir.glob(input.to_s + ".*").reject{|f| f =~ /\.md5$/}.first if file.nil? or not (File.symlink?(file) || file.exists?)
21
- Log.debug "Trying #{ input }: #{file}"
22
- next unless file and (File.symlink?(file) || file.exists?)
23
-
24
- type = orig_type = input_types[input]
25
-
26
- type = :io if file.split(".").last == 'as_io'
27
-
28
- type = :io_array if file.split(".").last == 'as_io_array'
29
-
30
- type = :step if file.split(".").last == 'as_step'
31
-
32
- type = :step_array if file.split(".").last == 'as_step_array'
33
-
34
- type = :number_array if file.split(".").last == 'as_number_array'
35
-
36
- type = :step_file if file.split(".").last == 'as_step_file'
37
-
38
- type = :step_file_array if file.split(".").last == 'as_step_file_array'
39
-
40
- type = :path if file.split(".").last == 'as_path'
41
-
42
- type = :path_array if file.split(".").last == 'as_path_array'
43
-
44
- type = :filename if file.split(".").last == 'as_filename'
45
-
46
- type = :nofile if file.split(".").last == 'nofile'
47
-
48
- case type
49
- when :nofile
50
- inputs[input.to_sym] = Open.realpath(file)
51
- when :path_array
52
- inputs[input.to_sym] = Open.read(file).strip.split("\n").collect{|p| Path.setup(p) }
53
- when :path
54
- inputs[input.to_sym] = Path.setup(Open.read(file).strip.split("\n").first)
55
- when :io
56
- inputs[input.to_sym] = Open.open(Open.realpath(file))
57
- when :io_array
58
- inputs[input.to_sym] = Open.realpath(file).split("\n").collect{|f| Open.open(f)}
59
- when :step_array
60
- steps = Open.read(file).strip.split("\n").collect{|path| Workflow.load_step(path) }
61
- inputs[input.to_sym] = steps
62
- when :number_array
63
- numbers = Open.read(file).strip.split("\n").collect{|num| num.to_f }
64
- inputs[input.to_sym] = numbers
65
- when :step
66
- steps = Open.read(file).strip.split("\n").collect{|path| Workflow.load_step(path) }
67
- inputs[input.to_sym] = steps.first
68
- when :step_file
69
- path = Open.read(file).strip
70
- step_path, relative = path.match(/(.*)\.files\/(.*)/).values_at 1, 2
71
- step = Step.new Path.setup(step_path).find
72
- path = step.file(relative)
73
- inputs[input.to_sym] = path
74
- when :step_file_array
75
- paths = Open.read(file).split("\n")
76
- paths.each do |path|
77
- path.extend Path
78
- step_path = path.match(/(.*)\.files/)[1]
79
- path.resource = Step.new step_path
80
- end
81
- inputs[input.to_sym] = paths
82
- when :file, :binary
83
- Log.debug "Pointing #{ input } to #{file}"
84
- if file =~ /\.yaml/
85
- inputs[input.to_sym] = Misc.load_yaml(file)
86
- else
87
- if File.symlink?(file)
88
- link_target = File.expand_path(File.readlink(file), File.dirname(file))
89
- inputs[input.to_sym] = link_target
90
- else
91
- inputs[input.to_sym] = Open.realpath(file)
92
- end
93
- end
94
- when :text
95
- Log.debug "Reading #{ input } from #{file}"
96
- inputs[input.to_sym] = Open.read(file)
97
- when :array
98
- Log.debug "Reading array #{ input } from #{file}"
99
- inputs[input.to_sym] = Open.read(file).split("\n")
100
- when :tsv
101
- Log.debug "Opening tsv #{ input } from #{file}"
102
- inputs[input.to_sym] = TSV.open(file)
103
- when :boolean
104
- case file.read.strip.downcase
105
- when 'true'
106
- inputs[input.to_sym] = true
107
- when 'false'
108
- inputs[input.to_sym] = false
109
- end
110
- when :integer
111
- inputs[input.to_sym] = file.read.to_i
112
- when :float
113
- inputs[input.to_sym] = file.read.to_f
114
- else
115
- Log.debug "Loading #{ input } from #{file}"
116
- inputs[input.to_sym] = file.read.strip
117
- end
118
-
119
- end
120
- inputs = IndiferentHash.setup(inputs)
121
-
122
- dir.glob("*#*").each do |od|
123
- name = File.basename(od)
124
- name.sub!(/\.as_path$/,'')
125
- value = Open.read(od)
126
- Log.debug "Loading override dependency #{ name } as #{value}"
127
- inputs[name] = value.chomp
128
- end
129
-
130
- inputs
131
- end
132
- end
133
-
134
- def task_inputs_from_directory(task_name, directory)
135
- task_info = self.task_info(task_name)
136
- Workflow.load_inputs(directory, task_info[:inputs], task_info[:input_types])
137
- end
138
-
139
- def job_for_directory_inputs(task_name, directory, jobname = nil)
140
- inputs = task_inputs_from_directory(task_name, directory)
141
- job(task_name, jobname, inputs)
142
- end
143
- end
144
-
145
- class Step
146
- def self.save_input(name, value, type, dir)
147
- path = File.join(dir, name.to_s)
148
-
149
- case value
150
- when Path
151
- if Step === value.resource
152
- step = value.resource
153
- value = File.join('var/jobs', step.workflow.to_s, step.short_path + '.files', Misc.path_relative_to(step.files_dir, value))
154
- path = path + '.as_step_file'
155
- else
156
- path = path + '.as_path'
157
- end
158
- when String
159
- if Misc.is_filename?(value, true)
160
- value = value.dup
161
- value.extend Path
162
- return save_input(name, value, type, dir)
163
- end
164
- when IO
165
- path = path + '.as_io'
166
- when Step
167
- value = value.path
168
- path = path + '.as_step'
169
- when Array
170
- case value.first
171
- when Path
172
- if Step === value.first.resource
173
- path = path + '.as_step_file_array'
174
- else
175
- path = path + '.as_path_array'
176
- end
177
- when String
178
- if Misc.is_filename?(value.first, true)
179
- path = path + '.as_path_array'
180
- end
181
- when IO
182
- path = path + '.as_io_array'
183
- when Step
184
- path = path + '.as_step_array'
185
- value = value.collect{|s| s.path }
186
- when Numeric
187
- path = path + '.as_number_array'
188
- end
189
-
190
- value = value * "\n"
191
- end
192
-
193
- Log.debug "Saving job input #{name} (#{type}) into #{path}"
194
-
195
- if IO === value && value.respond_to?(:filename) && value.filename
196
- Open.write(path, value.filename)
197
- elsif IO === value
198
- Open.write(path, value)
199
- else
200
- Open.write(path, value.to_s)
201
- end
202
- end
203
-
204
- def self.save_inputs(inputs, input_types, dir)
205
- inputs.each do |name,value|
206
- next if value.nil?
207
- type = input_types[name]
208
- type = type.to_s if type
209
-
210
- save_input(name, value, type, dir)
211
- end.any?
212
- end
213
-
214
- def self.save_job_inputs(job, dir, options = nil)
215
- options = IndiferentHash.setup options.dup if options
216
-
217
- task_name = job.original_task_name || job.task_name
218
- workflow = job.original_workflow || job.workflow
219
- workflow = Kernel.const_get workflow if String === workflow
220
- if workflow
221
- task_info = IndiferentHash.setup(workflow.task_info(task_name))
222
- input_types = IndiferentHash.setup(task_info[:input_types])
223
- input_options = IndiferentHash.setup(task_info[:input_options])
224
- task_inputs = IndiferentHash.setup(task_info[:inputs])
225
- input_defaults = IndiferentHash.setup(task_info[:input_defaults])
226
- else
227
- task_info = IndiferentHash.setup({})
228
- input_types = IndiferentHash.setup({})
229
- task_inputs = IndiferentHash.setup({})
230
- task_options = IndiferentHash.setup({})
231
- input_defaults = IndiferentHash.setup({})
232
- end
233
-
234
- inputs = IndiferentHash.setup({})
235
- real_inputs = job.real_inputs || job.info[:real_inputs]
236
- job.recursive_inputs.zip(job.recursive_inputs.fields).each do |value,name|
237
- next unless task_inputs.include? name.to_sym
238
- next unless real_inputs.include? name.to_sym
239
- next if options && ! options.include?(name)
240
- next if value.nil?
241
- next if input_defaults[name] == value
242
- inputs[name] = value
243
- end
244
-
245
- if options && options.include?('override_dependencies')
246
- inputs.merge!(:override_dependencies => open[:override_dependencies])
247
- input_types = IndiferentHash.setup(input_types.merge(:override_dependencies => :array))
248
- end
249
-
250
- save_inputs(inputs, input_types, dir)
251
-
252
- inputs.keys
253
- end
254
- end
1
+ #module Workflow
2
+ #
3
+ # def self.load_inputs(dir, input_names, input_types)
4
+ # inputs = {}
5
+ # if File.exist?(dir) && ! File.directory?(dir)
6
+ # Log.debug "Loading inputs from #{dir}, not a directory trying as tar.gz"
7
+ # tarfile = dir
8
+ # digest = CMD.cmd("md5sum '#{tarfile}'").read.split(" ").first
9
+ # tmpdir = Rbbt.tmp.input_bundle[digest].find
10
+ # Misc.untar(tarfile, tmpdir) unless File.exist? tmpdir
11
+ # files = tmpdir.glob("*")
12
+ # if files.length == 1 && File.directory?(files.first)
13
+ # tmpdir = files.first
14
+ # end
15
+ # load_inputs(tmpdir, input_names, input_types)
16
+ # else
17
+ # dir = Path.setup(dir.dup)
18
+ # input_names.each do |input|
19
+ # file = dir[input].find
20
+ # file = dir.glob(input.to_s + ".*").reject{|f| f =~ /\.md5$/}.first if file.nil? or not (File.symlink?(file) || file.exists?)
21
+ # Log.debug "Trying #{ input }: #{file}"
22
+ # next unless file and (File.symlink?(file) || file.exists?)
23
+ #
24
+ # type = orig_type = input_types[input]
25
+ #
26
+ # type = :io if file.split(".").last == 'as_io'
27
+ #
28
+ # type = :io_array if file.split(".").last == 'as_io_array'
29
+ #
30
+ # type = :step if file.split(".").last == 'as_step'
31
+ #
32
+ # type = :step_array if file.split(".").last == 'as_step_array'
33
+ #
34
+ # type = :number_array if file.split(".").last == 'as_number_array'
35
+ #
36
+ # type = :step_file if file.split(".").last == 'as_step_file'
37
+ #
38
+ # type = :step_file_array if file.split(".").last == 'as_step_file_array'
39
+ #
40
+ # type = :path if file.split(".").last == 'as_path'
41
+ #
42
+ # type = :path_array if file.split(".").last == 'as_path_array'
43
+ #
44
+ # type = :filename if file.split(".").last == 'as_filename'
45
+ #
46
+ # type = :nofile if file.split(".").last == 'nofile'
47
+ #
48
+ # case type
49
+ # when :nofile
50
+ # inputs[input.to_sym] = Open.realpath(file)
51
+ # when :path_array
52
+ # inputs[input.to_sym] = Open.read(file).strip.split("\n").collect{|p| Path.setup(p) }
53
+ # when :path
54
+ # inputs[input.to_sym] = Path.setup(Open.read(file).strip.split("\n").first)
55
+ # when :io
56
+ # inputs[input.to_sym] = Open.open(Open.realpath(file))
57
+ # when :io_array
58
+ # inputs[input.to_sym] = Open.realpath(file).split("\n").collect{|f| Open.open(f)}
59
+ # when :step_array
60
+ # steps = Open.read(file).strip.split("\n").collect{|path| Workflow.load_step(path) }
61
+ # inputs[input.to_sym] = steps
62
+ # when :number_array
63
+ # numbers = Open.read(file).strip.split("\n").collect{|num| num.to_f }
64
+ # inputs[input.to_sym] = numbers
65
+ # when :step
66
+ # steps = Open.read(file).strip.split("\n").collect{|path| Workflow.load_step(path) }
67
+ # inputs[input.to_sym] = steps.first
68
+ # when :step_file
69
+ # path = Open.read(file).strip
70
+ # step_path, relative = path.match(/(.*)\.files\/(.*)/).values_at 1, 2
71
+ # step = Step.new Path.setup(step_path).find
72
+ # path = step.file(relative)
73
+ # inputs[input.to_sym] = path
74
+ # when :step_file_array
75
+ # paths = Open.read(file).split("\n")
76
+ # paths.each do |path|
77
+ # path.extend Path
78
+ # step_path = path.match(/(.*)\.files/)[1]
79
+ # path.resource = Step.new step_path
80
+ # end
81
+ # inputs[input.to_sym] = paths
82
+ # when :file, :binary
83
+ # Log.debug "Pointing #{ input } to #{file}"
84
+ # if file =~ /\.yaml/
85
+ # inputs[input.to_sym] = Misc.load_yaml(file)
86
+ # else
87
+ # if File.symlink?(file)
88
+ # link_target = File.expand_path(File.readlink(file), File.dirname(file))
89
+ # inputs[input.to_sym] = link_target
90
+ # else
91
+ # inputs[input.to_sym] = Open.realpath(file)
92
+ # end
93
+ # end
94
+ # when :text
95
+ # Log.debug "Reading #{ input } from #{file}"
96
+ # inputs[input.to_sym] = Open.read(file)
97
+ # when :array
98
+ # Log.debug "Reading array #{ input } from #{file}"
99
+ # inputs[input.to_sym] = Open.read(file).split("\n")
100
+ # when :tsv
101
+ # Log.debug "Opening tsv #{ input } from #{file}"
102
+ # inputs[input.to_sym] = TSV.open(file)
103
+ # when :boolean
104
+ # case file.read.strip.downcase
105
+ # when 'true'
106
+ # inputs[input.to_sym] = true
107
+ # when 'false'
108
+ # inputs[input.to_sym] = false
109
+ # end
110
+ # when :integer
111
+ # inputs[input.to_sym] = file.read.to_i
112
+ # when :float
113
+ # inputs[input.to_sym] = file.read.to_f
114
+ # else
115
+ # Log.debug "Loading #{ input } from #{file}"
116
+ # inputs[input.to_sym] = file.read.strip
117
+ # end
118
+ #
119
+ # end
120
+ # inputs = IndiferentHash.setup(inputs)
121
+ #
122
+ # dir.glob("*#*").each do |od|
123
+ # name = File.basename(od)
124
+ # name.sub!(/\.as_path$/,'')
125
+ # value = Open.read(od)
126
+ # Log.debug "Loading override dependency #{ name } as #{value}"
127
+ # inputs[name] = value.chomp
128
+ # end
129
+ #
130
+ # inputs
131
+ # end
132
+ # end
133
+ #
134
+ # def task_inputs_from_directory(task_name, directory)
135
+ # task_info = self.task_info(task_name)
136
+ # Workflow.load_inputs(directory, task_info[:inputs], task_info[:input_types])
137
+ # end
138
+ #
139
+ # def job_for_directory_inputs(task_name, directory, jobname = nil)
140
+ # inputs = task_inputs_from_directory(task_name, directory)
141
+ # job(task_name, jobname, inputs)
142
+ # end
143
+ #end
144
+ #
145
+ #class Step
146
+ # def self.save_input(name, value, type, dir)
147
+ # path = File.join(dir, name.to_s)
148
+ #
149
+ # case value
150
+ # when Path
151
+ # if Step === value.resource
152
+ # step = value.resource
153
+ # value = File.join('var/jobs', step.workflow.to_s, step.short_path + '.files', Misc.path_relative_to(step.files_dir, value))
154
+ # path = path + '.as_step_file'
155
+ # else
156
+ # path = path + '.as_path'
157
+ # end
158
+ # when String
159
+ # if Misc.is_filename?(value, true)
160
+ # value = value.dup
161
+ # value.extend Path
162
+ # return save_input(name, value, type, dir)
163
+ # end
164
+ # when IO
165
+ # path = path + '.as_io'
166
+ # when Step
167
+ # value = value.path
168
+ # path = path + '.as_step'
169
+ # when Array
170
+ # case value.first
171
+ # when Path
172
+ # if Step === value.first.resource
173
+ # path = path + '.as_step_file_array'
174
+ # else
175
+ # path = path + '.as_path_array'
176
+ # end
177
+ # when String
178
+ # if Misc.is_filename?(value.first, true)
179
+ # path = path + '.as_path_array'
180
+ # end
181
+ # when IO
182
+ # path = path + '.as_io_array'
183
+ # when Step
184
+ # path = path + '.as_step_array'
185
+ # value = value.collect{|s| s.path }
186
+ # when Numeric
187
+ # path = path + '.as_number_array'
188
+ # end
189
+ #
190
+ # value = value * "\n"
191
+ # end
192
+ #
193
+ # Log.debug "Saving job input #{name} (#{type}) into #{path}"
194
+ #
195
+ # if IO === value && value.respond_to?(:filename) && value.filename
196
+ # Open.write(path, value.filename)
197
+ # elsif IO === value
198
+ # Open.write(path, value)
199
+ # else
200
+ # Open.write(path, value.to_s)
201
+ # end
202
+ # end
203
+ #
204
+ # def self.save_inputs(inputs, input_types, dir)
205
+ # inputs.each do |name,value|
206
+ # next if value.nil?
207
+ # type = input_types[name]
208
+ # type = type.to_s if type
209
+ #
210
+ # save_input(name, value, type, dir)
211
+ # end.any?
212
+ # end
213
+ #
214
+ # def self.save_job_inputs(job, dir, options = nil)
215
+ # options = IndiferentHash.setup options.dup if options
216
+ #
217
+ # task_name = job.original_task_name || job.task_name
218
+ # workflow = job.original_workflow || job.workflow
219
+ # workflow = Kernel.const_get workflow if String === workflow
220
+ # if workflow
221
+ # task_info = IndiferentHash.setup(workflow.task_info(task_name))
222
+ # input_types = IndiferentHash.setup(task_info[:input_types])
223
+ # input_options = IndiferentHash.setup(task_info[:input_options])
224
+ # task_inputs = IndiferentHash.setup(task_info[:inputs])
225
+ # input_defaults = IndiferentHash.setup(task_info[:input_defaults])
226
+ # else
227
+ # task_info = IndiferentHash.setup({})
228
+ # input_types = IndiferentHash.setup({})
229
+ # task_inputs = IndiferentHash.setup({})
230
+ # task_options = IndiferentHash.setup({})
231
+ # input_defaults = IndiferentHash.setup({})
232
+ # end
233
+ #
234
+ # inputs = IndiferentHash.setup({})
235
+ # real_inputs = job.real_inputs || job.info[:real_inputs]
236
+ # job.recursive_inputs.zip(job.recursive_inputs.fields).each do |value,name|
237
+ # next unless task_inputs.include? name.to_sym
238
+ # next unless real_inputs.include? name.to_sym
239
+ # next if options && ! options.include?(name)
240
+ # next if value.nil?
241
+ # next if input_defaults[name] == value
242
+ # inputs[name] = value
243
+ # end
244
+ #
245
+ # if options && options.include?('override_dependencies')
246
+ # inputs.merge!(:override_dependencies => open[:override_dependencies])
247
+ # input_types = IndiferentHash.setup(input_types.merge(:override_dependencies => :array))
248
+ # end
249
+ #
250
+ # save_inputs(inputs, input_types, dir)
251
+ #
252
+ # inputs.keys
253
+ # end
254
+ #end