nextflow-io / nextflow-io/nextflow

awsbatch + S3: task outputs are not uploaded on non-zero exit

Open
#6,327 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

lang/processes triage/investigate
Dominant language
Groovy
Stars
3.5k
Forks
811
Avg merge
2d 11h
Merged PRs (30d)
61

Description

New feature

When a task executed with AWS Batch + S3 and it fails (non-zero exit status, OOM 137, timeout 143, spot reclaim, …) only .command.{out,err,trace} and .exitcode are uploaded to the work prefix. Any other files produced before the failure disappear because the stage-out code is skipped.

This makes it hard to debug tools that write their own log/metrics files instead of (or in addition to) stdout / stderr.

Checking the .command.run:

nxf_unstage() {
    true
    nxf_s3_upload .command.out s3://bucket-name/test_fail/work/d3/f73d112409f924d2c042506faeb3bd || true
    nxf_s3_upload .command.err s3://bucket-name/test_fail/work/d3/f73d112409f924d2c042506faeb3bd || true
    nxf_s3_upload .command.trace s3://bucket-name/test_fail/work/d3/f73d112409f924d2c042506faeb3bd || true
    [[ ${nxf_main_ret:=0} != 0 ]] && return
    uploads=()
    IFS=$'\n'
    for name in $(eval "ls -1d *.bam *.bam.bai * versions.yml" | sort | uniq); do
        uploads+=("nxf_s3_upload '$name' s3://bucket-name/test_fail/work/d3/f73d112409f924d2c042506faeb3bd")
    done
    unset IFS
    nxf_parallel "${uploads[@]}"
}

I think the issue is because of the line [[ ${nxf_main_ret:=0} != 0 ]] && return and this seems to come from this template where it is hardcoded:

nxf_unstage() {
    true
    {{unstage_controls}}
    [[ ${nxf_main_ret:=0} != 0 ]] && return
    {{unstage_outputs}}
}

So whenever .command.sh exits ≠ 0 the uploads defined in {{unstage_outputs}} are skipped.

Is there any flag, workaround or would it be possible to add some optional field to skip this line and push all the files that were created during the failed execution?

Use case

Some tools have logs and traces that are being saved on specific files rather that stdout or stderr and they are needed for debugging. Having this as optional flag would avoid us many reruns on local environments to debug the jobs.

Suggested implementation

Adding a flag to the publishDir directive to remove this line.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with modules/nextflow/src/main/resources/nextflow/executor/command-run.txt and trace how publishDir options reach the AWS Batch plus S3 stage-out logic. Reproduce a failed task that creates additional output files, then verify the proposed optional behavior uploads them after a non-zero exit while preserving the current default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, groovy
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.