25 ms·
You can just use nbclient/nbconvert as a library instead of on cmd. Execute the notebook, and the cell outputs are directly available as python objects [1]. Err
by abdullahkhalids 2y ago
You can just use nbclient/nbconvert as a library instead of on cmd. Execute the notebook, and the cell outputs are directly available as python objects [1]. Error handling is also inbuilt.
This should make integration with pytest etc, much simpler.
[1] https://nbconvert.readthedocs.io/en/latest/execute_api.html#executing-notebooks-using-the-python-api-interface https://nbconvert.readthedocs.io/en/latest/execute_api.html#...
- westurner 2y agoThere are a number of ways to run tests within notebooks and to run notebooks as tests. ipytest: https://github.com/chmp/ipytest https://github.com/chmp/ipytest nbval: https://github.com/computationalmodelling/nbval https://github.com/computationalmodelling/nbval papermill: https://github.com/nteract/papermill https://github.com/nteract/papermill awesome-jupyter > Testing: https://github.com/markusschanta/awesome-jupyter https://github.com/markusschanta/awesome-jupyter "Is there a cell tag convention to skip execution?" https://discourse.jupyter.org/t/is-there-a-cell-tag-convention-to-skip-execution/5445/10 https://discourse.jupyter.org/t/is-there-a-cell-tag-conventi... Methods for importing notebooks like regular Python modules: ipynb, import_ipnb, nbimporter, nbdev nbimporter README on why not to import notebooks like modules: https://github.com/grst/nbimporter#update-2019-06-i-do-not-recommend-any-more-to-use-nbimporter https://github.com/grst/nbimporter#update-2019-06-i-do-not-r... nbdev parses jupyter notebook cell comments to determine whether to export a module to a .py file: https://nbdev1.fast.ai/export.html https://nbdev1.fast.ai/export.html There's a Jupyter kernel for running ansible playbooks as notebooks with output. dask-labextension does more of a retry-on-failure workflow