Skip to content

Deprecate skimage.io plugin infrastructure#7353

Merged
jarrodmillman merged 10 commits intoscikit-image:mainfrom
lagru:deprecate-io-plugins
Oct 21, 2024
Merged

Deprecate skimage.io plugin infrastructure#7353
jarrodmillman merged 10 commits intoscikit-image:mainfrom
lagru:deprecate-io-plugins

Conversation

@lagru
Copy link
Copy Markdown
Member

@lagru lagru commented Mar 19, 2024

Description

Still very much a work in progress and trying to understand the problem better. See inline comments below.

See also

Checklist

Release note

We use changelist to compile each pull request into an item of the release notes. Please refer to the instructions and past release notes for guidance and examples.

...

@lagru lagru added the 📜 type: API Involves API change(s) label Mar 19, 2024
@mkcor
Copy link
Copy Markdown
Member

mkcor commented Jun 11, 2024

@lagru @stefanv did you know that dask has a function, namely dask.array.image.imread, which "defaults to skimage.io.imread?!" I just looked up where 'skimage' appears in the dask codebase: https://github.com/search?q=repo%3Adask%2Fdask%20skimage&type=code

And, I believe, because of their long-form documentation about image processing applications, the use of skimage.io has propagated, as can be seen in https://matthewrocklin.com/blog/work/2017/01/17/dask-images.

but keep imread, imsave and imread_collection around to work as simple
wrappers for imageio down the line.
Even if a parameter is deprecated, a value passed to it must be
preserved during the deprecation cycle! Othwerwise, we effectively
remove the deprecated behavior before the cycle is complete.

This is only relevant if there's no replacement for the deprecated
parameter. In that case, the given value preserved and passed to the
replacing parameter, and the deprecated one can be overwritten with
`DEPRECATED`.
@lagru lagru force-pushed the deprecate-io-plugins branch from 0509863 to 70ed9c2 Compare September 26, 2024 15:44
@lagru lagru added the 🔽 Deprecation Involves deprecation label Sep 26, 2024
@lagru
Copy link
Copy Markdown
Member Author

lagru commented Sep 26, 2024

Alright, I pushed an alternative deprecation approach that keeps imread, imsave and imread_collection around but deprecates everything that has to do with the plugin infrastructure.

#7552 should be merged before this one because it is required for the test suite to pass. To see whether this PR passes I temporarily included the changes from the other PR in 70ed9c2.

@lagru lagru marked this pull request as ready for review September 26, 2024 15:50
we are looking for something that we can pass to `**plugin_args` to
check whether a deprecation warning is raised.
@stefanv
Copy link
Copy Markdown
Member

stefanv commented Sep 27, 2024

Very quick glance; sorry if I missed some detail.

Are we still using tifffile as the default for loading tiffs, or is that what is transparently being used by imageio? I think that behavior is important to keep.

The deprecations look good, thanks. I didn't run this branch, but checking that imread(fn) works without deprecation, imread(fn, plugin=our_default) also without deprecation, but imread(fn, plugin=some_other_plugin) warns.

Checking: the todo says to remove all plugins, but probably requires moving imageio plugin directly into io.imread function?

@lagru
Copy link
Copy Markdown
Member Author

lagru commented Sep 28, 2024

Are we still using tifffile as the default for loading tiffs, or is that what is transparently being used by imageio? I think that behavior is important to keep.

Yes, I changed nothing about our plugin infrastructure besides tacking on deprecation warnings, whenever something uses a function or parameter directly related to it. As far as I'm aware, imageio defaults to tifffile if it is available. E.g. after applying the following diff

diff --git a/skimage/io/_io.py b/skimage/io/_io.py
--- a/skimage/io/_io.py	(revision 99c1e625ff02d478963e7c8f17d14b5a5631bf63)
+++ b/skimage/io/_io.py	(date 1727522910971)
@@ -76,7 +76,7 @@
 
     if plugin is None and hasattr(fname, 'lower'):
         if fname.lower().endswith(('.tiff', '.tif')):
-            plugin = 'tifffile'
+            plugin = 'imageio'
 
     with file_or_url_context(fname) as fname, _hide_plugin_deprecation_warnings():
         img = call_plugin('imread', fname, plugin=plugin, **plugin_args)

the test suite passes, except that test using **plugin_args to tifffile.imread fail because imageio doesn't use tifffile.imread under the hood. However, that's not a problem, because passing extra keyword arguments to the plugin is deprecated as well. So once we want to complete the deprecation, we should be able to replace call_plugin("imread", ...) with imageio.v3.imread and so forth.

I didn't run this branch, but checking that imread(fn) works without deprecation, imread(fn, plugin=our_default) also without deprecation, but imread(fn, plugin=some_other_plugin) warns.

I don't follow. What is the reason to keep supporting plugin=our_default? I intend to deprecate the parameter plugin fully so that passing anything, including the default, raises a deprecation warning. Not using the parameter, will use our_default internally.

Checking: the todo says to remove all plugins, but probably requires moving imageio plugin directly into io.imread function?

Yes, seeing that we have some custom code about making sure that we return an editable array in there. I'll reword the TODO slightly.

@lagru lagru added the 🥾 Path to skimage2 A step towards the new "API 2.0" label Sep 28, 2024
@stefanv
Copy link
Copy Markdown
Member

stefanv commented Sep 28, 2024

I don't follow. What is the reason to keep supporting plugin=our_default?

You're right; that's a fine route to take.

@lagru lagru marked this pull request as draft October 1, 2024 14:42
@lagru
Copy link
Copy Markdown
Member Author

lagru commented Oct 1, 2024

Converting to draft, since #7552 should go in before this one.

@lagru lagru marked this pull request as ready for review October 3, 2024 20:55
@stefanv stefanv added this to the 0.25 milestone Oct 3, 2024
@lagru lagru requested a review from stefanv October 10, 2024 12:05
@lagru
Copy link
Copy Markdown
Member Author

lagru commented Oct 19, 2024

@stefanv, @jarrodmillman, are you intentionally holding of on the merge because of the release preparation?

@jarrodmillman
Copy link
Copy Markdown
Contributor

@stefanv, @jarrodmillman, are you intentionally holding of on the merge because of the release preparation?

I was holding off to see if you had anything else you wanted to do before this was merged.

@jarrodmillman
Copy link
Copy Markdown
Contributor

Errr. Sorry, I clicked the wrong button....

@lagru
Copy link
Copy Markdown
Member Author

lagru commented Oct 21, 2024

No, unless the CI picks something up last minute, this should be fine to go in. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔽 Deprecation Involves deprecation 🥾 Path to skimage2 A step towards the new "API 2.0" 📜 type: API Involves API change(s)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants