Skip to content

Conversation

@BrianWhitneyAI
Copy link
Contributor

@BrianWhitneyAI BrianWhitneyAI commented May 21, 2025

Description

This PR migrates the writers to their respective reader while maintaining the import structure. It resolves #123 #124 and #125 when combined with its companion PRS. If you have the plugin installed, for example bioio-ome-tiff then users can access via the following import:

from bioio.writers import OmeTiffWriter

OmeTiffWriter.save(...)

This logic is tested with the DummyPlugin to prove modularity.

Since we offer BioImage.save this PR conditionally imports it if the plugin is installed. Otherwise warns the user that it needs to be installed.

The goal here is to have this be as seamless to users. Anyone who implements one of the readers should only have to add the necessary plugin to their dependencies without making any code changes.

@BrianWhitneyAI BrianWhitneyAI marked this pull request as ready for review May 21, 2025 22:46
@BrianWhitneyAI BrianWhitneyAI requested a review from a team as a code owner May 21, 2025 22:46
@BrianWhitneyAI
Copy link
Contributor Author

Documentation is a question here. Where to have writer documentation...


OmeTiffWriter = getattr(_writers, "OmeTiffWriter", None)

if OmeTiffWriter is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why log this if bioio-ome-tiff isn't installed? Wouldn't we also need to do this for ome-zarr if we go this direction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We implement a specific save function built into BioImage that defaults to the OmeTiffWriter. It never had the option of the OmeZarrWriter. This just maintains the old functionality but warns the user if OmeTiffWriter isnt installed since it comes from bioio-ome-tiff now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see that now - weird that we did that. Makes sense to include to until we do a major version change

Copy link
Contributor Author

@BrianWhitneyAI BrianWhitneyAI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is another argument for a more involved ABC in bioio_base for writers. Then we could implement a way to choose what writer to use for save @toloudis what do you think about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was written when OME-TIFF was clearly the only important open file format we wanted, and before we were dealing with multi-TB multiscene time series, nevermind chunked zarr 😄 . Right now I question whether a single save function in the BioImage class even is useful.

The code change as implemented here seems to make sense for maintaining existing functionality...
but I think long term if writers are being removed from bioio, then either (a) save should be removed from BioImage, or (b) save could get a abstract Writer passed in and the caller would have to do the importing and constructing the writer object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this moving of writers seems to be a breaking change anyway, maybe this is a good opportunity to remove save until we design something better (abstracted api or not)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have plans to add it back later I think that the current option is a better one for now. Itd be strange to have one release without the save function. hopefully this will be minimally breaking since all the imports remain the same and the usage is the same

@BrianWhitneyAI BrianWhitneyAI requested a review from SeanDuHare May 23, 2025 17:08
@BrianWhitneyAI BrianWhitneyAI changed the base branch from feature/v3-ome-zarr-writer to main May 23, 2025 17:22
__all__: List[str] = []

# Discover all registered writers
_eps = _entry_points(group="bioio.writers")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do writers get registered? This seems to need some documentation somewhere maybe?

Copy link
Contributor Author

@BrianWhitneyAI BrianWhitneyAI May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you add an entry point called bioio.writers to the pyproject.toml (of the plugin). Definitely agree on documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open another documentation branch once the writers are on main for their respective plugins. That way we can reference directly.

@BrianWhitneyAI BrianWhitneyAI self-assigned this Jun 6, 2025
@BrianWhitneyAI BrianWhitneyAI merged commit 103816c into main Jun 6, 2025
20 checks passed
@BrianWhitneyAI BrianWhitneyAI deleted the feature/migrate-writers branch June 6, 2025 17:41
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.

Migrate ome-zarr writer to https://github.com/bioio-devs/bioio-ome-zarr

4 participants