@@ -17,77 +17,70 @@ doc: |
17
17
18
18
19
19
inputs :
20
- sleep_time: { type : int , default : 33 }
21
- n_sleepers: { type : int ? , default : 5 }
20
+ sleep_time: {type : int , default : 3333 }
21
+ n_sleepers: {type : int , default : 4 }
22
22
23
23
24
24
steps :
25
- make_array :
25
+ roulette :
26
26
doc : |
27
- This step produces an array of sleep_time values to be used
28
- as inputs for the scatter_step. The array also serves as the
29
- workflow output which should be collected despite the
30
- kill switch triggered in the kill step below.
31
- in : { sleep_time: sleep_time, n_sleepers: n_sleepers }
32
- out : [ times ]
27
+ This step produces a boolean array with exactly one true value
28
+ whose index is assigned at random.
29
+ in : {n_sleepers: n_sleepers}
30
+ out : [mask]
33
31
run :
34
32
class: ExpressionTool
35
- inputs :
36
- sleep_time: { type : int }
37
- n_sleepers: { type : int }
38
- outputs : { times: { type : "int[]" } }
33
+ inputs : {n_sleepers: {type : int }}
34
+ outputs : {mask: {type : "boolean[]" }}
39
35
expression: |
40
- ${ return {"times" : Array(inputs.n_sleepers).fill(inputs.sleep_time)} }
36
+ ${
37
+ var mask = Array(inputs.n_sleepers).fill(false);
38
+ var spin = Math.floor(Math.random() * inputs.n_sleepers);
39
+ mask[spin] = true;
40
+ return {"mask" : mask}
41
+ }
41
42
42
43
scatter_step:
43
44
doc : |
44
45
This step starts several parallel jobs that each sleep for
45
- sleep_time seconds.
46
+ sleep_time seconds. The job whose k_mask value is true will
47
+ self-terminate early, thereby activating the kill switch.
46
48
in :
47
- time: make_array/times
48
- scatter : time
49
- out : [ ]
49
+ time: sleep_time
50
+ k_mask: roulette/mask
51
+ scatter : k_mask
52
+ out : [placeholder]
50
53
run :
51
54
class: CommandLineTool
55
+ requirements :
56
+ ToolTimeLimit:
57
+ timelimit: '${return inputs. k_mask ? 5 : inputs. time + 5}' # 5 is an arbitrary value
52
58
baseCommand : sleep
53
59
inputs :
54
- time: { type : int , inputBinding : { position : 1 } }
55
- outputs : { }
56
-
57
- kill:
58
- doc : |
59
- This step waits a few seconds and selects a random scatter_step job to kill.
60
- When `--on-error kill` is used, the runner should respond by terminating all
61
- remaining jobs and exiting. This means the workflow's overall runtime should be
62
- much less than max(sleep_time). The input force_upstream_order ensures that
63
- this step runs after make_array, and therefore roughly parallel to scatter_step.
64
- in:
65
- force_upstream_order: make_array/times
66
- sleep_time: sleep_time
67
- search_str:
68
- valueFrom: $("sleep " + inputs. sleep_time)
69
- out: [ pid ]
70
- run: .. /process_roulette. cwl
60
+ time: {type : int , inputBinding : {position : 1}}
61
+ k_mask: {type : boolean }
62
+ outputs :
63
+ placeholder: {type : string , outputBinding : {outputEval : $("foo" )}}
71
64
72
65
dangling_step:
73
66
doc : |
74
67
This step should never run. It confirms that additional jobs aren't
75
68
submitted and allowed to run to completion after the kill switch has
76
- been set. The input force_downstream_order ensures that this step runs
77
- after the kill step .
69
+ been set. The input force_downstream_order ensures that this step
70
+ doesn' t run before scatter_step completes .
78
71
in :
79
- force_downstream_order: kill/pid
72
+ force_downstream_order: scatter_step/placeholder
80
73
time: sleep_time
81
- out : [ ]
74
+ out : []
82
75
run :
83
76
class: CommandLineTool
84
77
baseCommand : sleep
85
78
inputs :
86
- time: { type : int , inputBinding : { position : 1 } }
87
- outputs : { }
79
+ time: {type : int , inputBinding : {position : 1} }
80
+ outputs : {}
88
81
89
82
90
83
outputs :
91
- instructed_sleep_times :
92
- type : int []
93
- outputSource : make_array/times
84
+ roulette_mask :
85
+ type : boolean []
86
+ outputSource : roulette/mask
0 commit comments