Notes based on the nbdev2 introductory video tutorial

  • YouTube tutorial
    • Create a Github repo
    • Terminal: nbdev_help to list help
    • Terminal: nbdev_new from git folder
    • Open Jupyter lab and edit files settings.ini and .ipynb about module and index page
    • nbdev_export to export notebooks to python modules
    • pip install -e . to install package in development mode
    • nbdev_preview to preview package documentation
    • use anottations such as #| hide and #| exportto control behavior
    • use @patch to add methods to previously defined classes. Good for sequentially testing and documenting the code
      • When the method is defined directly in the class we can add documentation by using show_doc(<class_name>.<method_name>)
    • nbdev_test: run test locally. We can use assert, test_eq, test_ne and the like to write the tests
      • We can add #!notest at the beginning of the cell to skip the cell during test.
    • Use %debug to debug your code
    • Golden rule when developing with nbdev: cells should either contain import general code to be exported, but not a mixture of the two
    • nbdev_clean: clean notebook metadata. Suggested before sending to GitHub.
      • There are hooks that can do that automatically. Look at the docs.
    • nbdev_prepare: run export, clean and test
    • nbdev_pypi: upload to pypi
    • Nice GitHub action to review notebooks in PR: https://github.com/marketplace/review-notebook-app

Notes based on How nbdev helps us structure our data science workflow in Jupyter Notebooks

Quarto

nbdev2 is based on Quarto. It is recommended to read the documentation to understand what features are available.