scout-gear 10.7.0 → 10.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +8 -1
  3. data/VERSION +1 -1
  4. data/lib/scout/association/index.rb +1 -1
  5. data/lib/scout/association.rb +21 -5
  6. data/lib/scout/entity/format.rb +9 -4
  7. data/lib/scout/entity/identifiers.rb +2 -2
  8. data/lib/scout/entity/named_array.rb +13 -0
  9. data/lib/scout/entity/property.rb +2 -1
  10. data/lib/scout/entity.rb +9 -4
  11. data/lib/scout/persist/tsv/adapter/base.rb +13 -1
  12. data/lib/scout/persist/tsv.rb +2 -1
  13. data/lib/scout/tsv/attach.rb +10 -2
  14. data/lib/scout/tsv/change_id.rb +3 -0
  15. data/lib/scout/tsv/dumper.rb +34 -30
  16. data/lib/scout/tsv/open.rb +1 -0
  17. data/lib/scout/tsv/parser.rb +22 -10
  18. data/lib/scout/tsv/path.rb +8 -0
  19. data/lib/scout/tsv/stream.rb +15 -8
  20. data/lib/scout/tsv/traverse.rb +12 -2
  21. data/lib/scout/tsv/util/process.rb +4 -1
  22. data/lib/scout/tsv/util/select.rb +8 -2
  23. data/lib/scout/tsv/util/sort.rb +23 -15
  24. data/lib/scout/tsv/util.rb +11 -2
  25. data/lib/scout/tsv.rb +23 -11
  26. data/lib/scout/workflow/definition.rb +24 -9
  27. data/lib/scout/workflow/deployment/orchestrator.rb +10 -7
  28. data/lib/scout/workflow/exceptions.rb +1 -0
  29. data/lib/scout/workflow/path.rb +40 -0
  30. data/lib/scout/workflow/step/dependencies.rb +36 -12
  31. data/lib/scout/workflow/step/file.rb +2 -1
  32. data/lib/scout/workflow/step/info.rb +20 -4
  33. data/lib/scout/workflow/step/load.rb +5 -3
  34. data/lib/scout/workflow/step/progress.rb +6 -0
  35. data/lib/scout/workflow/step/provenance.rb +1 -1
  36. data/lib/scout/workflow/step/status.rb +11 -4
  37. data/lib/scout/workflow/step.rb +33 -12
  38. data/lib/scout/workflow/task/dependencies.rb +33 -24
  39. data/lib/scout/workflow/task/inputs.rb +42 -12
  40. data/lib/scout/workflow/task.rb +22 -11
  41. data/lib/scout/workflow/usage.rb +3 -3
  42. data/lib/scout/workflow.rb +3 -0
  43. data/scout-gear.gemspec +13 -4
  44. data/scout_commands/db/query +83 -0
  45. data/scout_commands/db/register +43 -0
  46. data/scout_commands/db/show +47 -0
  47. data/test/scout/entity/test_named_array.rb +21 -0
  48. data/test/scout/persist/test_tsv.rb +20 -0
  49. data/test/scout/persist/tsv/adapter/test_base.rb +20 -0
  50. data/test/scout/test_tsv.rb +40 -0
  51. data/test/scout/tsv/test_dumper.rb +24 -0
  52. data/test/scout/tsv/test_path.rb +24 -0
  53. data/test/scout/tsv/test_stream.rb +93 -0
  54. data/test/scout/tsv/test_traverse.rb +99 -0
  55. data/test/scout/tsv/test_util.rb +2 -0
  56. data/test/scout/tsv/util/test_select.rb +22 -0
  57. data/test/scout/tsv/util/test_sort.rb +24 -0
  58. data/test/scout/workflow/step/test_dependencies.rb +26 -0
  59. data/test/scout/workflow/step/test_info.rb +35 -0
  60. data/test/scout/workflow/task/test_dependencies.rb +67 -1
  61. data/test/scout/workflow/task/test_inputs.rb +24 -7
  62. data/test/scout/workflow/test_definition.rb +31 -0
  63. data/test/scout/workflow/test_path.rb +9 -0
  64. data/test/scout/workflow/test_task.rb +36 -0
  65. data/test/scout/workflow/test_usage.rb +0 -1
  66. metadata +12 -3
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'scout'
4
+ require 'scout/association'
5
+
6
+ $0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
7
+
8
+ options = SOPT.setup <<EOF
9
+
10
+ Show a database
11
+
12
+ $ #{$0} [<options>] <name>
13
+
14
+ -h--help Print this help
15
+ EOF
16
+ if options[:help]
17
+ if defined? scout_usage
18
+ scout_usage
19
+ else
20
+ puts SOPT.doc
21
+ end
22
+ exit 0
23
+ end
24
+
25
+
26
+ registry = begin
27
+ Scout.var.databases.registry.yaml
28
+ rescue
29
+ {}
30
+ end
31
+
32
+ name = ARGV.first
33
+
34
+ if name.nil?
35
+ puts registry.keys * "\n"
36
+
37
+ else
38
+
39
+ raise ParameterException "Database #{name} not found Options: #{Log.fingerprint registry.keys}" unless registry.include? name
40
+
41
+ file, options = registry[name]
42
+
43
+ IndiferentHash.setup(options)
44
+ options.keys_to_sym!
45
+
46
+ Log.tsv Association.database(file, **options)
47
+ end
@@ -0,0 +1,21 @@
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 TestNamedArrayEntity < Test::Unit::TestCase
5
+ def setup
6
+ m = Module.new do
7
+ extend Entity
8
+ self.format = "SomeEntity"
9
+
10
+ property :prop do
11
+ "PROP: #{self}"
12
+ end
13
+ end
14
+ end
15
+
16
+ def test_true
17
+ a = NamedArray.setup(["a", "b"], %w(SomeEntity Other))
18
+ assert a["SomeEntity"].respond_to?(:prop)
19
+ end
20
+ end
21
+
@@ -40,6 +40,7 @@ row2 a a id3
40
40
  end
41
41
  end
42
42
 
43
+ assert_include tsv.fields, "ValueA"
43
44
  assert_include tsv.keys, 'row1'
44
45
  assert_include tsv.keys, 'row2'
45
46
  end
@@ -67,6 +68,7 @@ row2 a a id3
67
68
  end
68
69
  refute Open.exists?(tk)
69
70
  assert Open.exists?(data.persistence_path)
71
+ refute tsv.fields.nil?
70
72
  end
71
73
 
72
74
  assert_include tsv.keys, 'row1'
@@ -142,5 +144,23 @@ row2 a a id3
142
144
  assert_include tsv.keys, 'row1'
143
145
  assert_include tsv.keys, 'row2'
144
146
  end
147
+
148
+ def test_tsv_open_persist
149
+ content =<<-'EOF'
150
+ #Id ValueA ValueB OtherID
151
+ row1 a|aa|aaa b Id1|Id2
152
+ row2 A B Id3
153
+ row2 a a id3
154
+ EOF
155
+
156
+
157
+ tsv = nil
158
+ TmpFile.with_file(content) do |filename|
159
+ tsv = TSV.open(filename, sep: /\s+/, type: :double, persist: true, merge: true)
160
+ assert Array === tsv.fields
161
+ tsv = TSV.open(filename, sep: /\s+/, type: :double, persist: true, merge: true)
162
+ assert Array === tsv.fields
163
+ end
164
+ end
145
165
  end
146
166
 
@@ -39,5 +39,25 @@ class TestTSVAdapter < Test::Unit::TestCase
39
39
  assert_equal [1, 2, 3], tsv["a"]
40
40
  assert_equal [1, 2, 3], Marshal.load(tsv.orig_get("a"))
41
41
  end
42
+
43
+ def test_persist_annotations
44
+ content =<<-'EOF'
45
+ #: :sep=/\s+/#:type=:double#:merge=:concat
46
+ #Id ValueA ValueB OtherID
47
+ row1 a|aa|aaa b Id1|Id2
48
+ row2 A B Id3
49
+ row2 a a id3
50
+ EOF
51
+
52
+ TmpFile.with_file(content) do |tsv_file|
53
+ pid = Process.fork do
54
+ tsv = TSV.open tsv_file, persist: true
55
+ end
56
+ Process.waitpid pid
57
+ tsv = TSV.open tsv_file, persist: true
58
+ refute tsv.fields.nil?
59
+ end
60
+ end
61
+
42
62
  end
43
63
 
@@ -387,4 +387,44 @@ row2 A B Id3
387
387
  tsv = TSV.open(filename, :sep => /\s+/, :identifiers => Scout.share.identifiers)
388
388
  end
389
389
  end
390
+
391
+ def test_identifier_file_auto
392
+ content =<<-EOF
393
+ #Id ValueA ValueB OtherID
394
+ row1 a|aa|aaa b Id1|Id2
395
+ row2 A B Id3
396
+ EOF
397
+
398
+ ids =<<-EOF
399
+ #Id Alias
400
+ row1 r1
401
+ row2 r2
402
+ EOF
403
+
404
+ TmpFile.with_dir do |dir|
405
+ Path.setup(dir)
406
+ Open.write(dir.tsv_file, content)
407
+ Open.write(dir.identifiers, ids)
408
+ tsv = TSV.open(dir.tsv_file)
409
+ assert_equal dir.identifiers, tsv.identifiers
410
+ end
411
+ end
412
+
413
+ def test_single_field
414
+ content =<<-EOF
415
+ #Id ValueA ValueB OtherID
416
+ row1 a|aa|aaa b Id1|Id2
417
+ row2 A B Id3
418
+ EOF
419
+
420
+ TmpFile.with_file(content) do |filename|
421
+ tsv = TSV.open(filename, :sep => /\s+/, field: "ValueB")
422
+ assert_equal "b", tsv["row1"]
423
+ end
424
+
425
+ TmpFile.with_file(content) do |filename|
426
+ tsv = TSV.open(filename, :sep => /\s+/, field: "ValueA", type: :flat)
427
+ assert_equal %w(a aa aaa), tsv["row1"]
428
+ end
429
+ end
390
430
  end
@@ -78,5 +78,29 @@ b\t2|22\t3|33
78
78
  assert tsv2.filename
79
79
  end
80
80
 
81
+ def test_compact
82
+ dumper = TSV::Dumper.new :key_field => "Key", :fields => %w(Field1 Field2), :type => :double, compact: true
83
+ dumper.init
84
+ t = Thread.new do
85
+ dumper.add "a", [["1", "11"], ["2", "22"]]
86
+ dumper.add "b", [[nil, nil], ["3", "33"]]
87
+ dumper.close
88
+ end
89
+
90
+ tsv = TSV.open(dumper.stream)
91
+ assert_equal [], tsv["b"]["Field1"]
92
+
93
+ dumper = TSV::Dumper.new :key_field => "Key", :fields => %w(Field1 Field2), :type => :double, compact: false
94
+ dumper.init
95
+ t = Thread.new do
96
+ dumper.add "a", [["1", "11"], ["2", "22"]]
97
+ dumper.add "b", [[nil, nil], ["3", "33"]]
98
+ dumper.close
99
+ end
100
+
101
+ tsv = TSV.open(dumper.stream)
102
+ assert_equal ["", ""], tsv["b"]["Field1"]
103
+ end
104
+
81
105
  end
82
106
 
@@ -0,0 +1,24 @@
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 TestTsvPath < Test::Unit::TestCase
5
+ def test_tsv_open_persist
6
+ content =<<-'EOF'
7
+ #Id ValueA ValueB OtherID
8
+ row1 a|aa|aaa b Id1|Id2
9
+ row2 A B Id3
10
+ row2 a a id3
11
+ EOF
12
+
13
+
14
+ tsv = nil
15
+ TmpFile.with_file(content) do |filename|
16
+ Path.setup(filename)
17
+ tsv = filename.tsv persist: true, merge: true, type: :list, sep: /\s+/
18
+ assert_equal %w(ValueA ValueB OtherID), tsv.fields
19
+ tsv = filename.tsv persist: true, merge: true, type: :list, sep: /\s+/
20
+ assert_equal %w(ValueA ValueB OtherID), tsv.fields
21
+ end
22
+ end
23
+ end
24
+
@@ -218,5 +218,98 @@ row2\tBB
218
218
  assert_equal ["AAA"], tsv["row3"][0]
219
219
  end
220
220
 
221
+ def test_concat_4_streams
222
+
223
+ text1=<<-EOF
224
+ #Key\tValueA
225
+ row1\tA
226
+ row2\tAA
227
+ EOF
228
+
229
+ text2=<<-EOF
230
+ #Key\tValueA
231
+ row3\tAAA
232
+ row2\tBB
233
+ EOF
234
+
235
+ text3=<<-EOF
236
+ #Key\tValueA
237
+ row4\tAAA
238
+ row5\tBB
239
+ EOF
240
+
241
+ text4=<<-EOF
242
+ #Key\tValueA
243
+ row6\tAAA
244
+ row7\tBB
245
+ EOF
246
+
247
+ s1 = StringIO.new text1
248
+ s2 = StringIO.new text2
249
+ s3 = StringIO.new text3
250
+ s4 = StringIO.new text4
251
+ tsv = TSV.open TSV.concat_streams([s1,s2,s3,s4]), :merge => true
252
+ assert_equal ["A"], tsv["row1"][0]
253
+ assert_equal ["AA","BB"], tsv["row2"][0]
254
+ assert_equal ["AAA"], tsv["row3"][0]
255
+ assert_equal ["BB"], tsv["row7"][0]
256
+ end
257
+
258
+
259
+ def test_paste_streams_repeat
260
+ text1=<<-EOF
261
+ YHR055C 856452|856450 YHR055C|YHR055C
262
+ YPR161C 856290 YPR161C
263
+ YOL138C 853982 YOL138C
264
+ YDR395W 852004 YDR395W
265
+ YGR129W 853030 YGR129W
266
+ YPR165W 856294 YPR165W
267
+ YPR098C 856213 YPR098C
268
+ YPL015C 856092 YPL015C
269
+ YCL050C 850307 YCL050C
270
+ YAL069W YAL069W
271
+ EOF
272
+
273
+ text2=<<-EOF
274
+ YHR055C CUP1-2 AAA34541
275
+ YHR055C CUP1-2 AAB68382
276
+ YHR055C CUP1-2 AAS56843
277
+ YHR055C CUP1-2 DAA06748
278
+ YHR055C CUP1-2 AAB68384
279
+ YHR055C CUP1-2 AAT93096
280
+ YHR055C CUP1-2 DAA06746
281
+ YPR161C SGV1 BAA14347
282
+ YPR161C SGV1 AAB59314
283
+ YPR161C SGV1 AAB68058
284
+ EOF
285
+
286
+ s1 = StringIO.new text1
287
+ s2 = StringIO.new text2
288
+ tsv = TSV.open(TSV.paste_streams([s1,s2], sort:true, one2one: false), merge: true, one2one: false)
289
+ assert_equal 2, tsv["YHR055C"][0].length
290
+ assert_equal %w(SGV1) * 3, tsv["YPR161C"][2]
291
+ end
292
+
293
+ def test_paste_stream_flat
294
+ text1=<<-EOF
295
+ #: :sep=" "
296
+ #Row LabelA LabelB LabelC
297
+ row1 A B C
298
+ row2 AA BB CC
299
+ row3 AAA BBB CCC
300
+ EOF
301
+
302
+ text2=<<-EOF
303
+ #: :sep=" "#:type=:flat
304
+ #Row Flat
305
+ row1 f1 f2 f3
306
+ EOF
307
+
308
+
309
+ s1 = StringIO.new text1
310
+ s2 = StringIO.new text2
311
+ tsv = TSV.open TSV.paste_streams([s1,s2], :sep => " ", :type => :double)
312
+ assert_include tsv["row1"], %w(f1 f2 f3)
313
+ end
221
314
  end
222
315
 
@@ -275,5 +275,104 @@ row3 a
275
275
  assert_equal %w(a aa aaa), data["row1"]
276
276
  end
277
277
  end
278
+
279
+ def test_traverse_entity_list
280
+ m = Module.new do
281
+ extend Entity
282
+ self.format = "ValueA"
283
+ end
284
+
285
+ content =<<-EOF
286
+ #Id ValueA
287
+ row1 a
288
+ row2 A
289
+ row3 a
290
+ EOF
291
+
292
+ TmpFile.with_file(content) do |filename|
293
+ tsv = TSV.open(File.open(filename), :sep => /\s+/, :type => :list)
294
+ data = {}
295
+ k, f = tsv.traverse "Id", ["ValueA"] do |k,v|
296
+ data[k] = v
297
+ end
298
+ assert_equal %w(a), data["row1"]
299
+ assert Annotation::AnnotatedObject === data["row1"]
300
+ end
301
+ end
302
+
303
+ def test_traverse_entity_double
304
+ m = Module.new do
305
+ extend Entity
306
+ self.format = "ValueA"
307
+ end
308
+
309
+ content =<<-EOF
310
+ #Id ValueA
311
+ row1 a|aa|aaa
312
+ row2 A
313
+ row3 a
314
+ EOF
315
+
316
+ TmpFile.with_file(content) do |filename|
317
+ tsv = TSV.open(File.open(filename), :sep => /\s+/)
318
+ data = {}
319
+ k, f = tsv.traverse "Id", ["ValueA"] do |k,v|
320
+ data[k] = v
321
+ end
322
+ assert_equal %w(a aa aaa), data["row1"][0]
323
+ assert NamedArray === data["row1"]
324
+ assert AnnotatedArray === data["row1"]["ValueA"]
325
+ end
326
+ end
327
+
328
+
329
+ def test_traverse_entity_flat
330
+ m = Module.new do
331
+ extend Entity
332
+ self.format = "ValueA"
333
+ end
334
+
335
+ content =<<-EOF
336
+ #Id ValueA
337
+ row1 a aa aaa
338
+ row2 A
339
+ row3 a
340
+ EOF
341
+
342
+ TmpFile.with_file(content) do |filename|
343
+ tsv = TSV.open(File.open(filename), :sep => /\s+/, :type => :flat)
344
+ data = {}
345
+ k, f = tsv.traverse "Id", ["ValueA"] do |k,v|
346
+ data[k] = v
347
+ end
348
+ assert_equal %w(a aa aaa), data["row1"]
349
+ assert AnnotatedArray === data["row1"]
350
+ assert Annotation::AnnotatedObject === data["row1"][0]
351
+ end
352
+ end
353
+
354
+ def test_traverse_entity_single
355
+ m = Module.new do
356
+ extend Entity
357
+ self.format = "ValueA"
358
+ end
359
+
360
+ content =<<-EOF
361
+ #Id ValueA
362
+ row1 a
363
+ row2 A
364
+ row3 a
365
+ EOF
366
+
367
+ TmpFile.with_file(content) do |filename|
368
+ tsv = TSV.open(File.open(filename), :sep => /\s+/, :type => :single)
369
+ data = {}
370
+ k, f = tsv.traverse "Id", ["ValueA"] do |k,v|
371
+ data[k] = v
372
+ end
373
+ assert_equal "a", data["row1"]
374
+ assert Annotation::AnnotatedObject === data["row1"]
375
+ end
376
+ end
278
377
  end
279
378
 
@@ -16,6 +16,8 @@ row2 a a id3
16
16
  TSV.open(filename, :sep => " " )
17
17
  end
18
18
  assert_equal %w(row1 row2), tsv.collect{|k,v| k }
19
+ refute NamedArray === tsv.collect{|k,v| v }.first
20
+ tsv.unnamed = false
19
21
  assert NamedArray === tsv.collect{|k,v| v }.first
20
22
  assert "row1", tsv["row1"].key
21
23
  end
@@ -23,6 +23,28 @@ row2 AA BB Id33
23
23
  assert_equal ['row2'], s.keys
24
24
  end
25
25
 
26
+ def test_select_invert
27
+ content =<<-'EOF'
28
+ #: :sep=/\s+/#:type=:double
29
+ #Id ValueA ValueB OtherID
30
+ row1 a|aa|aaa b Id1|Id2
31
+ row2 A B Id3
32
+ row2 AA BB Id33
33
+ EOF
34
+
35
+ tsv = TmpFile.with_file(content) do |filename|
36
+ TSV.open(filename, :persist => true)
37
+ end
38
+
39
+ s = tsv.select("ValueA" => 'a')
40
+
41
+ assert_equal ['row1'], s.keys
42
+
43
+ s = tsv.select({"ValueA" => 'a'}, true)
44
+
45
+ assert_equal ['row2'], s.keys
46
+ end
47
+
26
48
  def test_select_values
27
49
  content =<<-'EOF'
28
50
  #: :sep=" "
@@ -46,5 +46,29 @@ row2 A b C
46
46
  assert_equal %w(row1 row2), tsv.sort("ValueB"){|a,b| a[1] <=> b[1] }.collect{|k,v| k}
47
47
  end
48
48
  end
49
+
50
+ def test_sort_entity
51
+ content =<<-EOF
52
+ #ID ValueA ValueB Comment NumericValue
53
+ row1 a B c 20
54
+ row2 A b C 100
55
+ row3 A b C 3
56
+ EOF
57
+
58
+ m = Module.new do
59
+ extend Entity
60
+ self.format = "NumericValue"
61
+
62
+ def <=>(b)
63
+ self.to_f <=> b.to_f
64
+ end
65
+ end
66
+
67
+
68
+ TmpFile.with_file(content) do |filename|
69
+ tsv = TSV.open(File.open(filename), :type => :list, :sep => /\s/)
70
+ assert_equal %w(row3 row1 row2), tsv.sort("NumericValue", true)
71
+ end
72
+ end
49
73
  end
50
74
 
@@ -89,5 +89,31 @@ class TestStepDependencies < Test::Unit::TestCase
89
89
  end
90
90
  end
91
91
  end
92
+
93
+ def test_recursive_inputs_priority
94
+ tmpfile = tmpdir.test_step
95
+ step1 = Step.new tmpfile.step1, NamedArray.setup(["1"], %w(input1)) do |s|
96
+ s.length
97
+ end
98
+
99
+ step2 = Step.new tmpfile.step2, NamedArray.setup(["2"], %w(input1)) do |times|
100
+ step1 = dependencies.first
101
+ (step1.inputs.first + " has " + step1.load.to_s + " characters") * times
102
+ end
103
+
104
+ step3 = Step.new tmpfile.step2, NamedArray.setup([], %w()) do |times|
105
+ step1 = dependencies.first
106
+ (step1.inputs.first + " has " + step1.load.to_s + " characters") * times
107
+ end
108
+
109
+
110
+ step2.dependencies = [step1]
111
+
112
+ step3.dependencies = [step1, step2]
113
+
114
+ assert_equal "2", step2.inputs["input1"]
115
+ assert_equal "2", step2.recursive_inputs["input1"]
116
+ assert_equal "1", step3.recursive_inputs["input1"]
117
+ end
92
118
  end
93
119
 
@@ -58,4 +58,39 @@ class TestStepInfo < Test::Unit::TestCase
58
58
  assert_equal %w(Message1 Message2), step1.messages
59
59
  end
60
60
  end
61
+
62
+ def test_overriden_fixed
63
+ TmpFile.with_file("HELLO") do |file|
64
+ wf = Module.new do
65
+ extend Workflow
66
+
67
+ self.name = "TestWF"
68
+
69
+ task :message => :string do
70
+ "HI"
71
+ end
72
+
73
+ dep :message
74
+ task :say => :string do
75
+ "I say #{step(:message).load}"
76
+ end
77
+
78
+ task_alias :say_hello, self, :say, "TestWF#message" => file, :not_overriden => true
79
+ end
80
+
81
+ assert_equal "I say HI", wf.job(:say).run
82
+
83
+ job1 = wf.job(:say, "TestWF#message" => file)
84
+ assert_equal "I say HELLO", job1.run
85
+
86
+ job2 = wf.job(:say_hello)
87
+ assert_equal "I say HELLO", job2.run
88
+
89
+ assert job1.overriden?
90
+ refute job2.overriden?
91
+
92
+ assert job1.overriden_deps.any?
93
+ refute job2.overriden_deps.any?
94
+ end
95
+ end
61
96
  end
@@ -353,5 +353,71 @@ class TestTaskDependencies < Test::Unit::TestCase
353
353
  assert_equal "0", wf.job(:step2, :input1 => "-2").run
354
354
  end
355
355
 
356
- end
356
+ def test_jobname_input
357
+ wf = Workflow.annonymous_workflow "JobnameInput" do
358
+ input :input1, :string, "", nil, jobname: true
359
+ task :step1 => :string do |i1|
360
+ i1
361
+ end
362
+
363
+ input :input2, :string, "", "Hi"
364
+ dep :step1 do |jobname,options|
365
+ {jobname: options[:input2]}
366
+ end
367
+ task :step2 do
368
+ step(:step1).load
369
+ end
370
+ end
371
+
372
+ assert_equal "Hi", wf.job(:step2).run.strip
373
+ assert_equal "Hello", wf.job(:step2, input2: "Hello").run.strip
357
374
 
375
+ job = wf.job(:step2, input1: "Hello")
376
+ assert_equal "Hello", job.run
377
+ assert_equal "Default", job.clean_name
378
+ assert_equal "Hi", job.step(:step1).clean_name
379
+ end
380
+
381
+ def test_jobname_input_reset
382
+ wf = Workflow.annonymous_workflow "JobnameInput" do
383
+ input :input1, :string, "", nil, jobname: true
384
+ task :step1 => :string do |i1|
385
+ i1
386
+ end
387
+
388
+ input :input2, :string, "", "Hi", jobname: true
389
+ dep :step1, input1: "Name1", jobname: nil do |jobname,options|
390
+ {inputs: options}
391
+ end
392
+ task :step2 do
393
+ step(:step1).load
394
+ end
395
+
396
+ end
397
+
398
+ job = wf.job(:step2, input2: "Name2")
399
+ assert_equal "Name2", job.clean_name
400
+ assert_equal "Name1", job.step(:step1).clean_name
401
+ assert_equal "Name", wf.job(:step1, input1: "Name").clean_name
402
+ end
403
+
404
+ def test_non_default_inputs_ignore_hidden
405
+ wf = Workflow.annonymous_workflow "JobnameInput" do
406
+ input :input1, :string, "", nil, jobname: true
407
+ task :step1 => :string do |i1|
408
+ i1
409
+ end
410
+
411
+ dep :step1, jobname: nil, input1: :placeholder do |jobname,options|
412
+ {inputs: options.merge(input1: "TEST") }
413
+ end
414
+ task :step2 do
415
+ step(:step1).load
416
+ end
417
+
418
+ end
419
+
420
+ job = wf.job(:step2, input2: "Name2")
421
+ assert job.non_default_inputs.empty?
422
+ end
423
+ end