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
Make most modules lazy load #1065
base: master
Are you sure you want to change the base?
Conversation
Ok I think I super broke this PR trying to pull in the most recent changes. Happy to fix just lmk! |
would be great if possible :) |
Okay I think that did it lol. Just gonna wait for the CI |
I think most of the linter issues can be fixed with |
Hmmmm...I'm not sure why only 3.9 is failing. Specifically something about the matplotlib import |
I think all the calibration Test should run without matpotlib installed but it's imported somewhere. |
Ah it was me being a dingus and not understanding how lazy_loader deals with missing imports. Seems ok now? |
Probably related: librosa/librosa#1721 |
Ah dang this seems like a deep problem. Matplotlib is easily the most time consuming import. At worst a fix might be to just move plotting imports to those specific functions that use them to avoid issues associated with using lazy_loader with mpl |
@@ -3,10 +3,9 @@ | |||
implemented in Python. | |||
""" | |||
|
|||
__version__ = '1.0.0' | |||
__version__ = "1.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity: why the change from ' to " for the strings? I always thought Python does accept both notations. Is it personal taste or a new general rule?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's almost certainly ruff's auto formatting. I try to avoid noisy commits that are primarily changes due to auto formatting but sometimes stuff slips by 😮💨
Seems like the root cause:
|
Yeah I think the solution is to try to move all mpl-related imports into the methods that use them so they get deferred until then. Will be a bit clunky but the speed up is significant. I'll try to push something today |
How about this PR ? Would be nice to include it in the next version, to be released soon. |
Hey sorry got caught up with dissertation work. Will make edits tonight to remove the lazy load module and move mpl imports into the respective plotting functions. Think that's the best we can do |
Addresses #1057. On my machine, import times were reduced from over 1 second to about 0.3 seconds.