From 87413bac87a6485c906a7c2348239e17ce0078d9 Mon Sep 17 00:00:00 2001 From: Will Furnass Date: Mon, 30 Sep 2019 16:40:08 +0100 Subject: [PATCH 1/5] tox.ini: find Notebooks to run with nbval-lax using unix find cmd --- tox.ini | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/tox.ini b/tox.ini index 1733590..190ff98 100644 --- a/tox.ini +++ b/tox.ini @@ -23,20 +23,9 @@ commands = ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) pytest --verbose --maxfail=1 --nbval-lax docs/MuMoTuserManual.ipynb - - ; Ensure test Notebooks runs *without errors* (do not check for regressions yet) + ; Ensure test and demo Notebooks runs *without errors* (do not check for regressions yet) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - pytest --verbose --maxfail=1 --nbval-lax --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append \ - TestNotebooks/MuMoTtest.ipynb \ - TestNotebooks/MiscTests/MuMoTtest_GreekLetters.ipynb \ - TestNotebooks/MiscTests/MuMoTtest_MultiController.ipynb \ - TestNotebooks/MiscTests/MuMoTtest_NoiseFixedPoints.ipynb \ - TestNotebooks/MiscTests/MuMoTtest_oneDimensionalModels.ipynb - - ; Additional example Notebooks (TODO; leave commented) - ; TestNotebooks/MiscTests/MuMoTtest_MasterEq.ipynb - currently hangs after showNoiseEqs() for second model? - ; TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb - ; TestNotebooks/MiscTests/MuMoTuserManual_for_LabPresentation.ipynb + pytest --verbose --maxfail=1 --nbval-lax --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append $(find TestNotebooks DemoNotebooks -type f -name '*.ipynb') ; Ensure the user manual and regression test Notebooks do not show regressions (TODO; leave commented) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) @@ -55,8 +44,7 @@ source = mumot ; Do not calculate coverage of third-party code. ; (NB here this is the _installed_ code in the hidden virtualenv created by tox, ; not the source code of the package) -omit = - */site-packages/mumot/gen/* +; omit = ; Used by pytest-cov [report] From 84bdd17d26c534dca0c17c76137f841f4dd9645f Mon Sep 17 00:00:00 2001 From: Will Furnass Date: Tue, 1 Oct 2019 10:00:30 +0100 Subject: [PATCH 2/5] tox: do not try to find .ipynbs using 'find' as subshells not permitted in tox.ini --- tox.ini | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index b64619c..d8ee810 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,8 @@ whitelist_externals = test wc make + xargs + find commands = ; Ensure ipywidgets Jupyter extension is installed jupyter nbextension enable --py --sys-prefix widgetsnbextension @@ -19,13 +21,13 @@ commands = ; Run unit tests and generate code coverage report pytest --verbose --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" tests - ; Ensure the user manual Notebook runs *without errors* (do not check for regressions yet) + ; Ensure user manual, test and demo Notebooks run *without errors* (do not check for regressions yet) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 docs/MuMoTuserManual.ipynb - - ; Ensure test and demo Notebooks runs *without errors* (do not check for regressions yet) - ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append $(find TestNotebooks DemoNotebooks -type f -name '*.ipynb') + pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append \ + docs/*.ipynb \ + TestNotebooks/*.ipynb \ + TestNotebooks/MiscTests/*.ipynb \ + DemoNotebooks/* ; Ensure the user manual and regression test Notebooks do not show regressions (TODO; leave commented) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) From 383f4136173124ab71443c3b58c9f3eccf2fe689 Mon Sep 17 00:00:00 2001 From: Will Furnass Date: Tue, 1 Oct 2019 14:51:28 +0100 Subject: [PATCH 3/5] test notebooks: ensure all can be run under pycov --- .../MiscTests/MuMoTtest_1dstream.ipynb | 2 +- .../MiscTests/MuMoTtest_3dstream.ipynb | 2 +- .../MiscTests/MuMoTtest_GreekLetters.ipynb | 2 +- .../MiscTests/MuMoTtest_MasterEq.ipynb | 63 +++++++++---------- .../MiscTests/MuMoTtest_MultiController.ipynb | 2 +- .../MiscTests/MuMoTtest_bifurcation.ipynb | 7 +-- TestNotebooks/MuMoTtest.ipynb | 2 +- tox.ini | 21 ++++--- 8 files changed, 50 insertions(+), 51 deletions(-) diff --git a/TestNotebooks/MiscTests/MuMoTtest_1dstream.ipynb b/TestNotebooks/MiscTests/MuMoTtest_1dstream.ipynb index b6e43b5..b839db1 100644 --- a/TestNotebooks/MiscTests/MuMoTtest_1dstream.ipynb +++ b/TestNotebooks/MiscTests/MuMoTtest_1dstream.ipynb @@ -75,7 +75,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.7.4" }, "toc": { "base_numbering": 1, diff --git a/TestNotebooks/MiscTests/MuMoTtest_3dstream.ipynb b/TestNotebooks/MiscTests/MuMoTtest_3dstream.ipynb index 435da9b..05494f6 100644 --- a/TestNotebooks/MiscTests/MuMoTtest_3dstream.ipynb +++ b/TestNotebooks/MiscTests/MuMoTtest_3dstream.ipynb @@ -131,7 +131,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.7.4" }, "toc": { "base_numbering": 1, diff --git a/TestNotebooks/MiscTests/MuMoTtest_GreekLetters.ipynb b/TestNotebooks/MiscTests/MuMoTtest_GreekLetters.ipynb index eea2a61..ad682c5 100644 --- a/TestNotebooks/MiscTests/MuMoTtest_GreekLetters.ipynb +++ b/TestNotebooks/MiscTests/MuMoTtest_GreekLetters.ipynb @@ -197,7 +197,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.4" + "version": "3.7.4" }, "toc": { "base_numbering": 1, diff --git a/TestNotebooks/MiscTests/MuMoTtest_MasterEq.ipynb b/TestNotebooks/MiscTests/MuMoTtest_MasterEq.ipynb index 9d0fac1..a2e6f1b 100644 --- a/TestNotebooks/MiscTests/MuMoTtest_MasterEq.ipynb +++ b/TestNotebooks/MiscTests/MuMoTtest_MasterEq.ipynb @@ -9,9 +9,27 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Created `%%model` as an alias for `%%latex`.\n" + ] + }, + { + "data": { + "text/plain": [ + "'1.0.0'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import mumot\n", "\n", @@ -20,15 +38,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ - "%%model\n", - "$\n", + "model1_str = (r\"\"\"\n", "A -> B : k_1\n", "B -> A : k_2\n", - "$" + "\"\"\")" ] }, { @@ -37,7 +54,7 @@ "metadata": {}, "outputs": [], "source": [ - "model1 = mumot.parseModel(In[2])" + "model1 = mumot.parseModel(model1_str)" ] }, { @@ -118,8 +135,7 @@ "metadata": {}, "outputs": [], "source": [ - "%%model\n", - "$\n", + "model2 = mumot.parseModel(r\"\"\"\n", "U -> A : g_1\n", "U -> B : g_2\n", "A -> U : a_1\n", @@ -128,16 +144,7 @@ "B + U -> B + B : r_2\n", "A + B -> A + U : s_1\n", "A + B -> B + U : s_2\n", - "$" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model2 = mumot.parseModel(In[12])" + "\"\"\")" ] }, { @@ -308,8 +315,7 @@ "metadata": {}, "outputs": [], "source": [ - "%%model\n", - "$\n", + "model4 = mumot.parseModel(r\"\"\"\n", "U -> A : g_1\n", "U -> B : g_2\n", "U -> C : g_3\n", @@ -325,16 +331,7 @@ "A + C -> C + U : s_4\n", "B + C -> B + U : s_5\n", "B + C -> C + U : s_6\n", - "$" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model4 = mumot.parseModel(In[44])" + "\"\"\")" ] }, { @@ -516,7 +513,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.4" + "version": "3.7.4" }, "toc": { "base_numbering": 1, diff --git a/TestNotebooks/MiscTests/MuMoTtest_MultiController.ipynb b/TestNotebooks/MiscTests/MuMoTtest_MultiController.ipynb index 6c36c3c..9260d22 100644 --- a/TestNotebooks/MiscTests/MuMoTtest_MultiController.ipynb +++ b/TestNotebooks/MiscTests/MuMoTtest_MultiController.ipynb @@ -262,7 +262,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.7.4" }, "toc": { "base_numbering": 1, diff --git a/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb b/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb index 8258854..e4d5504 100644 --- a/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb +++ b/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb @@ -24,8 +24,7 @@ "metadata": {}, "outputs": [], "source": [ - "%%model\n", - "$\n", + "model1 = mumot.parseModel(r\"\"\"\n", "U -> A : g_A\n", "U -> B : g_B\n", "A -> U : a_A\n", @@ -34,7 +33,7 @@ "B + U -> B + B : r_B\n", "A + B -> A + U : s\n", "A + B -> B + U : s\n", - "$" + "\"\"\")" ] }, { @@ -151,7 +150,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.4" + "version": "3.7.4" }, "toc": { "base_numbering": 1, diff --git a/TestNotebooks/MuMoTtest.ipynb b/TestNotebooks/MuMoTtest.ipynb index 0462a4b..6ddcfca 100644 --- a/TestNotebooks/MuMoTtest.ipynb +++ b/TestNotebooks/MuMoTtest.ipynb @@ -1044,7 +1044,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.7.4" }, "toc": { "base_numbering": 1, diff --git a/tox.ini b/tox.ini index d8ee810..aede90d 100644 --- a/tox.ini +++ b/tox.ini @@ -12,8 +12,6 @@ whitelist_externals = test wc make - xargs - find commands = ; Ensure ipywidgets Jupyter extension is installed jupyter nbextension enable --py --sys-prefix widgetsnbextension @@ -21,15 +19,20 @@ commands = ; Run unit tests and generate code coverage report pytest --verbose --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" tests - ; Ensure user manual, test and demo Notebooks run *without errors* (do not check for regressions yet) + ; Ensure the user manual Notebook runs *without errors* (do not check for regressions yet) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append \ - docs/*.ipynb \ - TestNotebooks/*.ipynb \ - TestNotebooks/MiscTests/*.ipynb \ - DemoNotebooks/* + pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 docs/MuMoTuserManual.ipynb - ; Ensure the user manual and regression test Notebooks do not show regressions (TODO; leave commented) + ; Ensure test Notebooks run *without errors* (do not check for regressions yet) + ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) + pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 \ + --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" TestNotebooks + + ; Ensure demo Notebooks run *without errors* (do not check for regressions yet) + ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) + pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 DemoNotebooks + + ; Ensure the main regression test Notebook does not show regressions (TODO; leave commented) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) ; pytest --verbose --maxfail=1 --nbval --nbval-cell-timeout=120 --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append TestNotebooks/MuMoTtest.ipynb From 9dc2d32fab9dcf89ea730e4fee2780bb45f657e8 Mon Sep 17 00:00:00 2001 From: Will Furnass Date: Tue, 1 Oct 2019 15:33:06 +0100 Subject: [PATCH 4/5] Increase cell execution timeout from 120s to 600s (for MuMoTtest_MasterEq.ipynb) --- tox.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index aede90d..bfa89e7 100644 --- a/tox.ini +++ b/tox.ini @@ -21,20 +21,20 @@ commands = ; Ensure the user manual Notebook runs *without errors* (do not check for regressions yet) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 docs/MuMoTuserManual.ipynb + pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=600 docs/MuMoTuserManual.ipynb ; Ensure test Notebooks run *without errors* (do not check for regressions yet) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 \ + pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=600 \ --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" TestNotebooks ; Ensure demo Notebooks run *without errors* (do not check for regressions yet) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=120 DemoNotebooks + pytest --verbose --maxfail=1 --nbval-lax --nbval-cell-timeout=600 DemoNotebooks ; Ensure the main regression test Notebook does not show regressions (TODO; leave commented) ; (add --nbdime if running tox locally and want to visualise/explore diffs in web browser) - ; pytest --verbose --maxfail=1 --nbval --nbval-cell-timeout=120 --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append TestNotebooks/MuMoTtest.ipynb + ; pytest --verbose --maxfail=1 --nbval --nbval-cell-timeout=600 --cov-config=tox.ini --cov="{envsitepackagesdir}/mumot" --cov-append TestNotebooks/MuMoTtest.ipynb ; Check user manual does not contain output cells bash -c 'test $(nbshow --outputs docs/MuMoTuserManual.ipynb | wc -c) -eq 0' From 59a5a2eb98ab7cbcc0f3611b3fc8023e4078ff58 Mon Sep 17 00:00:00 2001 From: Will Furnass Date: Tue, 1 Oct 2019 17:42:07 +0100 Subject: [PATCH 5/5] MuMoTtest_bifurcation.ipynb: ensure can run under pycov --- TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb b/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb index e4d5504..41376f6 100644 --- a/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb +++ b/TestNotebooks/MiscTests/MuMoTtest_bifurcation.ipynb @@ -36,15 +36,6 @@ "\"\"\")" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "model1 = mumot.parseModel(In[2])" - ] - }, { "cell_type": "code", "execution_count": null,