scout-gear 8.0.0 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +26 -9
  3. data/Rakefile +6 -1
  4. data/VERSION +1 -1
  5. data/bin/scout +15 -4
  6. data/doc/lib/scout/path.md +35 -0
  7. data/doc/lib/scout/workflow/task.md +13 -0
  8. data/lib/scout/cmd.rb +23 -24
  9. data/lib/scout/concurrent_stream.rb +36 -19
  10. data/lib/scout/exceptions.rb +10 -0
  11. data/lib/scout/log/color.rb +11 -11
  12. data/lib/scout/log/progress/report.rb +7 -5
  13. data/lib/scout/log/progress/util.rb +3 -0
  14. data/lib/scout/log/trap.rb +3 -3
  15. data/lib/scout/log.rb +64 -36
  16. data/lib/scout/meta_extension.rb +34 -0
  17. data/lib/scout/misc/digest.rb +11 -2
  18. data/lib/scout/misc/format.rb +12 -7
  19. data/lib/scout/misc/monitor.rb +11 -0
  20. data/lib/scout/misc/system.rb +48 -0
  21. data/lib/scout/named_array.rb +8 -0
  22. data/lib/scout/offsite/ssh.rb +171 -0
  23. data/lib/scout/offsite/step.rb +83 -0
  24. data/lib/scout/offsite/sync.rb +55 -0
  25. data/lib/scout/offsite.rb +3 -0
  26. data/lib/scout/open/lock.rb +5 -24
  27. data/lib/scout/open/remote.rb +12 -1
  28. data/lib/scout/open/stream.rb +110 -122
  29. data/lib/scout/open/util.rb +9 -0
  30. data/lib/scout/open.rb +5 -4
  31. data/lib/scout/path/find.rb +15 -10
  32. data/lib/scout/path/util.rb +5 -0
  33. data/lib/scout/persist/serialize.rb +3 -3
  34. data/lib/scout/persist.rb +1 -1
  35. data/lib/scout/resource/path.rb +4 -0
  36. data/lib/scout/resource/util.rb +10 -4
  37. data/lib/scout/tsv/dumper.rb +2 -0
  38. data/lib/scout/tsv/index.rb +28 -86
  39. data/lib/scout/tsv/open.rb +35 -14
  40. data/lib/scout/tsv/parser.rb +9 -2
  41. data/lib/scout/tsv/persist/tokyocabinet.rb +2 -0
  42. data/lib/scout/tsv/stream.rb +204 -0
  43. data/lib/scout/tsv/transformer.rb +11 -0
  44. data/lib/scout/tsv.rb +9 -2
  45. data/lib/scout/work_queue/worker.rb +2 -2
  46. data/lib/scout/work_queue.rb +36 -12
  47. data/lib/scout/workflow/definition.rb +2 -1
  48. data/lib/scout/workflow/deployment/orchestrator.rb +245 -0
  49. data/lib/scout/workflow/deployment.rb +1 -0
  50. data/lib/scout/workflow/step/dependencies.rb +37 -11
  51. data/lib/scout/workflow/step/file.rb +5 -0
  52. data/lib/scout/workflow/step/info.rb +5 -3
  53. data/lib/scout/workflow/step/load.rb +1 -1
  54. data/lib/scout/workflow/step/provenance.rb +1 -0
  55. data/lib/scout/workflow/step/status.rb +6 -8
  56. data/lib/scout/workflow/step.rb +75 -30
  57. data/lib/scout/workflow/task/dependencies.rb +114 -0
  58. data/lib/scout/workflow/task/inputs.rb +27 -13
  59. data/lib/scout/workflow/task.rb +9 -108
  60. data/lib/scout/workflow/usage.rb +40 -12
  61. data/lib/scout/workflow.rb +4 -2
  62. data/lib/scout-gear.rb +2 -0
  63. data/lib/scout.rb +6 -0
  64. data/scout-gear.gemspec +32 -7
  65. data/scout_commands/doc +37 -0
  66. data/scout_commands/find +1 -0
  67. data/scout_commands/offsite +30 -0
  68. data/scout_commands/update +29 -0
  69. data/scout_commands/workflow/info +15 -3
  70. data/scout_commands/workflow/install +102 -0
  71. data/scout_commands/workflow/task +26 -5
  72. data/test/scout/offsite/test_ssh.rb +15 -0
  73. data/test/scout/offsite/test_step.rb +33 -0
  74. data/test/scout/offsite/test_sync.rb +36 -0
  75. data/test/scout/offsite/test_task.rb +0 -0
  76. data/test/scout/resource/test_path.rb +6 -0
  77. data/test/scout/test_named_array.rb +6 -0
  78. data/test/scout/test_persist.rb +3 -2
  79. data/test/scout/test_tsv.rb +17 -0
  80. data/test/scout/test_work_queue.rb +63 -41
  81. data/test/scout/tsv/persist/test_adapter.rb +1 -1
  82. data/test/scout/tsv/test_index.rb +14 -0
  83. data/test/scout/tsv/test_parser.rb +14 -0
  84. data/test/scout/tsv/test_stream.rb +200 -0
  85. data/test/scout/tsv/test_transformer.rb +12 -0
  86. data/test/scout/workflow/deployment/test_orchestrator.rb +272 -0
  87. data/test/scout/workflow/step/test_dependencies.rb +68 -0
  88. data/test/scout/workflow/step/test_info.rb +18 -0
  89. data/test/scout/workflow/step/test_status.rb +0 -1
  90. data/test/scout/workflow/task/test_dependencies.rb +355 -0
  91. data/test/scout/workflow/task/test_inputs.rb +53 -0
  92. data/test/scout/workflow/test_definition.rb +18 -0
  93. data/test/scout/workflow/test_documentation.rb +24 -0
  94. data/test/scout/workflow/test_step.rb +109 -0
  95. data/test/scout/workflow/test_task.rb +0 -287
  96. data/test/test_scout.rb +9 -0
  97. metadata +83 -5
  98. data/scout_commands/workflow/task_old +0 -706
@@ -90,60 +90,82 @@ class TestWorkQueue < Test::Unit::TestCase
90
90
  end
91
91
 
92
92
  def test_queue_error
93
- num = 100
94
- reps = 10_000
95
-
96
- q = WorkQueue.new num do |obj|
97
- raise ScoutException if rand < 0.1
98
- [Process.pid.to_s, obj.to_s] * " "
99
- end
100
-
101
- res = []
102
- q.process do |out|
103
- res << out
104
- end
93
+ 5.times do |i|
94
+ num = 100
95
+ reps = 10_000
105
96
 
106
- Log.with_severity 7 do
107
- pid = Process.fork do
108
- reps.times do |i|
109
- q.write i
110
- end
97
+ q = WorkQueue.new num do |obj|
98
+ raise ScoutException if rand < 0.1
99
+ [Process.pid.to_s, obj.to_s] * " "
111
100
  end
112
101
 
113
- Process.waitpid pid
102
+ res = []
103
+ q.process do |out|
104
+ res << out
105
+ end
114
106
 
115
- assert_raise ScoutException do
116
- q.join
117
- t.join
107
+ Log.with_severity 7 do
108
+ t = Thread.new do
109
+ Thread.current["name"] = "queue writer"
110
+ Thread.current.report_on_exception = false
111
+ reps.times do |i|
112
+ q.write i
113
+ end
114
+ q.close
115
+ end
116
+ Thread.pass until t["name"]
117
+
118
+ assert_raise ScoutException do
119
+ begin
120
+ q.join(false)
121
+ rescue
122
+ t.raise($!)
123
+ raise $!
124
+ ensure
125
+ t.join
126
+ end
127
+ end
118
128
  end
119
129
  end
120
130
  end
121
131
 
122
132
  def test_queue_error_in_input
123
- num = 100
124
- reps = 10_000
133
+ 5.times do |i|
134
+ num = 100
135
+ reps = 10_000
125
136
 
126
- q = WorkQueue.new num do |obj|
127
- [Process.pid.to_s, obj.to_s] * " "
128
- end
129
-
130
- res = []
131
- q.process do |out|
132
- raise ScoutException
133
- res << out
134
- end
137
+ q = WorkQueue.new num do |obj|
138
+ [Process.pid.to_s, obj.to_s] * " "
139
+ end
135
140
 
136
- Log.with_severity 7 do
137
- pid = Process.fork do
138
- reps.times do |i|
139
- q.write i
140
- end
141
- q.close
141
+ res = []
142
+ q.process do |out|
143
+ raise ScoutException
144
+ res << out
142
145
  end
143
146
 
144
- assert_raise ScoutException do
145
- q.join
146
- t.join
147
+ Log.with_severity 7 do
148
+ t = Thread.new do
149
+ Thread.current.report_on_exception = false
150
+ Thread.current["name"] = "queue writer"
151
+ reps.times do |i|
152
+ q.write i
153
+ end
154
+ q.close
155
+ end
156
+ Thread.pass until t["name"]
157
+
158
+ assert_raise ScoutException do
159
+ begin
160
+ q.join(false)
161
+ rescue Exception
162
+ t.raise($!)
163
+ raise $!
164
+ ensure
165
+ t.join
166
+ q.clean
167
+ end
168
+ end
147
169
  end
148
170
  end
149
171
  end
@@ -3,7 +3,7 @@ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1
3
3
 
4
4
  require 'scout/tsv'
5
5
  class TestTSVAdapter < Test::Unit::TestCase
6
- def _test_get_set
6
+ def test_get_set
7
7
  tsv = TSV.setup({}, :type => :list, :key_field => "Key", :fields => %w(one two three))
8
8
  tsv.type = :list
9
9
  tsv.extend TSVAdapter
@@ -43,6 +43,20 @@ row2 a b id3
43
43
  end
44
44
  end
45
45
 
46
+ def test_index_from_flat
47
+ content =<<-'EOF'
48
+ #: :sep=" "#:type=:flat
49
+ #Id ValueA
50
+ row1 a aa aaa
51
+ row2 b bb bbb
52
+ EOF
53
+
54
+ TmpFile.with_file(content) do |filename|
55
+ index = TSV.index(filename, :target => "Id")
56
+ assert_equal "row1", index["aa"]
57
+ end
58
+ end
59
+
46
60
  def test_from_tsv
47
61
  content =<<-'EOF'
48
62
  #: :sep=/\s+/#:type=:double#:merge=:concat
@@ -119,6 +119,20 @@ k a|A b|B
119
119
  assert_equal [%w(b B), %w(k)], tsv['k']
120
120
  end
121
121
 
122
+ def test_parse_flat
123
+ content =<<-EOF
124
+ #: :sep=" "#:type=:flat
125
+ #Key ValueA
126
+ row1 a aa aaa
127
+ row2 b bb bbb
128
+ EOF
129
+
130
+ tsv = TSV.open(content)
131
+ assert_equal %w(a aa aaa), tsv["row1"]
132
+ tsv = TSV.open(content, :fields => ["ValueA"])
133
+ assert_equal %w(a aa aaa), tsv["row1"]
134
+ end
135
+
122
136
  def test_parse_key
123
137
  content =<<-EOF
124
138
  #: :sep=" "#:type=:double
@@ -0,0 +1,200 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tsv'
5
+ class TestTSVStream < Test::Unit::TestCase
6
+ def test_paste_stream
7
+ text1=<<-EOF
8
+ #: :sep=" "
9
+ #Row LabelA LabelB LabelC
10
+ row1 A B C
11
+ row2 AA BB CC
12
+ row3 AAA BBB CCC
13
+ EOF
14
+
15
+ text2=<<-EOF
16
+ #: :sep=" "
17
+ #Row Labela Labelb
18
+ row1 a b
19
+ row2 aa bb
20
+ row3 aaa bbb
21
+ EOF
22
+
23
+ text3=<<-EOF
24
+ #: :sep=" "
25
+ #Row LabelC
26
+ row1 c
27
+ row2 cc
28
+ row3 ccc
29
+ EOF
30
+
31
+ s1 = StringIO.new text1
32
+ s2 = StringIO.new text2
33
+ s3 = StringIO.new text3
34
+ tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list)
35
+ assert_equal ["A", "B", "C", "a", "b", "c"], tsv["row1"]
36
+ assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
37
+ assert_equal ["AAA", "BBB", "CCC", "aaa", "bbb", "ccc"], tsv["row3"]
38
+ end
39
+
40
+ def test_paste_stream_sort
41
+ text1=<<-EOF
42
+ #: :sep=" "
43
+ #Row LabelA LabelB LabelC
44
+ row2 AA BB CC
45
+ row1 A B C
46
+ row3 AAA BBB CCC
47
+ EOF
48
+
49
+ text2=<<-EOF
50
+ #: :sep=" "
51
+ #Row Labela Labelb
52
+ row1 a b
53
+ row3 aaa bbb
54
+ row2 aa bb
55
+ EOF
56
+
57
+ text3=<<-EOF
58
+ #: :sep=" "
59
+ #Row Labelc
60
+ row3 ccc
61
+ row1 c
62
+ row2 cc
63
+ EOF
64
+
65
+ s1 = StringIO.new text1
66
+ s2 = StringIO.new text2
67
+ s3 = StringIO.new text3
68
+ tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list, :sort => true)
69
+ assert_equal "Row", tsv.key_field
70
+ assert_equal %w(LabelA LabelB LabelC Labela Labelb Labelc), tsv.fields
71
+ assert_equal ["A", "B", "C", "a", "b", "c"], tsv["row1"]
72
+ assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
73
+ assert_equal ["AAA", "BBB", "CCC", "aaa", "bbb", "ccc"], tsv["row3"]
74
+ end
75
+
76
+ def test_paste_stream_missing_2
77
+ text1=<<-EOF
78
+ #: :sep=" "
79
+ #Row LabelA LabelB LabelC
80
+ row2 AA BB CC
81
+ row1 A B C
82
+ EOF
83
+
84
+ text2=<<-EOF
85
+ #: :sep=" "
86
+ #Row Labela Labelb
87
+ row2 aa bb
88
+ EOF
89
+
90
+ text3=<<-EOF
91
+ #: :sep=" "
92
+ #Row Labelc
93
+ row3 ccc
94
+ row2 cc
95
+ EOF
96
+
97
+ s1 = StringIO.new text1
98
+ s2 = StringIO.new text2
99
+ s3 = StringIO.new text3
100
+ tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list, :sort => true)
101
+ assert_equal "Row", tsv.key_field
102
+ assert_equal %w(LabelA LabelB LabelC Labela Labelb Labelc), tsv.fields
103
+ assert_equal ["A", "B", "C", "", "", ""], tsv["row1"]
104
+ assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
105
+ assert_equal ["", "", "", "", "", "ccc"], tsv["row3"]
106
+ end
107
+
108
+ def test_paste_stream_missing
109
+ text1=<<-EOF
110
+ #: :sep=" "
111
+ #Row LabelA LabelB LabelC
112
+ row2 AA BB CC
113
+ row1 A B C
114
+ EOF
115
+
116
+ text2=<<-EOF
117
+ #: :sep=" "
118
+ #Row Labela Labelb
119
+ row2 aa bb
120
+ EOF
121
+
122
+ text3=<<-EOF
123
+ #: :sep=" "
124
+ #Row Labelc
125
+ row3 ccc
126
+ row2 cc
127
+ EOF
128
+
129
+ s1 = StringIO.new text1
130
+ s2 = StringIO.new text2
131
+ s3 = StringIO.new text3
132
+ tsv = TSV.open TSV.paste_streams([s1,s2,s3], :sep => " ", :type => :list, :sort => true)
133
+ assert_equal "Row", tsv.key_field
134
+ assert_equal %w(LabelA LabelB LabelC Labela Labelb Labelc), tsv.fields
135
+ assert_equal ["A", "B", "C", "", "", ""], tsv["row1"]
136
+ assert_equal ["AA", "BB", "CC", "aa", "bb", "cc"], tsv["row2"]
137
+ assert_equal ["", "", "", "", "", "ccc"], tsv["row3"]
138
+ end
139
+
140
+ def test_paste_stream_missing_3
141
+ text1=<<-EOF
142
+ #: :sep=" "
143
+ #Row LabelA LabelB LabelC
144
+ row2 AA BB CC
145
+ row1 A B C
146
+ EOF
147
+
148
+ text2=<<-EOF
149
+ #: :sep=" "
150
+ #Row Labelc
151
+ EOF
152
+
153
+ s1 = StringIO.new text1
154
+ s2 = StringIO.new text2
155
+ tsv = TSV.open TSV.paste_streams([s1,s2], :sep => " ", :type => :list, :sort => true)
156
+ assert_equal "Row", tsv.key_field
157
+ assert_equal %w(LabelA LabelB LabelC Labelc), tsv.fields
158
+ assert_equal ["A", "B", "C", ""], tsv["row1"]
159
+ assert_equal ["AA", "BB", "CC", ""], tsv["row2"]
160
+ end
161
+
162
+ def test_paste_stream_same_field
163
+ text1=<<-EOF
164
+ #: :sep=" "
165
+ #Row LabelA
166
+ row1 A
167
+ row2 AA
168
+ EOF
169
+
170
+ text2=<<-EOF
171
+ #: :sep=" "
172
+ #Row LabelA
173
+ row2 AAA
174
+ EOF
175
+
176
+ s1 = StringIO.new text1
177
+ s2 = StringIO.new text2
178
+ tsv = TSV.open TSV.paste_streams([s1,s2], :sep => " ", :type => :double, :sort => false, :same_fields => true)
179
+ assert_equal "Row", tsv.key_field
180
+ assert_equal ["AA", "AAA"], tsv["row2"][0]
181
+ end
182
+
183
+ def test_paste_stream_nohead
184
+ text1=<<-EOF
185
+ row1\tA
186
+ row2\tAA
187
+ EOF
188
+
189
+ text2=<<-EOF
190
+ row2\tAAA
191
+ EOF
192
+
193
+ s1 = StringIO.new text1
194
+ s2 = StringIO.new text2
195
+ tsv = TSV.open TSV.paste_streams([s1,s2], :type => :double, :sort => false, :same_fields => true)
196
+ assert_equal ["AA", "AAA"], tsv["row2"][0]
197
+ end
198
+
199
+ end
200
+
@@ -105,4 +105,16 @@ row2 A2|A22 B2|B22
105
105
  assert_equal "A1", tsv.to_single["row1"]
106
106
  assert_equal "A2", tsv.to_single["row2"]
107
107
  end
108
+
109
+ def test_to_flat
110
+ content =<<-EOF
111
+ #: :sep=" "
112
+ #ID ValueA ValueB
113
+ row1 A1|A11 B1|B11
114
+ row2 A2|A22 B2|B22
115
+ EOF
116
+
117
+ tsv = TSV.open(content)
118
+ assert_equal %w(A1 A11 B1 B11), tsv.to_flat["row1"]
119
+ end
108
120
  end
@@ -0,0 +1,272 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestOrchestrator < Test::Unit::TestCase
5
+ setup do
6
+ module TestWF
7
+ extend Workflow
8
+
9
+ MULT = 0.01
10
+ task :a => :text do
11
+ sleep(TestWF::MULT * (rand(10) + 2))
12
+ end
13
+
14
+ dep :a
15
+ task :b => :text do
16
+ sleep(TestWF::MULT * (rand(10) + 2))
17
+ end
18
+
19
+ dep :a
20
+ dep :b
21
+ task :c => :text do
22
+ sleep(TestWF::MULT * (rand(10) + 2))
23
+ end
24
+
25
+ dep :c
26
+ task :d => :text do
27
+ sleep(TestWF::MULT * (rand(10) + 2))
28
+ end
29
+
30
+ dep :c
31
+ task :e => :text do
32
+ sleep(TestWF::MULT * (rand(10) + 2))
33
+ end
34
+ end
35
+ end
36
+
37
+ def TODO_test_orchestrate_resources
38
+
39
+ jobs =[]
40
+
41
+ num = 10
42
+ num.times do |i|
43
+ jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
44
+ end
45
+ jobs.each do |j| j.recursive_clean end
46
+
47
+ rules = YAML.load <<-EOF
48
+ defaults:
49
+ log: 4
50
+ default_resources:
51
+ IO: 1
52
+ TestWF:
53
+ a:
54
+ resources:
55
+ cpus: 7
56
+ b:
57
+ resources:
58
+ cpus: 2
59
+ c:
60
+ resources:
61
+ cpus: 10
62
+ d:
63
+ resources:
64
+ cpus: 15
65
+ EOF
66
+
67
+ orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
68
+ Log.with_severity 0 do
69
+ orchestrator.process(rules, jobs)
70
+ end
71
+
72
+ data = Workflow.trace jobs, :plot_data => true
73
+ eend = data.column("End.second").values.collect{|v| v.to_f}.max
74
+ second_cpus = TSV.setup({}, "Second~CPUS#:type=:single#:cast=:to_f")
75
+ (0..eend.to_i).each do |second|
76
+ tasks = data.select("Start.second"){|s| s <= second}.select("End.second"){|s| s > second}
77
+ cpus = 0
78
+ tasks.through :key, ["Workflow", "Task"] do |k, values|
79
+ workflow, task = values
80
+ cpus += rules[workflow][task.to_s]["resources"]["cpus"]
81
+ end
82
+ second_cpus[second] = cpus
83
+ end
84
+
85
+ assert Misc.mean(second_cpus.values) > 15
86
+ assert Misc.mean(second_cpus.values) < 30
87
+ end
88
+
89
+ def TODO_test_orchestrate_erase
90
+
91
+ jobs =[]
92
+
93
+ num = 10
94
+ num.times do |i|
95
+ jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
96
+ end
97
+ jobs.each do |j| j.recursive_clean end
98
+
99
+ rules = YAML.load <<-EOF
100
+ defaults:
101
+ log: 4
102
+ default_resources:
103
+ IO: 1
104
+ TestWF:
105
+ a:
106
+ erase: true
107
+ resources:
108
+ cpus: 7
109
+ b:
110
+ erase: true
111
+ resources:
112
+ cpus: 2
113
+ c:
114
+ resources:
115
+ cpus: 10
116
+ d:
117
+ resources:
118
+ cpus: 15
119
+ EOF
120
+
121
+ orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
122
+ Log.with_severity 3 do
123
+ orchestrator.process(rules, jobs)
124
+ end
125
+
126
+ jobs.each do |job|
127
+ assert job.step(:c).dependencies.empty?
128
+ assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/a/")}.any?
129
+ assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/b/")}.any?
130
+ end
131
+
132
+ end
133
+
134
+ def TODO_test_orchestrate_default
135
+
136
+ jobs =[]
137
+
138
+ num = 3
139
+ num.times do |i|
140
+ jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
141
+ end
142
+ jobs.each do |j| j.recursive_clean end
143
+
144
+ rules = YAML.load <<-EOF
145
+ defaults:
146
+ erase: true
147
+ log: 4
148
+ default_resources:
149
+ IO: 1
150
+ TestWF:
151
+ a:
152
+ erase: true
153
+ resources:
154
+ cpus: 7
155
+ b:
156
+ erase: true
157
+ resources:
158
+ cpus: 2
159
+ c:
160
+ erase: false
161
+ resources:
162
+ cpus: 10
163
+ d:
164
+ resources:
165
+ cpus: 15
166
+ EOF
167
+
168
+ orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
169
+ Log.with_severity 3 do
170
+ orchestrator.process(rules, jobs)
171
+ end
172
+
173
+ jobs.each do |job|
174
+ assert job.step(:c).dependencies.empty?
175
+ assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/a/")}.any?
176
+ assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/b/")}.any?
177
+ end
178
+
179
+ end
180
+
181
+ def TODO_test_orchestrate_top_level
182
+
183
+ jobs =[]
184
+
185
+ num = 3
186
+ num.times do |i|
187
+ jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
188
+ jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:c, name + " #{i}") }
189
+ end
190
+ jobs.each do |j| j.recursive_clean end
191
+
192
+ rules = YAML.load <<-EOF
193
+ defaults:
194
+ erase: true
195
+ log: 4
196
+ default_resources:
197
+ IO: 1
198
+ TestWF:
199
+ a:
200
+ resources:
201
+ cpus: 7
202
+ b:
203
+ resources:
204
+ cpus: 2
205
+ c:
206
+ resources:
207
+ cpus: 10
208
+ d:
209
+ resources:
210
+ cpus: 15
211
+ EOF
212
+
213
+ orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
214
+ Log.with_severity 3 do
215
+ orchestrator.process(rules, jobs)
216
+ end
217
+
218
+ jobs.each do |job|
219
+ next unless job.task_name.to_s == 'd'
220
+ assert job.step(:c).dependencies.empty?
221
+ assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/a/")}.any?
222
+ assert job.step(:c).info[:archived_info].keys.select{|k| k.include?("TestWF/b/")}.any?
223
+ end
224
+
225
+ end
226
+
227
+ def TODO_test_orchestrate_top_level_double_dep
228
+
229
+ jobs =[]
230
+
231
+ num = 10
232
+ num.times do |i|
233
+ jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:e, name + " #{i}") }
234
+ jobs.concat %w(TEST1 TEST2).collect{|name| TestWF.job(:d, name + " #{i}") }
235
+ end
236
+ jobs.each do |j| j.recursive_clean end
237
+
238
+ rules = YAML.load <<-EOF
239
+ defaults:
240
+ erase: true
241
+ log: 4
242
+ default_resources:
243
+ IO: 1
244
+ TestWF:
245
+ a:
246
+ resources:
247
+ cpus: 7
248
+ b:
249
+ resources:
250
+ cpus: 2
251
+ c:
252
+ resources:
253
+ cpus: 10
254
+ d:
255
+ resources:
256
+ cpus: 15
257
+ EOF
258
+
259
+ orchestrator = Workflow::Orchestrator.new(TestWF::MULT, "cpus" => 30, "IO" => 4, "size" => 10 )
260
+ Log.with_severity 3 do
261
+ orchestrator.process(rules, jobs)
262
+ end
263
+
264
+ jobs.each do |job|
265
+ next unless job.task_name.to_s == 'd' || job.task_name.to_s == 'e'
266
+ assert job.info[:archived_info].keys.select{|k| k.include?("TestWF/c/")}.any?
267
+ assert job.info[:archived_info].keys.select{|k| k.include?("TestWF/c/")}.any?
268
+ end
269
+
270
+ end
271
+ end
272
+