|
| 1 | +# Troubleshooting |
| 2 | + |
| 3 | +In this section you will find ways to troubleshoot when you have problems executing CWL. |
| 4 | +We focus on `cwltool` here but some of these techniques may apply to other CWL Runners. |
| 5 | + |
| 6 | +## Run `cwltool` with `cachedir` |
| 7 | + |
| 8 | +You can use the `--cachedir` option when running a workflow to tell `cwltool` to |
| 9 | +cache intermediate files (files that are not input nor output files, but created |
| 10 | +while your workflow is running). By default, these files are created in a |
| 11 | +temporary directory but writing them to a separate directory makes accessing |
| 12 | +them easier. |
| 13 | + |
| 14 | +In the following example `troubleshooting-wf1.cwl` we have two steps, `step_a` and `step_b`. |
| 15 | +The workflow is equivalent to `echo "Hello World" | rev`, which would print the message |
| 16 | +"Hello World" reversed, i.e. "dlroW olleH". However, the second step, `step_b`, **has a typo**, |
| 17 | +where instead of executing the `rev` command it tries to execute `revv`, which |
| 18 | +fails. |
| 19 | + |
| 20 | +```{literalinclude} /_includes/cwl/troubleshooting/troubleshooting-wf1.cwl |
| 21 | +:language: cwl |
| 22 | +:name: "`troubleshooting-wf1.cwl`" |
| 23 | +:caption: "`troubleshooting-wf1.cwl`" |
| 24 | +:emphasize-lines: 42 |
| 25 | +``` |
| 26 | + |
| 27 | +Let's execute this workflow with `/tmp/cachedir/` as the `--cachedir` value (`cwltool` will |
| 28 | +create the directory for you if it does not exist already): |
| 29 | + |
| 30 | +```{runcmd} cwltool --cachedir /tmp/cachedir/ troubleshooting-wf1.cwl |
| 31 | +:working-directory: src/_includes/cwl/troubleshooting |
| 32 | +:emphasize-lines: 12-14, 19-21 |
| 33 | +``` |
| 34 | + |
| 35 | +The workflow is in the `permanentFail` status due to `step_b` failing to execute the |
| 36 | +non-existent `revv` command. The `step_a` was executed successfully and its output |
| 37 | +has been cached in your `cachedir` location. You can inspect the intermediate files |
| 38 | +created: |
| 39 | + |
| 40 | +```{runcmd} tree /tmp/cachedir |
| 41 | +:emphasize-lines: 4 |
| 42 | +``` |
| 43 | + |
| 44 | +Each workflow step has received a unique ID (the long value that looks like a hash). |
| 45 | +The `${HASH}.status` files display the status of each step executed by the workflow. |
| 46 | +And the `step_a` output file `stdout.txt` is visible in the output of the command above. |
| 47 | + |
| 48 | +Now fix the typo so `step_b` executes `rev` (i.e. replace `revv` by `rev` in the |
| 49 | +`step_b`). After fixing the typo, when you execute `cwltool` with the same arguments |
| 50 | +as the previous time, note that now `cwltool` output contains information about |
| 51 | +pre-cached outputs for `step_a`, and about a new cache entry for the output of `step_b`. |
| 52 | +Also note that the status of `step_b` is now of success. |
| 53 | + |
| 54 | +```{runcmd} cwltool --cachedir /tmp/cachedir/ troubleshooting-wf1-stepb-fixed.cwl |
| 55 | +:working-directory: src/_includes/cwl/troubleshooting |
| 56 | +:emphasize-lines: 12, 16-18 |
| 57 | +``` |
| 58 | + |
| 59 | +In this example the workflow step `step_a` was not re-evaluated as it had been cached, and |
| 60 | +there was no change in its execution or output. Furthermore, `cwltool` was able to recognize |
| 61 | +when it had to re-evaluate `step_b` after we fixed the executable name. This technique is |
| 62 | +useful for troubleshooting your CWL documents and also as a way to prevent `cwltool` to |
| 63 | +re-evaluate steps unnecessarily. |
0 commit comments