Standalone Remote Kernel Execution#

Remote kernels can be executed by using the RemoteKernelManager class directly. This enables running kernels using ProcessProxys without requiring deployment of the Enterprise Gateway web application. This approach is also known as Library Mode.

This can be useful in niche situations, for example, using nbconvert or nbclient to execute a kernel on a remote cluster.

Sample code using nbclient 0.2.0:

import nbformat
from nbclient import NotebookClient
from enterprise_gateway.services.kernels.remotemanager import RemoteKernelManager

with open("my_notebook.ipynb") as fp:
    test_notebook = nbformat.read(fp, as_version=4)

client = NotebookClient(nb=test_notebook, kernel_manager_class=RemoteKernelManager)
client.execute(kernel_name='my_remote_kernel')

The above code will execute the notebook on a kernel named my_remote_kernel using its configured ProcessProxy.

Depending on the process proxy, the hosting application (e.g., nbclient) will likely need to be configured to run on the same network as the remote kernel. So, for example, with Kubernetes, nbclient would need to be configured as a Kubernetes POD.