在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:jpmorganchase/nbcelltests开源软件地址:https://github.com/jpmorganchase/nbcelltests开源编程语言:Python 74.0%开源软件介绍:Cell-by-cell testing for production Jupyter notebooks in JupyterLab Overview
InstallationPython package installation: To use in JupyterLab, you will also need the lab and server extensions. Typically, these are
automatically installed alongside nbcelltests, so you should not need to do anything special
to use them. The lab extension will require a rebuild of JupyterLab, which you'll be prompted
to do on starting JupyterLab the first time after installing celltests (or you can do manually
with To see what extensions you have, check the output of jupyter labextension install jupyterlab_celltests
jupyter serverextension enable --py nbcelltests (Note: if using in an environment, you might wish to add "Linearly executed notebooks?"When converting notebooks into html/pdf/email reports, they are executed top-to-bottom one time, and are expected to contain as little code as reasonably possible, focusing primarily on the plotting and markdown bits. Libraries for this type of thing include Papermill, JupyterLab Emails, etc. Doesn't this already exist?Nbval is a great product (we leverage it in this project) and I recommend using it for notebook regression tests. But it only allows for testing for unexpected failures or simple output equality tests. So why do I want this again?This doesn't necessarily help you if your data sources go down, but its likely you'll notice this anyway. Where this comes in handy is:
So what does this do?Given a notebook, you can write mocks and assertions for individual cells. You can then generate a testing script for this notebook, allowing you to hook it into your testing system and thereby provide unittests of your report. Writing testsWhen you write tests for a cell, we create a new method on a Running testsYou can run the tests offline from an Extra Tests
ExampleIn the committed TestsThe following output is generated by running examples/_Example_test.py::TestNotebook::test_cell_coverage PASSED [ 20%]
examples/_Example_test.py::TestNotebook::test_code_cell_1 PASSED [ 40%]
examples/_Example_test.py::TestNotebook::test_code_cell_2 PASSED [ 60%]
examples/_Example_test.py::TestNotebook::test_code_cell_3 PASSED [ 80%]
examples/_Example_test.py::TestNotebook::test_code_cell_4 PASSED [100%] LintThe following output is generated by running PASSED: Checking lines in cell (max=10; actual=2) (Cell 1)
PASSED: Checking lines in cell (max=10; actual=1) (Cell 2)
PASSED: Checking lines in cell (max=10; actual=1) (Cell 3)
PASSED: Checking lines in cell (max=10; actual=1) (Cell 4)
PASSED: Checking cells per notebook (max=10; actual=4)
PASSED: Checking functions per notebook (max=10; actual=0)
PASSED: Checking classes per notebook (max=10; actual=0)
FAILED: Checking lint:
examples/Example.ipynb (in /var/folders/s3/1mjw0y192zg3450tkkn1yfnm0000gn/T/tmpp91li59p.py):32:1: F821 undefined name 'test3'
examples/Example.ipynb (in /var/folders/s3/1mjw0y192zg3450tkkn1yfnm0000gn/T/tmpp91li59p.py):32:6: W291 trailing whitespace NB: In jupyterlab, notebooks will be lint checked in-process using the version of python that is running jupyter lab itself. A notebook intended to be run with a Python 2 kernel could therefore generate syntax errors during lint checking. DevelopmentSee CONTRIBUTING.md for guidelines. LicenseThis software is licensed under the Apache 2.0 license. See the LICENSE and AUTHORS files for details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论