rbbt-util 5.43.0 → 5.44.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/etc/app.d/base.rb +1 -1
  3. data/lib/rbbt/association/util.rb +1 -1
  4. data/lib/rbbt/hpc/batch.rb +19 -17
  5. data/lib/rbbt/persist/tsv/sharder.rb +1 -1
  6. data/lib/rbbt/tsv/accessor.rb +6 -11
  7. data/lib/rbbt/tsv/dumper.rb +21 -10
  8. data/lib/rbbt/tsv/index.rb +2 -1
  9. data/lib/rbbt/util/misc/math.rb +0 -1
  10. data/lib/rbbt/util/misc/omics.rb +2 -1
  11. data/lib/rbbt/util/misc/ssw.rb +298 -0
  12. data/lib/rbbt/util/open.rb +1 -1
  13. data/lib/rbbt/workflow/step/info.rb +3 -2
  14. data/lib/rbbt/workflow/step.rb +2 -1
  15. data/python/rbbt/__init__.py +2 -2
  16. data/share/rbbt_commands/workflow/server +6 -1
  17. data/share/rbbt_commands/workflow/task +1 -1
  18. metadata +5 -220
  19. data/test/rbbt/annotations/test_util.rb +0 -43
  20. data/test/rbbt/association/test_database.rb +0 -87
  21. data/test/rbbt/association/test_index.rb +0 -127
  22. data/test/rbbt/association/test_item.rb +0 -15
  23. data/test/rbbt/association/test_open.rb +0 -63
  24. data/test/rbbt/association/test_util.rb +0 -108
  25. data/test/rbbt/entity/test_identifiers.rb +0 -34
  26. data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
  27. data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
  28. data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
  29. data/test/rbbt/hpc/test_batch.rb +0 -64
  30. data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
  31. data/test/rbbt/hpc/test_orchestrate.rb +0 -144
  32. data/test/rbbt/hpc/test_pbs.rb +0 -43
  33. data/test/rbbt/hpc/test_slurm.rb +0 -28
  34. data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
  35. data/test/rbbt/knowledge_base/test_entity.rb +0 -62
  36. data/test/rbbt/knowledge_base/test_query.rb +0 -46
  37. data/test/rbbt/knowledge_base/test_registry.rb +0 -74
  38. data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
  39. data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
  40. data/test/rbbt/persist/test_tsv.rb +0 -88
  41. data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
  42. data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
  43. data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
  44. data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
  45. data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
  46. data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
  47. data/test/rbbt/resource/test_path.rb +0 -49
  48. data/test/rbbt/test_annotations.rb +0 -167
  49. data/test/rbbt/test_association.rb +0 -103
  50. data/test/rbbt/test_entity.rb +0 -252
  51. data/test/rbbt/test_fix_width_table.rb +0 -135
  52. data/test/rbbt/test_knowledge_base.rb +0 -226
  53. data/test/rbbt/test_monitor.rb +0 -11
  54. data/test/rbbt/test_packed_index.rb +0 -68
  55. data/test/rbbt/test_persist.rb +0 -85
  56. data/test/rbbt/test_resource.rb +0 -110
  57. data/test/rbbt/test_tsv.rb +0 -669
  58. data/test/rbbt/test_workflow.rb +0 -609
  59. data/test/rbbt/tsv/parallel/test_through.rb +0 -40
  60. data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
  61. data/test/rbbt/tsv/test_accessor.rb +0 -319
  62. data/test/rbbt/tsv/test_attach.rb +0 -715
  63. data/test/rbbt/tsv/test_change_id.rb +0 -61
  64. data/test/rbbt/tsv/test_csv.rb +0 -49
  65. data/test/rbbt/tsv/test_excel.rb +0 -171
  66. data/test/rbbt/tsv/test_field_index.rb +0 -19
  67. data/test/rbbt/tsv/test_filter.rb +0 -187
  68. data/test/rbbt/tsv/test_index.rb +0 -308
  69. data/test/rbbt/tsv/test_manipulate.rb +0 -334
  70. data/test/rbbt/tsv/test_marshal.rb +0 -24
  71. data/test/rbbt/tsv/test_matrix.rb +0 -20
  72. data/test/rbbt/tsv/test_parallel.rb +0 -7
  73. data/test/rbbt/tsv/test_parser.rb +0 -101
  74. data/test/rbbt/tsv/test_stream.rb +0 -253
  75. data/test/rbbt/tsv/test_util.rb +0 -52
  76. data/test/rbbt/util/R/test_eval.rb +0 -43
  77. data/test/rbbt/util/R/test_model.rb +0 -128
  78. data/test/rbbt/util/R/test_plot.rb +0 -38
  79. data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
  80. data/test/rbbt/util/concurrency/test_processes.rb +0 -192
  81. data/test/rbbt/util/concurrency/test_threads.rb +0 -40
  82. data/test/rbbt/util/log/test_progress.rb +0 -111
  83. data/test/rbbt/util/misc/test_bgzf.rb +0 -48
  84. data/test/rbbt/util/misc/test_communication.rb +0 -13
  85. data/test/rbbt/util/misc/test_development.rb +0 -26
  86. data/test/rbbt/util/misc/test_format.rb +0 -10
  87. data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
  88. data/test/rbbt/util/misc/test_lock.rb +0 -77
  89. data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
  90. data/test/rbbt/util/misc/test_omics.rb +0 -116
  91. data/test/rbbt/util/misc/test_pipes.rb +0 -343
  92. data/test/rbbt/util/misc/test_serialize.rb +0 -24
  93. data/test/rbbt/util/python/test_util.rb +0 -25
  94. data/test/rbbt/util/simpleopt/test_get.rb +0 -12
  95. data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
  96. data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
  97. data/test/rbbt/util/test_R.rb +0 -37
  98. data/test/rbbt/util/test_chain_methods.rb +0 -22
  99. data/test/rbbt/util/test_cmd.rb +0 -87
  100. data/test/rbbt/util/test_colorize.rb +0 -22
  101. data/test/rbbt/util/test_concurrency.rb +0 -6
  102. data/test/rbbt/util/test_config.rb +0 -69
  103. data/test/rbbt/util/test_excel2tsv.rb +0 -10
  104. data/test/rbbt/util/test_filecache.rb +0 -36
  105. data/test/rbbt/util/test_log.rb +0 -52
  106. data/test/rbbt/util/test_migrate.rb +0 -34
  107. data/test/rbbt/util/test_misc.rb +0 -728
  108. data/test/rbbt/util/test_open.rb +0 -200
  109. data/test/rbbt/util/test_procpath.rb +0 -23
  110. data/test/rbbt/util/test_python.rb +0 -144
  111. data/test/rbbt/util/test_semaphore.rb +0 -36
  112. data/test/rbbt/util/test_simpleDSL.rb +0 -55
  113. data/test/rbbt/util/test_simpleopt.rb +0 -11
  114. data/test/rbbt/util/test_ssh.rb +0 -10
  115. data/test/rbbt/util/test_tmpfile.rb +0 -32
  116. data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
  117. data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
  118. data/test/rbbt/workflow/test_doc.rb +0 -30
  119. data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
  120. data/test/rbbt/workflow/test_schedule.rb +0 -0
  121. data/test/rbbt/workflow/test_step.rb +0 -231
  122. data/test/rbbt/workflow/test_task.rb +0 -85
  123. data/test/rbbt/workflow/util/test_archive.rb +0 -27
  124. data/test/rbbt/workflow/util/test_data.rb +0 -67
  125. data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
  126. data/test/test_helper.rb +0 -114
@@ -1,295 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
- require 'rbbt/workflow'
3
-
4
- module DepWorkflow
5
- extend Workflow
6
-
7
- input :input_file, :file, "Input file", nil, :stream => true
8
- task :s1 => :array do |input_file|
9
- TSV.traverse input_file, :type => :array, :into => :stream, :bar => "Task1" do |line|
10
- line + "\t" << "Task1"
11
- end
12
- end
13
-
14
- dep :s1
15
- task :s2 => :array do |input_file|
16
- TSV.traverse step(:s1), :type => :array, :into => :stream, :bar => "Task2" do |line|
17
- next [line.split("\t").first, Misc::SKIP_TAG] * "\t" if rand < 0.9
18
- line + "\t" << "Task2"
19
- end
20
- end
21
-
22
- dep :s1
23
- dep :s2
24
- task :s3 => :array do |input_file|
25
- Misc.paste_streams(dependencies.reverse)
26
- end
27
-
28
- input :input_file, :file, "Input file", nil, :stream => true
29
- task :task1 => :array do |input_file|
30
- TSV.traverse input_file, :type => :array, :into => :stream, :bar => "Task1" do |line|
31
- line + "\t" << "Task1"
32
- end
33
- end
34
-
35
- dep :task1
36
- task :task2 => :array do
37
- TSV.traverse step(:task1), :type => :array, :into => :stream, :bar => "Task2" do |line|
38
- line + "\t" << "Task2"
39
- end
40
- end
41
-
42
- dep :task1
43
- task :task3 => :array do
44
- TSV.traverse step(:task1), :type => :array, :into => :stream, :bar => "Task3" do |line|
45
- line + "\t" << "Task3"
46
- end
47
- end
48
-
49
- dep :task2
50
- dep :task3
51
- task :task4 => :array do
52
- Misc.paste_streams(dependencies)
53
- end
54
-
55
- dep :task4
56
- task :task5 => :array do
57
- TSV.traverse step(:task4), :type => :array, :into => :stream, :bar => "Task5" do |line|
58
- line + "\t" << "Task5"
59
- end
60
- end
61
-
62
- dep :task2
63
- dep :task5
64
- task :task6 => :array do
65
- Misc.paste_streams(dependencies)
66
- end
67
-
68
- input :stream_file, :file, "Streamed file", nil, :stream => true
69
- task :task7 => :array do |file|
70
- TSV.traverse file, :type => :array, :into => :stream, :bar => "Task7" do |line|
71
- line + "\t" << "Task7"
72
- end
73
- end
74
-
75
- dep :task6
76
- dep :task7, :stream_file => :task6
77
- task :task8 => :array do
78
- TSV.get_stream step(:task7)
79
- end
80
- end
81
-
82
- module ComputeWorkflow
83
- extend Workflow
84
-
85
- input :input_file, :file, "Input file", nil, :stream => true
86
- task :task1 => :array do |input_file|
87
- TSV.traverse input_file, :type => :array, :into => :stream, :bar => "Task1" do |line|
88
- line + "\t" << "Task1"
89
- end
90
- end
91
-
92
- dep :task1, :compute => :produce
93
- task :task2 => :array do
94
- TSV.traverse step(:task1), :type => :array, :into => :stream, :bar => "Task2" do |line|
95
- line + "\t" << "Task2"
96
- end
97
- end
98
-
99
- end
100
-
101
- module ResumeWorkflow
102
- extend Workflow
103
-
104
- resumable
105
- task :resume => :string do
106
- if file('foo').exists?
107
- 'done'
108
- else
109
- Open.mkdir files_dir
110
- Open.touch(file('foo'))
111
- raise
112
- end
113
- end
114
-
115
- dep :resume
116
- task :reverse => :string do
117
- step(:resume).load.reverse
118
- end
119
- end
120
-
121
- class TestWorkflowDependency < Test::Unit::TestCase
122
- def test_task1
123
- size = 10000
124
- content = (0..size).to_a.collect{|num| "Line #{num}" } * "\n"
125
- TmpFile.with_file(content) do |input_file|
126
- job = DepWorkflow.job(:task1, "TEST", :input_file => input_file)
127
- io = TSV.get_stream job.run(:stream)
128
- last_line = nil
129
- while line = io.gets
130
- last_line = line.strip
131
- end
132
- io.join
133
-
134
- assert_equal "Line #{size}\tTask1", last_line
135
- end
136
- end
137
-
138
- def test_task2
139
- size = 10000
140
- content = (0..size).to_a.collect{|num| "Line #{num}" } * "\n"
141
- TmpFile.with_file(content) do |input_file|
142
- job = DepWorkflow.job(:task2, "TEST", :input_file => input_file)
143
- io = TSV.get_stream job.run(:stream)
144
- last_line = nil
145
- while line = io.gets
146
- last_line = line.strip
147
- end
148
- io.join
149
-
150
- assert_equal "Line #{size}\tTask1\tTask2", last_line
151
- end
152
- end
153
-
154
- def test_task3
155
- size = 100000
156
- content = (0..size).to_a.collect{|num| "Line #{num}" } * "\n"
157
- TmpFile.with_file(content) do |input_file|
158
- job = DepWorkflow.job(:task3, "TEST", :input_file => input_file)
159
- io = TSV.get_stream job.run(:stream)
160
- last_line = nil
161
- while line = io.gets
162
- last_line = line.strip
163
- end
164
- io.join
165
-
166
- assert_equal "Line #{size}\tTask1\tTask3", last_line
167
- end
168
- end
169
-
170
- def test_task4
171
- size = 100000
172
- content = (0..size).to_a.collect{|num| "Line #{num}" } * "\n"
173
- last_line = nil
174
- TmpFile.with_file(content) do |input_file|
175
- job = DepWorkflow.job(:task4, "TEST", :input_file => input_file)
176
- io = TSV.get_stream job.run(:stream)
177
- while line = io.gets
178
- last_line = line.strip
179
- end
180
- io.join
181
- end
182
-
183
- assert_equal "Line #{size}\tTask1\tTask2\tTask1\tTask3", last_line
184
- end
185
-
186
- def test_task5
187
- size = 10000
188
- content = (0..size).to_a.collect{|num| "Line #{num}" } * "\n"
189
- last_line = nil
190
- TmpFile.with_file(content) do |input_file|
191
- job = DepWorkflow.job(:task5, "TEST", :input_file => input_file)
192
- io = TSV.get_stream job.run(:stream)
193
- while line = io.gets
194
- last_line = line.strip
195
- end
196
- io.join
197
- end
198
- assert_equal "Line #{size}\tTask1\tTask2\tTask1\tTask3\tTask5", last_line
199
- end
200
-
201
- def test_s3
202
- size = 100000
203
- content = (1..size).to_a.collect{|num| "Line #{num}" } * "\n"
204
- last_line = nil
205
- Log.with_severity 0 do
206
- TmpFile.with_file(content) do |input_file|
207
- begin
208
- job = DepWorkflow.job(:s3, "TEST", :input_file => input_file)
209
- job.recursive_clean
210
- job.run(:stream)
211
- io = TSV.get_stream job
212
- while line = io.gets
213
- last_line = line.strip
214
- end
215
- io.join if io.respond_to? :join
216
- rescue Exception
217
- job.abort
218
- raise $!
219
- end
220
- end
221
- end
222
- assert last_line.include? "Line #{size}"
223
- end
224
-
225
- def test_task6
226
- size = 100000
227
- content = (1..size).to_a.collect{|num| "Line #{num}" } * "\n"
228
- last_line = nil
229
- TmpFile.with_file(content) do |input_file|
230
- begin
231
- job = DepWorkflow.job(:task6, "TEST", :input_file => input_file)
232
- job.recursive_clean
233
- job.run(:stream)
234
- io = TSV.get_stream job
235
- while line = io.gets
236
- last_line = line.strip
237
- end
238
- io.join
239
- rescue Exception
240
- job.abort
241
- raise $!
242
- end
243
- end
244
- assert_equal "Line #{size}\tTask1\tTask2\tTask1\tTask2\tTask1\tTask3\tTask5", last_line
245
- end
246
-
247
- def test_task8
248
- size = 10000
249
- content = (0..size).to_a.collect{|num| "Line #{num}" } * "\n"
250
- last_line = nil
251
- TmpFile.with_file(content) do |input_file|
252
- begin
253
- job = DepWorkflow.job(:task8, "TEST", :input_file => input_file)
254
- job.run(:stream)
255
- io = TSV.get_stream job
256
- while line = io.gets
257
- last_line = line.strip
258
- end
259
- io.join
260
- rescue Exception
261
- job.abort
262
- raise $!
263
- end
264
- end
265
- assert_equal "Line #{size}\tTask1\tTask2\tTask1\tTask2\tTask1\tTask3\tTask5\tTask7", last_line
266
- end
267
-
268
- def test_compute
269
- size = 10000
270
- content = (0..size).to_a.collect{|num| "Line #{num}" } * "\n"
271
- TmpFile.with_file(content) do |input_file|
272
- job = ComputeWorkflow.job(:task2, "TEST", :input_file => input_file)
273
- io = TSV.get_stream job.run(:stream)
274
- last_line = nil
275
- while line = io.gets
276
- last_line = line.strip
277
- end
278
- io.join
279
-
280
- assert_equal "Line #{size}\tTask1\tTask2", last_line
281
- end
282
- end
283
-
284
- def test_resume
285
- job = ResumeWorkflow.job(:reverse)
286
- job.recursive_clean
287
- assert_raise do
288
- job.run
289
- end
290
- assert job.dependencies.first.file('foo').exists?
291
- assert_equal 'done'.reverse, job.run
292
- end
293
-
294
- end
295
-
@@ -1,136 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
2
- require 'rbbt/workflow/step/save_load_inputs'
3
-
4
- ENV["RBBT_DEBUG_JOB_HASH"] = true.to_s
5
- require 'rbbt/workflow'
6
- module TestSaveLoadWF
7
- extend Workflow
8
-
9
- task :number => :integer do
10
- 10
11
- end
12
-
13
- task :list => :array do
14
- (0..10).to_a.collect{|e| e.to_s}
15
- end
16
-
17
- input :list, :array
18
- input :number, :integer
19
- task :reverse => :array do |list|
20
- list.reverse
21
- end
22
-
23
- dep :list
24
- dep :number
25
- dep :reverse, :list => :list, :number => :number
26
- task :prefix => :array do
27
- step(:reverse).run.collect{|e| "A-#{e}" }
28
- end
29
-
30
- input :integer, :integer
31
- input :float, :float
32
- input :file, :file
33
- input :file_no_file, :file, "", nil, :nofile => true
34
- input :string, :string
35
- input :select, :select
36
- input :array, :array
37
- input :array_no_file, :array, "", nil, :nofile => true
38
- input :tsv, :tsv, "", nil, :nofile => true
39
- input :tsv_no_file, :tsv, "", nil, :nofile => true
40
- input :binary, :binary, "", nil, :nofile => true
41
- input :binary_no_file, :tsv, "", nil, :nofile => true
42
- task :save_test => :string do
43
- "DONE"
44
- end
45
- end
46
-
47
- class TestSaveLoad < Test::Unit::TestCase
48
- def test_save
49
- job = TestSaveLoadWF.job(:prefix)
50
- job.recursive_clean
51
- job = TestSaveLoadWF.job(:prefix)
52
- TmpFile.with_file do |directory|
53
- Step.save_job_inputs(job.step(:reverse), directory)
54
- job.produce
55
- newjob = TestSaveLoadWF.job_for_directory_inputs(:reverse, directory)
56
- assert_equal job.rec_dependencies.last.path, newjob.path
57
- end
58
- end
59
-
60
- def test_save_all_normal
61
- tsv = TSV.setup({}, "Key~Value#:type=:single")
62
- tsv["key"] = "value"
63
- options = {
64
- :float => 0.5,
65
- :integer => 15,
66
- :string => "STRING",
67
- :select => "option",
68
- :array => [0,1,2,3],
69
- :tsv => tsv,
70
- }
71
- Log.with_severity 0 do
72
- Misc.with_env "RBBT_DEBUG_JOB_HASH", "true" do
73
- job = TestSaveLoadWF.job(:save_test, nil, options)
74
- TmpFile.with_file do |directory|
75
- Step.save_job_inputs(job, directory)
76
- newjob = TestSaveLoadWF.job_for_directory_inputs(:save_test, directory)
77
- assert_equal job.path, newjob.path
78
- end
79
- end
80
- end
81
- end
82
-
83
- def test_save_all_file
84
- tsv = TSV.setup({}, "Key~Value#:type=:single")
85
- tsv["key"] = "value"
86
- Log.with_severity 0 do
87
- Misc.with_env "RBBT_DEBUG_JOB_HASH", "true" do
88
- TmpFile.with_file do |input_file|
89
- Path.setup(input_file)
90
- options = {
91
- :float => input_file.float,
92
- :integer => input_file.integer,
93
- :string => input_file.string,
94
- :select => input_file.select,
95
- :array => input_file.array,
96
- :tsv => input_file.tsv_file,
97
- }
98
- job = TestSaveLoadWF.job(:save_test, nil, options)
99
- TmpFile.with_file do |directory|
100
- Step.save_job_inputs(job, directory)
101
- newjob = TestSaveLoadWF.job_for_directory_inputs(:save_test, directory)
102
- assert_equal job.path, newjob.path
103
- end
104
- end
105
- end
106
- end
107
- end
108
-
109
- def test_save_all_job_file
110
- tsv = TSV.setup({}, "Key~Value#:type=:single")
111
- tsv["key"] = "value"
112
- Log.with_severity 0 do
113
- Misc.with_env "RBBT_DEBUG_JOB_HASH", "true" do
114
- TmpFile.with_file do |input_file|
115
- Path.setup(input_file)
116
- options = {
117
- :float => input_file.float,
118
- :integer => input_file.integer,
119
- :string => input_file.string,
120
- :select => input_file.select,
121
- :array => TestSaveLoadWF.job(:list),
122
- :binary => TestSaveLoadWF.job(:list).file('binary'),
123
- :tsv => input_file.tsv_file,
124
- }
125
- job = TestSaveLoadWF.job(:save_test, nil, options)
126
- TmpFile.with_file do |directory|
127
- Step.save_job_inputs(job, directory)
128
- newjob = TestSaveLoadWF.job_for_directory_inputs(:save_test, directory)
129
- assert_equal job.path, newjob.path
130
- end
131
- end
132
- end
133
- end
134
- end
135
- end
136
-
@@ -1,30 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
- require 'rbbt/workflow'
3
-
4
- class TestWorkflowDoc < Test::Unit::TestCase
5
- TEMPLATE=<<-EOF
6
- Title of the template
7
-
8
- Paragraph1
9
-
10
- Paragraph2
11
-
12
- # Tasks
13
-
14
- Paragraph3
15
-
16
- ## task1
17
-
18
- Task 1
19
-
20
- ## task2
21
-
22
- Task 2
23
-
24
- EOF
25
- def test_parse
26
- i = Workflow.parse_workflow_doc(TEMPLATE)
27
- assert_equal "Title of the template", i[:title]
28
- end
29
- end
30
-
@@ -1,99 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
- require 'rbbt/workflow'
3
- require 'rbbt/workflow/remote_workflow'
4
-
5
- class TestWFRest
6
- extend Workflow
7
-
8
- input :name, :string, "Name to greet", "World"
9
- task :hi => :string do |name|
10
- "Hello #{name}"
11
- end
12
-
13
- dep :hi
14
- task :intro => :string do
15
- step(:hi).load + ", nice to meet you"
16
- end
17
- end
18
-
19
- class TestRemoteWorkflow < Test::Unit::TestCase
20
-
21
- def remote_workflow_server(workflow, options = {}, &block)
22
- trap(:USR1){ raise TestServerLoaded}
23
-
24
- begin
25
- pid = Process.fork do
26
- TmpFile.with_file do |app_dir|
27
- Misc.in_dir(app_dir) do
28
- require 'rack'
29
- ENV["RBBT_WORKFLOW_EXPORT_ALL"] = 'true'
30
-
31
- app_dir = Path.setup(app_dir.dup)
32
- Open.write(app_dir.etc.target_workflow.find, workflow.to_s)
33
-
34
- config_ru_file = File.exist?('./workflow_config.ru') ? './workflow_config.ru' : Rbbt.share['workflow_config.ru'].find
35
- options[:config] = config_ru_file
36
- app = Rack::Server.new(options)
37
- app.start do
38
- Process.kill :USR1, Process.ppid
39
- end
40
- end
41
- end
42
- end
43
-
44
- begin
45
- sleep 1 while true
46
- rescue TestServerLoaded
47
- end
48
-
49
- client = RemoteWorkflow.new "http://localhost:#{options[:Port] || 9292}/#{workflow.to_s}", workflow.to_s
50
-
51
- yield client
52
-
53
- rescue
54
- Log.exception $!
55
- ensure
56
- Process.kill :INT, pid
57
- Process.wait pid
58
- end
59
- end
60
-
61
- def test_rest
62
- keyword_test :rest do
63
-
64
- remote_workflow_server(TestWFRest) do |client|
65
- job = client.job(:hi, nil, {})
66
- job.clean
67
- job = client.job(:hi, nil, {})
68
- assert ! job.done?
69
- job.run
70
- job.produce
71
- job = client.job(:hi, nil, {})
72
- assert job.done?
73
- sleep 1
74
- end
75
-
76
- remote_workflow_server(TestWFRest) do |client|
77
- assert_equal "Hello World", client.job(:hi, nil, {}).run.chomp
78
- assert_equal "Hello Miguel", client.job(:hi, nil, {:name => :Miguel}).run.chomp
79
- assert_equal "Hello Miguel, nice to meet you", client.job(:intro, nil, {:name => :Miguel}).run.chomp
80
- end
81
-
82
- remote_workflow_server(TestWFRest, :Port => 1902) do |client|
83
- assert_equal "Hello World", client.job(:hi, nil, {}).run.chomp
84
- assert_equal "Hello Miguel", client.job(:hi, nil, {:name => :Miguel}).run.chomp
85
- assert_equal "Hello Miguel, nice to meet you", client.job(:intro, nil, {:name => :Miguel}).run.chomp
86
- end
87
- end
88
- end
89
-
90
-
91
- def test_ssh
92
- keyword_test :ssh do
93
- client = RemoteWorkflow.new "ssh://#{ENV["HOSTNAME"] || 'localhost'}:Translation", "Translation"
94
- job = client.job("translate", "SSH-TEST-1", :genes => ["TP53","KRAS"])
95
- assert_equal 2, job.run.select{|l| l =~ /ENSG/}.length
96
- end
97
- end
98
- end
99
-
File without changes