|
| 1 | +#!/usr/bin/env cwl-runner |
| 2 | + |
| 3 | +cwlVersion: v1.2 |
| 4 | +class: Workflow |
| 5 | +requirements: |
| 6 | + ScatterFeatureRequirement: {} |
| 7 | + InlineJavascriptRequirement: {} |
| 8 | + StepInputExpressionRequirement: {} |
| 9 | + |
| 10 | + |
| 11 | +doc: | |
| 12 | + This workflow tests the optional argument --on-error kill. |
| 13 | + MultithreadedJobExecutor() or --parallel should be used. |
| 14 | + A successful run should: |
| 15 | + 1) Finish in (much) less than sleep_time seconds. |
| 16 | + 2) Return outputs produced by successful steps. |
| 17 | + |
| 18 | + |
| 19 | +inputs: |
| 20 | + sleep_time: { type: int, default: 33 } |
| 21 | + n_sleepers: { type: int?, default: 5 } |
| 22 | + |
| 23 | + |
| 24 | +steps: |
| 25 | + make_array: |
| 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 ] |
| 33 | + run: |
| 34 | + class: ExpressionTool |
| 35 | + inputs: |
| 36 | + sleep_time: { type: int } |
| 37 | + n_sleepers: { type: int } |
| 38 | + outputs: { times: { type: "int[]" } } |
| 39 | + expression: | |
| 40 | + ${ return {"times": Array(inputs.n_sleepers).fill(inputs.sleep_time)} } |
| 41 | + |
| 42 | + scatter_step: |
| 43 | + doc: | |
| 44 | + This step starts several parallel jobs that each sleep for |
| 45 | + sleep_time seconds. |
| 46 | + in: |
| 47 | + time: make_array/times |
| 48 | + scatter: time |
| 49 | + out: [ ] |
| 50 | + run: |
| 51 | + class: CommandLineTool |
| 52 | + baseCommand: sleep |
| 53 | + 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 |
| 71 | +
|
| 72 | + dangling_step: |
| 73 | + doc: | |
| 74 | + This step should never run. It confirms that additional jobs aren't |
| 75 | + 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. |
| 78 | + in: |
| 79 | + force_downstream_order: kill/pid |
| 80 | + time: sleep_time |
| 81 | + out: [ ] |
| 82 | + run: |
| 83 | + class: CommandLineTool |
| 84 | + baseCommand: sleep |
| 85 | + inputs: |
| 86 | + time: { type: int, inputBinding: { position: 1 } } |
| 87 | + outputs: { } |
| 88 | + |
| 89 | + |
| 90 | +outputs: |
| 91 | + instructed_sleep_times: |
| 92 | + type: int[] |
| 93 | + outputSource: make_array/times |
0 commit comments