feat(cli): add iohub compute-pyramid command#412
Conversation
Wraps `Position.compute_pyramid` so users can build multiscale pyramid levels in place from the command line, mirroring the ergonomics of `iohub set-scale` (per-position glob, plate expansion, mode="r+"). iohub compute-pyramid -i input.zarr/*/*/* --levels 4 iohub compute-pyramid -i input.zarr/*/*/* -l 3 -m median --dims y,x Tests cover: - happy path with explicit levels and method - plate-glob expansion (passing the plate root) - partial-axis downsampling via --dims y,x (Z preserved) - --help and invalid --dims rejection
|
@edyoshikun We have the ability to create pyramids from cli over in biahub: https://github.com/czbiohub-sf/biahub/blob/main/biahub/pyramid.py Is there a specific reason you want it in |
|
IMO this is an iohub feature. you have all the code for multiscale here, so we should support the call here |
|
Also, that's the function I was looking for but you guys pointed me to the example in the website so I thought it didn't exist. |
|
@edyoshikun as you said we currently have iohub API that computes a pyramid: I don't mind adding a iohub CLI for computing pyramids too, as in this PR, the downside of that if that it will happen sequentially for multiple positions. |
|
@edyoshikun gotcha I see. Sure I think it'd be nice to have it here. Could be useful for just small one off things, and we would recommend users to go to |
|
For the 20GB dataset it was fairly fast ~ 5 min tops, so I think it's useful to have it here and independent to biahub. I could use some of this for the DL course as well. |
|
@edyoshikun Feel free to request a review whenever you think this is ready for one! |
|
Agreed. We have a similar problem with convert. Currently |
Summary
iohub compute-pyramidto the CLI, wrappingPosition.compute_pyramidso users can build multiscale pyramid levels in place on existing OME-Zarr stores from the shell.iohub set-scale: uses@input_position_dirpaths()(so plates and globs likeinput.zarr/*/*/*Just Work), opens each position withmode=\"r+\", mutates in place.Why
Position.compute_pyramidis already a public, tested method, but there is no shell-level entry point. Pipelines that produce a single-level zarr (e.g.biahub concatenate) currently need a custom Python script per project to add downsampled levels. Surfacing it as a CLI subcommand makes it a one-liner and matches the precedent set byset-scale.Usage
Options
Tests
`tests/cli/test_cli.py` adds 5 new tests covering:
`uvx prek run --files src/iohub/cli/cli.py tests/cli/test_cli.py` is clean.
Test plan
🤖 Generated with Claude Code