Skip to content

ext.volumes mounts collide with nf-core's staged path DB inputs (taxprofiler db_path) — volume-provided data has no "already here, don't stage" path #49

Closed

Description

@scttfrdmn

Summary

ext.volumes (0.3.0, #45) attaches an EBS volume and mounts it at a fixed path on the task instance. But nf-core pipelines that take a reference DB as a staged path input — i.e. essentially all of them — don't consume data that way: they take a db_path, and Nextflow stages it from the head into each task's work dir. The two mechanisms compete, and ext.volumes can't actually feed such a pipeline.

Concretely, with nf-core/taxprofiler 2.0.0 and a databases.csv whose db_path is the volume mount point (/opt/databases/metaphlan):

  1. Head-side validation fails first. taxprofiler validates every db_path exists on the head node (samplesheetToList vs schema_database.json, in pipeline init — before any task launches). The volume mounts on the task, not the head, so the path doesn't exist there:
    Entry 2: Error for field 'db_path' (/opt/databases/metaphlan):
      the file or directory '/opt/databases/metaphlan' does not exist
    → SchemaValidationException → whole pipeline aborts
    
  2. Even past validation, db_path is a staged input. workflows/taxprofiler.nf branches on db_path.name.endsWith('.tar.gz') and the profiling subworkflow carries db as a path object into KRAKEN2_KRAKEN2(reads, db) / METAPHLAN_METAPHLAN(…, db) (both path db). So Nextflow wants to copy db_path head→task work dir — which conflicts with the volume already mounted at that path.

How I found it (and a false positive to flag)

Migrating the demo's Kraken2 + MetaPhlAn DBs onto EBS volumes (spawn snapshot create + ext.volumes). Kraken2 appeared to work in an earlier run — but that was a false positive: the AMI still had the DB baked at the same path, so it satisfied both the head validation and was physically on the task; Kraken2 read the baked copy and the volume was never actually exercised. MetaPhlAn (no baked copy) is what exposed the incompatibility.

The gap

ext.volumes is great for data a process reads directly from a known mount path (a tool you call yourself, like our hand-rolled FETCH_FASTQ could). It does not work when the pipeline models the data as a declared path input it stages itself — there's no way to tell Nextflow/the module "this input is already present at the mount, don't stage it, and don't fail head-side validation."

Possible directions (raising, not prescribing)

  • Docs/guidance: document that ext.volumes suits self-mounted data, not staged path inputs — so people don't try to back an nf-core db_path with it (as I did).
  • An s3:// db_path path instead: for staged inputs, the thing that does fit is nf-spawn's existing 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 input localization — if a pipeline accepts an s3:// db_path, nf-spawn already aws s3 cps declared inputs to the task. That sidesteps volumes entirely for DBs (at the cost of staging 16–34 GB per task). Worth documenting as the recommended pattern for staged-input DBs, with ext.volumes reserved for self-mounted data.
  • Head-side presence: validation-style checks that run on the head can't see a task-only mount — inherent to the split. Nothing nf-spawn can do about a pipeline's head-side validation, which is why volumes can't satisfy it.

Context

nf-spawn 0.4.0, spawn 0.50.0, taxprofiler 2.0.0, AL2023 arm64. Not a regression — ext.volumes does what it says; this is about which data-delivery model it fits. Full write-up in the demo repo's docs/ami-vs-data-volume.md. Happy to test a documented pattern or a fix.

Activity

  1. added
    bug
    on Jun 14, 2026
  2. added
    documentation
    and removed
    bug
    on Jun 14, 2026
  3. scttfrdmn commented on Jun 14, 2026

    @scttfrdmn
    CollaboratorAuthor

    Confirmed your analysis end-to-end — and agree it's not a bug: ext.volumes does exactly what it says; this is about which data-delivery model it fits. I checked the code for a possible fix and there isn't a viable one, because both failure points are outside nf-spawn's reach:

    1. Head-side validation runs in pipeline init, before any task launches — a task-only volume mount can't exist on the head, so nf-spawn never even gets control to intervene.
    2. Nextflow stages path inputs itself (head → task work dir); there's no hook for a module to say "already mounted, skip staging," and the staged copy collides with the mount.

    So this is documentation. Merged #50, which adds a Delivering reference data section to the README spelling out the two models:

    Good catch on the Kraken2 false positive too (baked DB at the same path satisfied both head validation and the task) — that's exactly the kind of thing that hides this until a DB without a baked copy (MetaPhlAn) exposes it. I noted it in the PR.

    Closing as resolved-by-docs. If you hit a pipeline that takes an s3:// db_path and the #37 localization misbehaves with a 30 GB DB, open a fresh issue — that path I can fix.

  4. scttfrdmn commented on Jun 14, 2026

    @scttfrdmn
    CollaboratorAuthor

    Update — the conclusion on this changed for the better. I'd first said volume-backed staged path inputs were impossible and to use an s3:// db_path (download per task). On a closer trace that was wrong: it's two small, fixable gaps in nf-spawn, not an inherent limit. Fixed in nf-spawn v0.5.0 (#51 / PR #52):

    1. Symlink, don't skip. A path input is referenced by its work-dir stage name (taxprofiler's metaphlan does find -L metaphlan_db ...). nf-spawn now symlinks that stage name → the local ext.volumes mount (the spawn equivalent of stageInMode=symlink), so find -L resolves to the read-only volume — no copy.
    2. Bind-mount the volume into the container, so the tool can actually see /opt/databases/x inside Docker.

    The one piece nf-spawn can't do — the head-side exists check — you cover by attaching the same read-only snapshot on the head node at the same path. Validation passes, no pipeline fork. (Read-only data replicates freely: attach the one snapshot to head + every task.)

    So the full pattern is now: spawn snapshot create once → attach read-only on head + tasks via ext.volumes → unmodified nf-core pipeline reads the DB off the mount, zero copy, zero per-task download. The s3:// route stays only as a fallback when you can't mount on the head. README's "Delivering reference data" section has the recipe.

    Bump TARGET_NF_SPAWN_VERSION to 0.5.0. The one thing I'd validate on your end: confirm the MetaPhlAn find -L resolves the symlinked stage name to the volume on a real run (directory path input → stage-name basename match), and that a .tar.gz-named DB vs a directory mount behaves. Keen to hear.

  5. scttfrdmn commented on Jun 14, 2026

    @scttfrdmn
    CollaboratorAuthor

    Tested the full volume-backed-DB path on nf-spawn 0.5.0 + spawn 0.51.1 (the #166 mount-ordering fix). Big progress, and one remaining MetaPhlAn-specific snag — with the artifacts you asked for.

    What works now ✅

    • spawn 0.51.1 mounts the --attach-volume DBs before the workload, so taxprofiler's head-side db_path validation passes (was the earlier abort).
    • Kraken2 reads its DB zero-copy from the volume and completes — real classification output. Its .command.sh does kraken2 --db kraken2 (relative stage name), the symlink→mount resolves, exit 0. So the 0.5.0 symlink+bind-mount mechanism demonstrably works for at least the direct-path case.
    • The task AMI has no baked DB (confirmed: bake log has 0 DB-download lines), so this is genuinely the volume feeding Kraken2.

    What still fails: MetaPhlAn (find -L on the stage name) ❌

    Same setup (its own ext.volumes mount /opt/databases/metaphlan, snapshot has the full bowtie2 index — verified on the head). MetaPhlAn's task: FAILED exit=0 (clean container exit, no *_profile.txt → Nextflow fails it). The error:

    read_fastx.py … BrokenPipeError: [Errno 32] Broken pipe
    

    i.e. bowtie2 died immediately (no DB), breaking the reads pipe. The cause is the DB lookup in .command.sh:

    BT2_DB=`find -L "metaphlan" -name "*rev.1.bt2*" -exec dirname {} \;`
    metaphlan ... --bowtie2db $BT2_DB --index $BT2_DB_INDEX ...

    find -L metaphlan (relative stage name) returns nothing → $BT2_DB empty → bowtie2 fails. And the task work dir has no metaphlan entry (only the staged FASTQs + .command.*).

    The diagnostic contrast

    Both DBs are directory ext.volumes mounts referenced by relative stage name in .command.sh:

    • Kraken2: --db kraken2 → resolves, works.
    • MetaPhlAn: find -L metaphlan → empty, fails.

    So for MetaPhlAn the stage-name symlink→mount either wasn't created or find -L can't traverse it, whereas Kraken2's did. Possibly relevant differences: MetaPhlAn's mount basename is metaphlan and it's accessed via find -L <name> (needs the symlink to be a traversable dir), vs Kraken2 handing the name straight to the tool. The MetaPhlAn DB is also larger (34 GB vol vs 16 GB) and the task needed a 100 GB root to even pull the (conda) image — but the failure here is purely the missing metaphlan stage entry, not space.

    Artifacts

    • MetaPhlAn .command.sh: the find -L "metaphlan" block above (verbatim).
    • MetaPhlAn work-dir listing: .command.{sh,err,out}, .exitcode, the 2 *.fastp.fastq.gz, versions.yml — no metaphlan symlink/dir.
    • Kraken2 work-dir listing (works): same shape, --db kraken2, plus its .report.txt output.

    Happy to pull the task instance's ls -la of the work dir live or the spawn staging script if that pins it down — say the word. Env: nf-spawn 0.5.0, spawn 0.51.1, taxprofiler 2.0.0, AL2023 arm64, both DBs via ext.volumes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions