-
Notifications
You must be signed in to change notification settings - Fork 46
Reduce Import TIme #1265
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
Reduce Import TIme #1265
Conversation
…at the top of the list that was taking most time. Need to Apply This Pattern Broadly
|
On my local the time has gone down from 5.4 to 3.1 now! |
|
Nice work @rajeeja Going to push a few more changes that I had in mind also. |
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.
Pull Request Overview
This PR aims to reduce import times across the codebase by moving heavy module imports into function scopes (i.e. lazy loading) and removing unused or redundant modules. Key changes include:
- Moving imports (e.g. matplotlib, cartopy, geopandas) into function bodies across multiple modules.
- Removing the deprecated "dataarray_plot.py" and "cmaps.py" modules.
- Adjusting function signatures by removing explicit type annotations for parameters such as projection.
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| uxarray/plot/utils.py | Refactored lazy initialization of the matplotlib backend for better performance. |
| uxarray/plot/accessor.py | Updated backend assignment to use the new plotting_backend and removed deprecated rasterize wrappers. |
| uxarray/io/, uxarray/grid/ | Introduced lazy imports to reduce startup time and unnecessary global imports. |
| uxarray/core/*, uxarray/init.py | Adjusted API signatures and removed unused modules to streamline the public API. |
Comments suppressed due to low confidence (1)
uxarray/cmaps.py:1
- The removal of the cmaps definitions changes the public API; please ensure that users are informed via deprecation warnings or documentation updates if they rely on these colormap definitions.
from matplotlib.colors import LinearSegmentedColormap
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Why are we removing our color maps? @philipc2 |
These were being computed eagerly when loading the package and leading to degraded import times, and the blue/green ones are not great in terms of accessibility. |


Need to do more profiling and lazy loading etc. lots of room for improvement #1260