You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
0.5.0 stage-name symlink works for --db <name> (Kraken2) but not find -L <name> (MetaPhlAn) — symlink missing in task work dir #55
Follow-up to #49 / #51 (PR #52), filed fresh since #49 is closed. The 0.5.0 symlink-the-stage-name-to-the-ext.volumes-mount fix works for one access pattern but not another, so a volume-backed DB feeds Kraken2 but not MetaPhlAn.
Validated on nf-spawn 0.5.0 + spawn 0.51.1 (incl. the #166 mount-before-workload fix), taxprofiler 2.0.0, AL2023 arm64, both DBs via ext.volumes, no baked DB on the AMI (bake log has 0 DB-download lines, so the volume is genuinely the source).
Works: Kraken2 (direct --db <stagename>)
.command.sh: kraken2 --db kraken2 ... → resolves the stage-name symlink → mount, exit 0, real classification output. So 0.5.0's symlink+bind-mount works for a tool handed the stage name directly.
find -L metaphlan returns nothing → empty --bowtie2db → bowtie2 finds no index → read_fastx.py … BrokenPipeError → FAILED exit=0 (clean container exit, no *_profile.txt).
The task work-dir listing shows no metaphlan entry at all — only the staged FASTQs, .command.*, versions.yml. So the stage-name symlink for this path input was not created in the work dir (whereas Kraken2's kraken2 one was).
The contrast (the useful signal)
Same ext.volumes directory-mount setup, same relative-stage-name pattern in .command.sh:
tool
references DB as
stage symlink in work dir?
result
Kraken2
--db kraken2
yes
✅ exit 0
MetaPhlAn
find -L metaphlan
no
❌ empty $BT2_DB, bowtie2 dies
So this isn't find -L vs direct-path semantics per se — it's that the stage symlink is present for the Kraken2 task and absent for the MetaPhlAn task. Candidate differences to check on your side:
MetaPhlAn's DB input may be wired through a different channel/stage-name in taxprofiler than Kraken2's (e.g. the basename nf-spawn symlinks doesn't match the find -L argument the module uses).
Or the symlink is created under a different name than the module's find -L target (metaphlan here).
Artifacts I have
Both .command.sh files (verbatim DB-reference lines above).
Both task work-dir listings (Kraken2 has its .report.txt; MetaPhlAn has no metaphlan entry).
Can pull a live ls -la of a MetaPhlAn task work dir (incl. whether any symlink exists and where it points) + the spawn staging script off the instance if that pins it down — just say the word and I'll grab it before the task self-terminates.
Thanks — the "symlink present for Kraken2, absent for MetaPhlAn" contrast is the key signal, and it tells me this is almost certainly not a find -L issue. nf-spawn's symlink logic is identical for both: in buildInputStaging, every entry in task.getInputFilesMap() whose source is a local path gets ln -sfn <mount> ${LOCAL_DIR}/<stageName> (guarded by [ -e <mount> ]). Kraken2's db clearly went through that path; MetaPhlAn's clearly didn't. Two possible reasons, and they have different fixes:
MetaPhlAn's db isn't in getInputFilesMap() as a local path — i.e. taxprofiler wires the MetaPhlAn db into the module differently than Kraken2's (different channel/operator), so Nextflow doesn't present it to the executor as a staged path input nf-spawn can see. → fix is on the nf-spawn side only if the input is there but shaped oddly; if it's genuinely absent from the map, it's a pipeline-wiring thing.
The symlink line WAS emitted but the [ -e ] guard was false at staging time — e.g. the metaphlan volume mounted a moment later than staging ran, or at a slightly different path than the stage name's source. → fix is nf-spawn (drop/loosen the guard, or retry).
The work-dir listing distinguishes these instantly: no metaphlan entry → reason 1 (line never emitted); a dangling metaphlan symlink → reason 2 (emitted, target missing). You said "no metaphlan entry at all," which points at #1 — but I want to confirm against the actual generated script rather than infer.
Could you grab, off a MetaPhlAn task instance before it self-terminates:
# the spawn staging script nf-spawn generated (shows whether a symlink line for 'metaphlan' was emitted at all)
sudo cat /var/lib/cloud/instance/user-data.txt 2>/dev/null | grep -nE "metaphlan|ln -sfn|find -L|/opt/databases"# the work dir — is there a metaphlan symlink, dangling or otherwise?
ls -la /var/lib/nf-work/ ; readlink -f /var/lib/nf-work/metaphlan 2>/dev/null
# and is the mount actually there + populated?
ls -la /opt/databases/metaphlan/ | head ; mountpoint /opt/databases/metaphlan 2>/dev/null
The first command is the decisive one: if there's no ln -sfn ... metaphlan line in the staging script, then getInputFilesMap() didn't contain MetaPhlAn's db (reason 1) — and the fix is to understand how taxprofiler presents that input (it may need the s3:// route, or a small nf-spawn change if Nextflow exposes it via a different accessor than getInputFilesMap()). If the line is there but the work dir has no/dangling symlink, it's reason 2 and squarely mine to fix.
(The Kraken2 success in the same run already proves the mechanism works end-to-end, so we're isolating one specific input's wiring — close to done.)
Got the staging scripts off the head (/tmp/nf-spawn-nf-*.sh). The answer is neither of your two hypotheses — and it overturns my "symlink missing" framing. nf-spawn isn't symlinking at all; it's copying both DBs per-task via the #37 S3-localization path. The 0.5.0 symlink-to-ext.volumes-mount (#51) never engages for these db_path inputs.
What the generated MetaPhlAn staging script actually does (verbatim)
# Localize declared inputs by source URI (#37 — they live outside this work dir).
aws s3 cp 's3://…/classify/62/…/SRR059376…_1.fastp.fastq.gz'"${LOCAL_DIR}/"'…_1.fastp.fastq.gz' … || { … exit 1; }
aws s3 cp 's3://…/classify/stage-367ee240-…/70/…/metaphlan'"${LOCAL_DIR}/"'metaphlan' --region … --recursive --quiet || { echo"nf-spawn: failed to stage input metaphlan …">&2;exit 1; }
aws s3 cp 's3://…/classify/62/…/SRR059376…_2.fastp.fastq.gz'"${LOCAL_DIR}/"'…_2.fastp.fastq.gz' … || { … exit 1; }
...
docker run --rm -v "${LOCAL_DIR}":"${LOCAL_DIR}" -w "${LOCAL_DIR}" -v '/opt/databases/metaphlan:/opt/databases/metaphlan:ro''quay.io/aarchbio/metaphlan:…' bash .command.sh …
So for the db_path input nf-spawn emits an aws s3 cp --recursive of s3://…/classify/stage-<uuid>/…/metaphlan → ${LOCAL_DIR}/metaphlan — i.e. the #37 source-URI localization, not a symlink to the bind-mounted volume. The ext.volumes mount IS bind-mounted (-v /opt/databases/metaphlan:…:ro on line 49) but is unused — the tool's find -L metaphlan looks at ${LOCAL_DIR}/metaphlan, the copy target.
Why Kraken2 "worked" and MetaPhlAn didn't — same code path, different size
metaphlan stage prefix: 36.1 GB, 10 files (incl. two ~8.6 GB .bt2l) → copy fails/incomplete → find -L metaphlan finds no *rev.1.bt2* → empty --bowtie2db → bowtie2 dies → BrokenPipe.
So my earlier "Kraken2 is zero-copy from the volume" was also wrong — neither is zero-copy; Kraken2 just copies a smaller DB that fits/completes.
The actual bug
0.5.0 was supposed to symlink a path input whose source is a local ext.volumes mount, instead of copying it (#51). Here the source nf-spawn sees is the s3://…/classify/stage-…/metaphlan that taxprofiler staged — not the /opt/databases/metaphlan mount — so the #51 "is this a local mount?" check is false and it falls back to the #37aws s3 cp. taxprofiler interposes its own S3 stage copy of db_path between the mount and the task, so nf-spawn never sees the mount as the input source.
Net: with taxprofiler, ext.volumes doesn't avoid the per-task download — Nextflow stages db_path to S3 and nf-spawn copies it back. The mount is dead weight. (This is basically #49 resurfacing: taxprofiler stagesdb_path, so the source URI is always the Nextflow stage copy, never the mount.)
Repro artifacts (have them / can re-grab)
Both full staging scripts (/tmp/nf-spawn-nf-*.sh) — MetaPhlAn + Kraken2, showing identical aws s3 cp --recursive for the db input.
The two stage-prefix sizes above (16.6 vs 36.1 GB).
The bind-mount line proving the volume is attached but unused.
Happy to test whatever you think the fix is — e.g. if nf-spawn can detect "this path input's content is already present at an ext.volumes mount of the same basename and symlink to it instead of copying the Nextflow stage URI." Env: nf-spawn 0.5.0, spawn 0.51.1, taxprofiler 2.0.0, AL2023 arm64.
Fixed in nf-spawn v0.6.0 (#56). Your staging-script grep was the key — it disproved both my hypotheses and the original "symlink missing" framing, and pinned the real bug exactly:
0.5.0 matched on the input's source URI being the mount. But taxprofiler stagesdb_path (copies it into the Nextflow S3 work area), so the source nf-spawn saw was always s3://…/classify/stage-…/metaphlan — never /opt/databases/metaphlan. The #51 "is this a local mount?" check was always false → fell back to aws s3 cp and downloaded the DB per task. The mount was bind-mounted but unused. Kraken2 only "worked" because 16.6 GB copied cleanly; MetaPhlAn's 36 GB truncated. Neither was zero-copy. You called all of that correctly.
The fix (your suggestion, exactly): match a declared input's stage-name basename against the attached ext.volumes mounts, and on a match symlink stage-name → mount, skip the copy — regardless of the source URI. So a volume-backed DB is read straight off the read-only volume even when the pipeline stages db_path.
To validate on 0.6.0: ensure the mount basename matches the input stage name. For taxprofiler that's driven by db_name in databases.csv — so for the MetaPhlAn row, the stage name nf-spawn sees should equal the mount basename. From your artifact the input was metaphlan, so mount at /opt/databases/metaphlan (which you did). Expect on a re-run:
no aws s3 cp of the DB in the staging script,
a metaphlan symlink → /opt/databases/metaphlan in the work dir,
MetaPhlAn completes zero-copy like Kraken2.
If the stage name and mount basename ever differ (e.g. taxprofiler names the stage from db_name rather than the path), just name the mount to match. Grab the staging script again on the re-run and you'll see the ln -sfn line instead of aws s3 cp — keen to confirm it lands.
✅ Confirmed: 0.6.0 lands it — full zero-copy, no fork, both DBs. Re-ran taxprofiler on nf-spawn 0.6.0 + spawn 0.51.1. Every task COMPLETED, including all 3 METAPHLAN_METAPHLAN (was the holdout), with real profile output (k__Bacteria|p__Fusobacteriota|…|g__Fusobacterium, matching Kraken2's calls on the same stool sample). Kraken2 + MetaPhlAn both classified straight off their read-only EBS volumes.
Verified the fix in the generated staging script — exactly as you described, the DB input is now symlinked, not copied:
if [ -e'/opt/databases/metaphlan' ];then ln -sfn '/opt/databases/metaphlan'"${LOCAL_DIR}/"'metaphlan';elseecho"nf-spawn: ext.volumes mount … not present">&2;exit 1;fi
No aws s3 cp of the 36 GB DB anymore; find -L metaphlan resolves the bowtie2 index straight on the mount. So #55 is fully resolved — thanks for the quick turnaround.
Two findings from the same run, for the record (not nf-spawn bugs — sizing on my side):
After the symlink fix, MetaPhlAn first hit bowtie2-align exited with value 137 (OOM) on a 16 GB instance loading the full CHOCOPhlAnSGB index — fixed by moving that task to a 128 GB instance. Expected for this DB; flagging in case it's worth a doc note that volume-mounted DBs still need the task instance sized for the tool's resident memory (the volume removes the copy, not the RAM footprint).
Cosmetic: find -L "metaphlan" emits find: 'metaphlan/lost+found': Permission denied to stderr (the ext4 volume's lost+found, mode 700, root-owned). Harmless — find still resolves the index — but if spawn snapshot create made the fs without a lost+found (or chmod'd it) that stderr line would go away.
Net for the demo: the whole stock-tools-AMI + DBs-on-read-only-EBS-volumes + zero-copy pattern now works end-to-end for an unmodified nf-core pipeline. Appreciate the fast iteration across #45/#47/#49/#51/#55 (and spawn #157/#161/#166). 🙏
Activity
scttfrdmn commentedon Jun 14, 2026
Thanks — the "symlink present for Kraken2, absent for MetaPhlAn" contrast is the key signal, and it tells me this is almost certainly not a
find -Lissue. nf-spawn's symlink logic is identical for both: inbuildInputStaging, every entry intask.getInputFilesMap()whose source is a local path getsln -sfn <mount> ${LOCAL_DIR}/<stageName>(guarded by[ -e <mount> ]). Kraken2'sdbclearly went through that path; MetaPhlAn's clearly didn't. Two possible reasons, and they have different fixes:dbisn't ingetInputFilesMap()as a local path — i.e. taxprofiler wires the MetaPhlAn db into the module differently than Kraken2's (different channel/operator), so Nextflow doesn't present it to the executor as a stagedpathinput nf-spawn can see. → fix is on the nf-spawn side only if the input is there but shaped oddly; if it's genuinely absent from the map, it's a pipeline-wiring thing.[ -e ]guard was false at staging time — e.g. the metaphlan volume mounted a moment later than staging ran, or at a slightly different path than the stage name's source. → fix is nf-spawn (drop/loosen the guard, or retry).The work-dir listing distinguishes these instantly: no
metaphlanentry → reason 1 (line never emitted); a danglingmetaphlansymlink → reason 2 (emitted, target missing). You said "nometaphlanentry at all," which points at #1 — but I want to confirm against the actual generated script rather than infer.Could you grab, off a MetaPhlAn task instance before it self-terminates:
The first command is the decisive one: if there's no
ln -sfn ... metaphlanline in the staging script, thengetInputFilesMap()didn't contain MetaPhlAn's db (reason 1) — and the fix is to understand how taxprofiler presents that input (it may need thes3://route, or a small nf-spawn change if Nextflow exposes it via a different accessor thangetInputFilesMap()). If the line is there but the work dir has no/dangling symlink, it's reason 2 and squarely mine to fix.(The Kraken2 success in the same run already proves the mechanism works end-to-end, so we're isolating one specific input's wiring — close to done.)
scttfrdmn commentedon Jun 14, 2026
Got the staging scripts off the head (
/tmp/nf-spawn-nf-*.sh). The answer is neither of your two hypotheses — and it overturns my "symlink missing" framing. nf-spawn isn't symlinking at all; it's copying both DBs per-task via the #37 S3-localization path. The 0.5.0 symlink-to-ext.volumes-mount (#51) never engages for thesedb_pathinputs.What the generated MetaPhlAn staging script actually does (verbatim)
So for the
db_pathinput nf-spawn emits anaws s3 cp --recursiveofs3://…/classify/stage-<uuid>/…/metaphlan→${LOCAL_DIR}/metaphlan— i.e. the #37 source-URI localization, not a symlink to the bind-mounted volume. Theext.volumesmount IS bind-mounted (-v /opt/databases/metaphlan:…:roon line 49) but is unused — the tool'sfind -L metaphlanlooks at${LOCAL_DIR}/metaphlan, the copy target.Why Kraken2 "worked" and MetaPhlAn didn't — same code path, different size
Kraken2's script is identical in shape (line 22):
Both DBs were uploaded by Nextflow/taxprofiler into the work area and are copied per task:
.bt2l) → copy fails/incomplete →find -L metaphlanfinds no*rev.1.bt2*→ empty--bowtie2db→ bowtie2 dies → BrokenPipe.So my earlier "Kraken2 is zero-copy from the volume" was also wrong — neither is zero-copy; Kraken2 just copies a smaller DB that fits/completes.
The actual bug
0.5.0 was supposed to symlink a
pathinput whose source is a localext.volumesmount, instead of copying it (#51). Here the source nf-spawn sees is thes3://…/classify/stage-…/metaphlanthat taxprofiler staged — not the/opt/databases/metaphlanmount — so the #51 "is this a local mount?" check is false and it falls back to the #37aws s3 cp. taxprofiler interposes its own S3 stage copy ofdb_pathbetween the mount and the task, so nf-spawn never sees the mount as the input source.Net: with taxprofiler,
ext.volumesdoesn't avoid the per-task download — Nextflow stagesdb_pathto S3 and nf-spawn copies it back. The mount is dead weight. (This is basically #49 resurfacing: taxprofiler stagesdb_path, so the source URI is always the Nextflow stage copy, never the mount.)Repro artifacts (have them / can re-grab)
/tmp/nf-spawn-nf-*.sh) — MetaPhlAn + Kraken2, showing identicalaws s3 cp --recursivefor the db input.Happy to test whatever you think the fix is — e.g. if nf-spawn can detect "this
pathinput's content is already present at anext.volumesmount of the same basename and symlink to it instead of copying the Nextflow stage URI." Env: nf-spawn 0.5.0, spawn 0.51.1, taxprofiler 2.0.0, AL2023 arm64.fix: symlink ext.volumes DB by stage-name basename, not source URI (#55…
scttfrdmn commentedon Jun 15, 2026
Fixed in nf-spawn v0.6.0 (#56). Your staging-script grep was the key — it disproved both my hypotheses and the original "symlink missing" framing, and pinned the real bug exactly:
0.5.0 matched on the input's source URI being the mount. But taxprofiler stages
db_path(copies it into the Nextflow S3 work area), so the source nf-spawn saw was alwayss3://…/classify/stage-…/metaphlan— never/opt/databases/metaphlan. The #51 "is this a local mount?" check was always false → fell back toaws s3 cpand downloaded the DB per task. The mount was bind-mounted but unused. Kraken2 only "worked" because 16.6 GB copied cleanly; MetaPhlAn's 36 GB truncated. Neither was zero-copy. You called all of that correctly.The fix (your suggestion, exactly): match a declared input's stage-name basename against the attached
ext.volumesmounts, and on a match symlink stage-name → mount, skip the copy — regardless of the source URI. So a volume-backed DB is read straight off the read-only volume even when the pipeline stagesdb_path.To validate on 0.6.0: ensure the mount basename matches the input stage name. For taxprofiler that's driven by
db_nameindatabases.csv— so for the MetaPhlAn row, the stage name nf-spawn sees should equal the mount basename. From your artifact the input wasmetaphlan, so mount at/opt/databases/metaphlan(which you did). Expect on a re-run:aws s3 cpof the DB in the staging script,metaphlansymlink →/opt/databases/metaphlanin the work dir,If the stage name and mount basename ever differ (e.g. taxprofiler names the stage from
db_namerather than the path), just name the mount to match. Grab the staging script again on the re-run and you'll see theln -sfnline instead ofaws s3 cp— keen to confirm it lands.scttfrdmn commentedon Jun 15, 2026
✅ Confirmed: 0.6.0 lands it — full zero-copy, no fork, both DBs. Re-ran taxprofiler on nf-spawn 0.6.0 + spawn 0.51.1. Every task COMPLETED, including all 3
METAPHLAN_METAPHLAN(was the holdout), with real profile output (k__Bacteria|p__Fusobacteriota|…|g__Fusobacterium, matching Kraken2's calls on the same stool sample). Kraken2 + MetaPhlAn both classified straight off their read-only EBS volumes.Verified the fix in the generated staging script — exactly as you described, the DB input is now symlinked, not copied:
No
aws s3 cpof the 36 GB DB anymore;find -L metaphlanresolves the bowtie2 index straight on the mount. So #55 is fully resolved — thanks for the quick turnaround.Two findings from the same run, for the record (not nf-spawn bugs — sizing on my side):
bowtie2-align exited with value 137(OOM) on a 16 GB instance loading the full CHOCOPhlAnSGB index — fixed by moving that task to a 128 GB instance. Expected for this DB; flagging in case it's worth a doc note that volume-mounted DBs still need the task instance sized for the tool's resident memory (the volume removes the copy, not the RAM footprint).find -L "metaphlan"emitsfind: 'metaphlan/lost+found': Permission deniedto stderr (the ext4 volume'slost+found, mode 700, root-owned). Harmless —findstill resolves the index — but ifspawn snapshot createmade the fs without alost+found(or chmod'd it) that stderr line would go away.Net for the demo: the whole stock-tools-AMI + DBs-on-read-only-EBS-volumes + zero-copy pattern now works end-to-end for an unmodified nf-core pipeline. Appreciate the fast iteration across #45/#47/#49/#51/#55 (and spawn #157/#161/#166). 🙏
feat: forward ext.fsx/ext.efs to spawn launch for shared reference fi…
feat: dispatch each task via spawn task run (spawn#386 adapter migrat…
fix: stage-out skips inputs stage-in symlinked to a mount (#99) (#110)