How to: prepare notebooks so that all checks pass - gmlc-dispatches/dispatches GitHub Wiki

Writing the notebook

  • Use absolute import paths when importing Python modules located in the dispatches package. This includes Python files located in the same directory as the notebook file

Skipping individual code cells when running the notebook in CI

When should code cells be skipped in CI?

Code cells should be skipped if any of the following is true:

  • The cell takes a long time to run (more than 5-10 minutes)
  • The cell requires particular solvers, executables, etc that are not available in the CI environment
    • e.g. the gurobi solver is typically not available
  • The cell depends on previous cells that have also been skipped
    • e.g. if a cell contains code to generate a plot, which depends on a data file that would be generated in a skipped cell

How to mark a code cell for skipping

Code cells will be skipped in CI if the cell has a cell tag named nbval-skip. Refer to the How to: add a tag to a notebook cell page in this wiki.

Pre-commit checklist

  • Remove empty cells
  • Ensure notebook starts with Markdown (text) cell containing a level 1 header/title (i.e. if the title of the notebook is "My notebook", the first line of the Markdown source is # My notebook)
  • Ensure all cells of the notebook have been run in order without errors. To do so from the Jupyter notebook interface, select Kernel > Restart and run all