-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Lazily load data_dir into the top-level namespace #5996
Conversation
The top-level import of data_dir in skimage/__init__.py accounted for approximately 1/3 of the package import time. This PR removes this overhead. This commit moves skimage/data/__init__.py to skimage/data/_fetchers.py and then adds a new skimage/data/__init__.py that lazily loads from the skimage.data submodules.
lazy.attach generates __all__ in data/__init__.py now
Hello @grlee77! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-10-29 20:08:35 UTC |
This lazy loading should also help resolve #5146 (at least the error would not occur upon the top-level import). I will add another commit here to deal with the issue of missing |
conditionally check pooch.__version__
I manually verified that 26a580e avoids the problem with |
closes #5146 |
Thank you @grlee77! |
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/why-does-init-py-attempt-to-download-sample-data/79665/4 |
Description
This is a follow up PR to #5101 that delays loading of
skimage.data_dir
. Currently, importing that in the top-level__init__.py
results in importing Pooch. With the change here,data_dir
is lazily loaded.The diff here is much smaller than it appears because all code in
_fetchers.py
is just the old__init__.py
. Aside from removing__all__
after the rename, I made only a 1 line change to fix an issue with parsing the modified__version__
string containing the git hash introduced in #5909.This PR also fixes an issue where
skimage.data.vortex
was missing fromskimage.data.__all__
.Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.