Run .ipynb programmatically

Hi,
We use Enterprise Gateway with Jupyterlab in our setup. There is a use case, wherein we want to run .ipynb against the jupyter server programmatically (via an api or any other way). I came across papermill doing exactly the same, but its not an jupyterlab extension and also it doesnt support Enterprise gateway.
Whats the best way to achieve this functionality? Not sure if such a functionality can be achieved via an extension? Any help is greatly appreciated.

Thanks
Amit

Is this a viable approach?

https://nbconvert.readthedocs.io/en/latest/execute_api.html#module-nbconvert.preprocessors

You can write an extension that will run all the cells in a notebook. Is that what you are looking for?

Here is an example of iterating over cells and running them: etc-jupyterlab-cell-iterate-run/index.ts at cfa483b168c04ce3f10e0b8d0f7d1ced7074048b · educational-technology-collective/etc-jupyterlab-cell-iterate-run · GitHub

The functions in the NotebookActions namespace may also be relevant: NotebookActions | @jupyterlab

1 Like

Thanks a lot @adpatter for your reply. I looked at nbcovert, but wasnt sure how it works with enterprise gateway, but got some good leads from gitter chat, let me explore more.

1 Like

Papermill
https://papermill.readthedocs.io/en/latest/reference/papermill-workflow.html#module-papermill.execute

I was able to run this using nbclient here

1 Like