Skip to content

Commit

Permalink
Fix failOnIgnore causes task monitor to stop submitting tasks (#5293)
Browse files Browse the repository at this point in the history

Signed-off-by: Ben Sherman <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
bentsherman and pditommaso authored Oct 2, 2024
1 parent 290f2d0 commit d687033
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
6 changes: 6 additions & 0 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,12 @@ class Session implements ISession {

boolean isSuccess() { !aborted && !cancelled && !failOnIgnore }

boolean canSubmitTasks() {
// tasks should be submitted even when 'failOnIgnore' is set to true
// https://github.com/nextflow-io/nextflow/issues/5291
return !aborted && !cancelled
}

void processRegister(TaskProcessor process) {
log.trace ">>> barrier register (process: ${process.name})"
processesBarrier.register(process)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ class TaskPollingMonitor implements TaskMonitor {

int count = 0
def itr = pendingQueue.iterator()
while( itr.hasNext() && session.isSuccess() ) {
while( itr.hasNext() && session.canSubmitTasks() ) {
final handler = itr.next()
submitRateLimit?.acquire()
try {
Expand Down
3 changes: 2 additions & 1 deletion tests/checks/error-ignore-then-fail.nf/.checks
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ set -e

[ $status -ne 0 ] || false

[[ `< .nextflow.log grep -c 'Submitted process > foo'` == 1 ]] || false
[[ `< .nextflow.log grep -c 'Submitted process > foo'` == 3 ]] || false
[[ `< .nextflow.log grep -c 'Submitted process > bar'` == 1 ]] || false
[[ `< .nextflow.log grep -c 'Error is ignored'` == 1 ]] || false
7 changes: 6 additions & 1 deletion tests/checks/error-ignore-then-fail.nf/.config
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
workflow.failOnIgnore = true
workflow {
failOnIgnore = true
}
process {
errorStrategy = 'ignore'
}
36 changes: 30 additions & 6 deletions tests/error-ignore-then-fail.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,39 @@
* limitations under the License.
*/

workflow {
input_channel = channel.of("SAMP1", "SAMP2", "SAMP3")
foo(input_channel)
bar(foo.out.sample_ids.collect())
}

process foo {
errorStrategy 'ignore'
input:
val sample_id

output:
val sample_id, emit: sample_ids

script:
'''
exit 1
'''
"""
if [[ $sample_id == "SAMP1" ]]; then
exit 2
fi
ls -lah .*
"""
}

workflow {
foo()
process bar {
input:
val ready

output:
stdout

script:
"""
ls -lah .*
"""

}

0 comments on commit d687033

Please sign in to comment.