Google Colab
See work and example on googlecolab/jupyter-kernel-client#1 (comment)
A minimal usage with Colab VMs looks like:
rtp-mac:jupyter_kernel_client rtp$ cat test.py
import logging
import time
from jupyter_kernel_client import KernelClient
from jupyter_kernel_client import JupyterSubprotocol
SERVER = "https://8080-m-s-kkb-use1d2-3435tg2zm2d8x-d.us-east1-2.sandbox.colab.dev"
KERNEL = "fd343487-3cb8-4573-8677-8beecc39585d"
TOKEN = "..."
with KernelClient(
server_url=SERVER,
kernel_id=KERNEL,
token='unused',
client_kwargs = {
'subprotocol': JupyterSubprotocol.DEFAULT,
'extra_params': { 'colab-runtime-proxy-token': TOKEN },
},
headers = {
'X-Colab-Client-Agent': 'colab-mcp',
'X-Colab-Runtime-Proxy-Token': TOKEN,
}) as kc:
reply = kc.execute("print('hey')")
print(reply)
(the values of SERVER / KERNEL / TOKEN come from our assignment API)
We don't use the regular jupyter token parameter, but its required, so it ends up as 'unused' (ick?) otherwise we plumb all our bits through via client_kwargs and headers, with most of the modification going to a new subprotocol selector in client_kwargs.
Google Colab
See work and example on googlecolab/jupyter-kernel-client#1 (comment)
A minimal usage with Colab VMs looks like:
We don't use the regular jupyter token parameter, but its required, so it ends up as 'unused' (ick?) otherwise we plumb all our bits through via client_kwargs and headers, with most of the modification going to a new subprotocol selector in client_kwargs.