Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features / Bugs / Eva Notes #18

Open
evamaxfield opened this issue Nov 2, 2023 · 6 comments
Open

Features / Bugs / Eva Notes #18

evamaxfield opened this issue Nov 2, 2023 · 6 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@evamaxfield
Copy link
Contributor

Wanted to give the new libraries a whirl and figured I would make a couple of notes as I go along. I will try to resolve these issues / features this weekend or something as many of them are "optional" / maybe nice for dev and debugging experience.


  1. BIOIO_BASE_DIST_NAME needs to be updated from bioio-types to bioio-base

  2. It would be nice to have access to what plugin read the file somehow. Currently on image read, the __repr__ returns: <BioImage [Reader: Reader, Image-is-in-Memory: False]> but it might be better to return <BioImage [plugin: {plugin_name}, Image-is-in-Memory: False]>, esp. because most plugins will generally all use the same class name of Reader instead of say OmeTiffReader, better might be <BioImage [reader_path: {python_module_path_of_reader}, Image-is-in-Memory: False]>

  3. plugin_cache should be made into a set, dict, or deduped list:

In [2]: from bioio.plugins import get_plugins

In [3]: get_plugins()
Out[3]: 
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347)]

In [4]: get_plugins()
Out[4]: 
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347)]
  1. get_plugins should be called at the top of determine_reader? Currently cannot read files until manual get_plugins call (ignore debugging print statements):
In [1]: from bioio import BioImage, plugins

In [2]: img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")
---------------------------------------------------------------------------
UnsupportedFileFormatError                Traceback (most recent call last)
Cell In[2], line 1
----> 1 img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")

File ~/active/cell/bioio/bioio/bio_image.py:196, in BioImage.__init__(self, image, reader, reconstruct_mosaic, fs_kwargs, **kwargs)
    186 def __init__(
    187     self,
    188     image: biob.types.ImageLike,
   (...)
    192     **kwargs: Any,
    193 ):
    194     if reader is None:
    195         # Determine reader class and create dask delayed array
--> 196         ReaderClass = BioImage.determine_reader(
    197             image, fs_kwargs=fs_kwargs, **kwargs
    198         )
    199     else:
    200         # Init reader
    201         ReaderClass = reader

File ~/active/cell/bioio/bioio/bio_image.py:177, in BioImage.determine_reader(image, fs_kwargs, **kwargs)
    174 # If we haven't hit anything yet, we likely don't support this file / object
    175 # with the current plugins installed
    176 image_type = str(type(image))
--> 177 raise biob.exceptions.UnsupportedFileFormatError(
    178     "BioImage",
    179     image_type,
    180     msg_extra=(
    181         "You may need to install an extra format dependency. "
    182         "See bioio README for list of some known plugins."
    183     ),
    184 )

UnsupportedFileFormatError: BioImage does not support the image: '<class 'str'>'. You may need to install an extra format dependency. See bioio README for list of some known plugins.

In [3]: plugins.get_plugins()
Out[3]: 
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347),
 PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698949015.0319347)]

In [4]: img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")

In [5]: img
Out[5]: <BioImage [Reader: Reader, Image-is-in-Memory: False]>
  1. I think the error that is throw in determine_reader should include the image path (and parameter type) rather than just the parameter type. For example: UnsupportedFileFormatError: BioImage does not support the image: '<class 'str'>'. You may need to install an extra format dependency. See bioio README for list of some known plugins. is a confusing error because uhhh "what do you mean you don't take a str path? Do you want a pathlib.Path path?"

  2. Related to 2 and 4, I think all of the readers calling their image reading class Reader is causing namespace / object override issues? I have bioio-lif installed locally and can read LIF files directly using it's reader but reading fails from bioio directly. I think this is especially true because I installed bioio-tifffile later than bioio-ome-tiff and even though I am trying to read an OME-TIFF, it is using the tifffile reader. I also wonder if this is because each of the plugins has this line in their base level __init__.py: from .reader import Reader and that is causing the namespace override, whichever plugin is installed most recently is the only plugin that has a "valid" Reader object. All the others are just pointers to the newly installed Reader?

In [1]: import bioio_lif

In [2]: bioio_lif.Reader("../aicsimageio/aicsimageio/tests/resources/tiled.lif")
Out[2]: <Reader [Image-is-in-Memory: False]>

In [3]: from bioio import BioImage, plugins

In [4]: plugins.get_plugins()
Out[4]: 
[PluginEntry(entrypoint=EntryPoint(name='bioio-tifffile', value='bioio_tifffile', group='bioio.readers'), metadata=<class 'bioio_tifffile.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-tiff', value='bioio_ome_tiff', group='bioio.readers'), metadata=<class 'bioio_ome_tiff.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923),
 PluginEntry(entrypoint=EntryPoint(name='bioio-ome-zarr', value='bioio_ome_zarr', group='bioio.readers'), metadata=<class 'bioio_ome_zarr.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923),
 PluginEntry(entrypoint=EntryPoint(name='bioio-lif', value='bioio_lif', group='bioio.readers'), metadata=<class 'bioio_lif.reader_metadata.ReaderMetadata'>, timestamp=1698950076.8994923)]

In [5]: BioImage("../aicsimageio/aicsimageio/tests/resources/tiled.lif")
---------------------------------------------------------------------------
UnsupportedFileFormatError                Traceback (most recent call last)
Cell In[5], line 1
----> 1 BioImage("../aicsimageio/aicsimageio/tests/resources/tiled.lif")

File ~/active/cell/bioio/bioio/bio_image.py:191, in BioImage.__init__(self, image, reader, reconstruct_mosaic, fs_kwargs, **kwargs)
    181 def __init__(
    182     self,
    183     image: biob.types.ImageLike,
   (...)
    187     **kwargs: Any,
    188 ):
    189     if reader is None:
    190         # Determine reader class and create dask delayed array
--> 191         ReaderClass = BioImage.determine_reader(
    192             image, fs_kwargs=fs_kwargs, **kwargs
    193         )
    194     else:
    195         # Init reader
    196         ReaderClass = reader

File ~/active/cell/bioio/bioio/bio_image.py:172, in BioImage.determine_reader(image, fs_kwargs, **kwargs)
    170 image_value = str(image)
    171 image_type = str(type(image))
--> 172 raise biob.exceptions.UnsupportedFileFormatError(
    173     "BioImage",
    174     f"{image_value} ({image_type})",
    175     msg_extra=(
    176         "You may need to install an extra format dependency. "
    177         "See bioio README for list of some known plugins."
    178     ),
    179 )

UnsupportedFileFormatError: BioImage does not support the image: '../aicsimageio/aicsimageio/tests/resources/tiled.lif (<class 'str'>)'. You may need to install an extra format dependency. See bioio README for list of some known plugins.

In [6]: img = BioImage("../aicsimageio/aicsimageio/tests/resources/3d-cell-viewer.ome.tiff")

In [7]: type(img.metadata)
Out[7]: str
@evamaxfield evamaxfield added enhancement New feature or request bug Something isn't working labels Nov 2, 2023
@toloudis
Copy link
Contributor

toloudis commented Nov 2, 2023

I put a quick PR to address item 1. #19

@toloudis
Copy link
Contributor

toloudis commented Nov 2, 2023

Item number 5 is addressed here : #20

@SeanLeRoy
Copy link
Contributor

Item number 2 is address here: #21

@SeanLeRoy
Copy link
Contributor

Item numbers 3 & 4 are addressed here: #22

@SeanLeRoy
Copy link
Contributor

SeanLeRoy commented Nov 3, 2023

I think this will address item number 6 #23. I did not try all the readers, but I tried ome-tiff sldy ome-zarr and tifffile which seemed problematic in your and Dan's tests

@SeanLeRoy SeanLeRoy self-assigned this Nov 8, 2023
@BrianWhitneyAI
Copy link
Contributor

@evamaxfield @SeanLeRoy @toloudis looks like all 6 of these have been addressed! Anything else here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants