nextflow-io / nextflow

A DSL for data-driven computational pipelines
http://nextflow.io
Apache License 2.0
2.71k stars 620 forks source link

Failure in stub causes nextflow to run the script-section? #5343

Open oyvinev opened 6 days ago

oyvinev commented 6 days ago

Hi,

Disclaimer: I'm a total newbie at Nextflow.

I have a question regarding stub-run, in particular what happens when the commands outlined under stub: are incomplete or fails.

I've been spending the better part of a day trying to figure out why my stub didn't run, even thought I had been calling my nextflow run-command correctly.

After much digging, and reduction to a trivial example, I came to this conclusion, which I hope I could get some comment on from the developers of Nextflow:

If a stub run fails (exit code > 0), or if it fails to produce the output specified under output:, Nextflow will silently ignore any error, and procede to execute the script:-section

Is this correct? It feels like very strange behaviour to me, as I would expect to be notified of errors in my stub-definition.

bentsherman commented 6 days ago

Can you provide a minimal test case?

oyvinev commented 3 days ago

Yes, here is a MWE:

process stubtest {
    debug true
    errorStrategy 'retry'
    maxRetries 1

    output:
    path("*.txt"), emit: final_vcf

    script:
    """
    echo "Not stubbing"
    touch dabla.txt
    """

    stub:
    """
    echo "Stubbing"
    echo "Not creating file"
    """
}

workflow {
    main:
    stubtest()
}

Running this with -stub, I would expect it to fail since I'm not creating the output file in the stub:-section. However, it retries, and runs the script:-section on the retry:

$ nextflow run mwe.nf -stub

 N E X T F L O W   ~  version 24.04.4

Launching `mwe.nf` [tiny_archimedes] DSL2 - revision: 10bfb6f10f

[-        ] stubtest -

executor >  local (2)
[6a/7ff75f] stubtest | 2 of 2, failed: 1, retries: 1 ✔
Not stubbing

[67/3ce64d] NOTE: Missing output file(s) `*.txt` expected by process `stubtest` -- Execution is retried (1)
oyvinev commented 3 days ago

Note: The behavior is the same for 24.04.4 and 24.08.0-edge (docker images).

jorgee commented 9 hours ago

It seems the copy of the task generated in the retry set the script body instead of the stub one. https://github.com/nextflow-io/nextflow/pull/5359 fixes it.