Embedding Jupyter/IPython in a client/server application

Hello all,

I’m implementing an application with clients communicating with a server over ZeroMQ. I’d like one of the server’s functionalities to be the hosting of a shared python kernel, allowing clients to connect an ipython shell or a web-based notebook interface and interact with the shared state.

I did a bunch of reading, and as a result I’m thoroughly confused on which parts of Jupyter/IPython I should be using to get this done.

  1. What’s the appropriate way to start/stop a kernel from inside a python application, such that other hosts can connect to it?
  2. If the answer is (unsurprisingly) embed_kernel, how should I communicate connection information to clients?
  3. On the client side, is there a component I can use to connect to the above kernel already, or should I be writing my own component that speaks the protocol?
  4. One of the features I’d like to support is asynchronous injection of state into the running kernel, possibly notifying all clients that a piece of shared state has been updated. Is this possible?

In the middle of all of this, I’ve been reading about kernel gateways, and I can’t quite seem to figure out whether it can be used programmatically.

Kernel Gateway provides an HTTP+WebSockets interface to kernel management and kernels. I’d recommend to look into the current development of jupyter_server though, if you’re interested in running your client over those protocols.

If you want to use ZeroMQ directly over the network, you’ll need something else than Kernel Gateway. You’ll probably have to implement authorization yourself, too.