From c437eb7e424de0dcb84fd34931ca04e60c1da75a Mon Sep 17 00:00:00 2001 From: jlarsen Date: Fri, 9 Feb 2024 10:00:51 -0800 Subject: [PATCH 1/2] add an option to skip_notebook when we have CI failures due to timeouts, etc... --- tests/test_notebooks.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py index 9e56219..7d7f452 100644 --- a/tests/test_notebooks.py +++ b/tests/test_notebooks.py @@ -1,7 +1,7 @@ import os from pathlib import Path import shutil -import glob +import platform import pytest @@ -17,6 +17,14 @@ } + +# Notebooks that we expect to have issues with autotesting on specific +# platforms +# Notebook : platform # reason +skip_notebook = { + "10_modpath-demo.ipynb" : "darwin" # VTK causes transient timeouts in CI +} + def included_notebooks(): include = ['notebooks/part0_python_intro', 'notebooks/part0_python_intro/solutions', @@ -59,12 +67,16 @@ def teardown(): def test_notebook(notebook, testdir): # run autotest on each notebook path, fname = os.path.split(notebook) - cmd = ('jupyter ' + 'nbconvert ' - '--ExecutePreprocessor.timeout=600 ' - '--ExecutePreprocessor.kernel_name=python3 ' - '--to ' + 'notebook ' - f'--execute {notebook} ' - f'--output-dir {testdir} ' - f'--output {fname}') - ival = os.system(cmd) - assert ival == 0, f'could not run {fname}' + if fname in skip_notebook: + if platform.system().lower() == skip_notebook[fname]: + pass + else: + cmd = ('jupyter ' + 'nbconvert ' + '--ExecutePreprocessor.timeout=600 ' + '--ExecutePreprocessor.kernel_name=python3 ' + '--to ' + 'notebook ' + f'--execute {notebook} ' + f'--output-dir {testdir} ' + f'--output {fname}') + ival = os.system(cmd) + assert ival == 0, f'could not run {fname}' From 23f34bc1ecfdedbcc649996ae0742565d12b0230 Mon Sep 17 00:00:00 2001 From: jlarsen Date: Fri, 9 Feb 2024 10:17:24 -0800 Subject: [PATCH 2/2] use pytest mark to skip notebooks --- tests/test_notebooks.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/test_notebooks.py b/tests/test_notebooks.py index 7d7f452..d691f09 100644 --- a/tests/test_notebooks.py +++ b/tests/test_notebooks.py @@ -20,9 +20,9 @@ # Notebooks that we expect to have issues with autotesting on specific # platforms -# Notebook : platform # reason -skip_notebook = { - "10_modpath-demo.ipynb" : "darwin" # VTK causes transient timeouts in CI +# Notebook : (platforms,), reason +skip_notebooks = { + "10_modpath-demo.ipynb" : [("darwin",), "transient timeout"] } def included_notebooks(): @@ -39,6 +39,11 @@ def included_notebooks(): if f.name in xfail_notebooks: param_input = pytest.param( f, marks=pytest.mark.xfail(reason=xfail_notebooks[f.name])) + elif f.name in skip_notebooks and \ + platform.system().lower() in skip_notebooks[f.name][0]: + param_input = pytest.param( + f, marks=pytest.mark.skip(reason=skip_notebooks[f.name][-1]) + ) else: param_input = f files_with_xfails.append(param_input) @@ -67,16 +72,13 @@ def teardown(): def test_notebook(notebook, testdir): # run autotest on each notebook path, fname = os.path.split(notebook) - if fname in skip_notebook: - if platform.system().lower() == skip_notebook[fname]: - pass - else: - cmd = ('jupyter ' + 'nbconvert ' - '--ExecutePreprocessor.timeout=600 ' - '--ExecutePreprocessor.kernel_name=python3 ' - '--to ' + 'notebook ' - f'--execute {notebook} ' - f'--output-dir {testdir} ' - f'--output {fname}') - ival = os.system(cmd) - assert ival == 0, f'could not run {fname}' + + cmd = ('jupyter ' + 'nbconvert ' + '--ExecutePreprocessor.timeout=600 ' + '--ExecutePreprocessor.kernel_name=python3 ' + '--to ' + 'notebook ' + f'--execute {notebook} ' + f'--output-dir {testdir} ' + f'--output {fname}') + ival = os.system(cmd) + assert ival == 0, f'could not run {fname}'