From f5f781c4d2503e06c17259e2d2deb25ae608020f Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Tue, 15 Oct 2024 08:34:01 +0200 Subject: [PATCH 1/2] experimental init: Fix Solara import by making it lazy --- mesa/experimental/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mesa/experimental/__init__.py b/mesa/experimental/__init__.py index a48c498f6f9..7798b04560c 100644 --- a/mesa/experimental/__init__.py +++ b/mesa/experimental/__init__.py @@ -2,6 +2,9 @@ from mesa.experimental import cell_space -from .solara_viz import JupyterViz, Slider, SolaraViz, make_text - -__all__ = ["cell_space", "JupyterViz", "SolaraViz", "make_text", "Slider"] +try: + from .solara_viz import JupyterViz, Slider, SolaraViz, make_text + __all__ = ["cell_space", "JupyterViz", "Slider", "SolaraViz", "make_text"] +except ImportError: + print("Could not import SolaraViz. If you need it, install with 'pip install --pre mesa[viz]'") + __all__ = ["cell_space"] From 218d279cf1d19a7b75f779fb61df10aa92d2efbe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 06:37:36 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mesa/experimental/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mesa/experimental/__init__.py b/mesa/experimental/__init__.py index 7798b04560c..5d396b5dc77 100644 --- a/mesa/experimental/__init__.py +++ b/mesa/experimental/__init__.py @@ -4,7 +4,10 @@ try: from .solara_viz import JupyterViz, Slider, SolaraViz, make_text + __all__ = ["cell_space", "JupyterViz", "Slider", "SolaraViz", "make_text"] except ImportError: - print("Could not import SolaraViz. If you need it, install with 'pip install --pre mesa[viz]'") + print( + "Could not import SolaraViz. If you need it, install with 'pip install --pre mesa[viz]'" + ) __all__ = ["cell_space"]