Skip to content

feat: symlink local/volume path inputs + bind-mount ext.volumes into container (#51) - #52

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/51-symlink-local-volume-path-inputs
Jun 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/51-symlink-local-volume-path-inputs

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Closes #51 (follow-up to #49). Makes ext.volumes feed an nf-core staged path input (db_path) with zero copy and zero per-task download — the wasteful download-per-task route is now only a fallback.

The two gaps (traced against taxprofiler 2.0.0 + Nextflow staging)

  1. Stage name vs absolute path. A path input is referenced in the task script by its work-dir stage name, not the mount path — taxprofiler's metaphlan module does find -L "${metaphlan_db_latest}" .... nf-spawn skipped local (non-s3://) inputs, so nothing by that stage name existed in the task CWD.
  2. Container couldn't see the mount. buildRunLine bind-mounted only the work dir, so /opt/databases/x (the host ext.volumes mount) was invisible inside the Docker task.

Fix

  1. Symlink instead of skip (buildInputStaging): when a declared path input's source is a local absolute path, emit if [ -e <path> ]; then ln -sfn <path> ${LOCAL_DIR}/<stageName>; fi. The spawn equivalent of stageInMode=symlink on a shared FS; find -L follows it to the read-only volume. The existence guard means it degrades safely when no matching volume is attached (genuinely-local files still fall to the work-dir sync).
  2. Bind-mount the volume into the container: each ext.volumes mount → docker run -v /mount:/mount[:ro] (:ro when the volume is read-only), appended to the resolved run options.

New helpers: localAbsolutePath (file:////abs → path, else '') and volumeBindMounts (ext.volumes → -v flags).

The head-node piece (documented, not code)

nf-core validates db_path exists on the head at init — nf-spawn can't reach that. The user attaches the same read-only snapshot on the head at the same path; validation passes, no pipeline fork. A read-only snapshot attaches to many instances freely (replicating read-only data is trivially consistent). README's Delivering reference data section rewritten to spell out the full pattern.

Tests

51 total, 0 failures. Added: local path input is symlinked (guarded, no copy); localAbsolutePath (file:// / bare-abs / relative→'' / null); volumeBindMounts (:ro default, :rw, multiple, null). Built/tested JDK 17.

Result

spawn snapshot create once → attach read-only on head + every task via ext.volumes → an unmodified nf-core pipeline reads the DB off the mount. No fork, no per-task download.

…container (#51)

ext.volumes mounts a read-only reference DB on the task host, but two gaps kept
it from feeding an nf-core staged `path` input (the db_path pattern):

1. A `path` input is referenced by its work-dir STAGE NAME, not the absolute
   mount path (e.g. metaphlan does `find -L metaphlan_db ...`). nf-spawn skipped
   local (non-s3://) inputs entirely, so no entry by that stage name existed →
   the tool found nothing. Now: when a declared path input's source is a local
   absolute path present on the task, symlink the stage name → that path (the
   spawn equivalent of Nextflow's stageInMode=symlink on a shared FS). Guarded by
   an existence test so it degrades safely when no matching volume is attached.
2. The task container only bind-mounted the work dir, so /opt/databases/x was
   invisible inside it. Now each ext.volumes mount is bind-mounted into the
   container (read-only when the volume is).

Result: a volume-backed DB is read straight off the mount — zero copy, zero
per-task download — for both direct-read tools and staged path inputs. Combined
with attaching the same read-only snapshot on the head node (satisfies nf-core's
head-side `exists` validation), an unmodified nf-core pipeline runs on a
volume-backed DB with no fork.

Helpers: localAbsolutePath (file://|/abs → path, else ''), volumeBindMounts
(ext.volumes → docker -v flags). Docs/README rewritten accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ext.volumes work with staged path inputs (symlink stage name → mount, bind-mount into container)

1 participant