Skip to content

Instantly share code, notes, and snippets.

@ronaldokun
Created January 26, 2024 01:49
Show Gist options
  • Save ronaldokun/ecc50749fce9b9b97012e4d5036a3c63 to your computer and use it in GitHub Desktop.
Save ronaldokun/ecc50749fce9b9b97012e4d5036a3c63 to your computer and use it in GitHub Desktop.
Execute notebook in a terminal
#!/usr/bin/env python
import nbformat,fire
from nbconvert.preprocessors import ExecutePreprocessor
def run_notebook(path):
nb = nbformat.read(open(path), as_version=nbformat.NO_CONVERT)
ExecutePreprocessor(timeout=600).preprocess(nb, {})
print('done')
if __name__ == '__main__': fire.Fire(run_notebook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment