2 title: "Running and Debugging a Workflow"
6 - "How do I provide input to run a workflow?"
7 - "What should I do if the workflow fails?"
9 - "Write an input parameter file."
10 - "Execute the workflow."
11 - "Diagnose workflow errors."
13 - "The input parameter file is a YAML file with values for each input parameter."
14 - "A common reason for a workflow step fails is insufficient RAM."
15 - "Use ResourceRequirement to set the amount of RAM to be allocated to the job."
16 - "Output parameter values are printed as JSON to standard output at the end of the run."
19 # The input parameter file
21 CWL input values are provided in the form of a YAML or JSON file.
24 This file gives the values for parameters declared in the `inputs`
25 section of our workflow. Our workflow takes `fq`, `genome` and `gtf`
28 When setting inputs, Files and Directories are given as an object with
29 `class: File` or `class: Directory`. This distinguishes them from
30 plain strings that may or may not be file paths.
32 Note: if you don't have example sequence data or the STAR index files, see [setup](/setup.html).
34 {% capture generic_input_tab_content %}
39 location: rnaseq/raw_fastq/Mov10_oe_1.subset.fq
40 format: http://edamontology.org/format_1930
43 location: hg19-chr1-STAR-index
46 location: rnaseq/reference_data/chr1-hg19_genes.gtf
50 > ## Running the workflow
52 > Type this into the terminal:
55 > cwl-runner main.cwl main-input.yaml
59 > This may take a few minutes to run, and will print some amount of
60 > logging. The logging you see, how access other logs, and how to
61 > track workflow progress will depend on your CWL runner platform.
65 {% capture arvados_input_tab_content %}
70 location: keep:9178fe1b80a08a422dbe02adfd439764+925/raw_fastq/Mov10_oe_1.subset.fq
71 format: http://edamontology.org/format_1930
74 location: keep:02a12ce9e2707610991bd29d38796b57+2912
77 location: keep:9178fe1b80a08a422dbe02adfd439764+925/reference_data/chr1-hg19_genes.gtf
81 > ## Running the workflow
83 > If you are using VSCode with Arvados tasks, select `main.cwl` and
84 > then use the `Run CWL Workflow on Arvados` task.
91 <li><a href="#section-arvados-input">arvados</a></li>
92 <li><a href="#section-generic-input">generic</a></li>
95 <section id="section-arvados-input">{{ arvados_input_tab_content | markdownify}}</section>
96 <section id="section-generic-input">{{ generic_input_tab_content | markdownify}}</section>
99 # Debugging the workflow
101 Depending on whether and how your workflow platform enforces memory
102 limits, your workflow may fail. Let's talk about what to do when a
105 A workflow can fail for many reasons: some possible reasons include
106 bad input, bugs in the code, or running out memory. In our example,
107 the STAR workflow may fail with an out of memory error.
109 To help diagnose these errors, the workflow runner produces logs that
110 record what happened, either in the terminal or the web interface.
112 Some errors you might see in the logs that would indicate an out of
116 EXITING: fatal error trying to allocate genome arrays, exception thrown: std::bad_alloc
117 Possible cause 1: not enough RAM. Check if you have enough RAM 5711762337 bytes
118 Possible cause 2: not enough virtual memory allowed with ulimit. SOLUTION: run ulimit -v 5711762337
124 Container exited with code: 137
127 (Exit code 137 most commonly occurs when a container goes "out of memory" and is terminated by the operating system).
129 If this happens, you will need to request more RAM.
131 # Setting runtime RAM requirements
133 By default, a step is allocated 256 MB of RAM. From the STAR error message:
135 > Check if you have enough RAM 5711762337 bytes
137 We can see that STAR requires quite a bit more RAM than 256 MB. To
138 request more RAM, add a "requirements" section with
139 "ResourceRequirement" to the "STAR" step:
146 run: bio-cwl-tools/STAR/STAR-Align.cwl
151 Resource requirements you can set include:
153 * coresMin: CPU cores
154 * ramMin: RAM (in megabytes)
155 * tmpdirMin: temporary directory available space
156 * outdirMin: output directory available space
158 > ## Running the workflow
160 > Now that you've fixed the workflow, run it again.
164 > ## Episode solution
165 > * <a href="../assets/answers/ep3/main.cwl">main.cwl</a>
170 The CWL runner will print a results JSON object to standard output. It will look something like this (it may include additional fields).
172 {% capture generic_output_tab_content %}
176 "bam_sorted_indexed": {
177 "location": "file:///home/username/rnaseq-cwl-training-exercises/Aligned.sortedByCoord.out.bam",
178 "basename": "Aligned.sortedByCoord.out.bam",
183 "basename": "Aligned.sortedByCoord.out.bam.bai",
184 "location": "file:///home/username/rnaseq-cwl-training-exercises/Aligned.sortedByCoord.out.bam.bai",
191 "location": "file:///home/username/rnaseq-cwl-training-exercises/Mov10_oe_1.subset_fastqc.html",
192 "basename": "Mov10_oe_1.subset_fastqc.html",
201 {% capture arvados_output_tab_content %}
204 "bam_sorted_indexed": {
205 "basename": "Aligned.sortedByCoord.out.bam",
207 "location": "keep:2dbaaef5aefd558e37f14280e47091a9+327/Aligned.sortedByCoord.out.bam",
210 "basename": "Aligned.sortedByCoord.out.bam.bai",
212 "location": "keep:2dbaaef5aefd558e37f14280e47091a9+327/Aligned.sortedByCoord.out.bam.bai"
218 "basename": "Mov10_oe_1.subset_fastqc.html",
220 "location": "keep:2dbaaef5aefd558e37f14280e47091a9+327/Mov10_oe_1.subset_fastqc.html",
230 <li><a href="#section-arvados-output">arvados</a></li>
231 <li><a href="#section-generic-output">generic</a></li>
234 <section id="section-arvados-output">{{ arvados_output_tab_content | markdownify}}</section>
235 <section id="section-generic-output">{{ generic_output_tab_content | markdownify}}</section>
238 This has a similar structure as `main-input.yaml`. The each output
239 parameter is listed, with the `location` field of each `File` object
240 indicating where the output file can be found.