Skip to content

Commit f31fb5b

Browse files
authored
Merge pull request #385 from nextflow-io/pinin4fjords-patch-1
Add exercise around the caching example
2 parents a57fc13 + 436497b commit f31fb5b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/basic_training/cache_and_resume.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,29 @@ A - b
343343

344344
So D is matched with 'a' here, which was not the intention. That order will likely be different every time the workflow is run, meaning that the processing will not be deterministic, and caching will also not work, since the inputs to FOOBAR will vary constantly.
345345

346+
!!! question "Exercise"
347+
348+
Re-run the above code a couple of times using `-resume`, and determine if the FOOBAR process reruns, or uses cached results.
349+
350+
??? solution
351+
352+
You should see that while FOO and BAR reliably re-use their cache, FOOBAR will re-run at least a subset of its tasks due to differences in the combinations of inputs it recieves.
353+
354+
The output will look like this:
355+
356+
```console title="Output"
357+
[58/f117ed] FOO (4) [100%] 4 of 4, cached: 4 ✔
358+
[84/e88fd9] BAR (4) [100%] 4 of 4, cached: 4 ✔
359+
[6f/d3f672] FOOBAR (1) [100%] 4 of 4, cached: 2 ✔
360+
D - c
361+
362+
A - d
363+
364+
C - a
365+
366+
B - b
367+
```
368+
346369
A common solution for this is to use what is commonly referred to as a _meta map_. A groovy object with sample information is passed out together with the file results within an output channel as a tuple. This can then be used to pair samples from separate channels together for downstream use.
347370

348371
To illustrate, here is a change to the above workflow, with meta maps added:

0 commit comments

Comments
 (0)