feat: Snakemake workflow — per-tile GPU SLURM jobs#24
Merged
Conversation
Add workflow/ (Snakefile + scripts + SLURM profile + config) that runs
the full pipeline — convert → prepare (checkpoint) → segment → merge —
and spreads the expensive Cellpose step across many GPUs by submitting
one GPU SLURM job per (non-empty) tile. Each job writes a disjoint
chunk of a shared stage store; a final CPU job stitches labels across
tile boundaries and writes them into the image as a calibrated,
multi-scale labels/ group.
- convert: any input → pyramidal OME-ZARR (auto chunks, optional shard)
- prepare: plan tiles, skip empties, create the empty stage store
- segment {tile}: read tile+halo → Cellpose → trim → write to stage (GPU)
- merge: zarr-native boundary merge + sequential relabel (default on)
- new [workflow] extra: snakemake + slurm executor plugin
Inspired by the sopa workflow's patch-scatter pattern.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address the 'why scripts if the API was fine' point: tile_process does stage+merge in one process, so there was no public way to run a single tile for distributed scatter. Add that to the public API and make the workflow thin: - new patchworks public API: spatial_tiles, create_stage, stage_tile (run fn on one tile → write a disjoint chunk of a shared stage), with tests - workflow scripts now just glue config → public API (cellpose, or a 'threshold' method for no-GPU testing) - split the workflow into rules/*.smk (convert / segment / merge / common) included from the Snakefile, like sopa - verified the whole pipeline runs end-to-end (snakemake, toy input): convert → prepare → segment ×N → merge, cross-boundary object stitched to a single label written into image.zarr/labels/ Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a thorough 'Cluster workflow (Snakemake + SLURM)' guide page (install → configure every field → dry-run → local vs SLURM → monitor → outputs → troubleshooting), wire it into the nav, and link it from the workflow README. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A SLURM-ready Snakemake pipeline that spreads the Cellpose step across many GPUs — one GPU job per tile.
shard)labels/<name>/pyramidNew
[workflow]extra installs snakemake + the SLURM executor plugin. GPU request lives inprofile/slurm/config.yaml(set-resources: segment: --gres=gpu:1); raisejobs:to use more GPUs at once.Addresses the 'days on one GPU' problem — N GPUs ≈ N× faster.
Validated: tiling+merge logic reproduces
tile_process(cross-boundary object → 1 label);snakemake -nbuilds a valid DAG; ruff + markdownlint clean. (Inspired by sopa's patch-scatter pattern.)🤖 Generated with Claude Code