2 ms·
I made a module to offer some more options for some of these problems recently - particularly useful when you have code that you _want_ to keep organized in a n
by breatheoften 8y ago
I made a module to offer some more options for some of these problems recently - particularly useful when you have code that you _want_ to keep organized in a notebook for continued interactive experimentation and/or for explaining a prototype process — but you also want to reuse that code in an external script or program. Let’s you call any notebook as a function. Keyword arguments can be passed and there’s a simple way to receive these values within the notebook to allow the notebook to be parametrizable when invoked externally.
https://github.com/breathe/NotebookScripter https://github.com/breathe/NotebookScripter
- davecap1 8y agoIs this similar to papermill? https://github.com/nteract/papermill https://github.com/nteract/papermill
- breatheoften 8y agoI hadn’t come across papermill before - looks quite full featured. Seems to be oriented a bit towards “scripting Notebooks” with the ability to generate output notebook files with populated output cells. I think it must have to emulate some of the logic of the Notebook ui to do that. NotebookScripter is much more minimal and doesn’t support generating/updating .ipynb files. It has just one api allowing one to treat a notebook file as a function that can be called from another python program. I’m not entirely sure whether papermill can run the target notebook in the calling process — it looks like it spins up a Jupyter kernel and communicates with it via message passing. NotebookScripter creates an ipython interpreter context in process and execs the notebook code in process.