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.
- checksums.yaml +4 -4
- data/etc/app.d/base.rb +1 -1
- data/lib/rbbt/association/util.rb +1 -1
- data/lib/rbbt/hpc/batch.rb +19 -17
- data/lib/rbbt/persist/tsv/sharder.rb +1 -1
- data/lib/rbbt/tsv/accessor.rb +6 -11
- data/lib/rbbt/tsv/dumper.rb +21 -10
- data/lib/rbbt/tsv/index.rb +2 -1
- data/lib/rbbt/util/misc/math.rb +0 -1
- data/lib/rbbt/util/misc/omics.rb +2 -1
- data/lib/rbbt/util/misc/ssw.rb +298 -0
- data/lib/rbbt/util/open.rb +1 -1
- data/lib/rbbt/workflow/step/info.rb +3 -2
- data/lib/rbbt/workflow/step.rb +2 -1
- data/python/rbbt/__init__.py +2 -2
- data/share/rbbt_commands/workflow/server +6 -1
- data/share/rbbt_commands/workflow/task +1 -1
- metadata +5 -220
- data/test/rbbt/annotations/test_util.rb +0 -43
- data/test/rbbt/association/test_database.rb +0 -87
- data/test/rbbt/association/test_index.rb +0 -127
- data/test/rbbt/association/test_item.rb +0 -15
- data/test/rbbt/association/test_open.rb +0 -63
- data/test/rbbt/association/test_util.rb +0 -108
- data/test/rbbt/entity/test_identifiers.rb +0 -34
- data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
- data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
- data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
- data/test/rbbt/hpc/test_batch.rb +0 -64
- data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
- data/test/rbbt/hpc/test_orchestrate.rb +0 -144
- data/test/rbbt/hpc/test_pbs.rb +0 -43
- data/test/rbbt/hpc/test_slurm.rb +0 -28
- data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
- data/test/rbbt/knowledge_base/test_entity.rb +0 -62
- data/test/rbbt/knowledge_base/test_query.rb +0 -46
- data/test/rbbt/knowledge_base/test_registry.rb +0 -74
- data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
- data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
- data/test/rbbt/persist/test_tsv.rb +0 -88
- data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
- data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
- data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
- data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
- data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
- data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
- data/test/rbbt/resource/test_path.rb +0 -49
- data/test/rbbt/test_annotations.rb +0 -167
- data/test/rbbt/test_association.rb +0 -103
- data/test/rbbt/test_entity.rb +0 -252
- data/test/rbbt/test_fix_width_table.rb +0 -135
- data/test/rbbt/test_knowledge_base.rb +0 -226
- data/test/rbbt/test_monitor.rb +0 -11
- data/test/rbbt/test_packed_index.rb +0 -68
- data/test/rbbt/test_persist.rb +0 -85
- data/test/rbbt/test_resource.rb +0 -110
- data/test/rbbt/test_tsv.rb +0 -669
- data/test/rbbt/test_workflow.rb +0 -609
- data/test/rbbt/tsv/parallel/test_through.rb +0 -40
- data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
- data/test/rbbt/tsv/test_accessor.rb +0 -319
- data/test/rbbt/tsv/test_attach.rb +0 -715
- data/test/rbbt/tsv/test_change_id.rb +0 -61
- data/test/rbbt/tsv/test_csv.rb +0 -49
- data/test/rbbt/tsv/test_excel.rb +0 -171
- data/test/rbbt/tsv/test_field_index.rb +0 -19
- data/test/rbbt/tsv/test_filter.rb +0 -187
- data/test/rbbt/tsv/test_index.rb +0 -308
- data/test/rbbt/tsv/test_manipulate.rb +0 -334
- data/test/rbbt/tsv/test_marshal.rb +0 -24
- data/test/rbbt/tsv/test_matrix.rb +0 -20
- data/test/rbbt/tsv/test_parallel.rb +0 -7
- data/test/rbbt/tsv/test_parser.rb +0 -101
- data/test/rbbt/tsv/test_stream.rb +0 -253
- data/test/rbbt/tsv/test_util.rb +0 -52
- data/test/rbbt/util/R/test_eval.rb +0 -43
- data/test/rbbt/util/R/test_model.rb +0 -128
- data/test/rbbt/util/R/test_plot.rb +0 -38
- data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
- data/test/rbbt/util/concurrency/test_processes.rb +0 -192
- data/test/rbbt/util/concurrency/test_threads.rb +0 -40
- data/test/rbbt/util/log/test_progress.rb +0 -111
- data/test/rbbt/util/misc/test_bgzf.rb +0 -48
- data/test/rbbt/util/misc/test_communication.rb +0 -13
- data/test/rbbt/util/misc/test_development.rb +0 -26
- data/test/rbbt/util/misc/test_format.rb +0 -10
- data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
- data/test/rbbt/util/misc/test_lock.rb +0 -77
- data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
- data/test/rbbt/util/misc/test_omics.rb +0 -116
- data/test/rbbt/util/misc/test_pipes.rb +0 -343
- data/test/rbbt/util/misc/test_serialize.rb +0 -24
- data/test/rbbt/util/python/test_util.rb +0 -25
- data/test/rbbt/util/simpleopt/test_get.rb +0 -12
- data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
- data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
- data/test/rbbt/util/test_R.rb +0 -37
- data/test/rbbt/util/test_chain_methods.rb +0 -22
- data/test/rbbt/util/test_cmd.rb +0 -87
- data/test/rbbt/util/test_colorize.rb +0 -22
- data/test/rbbt/util/test_concurrency.rb +0 -6
- data/test/rbbt/util/test_config.rb +0 -69
- data/test/rbbt/util/test_excel2tsv.rb +0 -10
- data/test/rbbt/util/test_filecache.rb +0 -36
- data/test/rbbt/util/test_log.rb +0 -52
- data/test/rbbt/util/test_migrate.rb +0 -34
- data/test/rbbt/util/test_misc.rb +0 -728
- data/test/rbbt/util/test_open.rb +0 -200
- data/test/rbbt/util/test_procpath.rb +0 -23
- data/test/rbbt/util/test_python.rb +0 -144
- data/test/rbbt/util/test_semaphore.rb +0 -36
- data/test/rbbt/util/test_simpleDSL.rb +0 -55
- data/test/rbbt/util/test_simpleopt.rb +0 -11
- data/test/rbbt/util/test_ssh.rb +0 -10
- data/test/rbbt/util/test_tmpfile.rb +0 -32
- data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
- data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
- data/test/rbbt/workflow/test_doc.rb +0 -30
- data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
- data/test/rbbt/workflow/test_schedule.rb +0 -0
- data/test/rbbt/workflow/test_step.rb +0 -231
- data/test/rbbt/workflow/test_task.rb +0 -85
- data/test/rbbt/workflow/util/test_archive.rb +0 -27
- data/test/rbbt/workflow/util/test_data.rb +0 -67
- data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
- data/test/test_helper.rb +0 -114
@@ -1,231 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/workflow'
|
3
|
-
require 'rbbt/workflow/task'
|
4
|
-
require 'rbbt/workflow/step'
|
5
|
-
require 'rbbt/tsv'
|
6
|
-
require 'rbbt'
|
7
|
-
require 'rbbt-util'
|
8
|
-
|
9
|
-
class TestStep < Test::Unit::TestCase
|
10
|
-
|
11
|
-
def test_step
|
12
|
-
task = Task.setup do "TEST" end
|
13
|
-
task2 = Task.setup do raise "Persistence ignored" end
|
14
|
-
TmpFile.with_file do |tmp|
|
15
|
-
step = Step.new tmp, task
|
16
|
-
assert_equal "TEST", step.run
|
17
|
-
assert File.exist? tmp
|
18
|
-
step = Step.new tmp, task2
|
19
|
-
assert_equal "TEST", step.run
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_dependency
|
24
|
-
str = "TEST"
|
25
|
-
str2 = "TEST2"
|
26
|
-
TmpFile.with_file do |tmpfile|
|
27
|
-
|
28
|
-
task1 = Task.setup :result_type => :string do
|
29
|
-
Open.write(tmpfile, str);
|
30
|
-
"done"
|
31
|
-
end
|
32
|
-
step1 = Step.new tmpfile + 'step1', task1
|
33
|
-
|
34
|
-
task2 = Task.setup :result_type => :string do
|
35
|
-
Open.read(tmpfile)
|
36
|
-
end
|
37
|
-
step2 = Step.new tmpfile + 'step2', task2, [], [step1]
|
38
|
-
|
39
|
-
step2.run
|
40
|
-
assert_equal "TEST", Open.read(tmpfile + 'step2')
|
41
|
-
|
42
|
-
task2 = Task.setup :result_type => :string do
|
43
|
-
str2
|
44
|
-
end
|
45
|
-
step2 = Step.new tmpfile + 'step2', task2, [], step1
|
46
|
-
|
47
|
-
step1.clean
|
48
|
-
step2.clean.run
|
49
|
-
assert_equal "TEST2", Open.read(tmpfile + 'step2')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def __test_dependency_log_relay
|
54
|
-
str = "TEST"
|
55
|
-
TmpFile.with_file do |tmpfile|
|
56
|
-
task1 = Task.setup :result_type => :string, :name => :task1 do
|
57
|
-
log(:starting_task1, "Starting Task1")
|
58
|
-
Open.write(tmpfile, str);
|
59
|
-
"done"
|
60
|
-
end
|
61
|
-
step1 = Step.new tmpfile + 'step1', task1
|
62
|
-
|
63
|
-
task2 = Task.setup :result_type => :string, :name => :task1 do
|
64
|
-
Open.read(tmpfile)
|
65
|
-
end
|
66
|
-
step2 = Step.new tmpfile + 'step2', task2, [], [step1]
|
67
|
-
|
68
|
-
step2.run
|
69
|
-
assert step2.messages.include? "Starting Task1"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_log_relay_step
|
74
|
-
str = "TEST"
|
75
|
-
TmpFile.with_file do |tmpfile|
|
76
|
-
task1 = Task.setup :result_type => :string, :name => :task1 do
|
77
|
-
log(:starting_task1, "Starting Task1")
|
78
|
-
Open.write(tmpfile, str);
|
79
|
-
"done"
|
80
|
-
end
|
81
|
-
step1 = Step.new tmpfile + 'step1', task1
|
82
|
-
|
83
|
-
|
84
|
-
task2 = Task.setup :result_type => :string, :name => :task1 do
|
85
|
-
Open.read(tmpfile)
|
86
|
-
end
|
87
|
-
step2 = Step.new tmpfile + 'step2', task2, [], [step1]
|
88
|
-
|
89
|
-
Step.log_relay_step = step2
|
90
|
-
step2.run
|
91
|
-
|
92
|
-
assert step2.messages.include? "Starting Task1"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
def test_exec
|
98
|
-
TmpFile.with_file do |lock|
|
99
|
-
task = Task.setup do "TEST" end
|
100
|
-
TmpFile.with_file do |tmp|
|
101
|
-
step = Step.new tmp, task
|
102
|
-
assert_equal "TEST", step.exec
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
def __test_fork
|
109
|
-
TmpFile.with_file do |lock|
|
110
|
-
task = Task.setup do while not File.exist?(lock) do sleep 1; end; "TEST" end
|
111
|
-
TmpFile.with_file do |tmp|
|
112
|
-
step = Step.new tmp, task
|
113
|
-
job = step.fork
|
114
|
-
assert !job.done?
|
115
|
-
assert_raise RuntimeError do step.fork end
|
116
|
-
sleep 1
|
117
|
-
Open.write(lock, "open")
|
118
|
-
assert_equal "TEST", job.join.load
|
119
|
-
assert job.done?
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def __test_abort
|
125
|
-
TmpFile.with_file do |lock|
|
126
|
-
task = Task.setup do while not File.exist?(lock) do sleep 1; end; "TEST" end
|
127
|
-
TmpFile.with_file do |tmp|
|
128
|
-
step = Step.new tmp, task
|
129
|
-
job = step.fork
|
130
|
-
assert !job.done?
|
131
|
-
step.clean.fork
|
132
|
-
job.abort
|
133
|
-
assert_equal :aborted, job.status
|
134
|
-
Open.write(lock, "open")
|
135
|
-
job.clean.fork
|
136
|
-
job.join
|
137
|
-
assert job.done?
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_files
|
143
|
-
TmpFile.with_file do |lock|
|
144
|
-
task = Task.setup do
|
145
|
-
Open.write(file("test"),"TEST")
|
146
|
-
end
|
147
|
-
TmpFile.with_file do |tmp|
|
148
|
-
step = Step.new tmp, task
|
149
|
-
#job = step.fork
|
150
|
-
#while not job.done? do sleep 1 end
|
151
|
-
step.run
|
152
|
-
assert_equal "TEST", Open.read(step.file("test"))
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_messages
|
158
|
-
TmpFile.with_file do |lock|
|
159
|
-
|
160
|
-
task = Task.setup do
|
161
|
-
message "WRITE"
|
162
|
-
Open.write(file("test"),"TEST")
|
163
|
-
Open.write(path,"done")
|
164
|
-
nil
|
165
|
-
end
|
166
|
-
|
167
|
-
TmpFile.with_file do |tmp|
|
168
|
-
step = Step.new tmp, task
|
169
|
-
job = step
|
170
|
-
step.run
|
171
|
-
while not job.done? do sleep 1 end
|
172
|
-
assert_equal "TEST", Open.read(job.file("test"))
|
173
|
-
assert job.messages.include? "WRITE"
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_subdir
|
179
|
-
TmpFile.with_file do |lock|
|
180
|
-
task = Task.setup do
|
181
|
-
message "WRITE"
|
182
|
-
Open.write(file("test"),"TEST")
|
183
|
-
end
|
184
|
-
|
185
|
-
TmpFile.with_file do |tmp|
|
186
|
-
step = Step.new File.join(tmp, 'subdir1', 'subdir2'), task
|
187
|
-
#job = step.fork
|
188
|
-
#while not job.done? do sleep 1 end
|
189
|
-
step.run
|
190
|
-
assert_equal "TEST", Open.read(step.file("test"))
|
191
|
-
assert step.messages.include? "WRITE"
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_semaphore
|
197
|
-
TmpFile.with_file do |semaphore|
|
198
|
-
begin
|
199
|
-
semaphore = "/" << semaphore.gsub('/','_')
|
200
|
-
RbbtSemaphore.create_semaphore(semaphore, 2)
|
201
|
-
|
202
|
-
task = Task.setup do
|
203
|
-
5.times do
|
204
|
-
puts "Process: #{Process.pid}"
|
205
|
-
sleep rand
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
jobs = []
|
210
|
-
10.times do
|
211
|
-
TmpFile.with_file do |tmp|
|
212
|
-
step = Step.new tmp, task
|
213
|
-
jobs << step.fork(semaphore)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
Step.wait_for_jobs(jobs)
|
217
|
-
ensure
|
218
|
-
RbbtSemaphore.delete_semaphore(semaphore)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
def __test_load_return_description
|
224
|
-
require 'rbbt/workflow'
|
225
|
-
Workflow.require_workflow "Study"
|
226
|
-
study = Study.setup("LICA-FR")
|
227
|
-
job = study.recurrent_mutations(:job)
|
228
|
-
iii job.load.organism
|
229
|
-
iii study.recurrent_mutations.organism
|
230
|
-
end
|
231
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/workflow/task'
|
3
|
-
require 'rbbt/tsv'
|
4
|
-
require 'rbbt'
|
5
|
-
|
6
|
-
class TEST
|
7
|
-
def self.times(str, times)
|
8
|
-
[str] * times
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class TestTask < Test::Unit::TestCase
|
13
|
-
def test_task_setup
|
14
|
-
a = [1,2]
|
15
|
-
p = Task.setup{|pos| self[pos]}
|
16
|
-
|
17
|
-
assert_equal 1, p.exec_in(a, 0)
|
18
|
-
assert_equal 2, p.exec_in(a, 1)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_task_exec
|
22
|
-
a = [1,2]
|
23
|
-
p = Proc.new{|pos| self[pos]}
|
24
|
-
p.extend Task
|
25
|
-
assert_equal 1, p.exec_in(a, 0)
|
26
|
-
assert_equal 2, p.exec_in(a, 1)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_task_named
|
30
|
-
t = Task.setup :inputs => %w(str times) do |str, times| [str] * times end
|
31
|
-
assert_equal %w(test test), t.exec(:str => "test", :times => 2)
|
32
|
-
assert_equal %w(test test), t.exec(:str => "test", :times => 2)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_task_persist
|
36
|
-
t = Task.setup :inputs => %w(str times) do |str, times|
|
37
|
-
[str] * times
|
38
|
-
end
|
39
|
-
|
40
|
-
TmpFile.with_file do |perfile|
|
41
|
-
assert_equal %w(test test), t.persist_exec_in(perfile, Object.new, :str => "test", :times => 2)
|
42
|
-
assert File.exist? perfile
|
43
|
-
|
44
|
-
t = Task.setup :inputs => %w(str times) do |str, times|
|
45
|
-
raise "Persistence ignored"
|
46
|
-
end
|
47
|
-
|
48
|
-
assert_equal %w(test test), t.persist_exec_in(perfile, Object.new, :str => "test", :times => 2)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_task_unbound_method
|
53
|
-
t = TEST.method :times
|
54
|
-
t.extend Task
|
55
|
-
t.inputs = %w(str times)
|
56
|
-
|
57
|
-
TmpFile.with_file do |perfile|
|
58
|
-
assert_equal %w(test test), t.persist_exec_in(perfile, Object.new, :str => "test", :times => 2)
|
59
|
-
assert File.exist? perfile
|
60
|
-
|
61
|
-
t = Task.setup :inputs => %w(str times) do |str, times|
|
62
|
-
raise "Persistence ignored"
|
63
|
-
end
|
64
|
-
|
65
|
-
assert_equal %w(test test), t.persist_exec_in(perfile, Object.new, :str => "test", :times => 2)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_task_unbound_method2
|
70
|
-
t = Task.setup :inputs => %w(str times), &TEST.method(:times)
|
71
|
-
|
72
|
-
TmpFile.with_file do |perfile|
|
73
|
-
assert_equal %w(test test), t.persist_exec_in(perfile, Object.new, :str => "test", :times => 2)
|
74
|
-
assert File.exist? perfile
|
75
|
-
|
76
|
-
t = Task.setup :inputs => %w(str times) do |str, times|
|
77
|
-
raise "Persistence ignored"
|
78
|
-
end
|
79
|
-
|
80
|
-
assert_equal %w(test test), t.persist_exec_in(perfile, Object.new, :str => "test", :times => 2)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
|
2
|
-
require 'rbbt-util'
|
3
|
-
require 'rbbt/workflow'
|
4
|
-
require 'rbbt/workflow/util/archive'
|
5
|
-
|
6
|
-
module ArchiveTestWF
|
7
|
-
extend Workflow
|
8
|
-
task :test_archive => :string do
|
9
|
-
Open.write(file(:file1), "Test file")
|
10
|
-
"TEST"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class TestClass < Test::Unit::TestCase
|
15
|
-
def test_migrate
|
16
|
-
job = ArchiveTestWF.job(:test_archive)
|
17
|
-
job.run
|
18
|
-
|
19
|
-
TmpFile.with_file do |tmpdir|
|
20
|
-
Misc.in_dir tmpdir do
|
21
|
-
Step.migrate(job.path, :current, :delete => false, :print => false)
|
22
|
-
end
|
23
|
-
assert_equal "TEST", Open.read(File.join(tmpdir, 'var/jobs/ArchiveTestWF/test_archive/Default'))
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/workflow/util/data'
|
3
|
-
|
4
|
-
module TestDataWF2
|
5
|
-
extend Workflow
|
6
|
-
extend Workflow::Data
|
7
|
-
|
8
|
-
input :salutation, :string
|
9
|
-
task :salute_antonio => :string do |name,salutation|
|
10
|
-
"Hi Antonio: #{salutation}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
module TestDataWF
|
15
|
-
extend Workflow
|
16
|
-
extend Workflow::Data
|
17
|
-
|
18
|
-
input :salutation, :string
|
19
|
-
task :salute_luis => :string do |name,salutation|
|
20
|
-
"Hi Luis: #{salutation}"
|
21
|
-
end
|
22
|
-
|
23
|
-
input :name, :string
|
24
|
-
input :salutation, :string
|
25
|
-
task :salute => :string do |name,salutation|
|
26
|
-
"Hi #{name}: #{salutation}"
|
27
|
-
end
|
28
|
-
|
29
|
-
data_task :salute_data, TestDataWF, :salute, :salutation => :placeholder do |directory,options|
|
30
|
-
options.merge({:salutation => directory.salutation.read})
|
31
|
-
end
|
32
|
-
|
33
|
-
data_task :salute_data2, TestDataWF, :salute, :salutation => :placeholder do |directory,options|
|
34
|
-
{:task => :salute_luis, :inputs => options.merge({:salutation => directory.salutation.read})}
|
35
|
-
end
|
36
|
-
|
37
|
-
data_task :salute_data3, TestDataWF, :salute, :salutation => :placeholder do |directory,options|
|
38
|
-
{:task => :salute_antonio, :workflow => TestDataWF2, :inputs => options.merge({:salutation => directory.salutation.read})}
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
class TestWorkflowData < Test::Unit::TestCase
|
44
|
-
def test_workflow_data
|
45
|
-
TmpFile.with_file do |tmpdir|
|
46
|
-
tmpdir = Path.setup(tmpdir.dup)
|
47
|
-
|
48
|
-
Open.write(tmpdir.TestDir.options.name, "Miguel")
|
49
|
-
Open.write(tmpdir.TestDir.salutation, "My salutations")
|
50
|
-
|
51
|
-
TestDataWF.data_dir tmpdir
|
52
|
-
|
53
|
-
job = TestDataWF.job(:salute_data, "TestDir")
|
54
|
-
job.recursive_clean.run
|
55
|
-
assert job.run.include? "Miguel"
|
56
|
-
|
57
|
-
job = TestDataWF.job(:salute_data2, "TestDir")
|
58
|
-
puts job.recursive_clean.run
|
59
|
-
assert job.run.include? "Luis"
|
60
|
-
|
61
|
-
job = TestDataWF.job(:salute_data3, "TestDir")
|
62
|
-
job.recursive_clean.run
|
63
|
-
assert job.run.include? "Antonio"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
@@ -1,263 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/workflow/util/orchestrator'
|
3
|
-
require 'rbbt/workflow/util/trace'
|
4
|
-
require 'rbbt-util'
|
5
|
-
require 'rbbt/workflow'
|
6
|
-
|
7
|
-
module TestWF
|
8
|
-
extend Workflow
|
9
|
-
|
10
|
-
MULT = 0.1
|
11
|
-
task :a => :text do
|
12
|
-
sleep(TestWF::MULT * (rand(10) + 2))
|
13
|
-
end
|
14
|
-
|
15
|
-
dep :a
|
16
|
-
task :b => :text do
|
17
|
-
sleep(TestWF::MULT * (rand(10) + 2))
|
18
|
-
end
|
19
|
-
|
20
|
-
dep :a
|
21
|
-
dep :b
|
22
|
-
task :c => :text do
|
23
|
-
sleep(TestWF::MULT * (rand(10) + 2))
|
24
|
-
end
|
25
|
-
|
26
|
-
dep :c
|
27
|
-
task :d => :text do
|
28
|
-
sleep(TestWF::MULT * (rand(10) + 2))
|
29
|
-
end
|
30
|
-
|
31
|
-
dep :c
|
32
|
-
task :e => :text do
|
33
|
-
sleep(TestWF::MULT * (rand(10) + 2))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class TestClass < Test::Unit::TestCase
|
38
|
-
def test_orchestrate_resources
|
39
|
-
|
40
|
-
jobs =[]
|
41
|
-
|
42
|
-
num = 10
|
43
|
-
num.times do |i|
|
44
|
-
jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
|
45
|
-
end
|
46
|
-
jobs.each do |j| j.recursive_clean end
|
47
|
-
|
48
|
-
rules = YAML.load <<-EOF
|
49
|
-
defaults:
|
50
|
-
log: 4
|
51
|
-
default_resources:
|
52
|
-
IO: 1
|
53
|
-
TestWF:
|
54
|
-
a:
|
55
|
-
resources:
|
56
|
-
cpus: 7
|
57
|
-
b:
|
58
|
-
resources:
|
59
|
-
cpus: 2
|
60
|
-
c:
|
61
|
-
resources:
|
62
|
-
cpus: 10
|
63
|
-
d:
|
64
|
-
resources:
|
65
|
-
cpus: 15
|
66
|
-
EOF
|
67
|
-
|
68
|
-
orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
|
69
|
-
orchestrator.process(rules, jobs)
|
70
|
-
|
71
|
-
data = Workflow.trace jobs, :plot_data => true
|
72
|
-
eend = data.column("End.second").values.collect{|v| v.to_f}.max
|
73
|
-
second_cpus = TSV.setup({}, "Second~CPUS#:type=:single#:cast=:to_f")
|
74
|
-
(0..eend.to_i).each do |second|
|
75
|
-
tasks = data.select("Start.second"){|s| s <= second}.select("End.second"){|s| s > second}
|
76
|
-
cpus = 0
|
77
|
-
tasks.through :key, ["Workflow", "Task"] do |k, values|
|
78
|
-
workflow, task = values
|
79
|
-
cpus += rules[workflow][task.to_s]["resources"]["cpus"]
|
80
|
-
end
|
81
|
-
second_cpus[second] = cpus
|
82
|
-
end
|
83
|
-
|
84
|
-
assert Misc.mean(second_cpus.values) > 15
|
85
|
-
assert Misc.mean(second_cpus.values) < 30
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_orchestrate_erase
|
89
|
-
|
90
|
-
jobs =[]
|
91
|
-
|
92
|
-
num = 10
|
93
|
-
num.times do |i|
|
94
|
-
jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
|
95
|
-
end
|
96
|
-
jobs.each do |j| j.recursive_clean end
|
97
|
-
|
98
|
-
rules = YAML.load <<-EOF
|
99
|
-
defaults:
|
100
|
-
log: 4
|
101
|
-
default_resources:
|
102
|
-
IO: 1
|
103
|
-
TestWF:
|
104
|
-
a:
|
105
|
-
erase: true
|
106
|
-
resources:
|
107
|
-
cpus: 7
|
108
|
-
b:
|
109
|
-
erase: true
|
110
|
-
resources:
|
111
|
-
cpus: 2
|
112
|
-
c:
|
113
|
-
resources:
|
114
|
-
cpus: 10
|
115
|
-
d:
|
116
|
-
resources:
|
117
|
-
cpus: 15
|
118
|
-
EOF
|
119
|
-
|
120
|
-
orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
|
121
|
-
orchestrator.process(rules, jobs)
|
122
|
-
|
123
|
-
jobs.each do |job|
|
124
|
-
assert job.step(:c).dependencies.empty?
|
125
|
-
assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/a/")}.any?
|
126
|
-
assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/b/")}.any?
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_orchestrate_default
|
132
|
-
|
133
|
-
jobs =[]
|
134
|
-
|
135
|
-
num = 3
|
136
|
-
num.times do |i|
|
137
|
-
jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
|
138
|
-
end
|
139
|
-
jobs.each do |j| j.recursive_clean end
|
140
|
-
|
141
|
-
rules = YAML.load <<-EOF
|
142
|
-
defaults:
|
143
|
-
erase: true
|
144
|
-
log: 4
|
145
|
-
default_resources:
|
146
|
-
IO: 1
|
147
|
-
TestWF:
|
148
|
-
a:
|
149
|
-
erase: true
|
150
|
-
resources:
|
151
|
-
cpus: 7
|
152
|
-
b:
|
153
|
-
erase: true
|
154
|
-
resources:
|
155
|
-
cpus: 2
|
156
|
-
c:
|
157
|
-
erase: false
|
158
|
-
resources:
|
159
|
-
cpus: 10
|
160
|
-
d:
|
161
|
-
resources:
|
162
|
-
cpus: 15
|
163
|
-
EOF
|
164
|
-
|
165
|
-
orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
|
166
|
-
orchestrator.process(rules, jobs)
|
167
|
-
|
168
|
-
jobs.each do |job|
|
169
|
-
assert job.step(:c).dependencies.empty?
|
170
|
-
assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/a/")}.any?
|
171
|
-
assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/b/")}.any?
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_orchestrate_top_level
|
177
|
-
|
178
|
-
jobs =[]
|
179
|
-
|
180
|
-
num = 3
|
181
|
-
num.times do |i|
|
182
|
-
jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
|
183
|
-
jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:c, name + " #{i}") }
|
184
|
-
end
|
185
|
-
jobs.each do |j| j.recursive_clean end
|
186
|
-
|
187
|
-
rules = YAML.load <<-EOF
|
188
|
-
defaults:
|
189
|
-
erase: true
|
190
|
-
log: 4
|
191
|
-
default_resources:
|
192
|
-
IO: 1
|
193
|
-
TestWF:
|
194
|
-
a:
|
195
|
-
resources:
|
196
|
-
cpus: 7
|
197
|
-
b:
|
198
|
-
resources:
|
199
|
-
cpus: 2
|
200
|
-
c:
|
201
|
-
resources:
|
202
|
-
cpus: 10
|
203
|
-
d:
|
204
|
-
resources:
|
205
|
-
cpus: 15
|
206
|
-
EOF
|
207
|
-
|
208
|
-
orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
|
209
|
-
orchestrator.process(rules, jobs)
|
210
|
-
|
211
|
-
jobs.each do |job|
|
212
|
-
next unless job.task_name.to_s == 'd'
|
213
|
-
assert job.step(:c).dependencies.empty?
|
214
|
-
assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/a/")}.any?
|
215
|
-
assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/b/")}.any?
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|
219
|
-
|
220
|
-
def test_orchestrate_top_level_double_dep
|
221
|
-
|
222
|
-
jobs =[]
|
223
|
-
|
224
|
-
num = 10
|
225
|
-
num.times do |i|
|
226
|
-
jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:e, name + " #{i}") }
|
227
|
-
jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
|
228
|
-
end
|
229
|
-
jobs.each do |j| j.recursive_clean end
|
230
|
-
|
231
|
-
rules = YAML.load <<-EOF
|
232
|
-
defaults:
|
233
|
-
erase: true
|
234
|
-
log: 4
|
235
|
-
default_resources:
|
236
|
-
IO: 1
|
237
|
-
TestWF:
|
238
|
-
a:
|
239
|
-
resources:
|
240
|
-
cpus: 7
|
241
|
-
b:
|
242
|
-
resources:
|
243
|
-
cpus: 2
|
244
|
-
c:
|
245
|
-
resources:
|
246
|
-
cpus: 10
|
247
|
-
d:
|
248
|
-
resources:
|
249
|
-
cpus: 15
|
250
|
-
EOF
|
251
|
-
|
252
|
-
orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
|
253
|
-
orchestrator.process(rules, jobs)
|
254
|
-
|
255
|
-
jobs.each do |job|
|
256
|
-
next unless job.task_name.to_s == 'd' || job.task_name.to_s == 'e'
|
257
|
-
assert job.info[:archived_info].keys.select{|k| k.include?("TestWF/c/")}.any?
|
258
|
-
assert job.info[:archived_info].keys.select{|k| k.include?("TestWF/c/")}.any?
|
259
|
-
end
|
260
|
-
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|