Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Override error on filterwarnings to pass notebook tests #1841

Merged
merged 27 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f160dca
chore: Update to scrapbook over deprecated nteract-scrapbook
matthewfeickert Apr 6, 2022
930eec1
Set compatible release to v0.5.x
matthewfeickert Apr 6, 2022
a27c4b5
Restrict papermill
matthewfeickert Apr 6, 2022
2bf3ba9
Ignore trailets deprecation warning
matthewfeickert Apr 6, 2022
c22174d
Ignore coroutine in notebook tests"
matthewfeickert Apr 6, 2022
5fb8ed8
Use test extra
matthewfeickert Apr 6, 2022
5599ec9
override-init to ignore filter warnings
matthewfeickert Apr 6, 2022
a5cff6d
Remove trailtlets ignore
matthewfeickert Apr 6, 2022
75d9987
ignore kernel_name
matthewfeickert Apr 6, 2022
5aad923
REMOVE: Run on push
matthewfeickert Apr 6, 2022
aa7ae98
Seperate out onto lines
matthewfeickert Apr 6, 2022
406ec16
Apply isort
matthewfeickert Apr 6, 2022
8730874
Set progress_bar to False
matthewfeickert Apr 6, 2022
6b32a59
Add cwd to all notebooks with specific paths
matthewfeickert Apr 6, 2022
43921e2
Remove quiet flag
matthewfeickert Apr 6, 2022
1a2abeb
Add a concurrency group to avoid wasting runtime
matthewfeickert Apr 6, 2022
7660096
Use Path over str
matthewfeickert Apr 6, 2022
ce6eb5a
Increase start_timeout to 120 seconds for runners
matthewfeickert Apr 6, 2022
f616c20
Add test to check if test_xml_importexport works at all on runners
matthewfeickert Apr 6, 2022
5e3851b
Set cwd even if not needed
matthewfeickert Apr 6, 2022
30aa908
Change directory for XML_ImportExport
matthewfeickert Apr 6, 2022
bab4c42
try multi bin poisson
matthewfeickert Apr 6, 2022
8987af5
Specify shell as bash
matthewfeickert Apr 6, 2022
8d55fc3
Get CI working
matthewfeickert Apr 6, 2022
887ee4b
Use str for paths for papermill and scrapbook
matthewfeickert Apr 6, 2022
ae38257
Remove debug
matthewfeickert Apr 6, 2022
d46bc21
Remove PYTHONWARNINGS to get passing
matthewfeickert Apr 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- cron: '1 0 * * *'
workflow_dispatch:

concurrency:
group: notebooks-${{ github.ref }}
cancel-in-progress: true

jobs:
test:

Expand All @@ -16,15 +20,23 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip --quiet install --upgrade .[complete]
python -m pip list
python -m pip install --upgrade .[test]

- name: List installed Python packages
run: python -m pip list

- name: Test example notebooks
run: |
pytest tests/test_notebooks.py
# 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
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
'pytest-console-scripts',
'pytest-mpl',
'pydocstyle',
'papermill~=2.0',
'nteract-scrapbook~=0.2',
'papermill~=2.3.4',
'scrapbook~=0.5.0',
'jupyter',
'graphviz',
]
Expand Down
40 changes: 21 additions & 19 deletions tests/test_notebooks.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sys
import os
from pathlib import Path

import papermill as pm
import scrapbook as sb
import pytest
import scrapbook as sb


@pytest.fixture()
Expand All @@ -11,6 +12,7 @@ def common_kwargs(tmpdir):
return {
'output_path': str(outputnb),
'kernel_name': f'python{sys.version_info.major}',
'progress_bar': False,
}


Expand All @@ -19,17 +21,19 @@ def test_hello_world(common_kwargs):


def test_xml_importexport(common_kwargs):
# Change directories to make users not have to worry about paths to follow example
execution_dir = Path.cwd() / "docs" / "examples" / "notebooks"
pm.execute_notebook(
'docs/examples/notebooks/XML_ImportExport.ipynb', **common_kwargs
execution_dir / "XML_ImportExport.ipynb", cwd=execution_dir, **common_kwargs
)


def test_statisticalanalysis(common_kwargs):
# The Binder example uses specific relative paths
cwd = os.getcwd()
os.chdir(os.path.join(cwd, 'docs/examples/notebooks/binderexample'))
pm.execute_notebook('StatisticalAnalysis.ipynb', **common_kwargs)
os.chdir(cwd)
execution_dir = Path.cwd() / "docs" / "examples" / "notebooks" / "binderexample"
pm.execute_notebook(
execution_dir / "StatisticalAnalysis.ipynb", cwd=execution_dir, **common_kwargs
)


def test_shapefactor(common_kwargs):
Expand All @@ -39,35 +43,33 @@ def test_shapefactor(common_kwargs):
def test_multichannel_coupled_histos(common_kwargs):
pm.execute_notebook(
'docs/examples/notebooks/multichannel-coupled-histo.ipynb',
parameters={'validation_datadir': 'validation/data'},
parameters={"validation_datadir": str(Path.cwd() / "validation" / "data")},
**common_kwargs,
)


def test_multibinpois(common_kwargs):
pm.execute_notebook(
'docs/examples/notebooks/multiBinPois.ipynb',
parameters={'validation_datadir': 'validation/data'},
parameters={"validation_datadir": str(Path.cwd() / "validation" / "data")},
**common_kwargs,
)
nb = sb.read_notebook(common_kwargs['output_path'])
assert nb.scraps['number_2d_successpoints'].data > 200


def test_pullplot(common_kwargs):
# Change directories to make users not have to worry about paths to follow example
cwd = os.getcwd()
os.chdir(os.path.join(cwd, "docs/examples/notebooks"))
pm.execute_notebook("pullplot.ipynb", **common_kwargs)
os.chdir(cwd)
execution_dir = Path.cwd() / "docs" / "examples" / "notebooks"
pm.execute_notebook(
execution_dir / "pullplot.ipynb", cwd=execution_dir, **common_kwargs
)


def test_impactplot(common_kwargs):
# Change directories to make users not have to worry about paths to follow example
cwd = os.getcwd()
os.chdir(os.path.join(cwd, "docs/examples/notebooks"))
pm.execute_notebook("ImpactPlot.ipynb", **common_kwargs)
os.chdir(cwd)
execution_dir = Path.cwd() / "docs" / "examples" / "notebooks"
pm.execute_notebook(
execution_dir / "ImpactPlot.ipynb", cwd=execution_dir, **common_kwargs
)


def test_toys(common_kwargs):
Expand Down