executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
207 stars 84 forks source link

1.0.0: pytest is failing in 4 units #557

Closed kloczek closed 10 months ago

kloczek commented 11 months ago

Describe the bug

Looks like pytest is failing in 4 units

Reproduce the bug

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-myst-nb-1.0.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-myst-nb-1.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0 rootdir: /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0 configfile: tox.ini plugins: anyio-3.7.1, datadir-1.5.0, regressions-2.5.0, pytest_param_files-0.6.0 collected 80 items tests/test_ansi_lexer.py ........... [ 13%] tests/test_cli.py .. [ 16%] tests/test_codecell_file.py .. [ 18%] tests/test_docutils.py .............. [ 36%] tests/test_eval.py . [ 37%] tests/test_execute.py .............FF........FF [ 68%] tests/test_glue.py ..... [ 75%] tests/test_parser.py .... [ 80%] tests/test_render_outputs.py ............. [ 96%] tests/test_text_based.py ... [100%] ========================================================================================= FAILURES ========================================================================================== _____________________________________________________________________________ test_complex_outputs_unrun_cache ______________________________________________________________________________ sphinx_run = , file_regression = check_nbs = ._check_nbs at 0x7fcf6f7361f0> @pytest.mark.sphinx_params( "complex_outputs_unrun.ipynb", conf={"nb_execution_mode": "cache"} ) def test_complex_outputs_unrun_cache(sphinx_run, file_regression, check_nbs): sphinx_run.build() # print(sphinx_run.status()) > assert sphinx_run.warnings() == "" E assert '/tmp/pytest-...[mystnb.exec]' == '' E + /tmp/pytest-of-tkloczko/pytest-11/test_complex_outputs_unrun_cac0/source/complex_outputs_unrun.ipynb: WARNING: Executing notebook failed: CellExecutionError E + Traceback (most recent call last): E + File "/usr/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution E + executenb( E + File "/usr/lib/python3.8/site-packages/nbclient/client.py", line 1305, in execute E + return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute() E + File "/usr/lib/python3.8/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped... E E ...Full output truncated (26 lines hidden), use '-vv' to show /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:215: AssertionError ______________________________________________________________________________ test_complex_outputs_unrun_auto ______________________________________________________________________________ sphinx_run = , file_regression = check_nbs = ._check_nbs at 0x7fcf6f4e10d0> @pytest.mark.sphinx_params( "complex_outputs_unrun.ipynb", conf={"nb_execution_mode": "auto"} ) def test_complex_outputs_unrun_auto(sphinx_run, file_regression, check_nbs): sphinx_run.build() # print(sphinx_run.status()) > assert sphinx_run.warnings() == "" E assert '/tmp/pytest-...[mystnb.exec]' == '' E + /tmp/pytest-of-tkloczko/pytest-11/test_complex_outputs_unrun_aut0/source/complex_outputs_unrun.ipynb: WARNING: Executing notebook failed: CellExecutionError E + Traceback (most recent call last): E + File "/usr/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 58, in single_nb_execution E + executenb( E + File "/usr/lib/python3.8/site-packages/nbclient/client.py", line 1305, in execute E + return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute() E + File "/usr/lib/python3.8/site-packages/jupyter_core/utils/__init__.py", line 166, in wrapped... E E ...Full output truncated (26 lines hidden), use '-vv' to show /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:236: AssertionError _________________________________________________________________________________ test_custom_convert_auto __________________________________________________________________________________ file_regression = , sphinx_run = check_nbs = ._check_nbs at 0x7fcf6e9dc670> def regress_nb_doc(file_regression, sphinx_run, check_nbs): try: > file_regression.check( sphinx_run.get_nb(), check_fn=check_nbs, extension=".ipynb", encoding="utf-8", ) /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:14: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/conftest.py:286: in check return self.file_regression.check(self._strip_ignores(data), **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obtained_filename = PosixPath('/tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_auto0/test_execute/test_custom_convert_auto.obtained.ipynb') expected_filename = PosixPath('/tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_auto0/test_execute/test_custom_convert_auto.ipynb') def _check_nbs(obtained_filename, expected_filename): obtained_nb = nbf.read(str(obtained_filename), nbf.NO_CONVERT) expect_nb = nbf.read(str(expected_filename), nbf.NO_CONVERT) obtained_nb.nbformat_minor = 5 expect_nb.nbformat_minor = 5 for cell in expect_nb.cells: empty_non_deterministic_outputs(cell) cell.id = "none" for cell in obtained_nb.cells: empty_non_deterministic_outputs(cell) cell.id = "none" diff = diff_notebooks(obtained_nb, expect_nb) filename_without_path = str(expected_filename)[ str(expected_filename).rfind("/") + 1 : ] if diff: > raise AssertionError( pretty_print_diff(obtained_nb, diff, str(filename_without_path)) ) E AssertionError: None /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/conftest.py:240: AssertionError During handling of the above exception, another exception occurred: sphinx_run = , file_regression = check_nbs = ._check_nbs at 0x7fcf6e9dc670> @pytest.mark.sphinx_params( "custom-formats.Rmd", conf={ "nb_execution_mode": "auto", "nb_custom_formats": {".Rmd": ["jupytext.reads", {"fmt": "Rmd"}]}, }, ) def test_custom_convert_auto(sphinx_run, file_regression, check_nbs): sphinx_run.build() # print(sphinx_run.status()) assert sphinx_run.warnings() == "" > regress_nb_doc(file_regression, sphinx_run, check_nbs) /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:341: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:37: in regress_nb_doc file_regression.check(doctree_string, extension=".xml", encoding="utf-8") _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = data = '\n
\n' kwargs = {'encoding': 'utf-8', 'extension': '.xml'} def check(self, data, **kwargs): > return self.file_regression.check(self._strip_ignores(data), **kwargs) E AssertionError: FILES DIFFER: E /tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_auto0/test_execute/test_custom_convert_auto.xml E /tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_auto0/test_execute/test_custom_convert_auto.obtained.xml E HTML DIFF: /tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_auto0/test_execute/test_custom_convert_auto.obtained.diff.html E --- E +++ E @@ -12,10 +12,10 @@ E E E E - E + E E E E
E E - E + /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/conftest.py:286: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------ ## modified test_custom_convert_auto.ipynb/cells/3/outputs/0/data/text/plain: - + _________________________________________________________________________________ test_custom_convert_cache _________________________________________________________________________________ file_regression = , sphinx_run = check_nbs = ._check_nbs at 0x7fcf6e35b550> def regress_nb_doc(file_regression, sphinx_run, check_nbs): try: > file_regression.check( sphinx_run.get_nb(), check_fn=check_nbs, extension=".ipynb", encoding="utf-8", ) /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:14: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/conftest.py:286: in check return self.file_regression.check(self._strip_ignores(data), **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ obtained_filename = PosixPath('/tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_cache0/test_execute/test_custom_convert_cache.obtained.ipynb') expected_filename = PosixPath('/tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_cache0/test_execute/test_custom_convert_cache.ipynb') def _check_nbs(obtained_filename, expected_filename): obtained_nb = nbf.read(str(obtained_filename), nbf.NO_CONVERT) expect_nb = nbf.read(str(expected_filename), nbf.NO_CONVERT) obtained_nb.nbformat_minor = 5 expect_nb.nbformat_minor = 5 for cell in expect_nb.cells: empty_non_deterministic_outputs(cell) cell.id = "none" for cell in obtained_nb.cells: empty_non_deterministic_outputs(cell) cell.id = "none" diff = diff_notebooks(obtained_nb, expect_nb) filename_without_path = str(expected_filename)[ str(expected_filename).rfind("/") + 1 : ] if diff: > raise AssertionError( pretty_print_diff(obtained_nb, diff, str(filename_without_path)) ) E AssertionError: None /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/conftest.py:240: AssertionError During handling of the above exception, another exception occurred: sphinx_run = , file_regression = check_nbs = ._check_nbs at 0x7fcf6e35b550> @pytest.mark.sphinx_params( "custom-formats.Rmd", conf={ "nb_execution_mode": "cache", "nb_custom_formats": {".Rmd": ["jupytext.reads", {"fmt": "Rmd"}]}, }, ) def test_custom_convert_cache(sphinx_run, file_regression, check_nbs): """The outputs should be populated.""" sphinx_run.build() assert sphinx_run.warnings() == "" > regress_nb_doc(file_regression, sphinx_run, check_nbs) /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:361: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/test_execute.py:37: in regress_nb_doc file_regression.check(doctree_string, extension=".xml", encoding="utf-8") _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = data = '\n
\n' kwargs = {'encoding': 'utf-8', 'extension': '.xml'} def check(self, data, **kwargs): > return self.file_regression.check(self._strip_ignores(data), **kwargs) E AssertionError: FILES DIFFER: E /tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_cache0/test_execute/test_custom_convert_cache.xml E /tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_cache0/test_execute/test_custom_convert_cache.obtained.xml E HTML DIFF: /tmp/pytest-of-tkloczko/pytest-11/test_custom_convert_cache0/test_execute/test_custom_convert_cache.obtained.diff.html E --- E +++ E @@ -12,10 +12,10 @@ E E E E - E + E E E E
E E - E + /home/tkloczko/rpmbuild/BUILD/MyST-NB-1.0.0/tests/conftest.py:286: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------ ## modified test_custom_convert_cache.ipynb/cells/3/outputs/0/data/text/plain: - + ===================================================================================== warnings summary ====================================================================================== ../../../../../usr/lib/python3.8/site-packages/jupyter_client/connect.py:20 /usr/lib/python3.8/site-packages/jupyter_client/connect.py:20: DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs given by the platformdirs library. To remove this warning and see the appropriate new directories, set the environment variable `JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`. The use of platformdirs will be the default in `jupyter_core` v6 from jupyter_core.paths import jupyter_data_dir, jupyter_runtime_dir, secure_write ../../../../../usr/lib/python3.8/site-packages/jupyter_cache/cache/db.py:17 /usr/lib/python3.8/site-packages/jupyter_cache/cache/db.py:17: MovedIn20Warning: The ``declarative_base()`` function is now available as sqlalchemy.orm.declarative_base(). (deprecated since: 2.0) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9) OrmBase = declarative_base() tests/test_cli.py: 5 warnings tests/test_codecell_file.py: 4 warnings tests/test_docutils.py: 28 warnings tests/test_eval.py: 2 warnings tests/test_execute.py: 52 warnings tests/test_glue.py: 2 warnings tests/test_parser.py: 10 warnings tests/test_render_outputs.py: 24 warnings tests/test_text_based.py: 5 warnings /usr/lib/python3.8/site-packages/myst_parser/mdit_to_docutils/base.py:66: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later. settings = OptionParser(components=(parser_cls,)).get_default_values() tests/test_cli.py: 345 warnings tests/test_codecell_file.py: 276 warnings tests/test_docutils.py: 1932 warnings tests/test_eval.py: 138 warnings tests/test_execute.py: 3588 warnings tests/test_glue.py: 138 warnings tests/test_parser.py: 690 warnings tests/test_render_outputs.py: 1656 warnings tests/test_text_based.py: 345 warnings /usr/lib64/python3.8/optparse.py:1000: DeprecationWarning: The frontend.Option class will be removed in Docutils 0.21 or later. option = self.option_class(*args, **kwargs) tests/test_cli.py: 3 warnings tests/test_codecell_file.py: 2 warnings tests/test_eval.py: 2 warnings tests/test_execute.py: 25 warnings tests/test_glue.py: 2 warnings tests/test_parser.py: 4 warnings tests/test_render_outputs.py: 24 warnings tests/test_text_based.py: 3 warnings /home/tkloczko/rpmbuild/BUILDROOT/python-myst-nb-1.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/myst_nb/ext/execution_tables.py:79: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall(). for node in self.document.traverse(ExecutionStatsNode): -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ================================================================================== short test summary info ================================================================================== FAILED tests/test_execute.py::test_complex_outputs_unrun_cache - assert '/tmp/pytest-...[mystnb.exec]' == '' FAILED tests/test_execute.py::test_complex_outputs_unrun_auto - assert '/tmp/pytest-...[mystnb.exec]' == '' FAILED tests/test_execute.py::test_custom_convert_auto - AssertionError: FILES DIFFER: FAILED tests/test_execute.py::test_custom_convert_cache - AssertionError: FILES DIFFER: ================================================================== 4 failed, 76 passed, 9307 warnings in 72.33s (0:01:12) =================================================================== ```

List your environment

Here is list of installed modules in build env

```console Package Version ----------------------------- ----------- alabaster 0.7.13 anyio 3.7.1 argon2-cffi 23.1.0 argon2-cffi-bindings 21.2.0 asttokens 2.2.1 attrs 23.1.0 Babel 2.13.1 backcall 0.2.0 beautifulsoup4 4.12.2 bleach 6.1.0 build 1.0.0 cffi 1.16.0 charset-normalizer 3.3.1 click 8.1.7 coconut 3.0.1 colorama 0.4.6 comm 0.1.4 contourpy 1.0.7 cppclean 0.13 cPyparsing 2.4.7.2.2.3 cycler 0.12.1 debugpy 1.8.0 decorator 5.1.1 defusedxml 0.7.1 distro 1.8.0 docutils 0.20.1 exceptiongroup 1.1.3 executing 1.2.0 fastjsonschema 2.18.0 fonttools 4.43.1 gitdb 4.0.10 GitPython 3.1.40 gpg 1.22.0 greenlet 2.0.2 html5lib 1.1 idna 3.4 imagesize 1.4.1 importlib-metadata 6.8.0 importlib-resources 6.1.0 iniconfig 2.0.0 installer 0.7.0 ipykernel 6.26.0 ipython 8.12.0 jedi 0.19.0 Jinja2 3.1.2 jsonschema 4.19.1 jsonschema-specifications 2023.7.1 jupyter-cache 0.5.0 jupyter_client 8.4.0 jupyter_core 5.3.1 jupyter-events 0.8.0 jupyter_server 2.9.1 jupyter-server-mathjax 0.2.6 jupyter_server_terminals 0.4.4 jupyterlab-pygments 0.1.2 jupytext 1.15.2 kiwisolver 1.4.5 markdown-it-py 3.0.0 MarkupSafe 2.1.3 matplotlib 3.6.3 matplotlib-inline 0.1.6 mdit-py-plugins 0.4.0 mdurl 0.1.2 mistune 2.0.5 mpmath 1.3.0 myst-parser 2.0.0 nbclient 0.8.0 nbconvert 7.8.0 nbdime 3.2.1 nbformat 5.9.2 nest-asyncio 1.5.8 numpy 1.24.4 olefile 0.46 overrides 7.4.0 packaging 23.2 pandas 2.0.3 pandocfilters 1.5.0 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 Pillow 10.1.0 pkgutil_resolve_name 1.3.10 platformdirs 3.11.0 pluggy 1.3.0 ply 3.11 prometheus-client 0.17.1 prompt-toolkit 3.0.39 psutil 5.9.5 ptyprocess 0.7.0 pure-eval 0.2.2 pycparser 2.21 Pygments 2.16.1 pyparsing 3.1.1 pyproject_hooks 1.0.0 pytest 7.4.3 pytest-datadir 1.5.0 pytest_param_files 0.6.0 pytest-regressions 2.5.0 python-dateutil 2.8.2 python-json-logger 2.0.7 pytz 2023.3 PyYAML 6.0.1 pyzmq 25.1.1 referencing 0.30.2 requests 2.31.0 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rpds-py 0.10.6 ruamel.yaml 0.18.2 ruamel.yaml.clib 0.2.7 Send2Trash 1.8.2 six 1.16.0 smmap 5.0.0 sniffio 1.3.0 snowballstemmer 2.2.0 soupsieve 2.5 Sphinx 7.1.2 sphinxcontrib-applehelp 1.0.4 sphinxcontrib-devhelp 1.0.2 sphinxcontrib-htmlhelp 2.0.4 sphinxcontrib-jsmath 1.0.1 sphinxcontrib-qthelp 1.0.3 sphinxcontrib-serializinghtml 1.1.9 SQLAlchemy 2.0.22 stack-data 0.6.3 sympy 1.12 tabulate 0.9.0 terminado 0.17.1 tinycss2 1.2.1 toml 0.10.2 tomli 2.0.1 tornado 6.3.3 traitlets 5.11.2 typing_extensions 4.8.0 urllib3 1.26.18 wcwidth 0.2.8 webencodings 0.5.1 websocket-client 1.6.4 wheel 0.41.2 zipp 3.17.0 ```
kloczek commented 11 months ago

FYI: temporary I've added those 4 units to --deselect list so .. take your time 😋

agoose77 commented 10 months ago

I think this has been resolved. Let me know if not!