Skip to content

Conversation

@rajeeja
Copy link
Contributor

@rajeeja rajeeja commented May 16, 2025

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

@rajeeja
Copy link
Contributor Author

rajeeja commented May 16, 2025

On my local the time has gone down from 5.4 to 3.1 now!

@philipc2
Copy link
Member

Nice work @rajeeja

Going to push a few more changes that I had in mind also.

@philipc2 philipc2 self-assigned this May 16, 2025
@philipc2 philipc2 changed the title DRAFT: Reduce import uxarray time Reduce Import TIme May 16, 2025
@philipc2
Copy link
Member

Before

image

After

image

@philipc2 philipc2 requested a review from Copilot May 16, 2025 16:44
Copy link
Contributor

Copilot AI left a 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

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@aaronzedwick
Copy link
Member

Why are we removing our color maps? @philipc2

@philipc2
Copy link
Member

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.

@philipc2 philipc2 merged commit 1434fef into main May 18, 2025
19 of 20 checks passed
@philipc2 philipc2 mentioned this pull request May 18, 2025
@erogluorhan erogluorhan deleted the rajeeja/fix_import_uxarray_time branch September 26, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants