Skip to content

[notebook dependencies] import brightwind hard-requires notebook/GUI packages (gmaps, ipywidgets, IPython) #625

Description

@dancasey-ie

Describe the bug
import brightwind eagerly imports Jupyter/GUI-only packages, so they are mandatory just to load the library — even for headless/server/batch use that never touches plotting widgets or maps:

  • brightwind/__init__.py (line 11) → brightwind/utils/gis.py (line 3) import gmaps
  • brightwind/__init__.py (line 4) → brightwind/analyse/shear.py (lines 10-12) from ipywidgets import FloatProgress, from IPython.display import display, clear_output

Both are notebook-only features:

  • gmaps is used solely by plot_meas_station_on_gmap (a Google Maps widget).
  • ipywidgets/IPython are used solely for a progress bar in Shear.

To Reproduce
Steps to reproduce the behaviour:

  1. Create a clean environment with no Jupyter stack.
  2. Run pip install brightwind — this forces gmaps, ipywidgets, ipython and their dependency trees.
  3. In a minimal/headless container, any install or build hiccup in gmaps (an abandoned sdist) blocks import brightwind entirely.

Expected behavior
import brightwind should require only the core scientific stack (pandas, numpy, scipy, scikit-learn, matplotlib, requests, jsonschema, jinja2). Maps and notebook-progress features should import their dependencies lazily, inside the functions that use them, and those dependencies should be optional extras (brightwind[maps], brightwind[notebook]). Calling a feature without its extra installed should raise a clear, actionable ImportError (e.g. "install brightwind[maps]").

Additional context
The "make it optional" half depends on extras being declared (see the packaging-modernisation issue). The lazy-import guards can land independently in the current setup.py.
Downstream impact: the Lambda image bundles gmaps 0.9.0, ipywidgets 8.1.8 and ipython 9.15.0 solely to satisfy import brightwind.
Related: the abandoned-gmaps issue.

Code example

# gis.py
def plot_meas_station_on_gmap(meas_station, ...):
    try:
        import gmaps
    except ImportError as e:
        raise ImportError("plot_meas_station_on_gmap requires the 'maps' extra: pip install brightwind[maps]") from e

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions