diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a2e8e40..a0f25328 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,8 +24,8 @@ jobs: fetch-depth: 0 # history required so cmake can determine version - uses: conda-incubator/setup-miniconda@v2 - - run: conda install --yes conda-build - - run: conda build --channel conda-forge --channel scipp --python=3.8 --no-anaconda-upload --override-channels --output-folder conda/package conda + - run: conda install --yes conda-build boa + - run: conda mambabuild --channel conda-forge --channel scipp --python=3.8 --no-anaconda-upload --override-channels --output-folder conda/package conda - uses: actions/upload-artifact@v2 with: diff --git a/conda/meta.yaml b/conda/meta.yaml index 15d3ea5f..e5df6691 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -25,7 +25,6 @@ test: - pytest - ipympl - ipywidgets - - plotly - pythreejs - scipp >=0.12 - scipy diff --git a/requirements/base.txt b/requirements/base.txt index a18a6341..379c5c7f 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -32,7 +32,7 @@ comm==0.1.2 # via ipykernel confuse==2.0.0 # via scipp -debugpy==1.6.4 +debugpy==1.6.5 # via ipykernel decorator==5.1.1 # via ipython @@ -52,7 +52,7 @@ idna==3.4 # via # anyio # jsonschema -importlib-metadata==5.2.0 +importlib-metadata==6.0.0 # via nbconvert ipydatawidgets==4.3.2 # via pythreejs @@ -99,7 +99,7 @@ jupyter-client==7.4.8 # nbclassic # nbclient # notebook -jupyter-core==5.1.0 +jupyter-core==5.1.2 # via # jupyter-client # jupyter-server @@ -110,7 +110,7 @@ jupyter-core==5.1.0 # notebook jupyter-events==0.5.0 # via jupyter-server -jupyter-server==2.0.4 +jupyter-server==2.0.6 # via # nbclassic # notebook-shim @@ -156,7 +156,7 @@ notebook==6.5.2 # via widgetsnbextension notebook-shim==0.2.2 # via nbclassic -numpy==1.24.0 +numpy==1.24.1 # via # ipydatawidgets # pythreejs @@ -174,7 +174,7 @@ pexpect==4.8.0 # via ipython pickleshare==0.7.5 # via ipython -platformdirs==2.6.0 +platformdirs==2.6.2 # via jupyter-core prometheus-client==0.15.0 # via @@ -193,11 +193,11 @@ pure-eval==0.2.2 # via stack-data pycparser==2.21 # via cffi -pygments==2.13.0 +pygments==2.14.0 # via # ipython # nbconvert -pyrsistent==0.19.2 +pyrsistent==0.19.3 # via jsonschema python-dateutil==2.8.2 # via diff --git a/requirements/ci.txt b/requirements/ci.txt index 8931f07b..4680aed5 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -17,7 +17,7 @@ colorama==0.4.6 # via tox distlib==0.3.6 # via virtualenv -filelock==3.8.2 +filelock==3.9.0 # via # tox # virtualenv @@ -27,13 +27,13 @@ packaging==22.0 # via # pyproject-api # tox -platformdirs==2.6.0 +platformdirs==2.6.2 # via # tox # virtualenv pluggy==1.0.0 # via tox -pyproject-api==1.2.1 +pyproject-api==1.4.0 # via tox requests==2.28.1 # via -r requirements/ci.in @@ -41,7 +41,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.0.16 +tox==4.2.4 # via -r requirements/ci.in urllib3==1.26.13 # via requests diff --git a/requirements/docs.txt b/requirements/docs.txt index 10727f18..e0b47b29 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -47,9 +47,9 @@ matplotlib==3.6.2 # mpltoolbox mpltoolbox==0.3.0 # via -r requirements/docs.in -nbsphinx==0.8.10 +nbsphinx==0.8.11 # via -r requirements/docs.in -pillow==9.3.0 +pillow==9.4.0 # via # ipympl # matplotlib @@ -66,7 +66,7 @@ requests==2.28.1 # -r requirements/docs.in # pooch # sphinx -scipy==1.9.3 +scipy==1.10.0 # via -r requirements/docs.in smmap==5.0.0 # via gitdb diff --git a/requirements/mini.txt b/requirements/mini.txt index 1a1888d0..13d75128 100644 --- a/requirements/mini.txt +++ b/requirements/mini.txt @@ -9,13 +9,13 @@ attrs==22.2.0 # via pytest confuse==2.0.0 # via scipp -exceptiongroup==1.0.4 +exceptiongroup==1.1.0 # via pytest graphlib-backport==1.0.3 # via scipp iniconfig==1.1.1 # via pytest -numpy==1.24.0 +numpy==1.24.1 # via scipp packaging==22.0 # via pytest diff --git a/requirements/noplotly.in b/requirements/noplotly.in new file mode 100644 index 00000000..1cf404d7 --- /dev/null +++ b/requirements/noplotly.in @@ -0,0 +1,2 @@ +-r base.in +pytest diff --git a/requirements/noplotly.txt b/requirements/noplotly.txt new file mode 100644 index 00000000..3caedc4e --- /dev/null +++ b/requirements/noplotly.txt @@ -0,0 +1,18 @@ +# SHA1:a035a60fcbac4cd7bf595dbd81ee7994505d4a95 +# +# This file is autogenerated by pip-compile-multi +# To update, run: +# +# pip-compile-multi +# +-r base.txt +exceptiongroup==1.1.0 + # via pytest +iniconfig==1.1.1 + # via pytest +pluggy==1.0.0 + # via pytest +pytest==7.2.0 + # via -r requirements/noplotly.in +tomli==2.0.1 + # via pytest diff --git a/requirements/static.txt b/requirements/static.txt index c2fdfe96..c6040344 100644 --- a/requirements/static.txt +++ b/requirements/static.txt @@ -13,7 +13,7 @@ flake8==6.0.0 # via -r requirements/static.in jsonschema==4.17.3 # via nbformat -jupyter-core==5.1.0 +jupyter-core==5.1.2 # via nbformat mccabe==0.7.0 # via flake8 @@ -21,13 +21,13 @@ nbformat==5.7.1 # via nbstripout nbstripout==0.6.1 # via -r requirements/static.in -platformdirs==2.6.0 +platformdirs==2.6.2 # via jupyter-core pycodestyle==2.10.0 # via flake8 pyflakes==3.0.1 # via flake8 -pyrsistent==0.19.2 +pyrsistent==0.19.3 # via jsonschema toml==0.10.2 # via -r requirements/static.in diff --git a/requirements/test.txt b/requirements/test.txt index 1f3f1117..a1f8790b 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -10,7 +10,7 @@ contourpy==1.0.6 # via matplotlib cycler==0.11.0 # via matplotlib -exceptiongroup==1.0.4 +exceptiongroup==1.1.0 # via pytest fonttools==4.38.0 # via matplotlib @@ -24,7 +24,7 @@ kiwisolver==1.4.4 # via matplotlib matplotlib==3.6.2 # via ipympl -pillow==9.3.0 +pillow==9.4.0 # via # ipympl # matplotlib @@ -36,7 +36,7 @@ pyparsing==3.0.9 # via matplotlib pytest==7.2.0 # via -r requirements/test.in -scipy==1.9.3 +scipy==1.10.0 # via -r requirements/test.in tenacity==8.1.0 # via plotly diff --git a/src/plopp/backends/plotly/canvas.py b/src/plopp/backends/plotly/canvas.py index 9250cfb1..bffe51b2 100644 --- a/src/plopp/backends/plotly/canvas.py +++ b/src/plopp/backends/plotly/canvas.py @@ -3,7 +3,6 @@ from ...core.utils import maybe_variable_to_number -import plotly.graph_objects as go import scipp as sc from typing import Literal, Tuple, Union @@ -49,6 +48,7 @@ def __init__(self, # Instead, we forward all the kwargs from the figure to both the canvas and the # artist, and filter out the artist kwargs with `**ignored`. + import plotly.graph_objects as go self.fig = go.FigureWidget( layout={ 'modebar_remove': [ diff --git a/src/plopp/backends/plotly/line.py b/src/plopp/backends/plotly/line.py index 1cf73638..91ffb367 100644 --- a/src/plopp/backends/plotly/line.py +++ b/src/plopp/backends/plotly/line.py @@ -8,8 +8,6 @@ import numpy as np from typing import Dict import uuid -import plotly.graph_objects as go -from plotly.colors import qualitative as plotly_colors def _parse_dicts_in_kwargs(kwargs, name): @@ -89,6 +87,9 @@ def _make_line(self, - ``matplotlib.pyplot.plot`` for data with a non bin-edge coordinate - ``matplotlib.pyplot.step`` for data with a bin-edge coordinate """ + import plotly.graph_objects as go + from plotly.colors import qualitative as plotly_colors + has_mask = data["mask"] is not None mask_data_key = "mask" if has_mask else "values" diff --git a/tests/backends/plotly/plotly_canvas_test.py b/tests/backends/plotly/plotly_canvas_test.py index bf50bbcd..e1992f55 100644 --- a/tests/backends/plotly/plotly_canvas_test.py +++ b/tests/backends/plotly/plotly_canvas_test.py @@ -7,6 +7,8 @@ import tempfile import os +pytest.importorskip("plotly") + def test_creation(): title = 'My canvas' diff --git a/tests/backends/plotly/plotly_figure_test.py b/tests/backends/plotly/plotly_figure_test.py index 82e7e412..b5466562 100644 --- a/tests/backends/plotly/plotly_figure_test.py +++ b/tests/backends/plotly/plotly_figure_test.py @@ -5,6 +5,9 @@ from plopp.data.testing import data_array from plopp.graphics.figline import FigLine from plopp.backends.plotly.figure import Figure +import pytest + +pytest.importorskip("plotly") def test_logx_1d_toolbar_button(): diff --git a/tests/backends/plotly/plotly_line_test.py b/tests/backends/plotly/plotly_line_test.py index d3eaaae0..cb845272 100644 --- a/tests/backends/plotly/plotly_line_test.py +++ b/tests/backends/plotly/plotly_line_test.py @@ -6,6 +6,9 @@ from plopp.backends.plotly.line import Line import numpy as np import scipp as sc +import pytest + +pytest.importorskip("plotly") def test_line_creation(): diff --git a/tests/conftest.py b/tests/conftest.py index 9e3a8620..77dae435 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,3 +26,14 @@ def close_figures(): @pytest.fixture def use_ipympl(): matplotlib.use('module://ipympl.backend_nbagg') + + +def pytest_sessionfinish(session, exitstatus): + """ + When running no tests (e.g. in the noplotly tox env), pytest returns the exit code + 5, which causes the tox to fail. We use this to catch the exit status and convert + it to 0. + See https://github.com/pytest-dev/pytest/issues/2393#issuecomment-452634365 + """ + if exitstatus == 5: + session.exitstatus = 0 diff --git a/tox.ini b/tox.ini index 0e8eed83..31e3aa7c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = minimal,py38 +envlist = minimal,noplotly,py38 isolated_build = true [testenv] @@ -12,6 +12,12 @@ basepython = python3.8 deps = -r requirements/mini.txt commands = pytest tests/minimal_plot.py +[testenv:noplotly] +description = Test that plotly tests are skipped if plotly is not installed +basepython = python3.8 +deps = -r requirements/noplotly.txt +commands = pytest tests/backends/plotly + [testenv:docs] description = invoke sphinx-build to build the HTML docs basepython = python3.8