Skip to content

Task instances don't stage Nextflow file inputs (only sync the task's own work dir) — breaks any process with a staged path input #37

Closed

Description

@scttfrdmn

Summary

nf-spawn's staging script only does aws s3 sync <this-task's-own-workDir> <local>. It never runs Nextflow's input localization (.command.run / nxf_stage), so declared path inputs that live anywhere other than the task's own work dir are never placed on the instance. Any process whose inputs are produced by an upstream process, come from Channel.fromPath, or are listed as s3:// paths in a samplesheet will run with its input files missing.

This means stock nf-core modules (which all take staged path inputs) generally can't run under the spawn executor today.

Where it is

SpawnTaskHandler.buildStagingScript() (src/main/groovy/io/nextflow/spawn/SpawnTaskHandler.groovy):

// 1. Stage inputs down from the S3 work dir.
sb << 'aws s3 sync "${WORKDIR_S3}" "${LOCAL_DIR}/" --region "${AWS_REGION}" --quiet\n'

WORKDIR_S3 is the task's own work dir (task.workDirStr). The comment says "Stage inputs down from the S3 work dir," but Nextflow does not pre-place a task's declared inputs into its own work dir for a custom executor — input localization is normally emitted by Nextflow into .command.run (nxf_stage()), which copies each declared input (including foreign/cross-task/S3 files) into the work dir at run time. nf-spawn writes its own user-data wrapper that runs .command.sh directly and never invokes that stage-in step. (grep nxf_stage over the repo: 0 hits.)

How it manifests (real run — nf-core/taxprofiler 2.0.0)

A pipeline that fetches FASTQs in one process and feeds them to taxprofiler's FASTQC (input: path reads):

  • FASTQC's task work dir on S3 contained only .command.sh / .command.err / .exitcode — no input FASTQ.
  • .command.sh symlinks the expected basename, which isn't present:
    ln -s SRR059374_stool_1.fastq.gz SRR059374_stool_..._raw_1.gz
    fastqc ... SRR059374_stool_..._raw_1.gz
    → Skipping 'SRR059374_stool_..._raw_1.gz' which didn't exist, or couldn't be read
    
  • The upstream producer's outputs were in S3, just under the producer's work-dir prefix — a different prefix than the FASTQC task's work dir, so aws s3 sync <FASTQC-workdir> never pulls them.

The only process that worked was a hand-written one that does its own aws s3 cp of its inputs inside the script body — i.e. it sidesteps staging entirely. That's the current de-facto requirement, and it's not viable for stock nf-core modules.

Suggested fix

Have the staging script localize declared inputs the way Nextflow's nxf_stage does, before running .command.sh. Options, roughly in order of robustness:

  1. Emit/run Nextflow's own staging. Let Nextflow generate .command.run (with nxf_stage) and have the instance execute that instead of a hand-rolled wrapper — so foreign-file copy, symlinks, and stage-in mode all behave exactly as on other executors.
  2. Stage task.getInputFilesMap() explicitly. In buildStagingScript, iterate the task's resolved input files and aws s3 cp each source URI → ${LOCAL_DIR}/<stageName> before the aws s3 sync of the work dir. Covers cross-task and samplesheet s3:// inputs.
  3. At minimum, document that the spawn executor currently requires every process to self-fetch its inputs, since that's a hard constraint today.

Happy to test a fix against the taxprofiler demo that surfaced this (aws-microbiome-demo) — it reproduces reliably with a 2-process fetch→profile pipeline.

Environment

  • nf-spawn 0.2.8, spawn 0.45.0, Nextflow 26.04.x, AL2023 arm64 (Graviton), workDir = s3://…, nf-amazon 2.8.0.
  • Observed 2026-06-13.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions