question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FEAT: hook to run notebooks

See original GitHub issue

Request

A pre-commit hook that ensures notebooks have valid code and will run without error.

Motivation

We may push notebooks to remote repos and later discover that users experience errors caused from typos or insufficient kernels/python versions. Using a pre-push hook to defensively “validate” notebooks can guard against simple errors and reduce calls to CI.

Approaches

There may be some approaches to this:

  1. use nbconvert to run all notebooks
  2. parse the ast based on the notebook’s kernel (potentially faster)

Examples

Pre-commit hook

repos:
-     repo:  https://github.com/nbQA-dev/nbQA/issues/new
      rev: <latest>
      hooks:
      - id: nbqa-valid-nb

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pylangcommented, Nov 11, 2020

I’m stunned. Fastest, most helpful response on GitHub I’ve experienced yet. Wow. Thank you all.

1reaction
MarcoGorellicommented, Nov 11, 2020

@pylang this’ll be in the next release, but in the meantime, you can use it as

repos:
- repo: https://github.com/nbQA-dev/nbQA
  rev: 036332e96865994060159ac30d16dd5cdf29cc16  # this will be 0.5.0 in the future
  hooks:
   - id: nbqa-check-ast
     additional_dependencies: [pre-commit-hooks==3.3.0]

if you like - please do let us know if you run into any issues

Read more comments on GitHub >

github_iconTop Results From Across the Web

File save hooks — Jupyter Notebook 6.5.2 documentation
You can configure functions that are run whenever a file is saved. There are two hooks available: ContentsManager.pre_save_hook runs on the API path...
Read more >
Git-Friendly Jupyter - nbdev
It provides a set of hooks which enable git-friendly Jupyter notebooks in any git repo, including those that don't use the broader nbdev...
Read more >
CircuitPython with Jupyter Notebooks
When you launch notebooks using the CircuitPython-Kernel, it'll search the serial ports on your computer and connect to your Adafruit CircuitPython board.
Read more >
Example Notebooks: Use Your Own Algorithm or Model
The following Jupyter notebooks show how to use your own algorithms or pretrained models from an Amazon SageMaker notebook instance.
Read more >
nbstripout: strip output from Jupyter and IPython notebooks
Opens a notebook, strips its output, and writes the outputless version to the original file. Useful mainly as a git filter or pre-commit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found