Skip to content

feat(nextflow): make pipeline steps optional (skip tracking for neuromast/zebrafish) #306

Closed

Description

@tayllatheodoro

Problem

nextflow/mantis-v2.nf runs a fixed chain: flat-field → deskew → reconstruct → virtual-stain → assemble → track. Every step is mandatory. The workflow body errors without each config:

if (!params.track_config)       error "Provide --track_config"
if (!params.concatenate_config) error "Provide --concatenate_config"

and then unconditionally wires the step:

track_trigger = assemble_done.done
track_wf(all_positions, track_input, track_input_images, track_output, params.track_config, track_trigger)

Tracking is an A549 step. For neuromast/zebrafish datasets the deliverable is 5-assemble; tracking is not part of what those runs are for, and the tracking parameters (cellpose diameter, min_area/max_area, linking max_distance) are tuned for A549 cells, not neuromasts.

There is no way to express that today. A zebrafish run has to:

  1. author or copy a track.yml it does not want,
  2. pass it to --track_config purely so the workflow validates and starts,
  3. spend GPU wall time on a 4-track fan-out after assemble,
  4. produce a 4-track/<ds>.zarr that is discarded.

Since #282 / #279 reordered track to run after assemble and read the assembled plate, this is strictly serial: the unwanted step delays nothing else, but it does extend the run past the point where the deliverable already exists.

What I'd like

A way to declare which steps a run performs. Rough shape, not a strong opinion on syntax:

--steps flat_field,deskew,reconstruct,virtual_stain,assemble        # neuromast
--steps flat_field,deskew,reconstruct,virtual_stain,assemble,track  # A549 (default)

with the config requirement following from the selection — --track_config required only if track is in the list. Nextflow's native -entry is the other obvious option, but it needs one named entry workflow per useful prefix and does not compose as well as a list.

Two things worth preserving:

  • directory_layout() stays the single source of truth. A skipped step should not renumber the ones after it — 5-assemble should stay 5-assemble whether or not track runs, so paths remain comparable across datasets.
  • Validate the selection up front. Related: #304 asks for all step inits to run at the start so config errors surface immediately rather than hours in. Step selection should be validated in the same early pass — including rejecting a selection whose first step's input does not exist.

Why it matters beyond zebrafish

The same gap shows up whenever the chain needs to stop early or restart partway:

  • re-running only assemble after fixing a concatenate config, without re-validating the upstream configs
  • stopping after reconstruct to eyeball phase before committing GPU hours to virtual staining
  • #292's verify-then-clean, which wants assemble and track decoupled

Workaround today

Pass a placeholder track.yml and discard 4-track. This is what the reconstruct-with-nextflow skill does for zebrafish (PR #305, templates/configs/zebrafish/track.yml), with the placeholder marked as such and the plan telling the user the output is a by-product. Once this lands, that placeholder and the caveat around it can be deleted.

Activity

  1. tayllatheodoro commented on Aug 11, 2026

    @tayllatheodoro
    CollaboratorAuthor

    Prior art: #250, and why it does not cover this

    #250 ("standalone step entry points") is the closest existing work, but it does not resolve this, for three reasons:

    1. It is a stale, conflicting draft. isDraft: true, mergeable: CONFLICTING, last updated 2026-05-19.
    2. It targets a file that no longer exists. Its changes are to nextflow/mantis-v2-timelapse.nf; main now has only nextflow/mantis-v2.nf.
    3. Its valuable parts already landed separately — the assembly-before-tracking reorder and tracking reading the assembled plate came in through refactor: Single-shot concatenate on a reserved compute node (mantis-v2 assemble) #279 / refactor(concatenate): drop --resolve-config, resolve on --concat-data-paths #282 / refactor(track): --init/--cluster tracking CLI with Nextflow subworkflow #281, and its rename-channels piece overlaps refactor: rename-channels Nextflow subworkflow (track superseded by #281) #260.

    It is also a different mechanism. Standalone entry points let you rerun one step in isolation. That does let a zebrafish run avoid tracking by driving steps individually, but it does not make a step optional within the pipeline — which is what is wanted, so that one nextflow run produces the right deliverable for the dataset family.

    Verified on main today: nextflow/mantis-v2.nf has a single workflow { block and no named entry workflows, and biahub nf exposes only list-positions. So there is no step-selection mechanism at all right now.

    Fresh evidence for the priority

    A smoke test on 2026_08_05_dynatrack_2dpf (8 positions, T=2) ran the full chain: flat-field, deskew, compute-transfer-function, apply-inv-tf, virtual-stain-preprocess, virtual-stain and concatenate all COMPLETED on the first attempt, and 5-assemble came out correct — 6 channels, finite data.

    The run still reported FAILED, purely because of run_track — the step this dataset family does not want. Two separate faults there (#309): a cupy/CPU-path TypeError, and the task dropping into (Pdb) inside the SLURM job, which holds a GPU allocation to the wall limit and then gets retried because a time-limit kill is in the retryable 130–145 range.

    So the cost of a mandatory step is not just wasted wall time — it turns a fully successful reconstruction into a failed run, and burns GPU allocations retrying a deterministic failure in work that was going to be discarded.

    Being able to say --steps ...,assemble would have made that run green and saved 6 × (wall limit) × 8 positions of GPU time.

  2. tayllatheodoro commented on Aug 11, 2026

    @tayllatheodoro
    CollaboratorAuthor

    Cross-ref: the workaround in use today is a marked placeholder track.yml plus discarding 4-track, shipped in #305 (templates/configs/zebrafish/track.yml, references/caveats.md §4). Both come out when this lands.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions