Repository navigation
Make from skimage2.subpackage import X work - #8310
Conversation
These were the only subpackages still importing their attributes eagerly. Some special handling is needed for `reset_plugins()`, which is called eagerly upon module import. Assisted-by: claude-code:claude-opus-5
Unlike `from skimage2 import filters; filters.X`, `from skimage2.filters import X` is resolved directly by the import machinery, and never reaches the module `__getattr__`. Add a shim for each subpackage, which forwards to `_skimage2`, which restores the ability to import from the subpackage directly. Assisted-by: claude-code:claude-opus-5
|
Reviews (1): Last reviewed commit: "Mirror `_skimage2` subpackages under `sk..." | Re-trigger Greptile |
|
This is an alternative approach to #8291 It adds more files, but it's pretty straightforward what those files do. |
|
Community call: add test to ensure _skimage2 and skimage2 structures match. |
|
Reviews (2): Last reviewed commit: "Add test to ensure _skimage2 and skimage..." | Re-trigger Greptile |
PARALLEL FAILED tests/skimage2/test_skimage2.py::test_skimage2_modules_match - Failed: DID NOT WARN. No warnings of type (<class '_skimage2._shared._warnings.ExperimentalAPIWarning'>,) were emitted.Maybe that path got mangled here? |
|
Interesting; is there a reason the warning wouldn't pop up in all threads? |
|
There is a race condition because |
|
Test only needs to run once, on a single platform, so I'll just mark it as thread-unsafe. |
|
Reviews (3): Last reviewed commit: "Mark module comparison test thread unsaf..." | Re-trigger Greptile |
|
OK, should be good to go now. |
Merging upstream main (which includes scikit-image#8310: physical skimage2 sub-package shims) makes skimage2.data a distinct shim module, not the same module as _skimage2.data. The test asserted module identity, which now fails in CI. Assert instead that the shim forwards to the same objects and exposes the same __all__.
This is done by adding a simple shim for each submodule that forwards to
_skimage2.To make things consistent, I also added lazy-loading for
_skimage2.ioand_skimage2.filters.rank, which were still eager.Assisted-by: claude-code:claude-opus-5