I'm currently experimenting with ipylab, that uses ipywidgets for comms and am wondering if there is simple way to obtain the kernel_id in the Python kernel.
I found it can be extracted from the kernel config, but this is a bit hacky.
from IPython.core.getipython import get_ipython
ip = get_ipython()
kernel_id = (
ip.kernel.config["IPKernelApp"]["connection_file"].rsplit("kernel-", 1)[1].removesuffix(".json")
)
I'm currently experimenting with ipylab, that uses ipywidgets for comms and am wondering if there is simple way to obtain the kernel_id in the Python kernel.
I found it can be extracted from the kernel config, but this is a bit hacky.