Skip to content

Commit

Permalink
fix: Use non-gui matplotlib backend for tests to avoid hanging on ipy…
Browse files Browse the repository at this point in the history
…widgets interact (#2098)

* Avoid the notebook tests hanging on the ipywidgets interact sections of `InterpolationCodes.ipynb`
  by setting the matplotlib backend to the non-gui Agg which disallows the creation of the gui elements
  that are causing the problem.
* Remove '%pylab inline' from InterpolationCodes.ipynb as pylab is very deprecated.
* Add --verobse flag to notebook tests to make it easier to track the progress of the notebooks in the
  CI logs.
  • Loading branch information
matthewfeickert committed Jan 20, 2023
1 parent 14127ae commit e942d85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
# Override the ini option for filterwarnings with an empty list to disable error
# on filterwarnings as testing for notebooks to run with the latest API, not if
# Jupyter infrastructure is warning free.
pytest --override-ini filterwarnings= tests/test_notebooks.py
pytest --verbose --override-ini filterwarnings= tests/test_notebooks.py
14 changes: 3 additions & 11 deletions docs/examples/notebooks/learn/InterpolationCodes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
]
}
],
"outputs": [],
"source": [
"%pylab inline\n",
"from ipywidgets import interact\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from ipywidgets import interact\n",
"from mpl_toolkits.mplot3d import Axes3D"
]
},
Expand Down
4 changes: 4 additions & 0 deletions tests/test_notebooks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import sys
from pathlib import Path

import papermill as pm
import pytest
import scrapbook as sb

# Avoid hanging on with ipywidgets interact by using non-gui backend
os.environ["MPLBACKEND"] = "agg"


@pytest.fixture()
def common_kwargs(tmpdir):
Expand Down

0 comments on commit e942d85

Please sign in to comment.