Hi! I see ways to execute process B when process A fails by using branch or filter, but for this a channel A.out must exist. Is it possible to do something similar to this solution, but on an absence/presence of channel (i.e., can we distinguish absence of channel caused by the process not yet run and by the process failed)? It feels possible, because nextflow definitely “knows” when a process failed - so can this information be used to trigger another process?
Ok, I think I figured this out ![]()
input_ch = channel.fromPath(params.input) // [val(meta), path(input)]
PROCESS_A(input_ch)
failed_ch = input_ch
.join(PROCESS_A.out, remainder: true) // [val(meta), path(input), path(output)|null]
.filter{i -> i[2] == null} // [val(meta), path(input), null]
.map{i -> return [i[0], i[1]]} // [val(meta), path(input)]
PROCESS_B(failed_ch)
I’m not so clear on the question, but if you want to a solution to use another channel if one is empty here is one way: How can I assign a default channel to another channel if it’s empty, while retaining its original content when it’s not empty, considering the default value is also a channel? - #3 by mahesh.binzerpanchal
Edit: Ah, now I got it. Yes, your solution to use a sentinel value is correct. There’s some examples in the Nextflow Slack if you search for Sentinel.
1 Like