Skip to content

feat: introduce optional dependency groups to reduce core footprint (…#150

Open
gyanranjanpanda wants to merge 1 commit into52North:mainfrom
gyanranjanpanda:feature/optional-dependencies-issue-131
Open

feat: introduce optional dependency groups to reduce core footprint (…#150
gyanranjanpanda wants to merge 1 commit into52North:mainfrom
gyanranjanpanda:feature/optional-dependencies-issue-131

Conversation

@gyanranjanpanda
Copy link

@gyanranjanpanda gyanranjanpanda commented Feb 26, 2026

Related Issue / Discussion:

Fixes Issue #131

Changes:

  • Modified pyproject.toml - added [project.optional-dependencies] with four groups: geo, vis, data, all
  • Modified requirements.txt - stripped to core-only libraries (numpy, pydantic, geovectorslib, astropy, xarray, pandas)
  • Modified requirements.test.txt - uses .[all] for CI to install all optional extras
  • Modified README.md - added documentation for optional installation paths
  • Modified WeatherRoutingTool/weather.py - lazy-load optional imports (xarray, dask)
  • Modified WeatherRoutingTool/constraints/constraints.py - lazy-load cartopy, geopandas, shapely, global_land_mask; renamed duplicate LandPolygonsCrossing(ContinuousCheck) to LandPolygonsDBCrossing
  • Modified WeatherRoutingTool/utils/graphics.py - lazy-load matplotlib, cartopy inside functions
  • Modified WeatherRoutingTool/routeparams.py - lazy-load cartopy in plot_route(); fixed WaterDepth type annotation
  • Modified WeatherRoutingTool/algorithms/genetic/__init__.py - lazy-load matplotlib
  • Modified WeatherRoutingTool/algorithms/genetic/mutation.py - lazy-load matplotlib
  • Modified WeatherRoutingTool/algorithms/genetic/repair.py - minor import cleanup
  • Modified WeatherRoutingTool/ship/direct_power_boat.py - removed unused imports
  • Modified tests/test_genetic.py - removed plt fixture; removed LaTeX math syntax from colorbar labels
  • Modified tests/basic_test_func.py - updated test utility imports

Further Details:

Summary:

This PR addresses Issue #131 by introducing optional dependency groups to reduce the core installation footprint of WRT.

Before: pip install . pulled in all libraries including heavy geospatial (cartopy, geopandas), visualisation (matplotlib, seaborn), and data-fetching (dask, datacube) packages - even if users only needed the core routing computation.

After: pip install . installs only the minimal core dependencies (numpy, pydantic, geovectorslib, astropy, xarray, pandas). Users can opt in to additional functionality:

  • pip install .[vis] - matplotlib, seaborn for visualisations
  • pip install .[geo] - cartopy, geopandas, shapely, global_land_mask for GIS features
  • pip install .[data] - dask, datacube, netcdf4, scikit-image for large-scale data
  • pip install .[all] - everything combined

All optional imports are now lazy-loaded inside the functions that use them, so the core module can be imported without any optional dependency installed. Unused imports and dead code flagged by flake8 were also removed.

Dependencies:

No new dependencies introduced. Existing dependencies are reorganised into optional groups. Core dependencies remain: numpy, pydantic, geovectorslib, astropy, xarray, pandas.

PR Checklist:

In the context of this PR, I:

  • have filled the 52North Contributor License Agreement and am waiting for feedback
  • provide unit tests embedded in the WRT test framework (WeatherRoutingTool/tests) that allow the simple testing of the new/modified functionalities. All (previous and new) unit tests execute without new error messages.
  • ensure that the code formatter runs without errors/warnings
  • ensure that my changes follow the WRT's guidelines for contributing at the time of the contribution

…ixes 52North#131)

- Add [project.optional-dependencies] in pyproject.toml with groups:
  geo (cartopy, geopandas, shapely, global_land_mask),
  vis (matplotlib, seaborn),
  data (dask, datacube, netcdf4, scikit-image), and
  all (combines all groups)
- Strip non-core libraries from requirements.txt (now only core dependencies)
- Update requirements.test.txt to install [all] extras for CI
- Lazy-load optional imports (cartopy, matplotlib, geopandas, shapely,
  datacube, xarray, dask) inside the specific methods that use them across
  weather.py, constraints/constraints.py, utils/graphics.py,
  algorithms/genetic/__init__.py and algorithms/genetic/mutation.py
- Remove unused top-level and local-scope imports flagged by flake8 (F401)
- Remove dead local variable assignment str_tree = None (F841)
- Rename duplicate LandPolygonsCrossing(ContinuousCheck) to
  LandPolygonsDBCrossing to resolve redefinition (F811)
- Fix matplotlib import in routingalg.py needed for class attribute annotation
- Fix WaterDepth.depth_data type annotation: replace xr -> object to avoid
  requiring xarray at module import time
- Update README.md with minimal and optional installation instructions
- Fix test_genetic.py: remove plt fixture argument, remove LaTeX math
  syntax from colorbar labels (latex not always available in CI)
@gyanranjanpanda
Copy link
Author

hi @kdemmich
could u review this

@gyanranjanpanda
Copy link
Author

hi @MartinPontius could u review this

@gyanranjanpanda
Copy link
Author

hi @kdemmich could u review this

@kdemmich
Copy link
Collaborator

kdemmich commented Mar 3, 2026

Hi @gyanranjanpanda, thank you for your PR. We appreciate the time and effort that was put into it but, unfortunately, you did only copy and not fill our PR template. We will not evaluate PRs without a filled PR template.

@kdemmich kdemmich added the question Further information is requested label Mar 3, 2026
@gyanranjanpanda
Copy link
Author

Hi @kdemmich, apologies for the oversight and thank you for the feedback! I've now updated the PR description with the properly filled template including the related issue, detailed list of changes, summary with before/after comparison, dependencies section, and the completed PR checklist. Please let me know if anything else needs to be addressed.

@kdemmich kdemmich added enhancement New feature or request and removed question Further information is requested labels Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants