Skip to content

Commit

Permalink
Merge pull request #137 from scipp/fixing_conda_build
Browse files Browse the repository at this point in the history
Skip plotly tests if plotly is not installed (for conda build)
  • Loading branch information
nvaytet authored Jan 6, 2023
2 parents dded80b + 48f06f7 commit 9e95d23
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ test:
- pytest
- ipympl
- ipywidgets
- plotly
- pythreejs
- scipp >=0.12
- scipy
Expand Down
16 changes: 8 additions & 8 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,21 +27,21 @@ 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
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
Expand Down
6 changes: 3 additions & 3 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements/mini.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions requirements/noplotly.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r base.in
pytest
18 changes: 18 additions & 0 deletions requirements/noplotly.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions requirements/static.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ 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
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
Expand Down
6 changes: 3 additions & 3 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/plopp/backends/plotly/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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': [
Expand Down
5 changes: 3 additions & 2 deletions src/plopp/backends/plotly/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions tests/backends/plotly/plotly_canvas_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import tempfile
import os

pytest.importorskip("plotly")


def test_creation():
title = 'My canvas'
Expand Down
3 changes: 3 additions & 0 deletions tests/backends/plotly/plotly_figure_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 3 additions & 0 deletions tests/backends/plotly/plotly_line_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = minimal,py38
envlist = minimal,noplotly,py38
isolated_build = true

[testenv]
Expand All @@ -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
Expand Down

0 comments on commit 9e95d23

Please sign in to comment.