Migration Guide#
Jupyter Client 6.0 to 7.0#
API Changes#
All of the API changes for KernelManager and AsyncKernelManager in the 7.0 release were confined to internal public methods, which we define as methods called from the formally public methods but could be overridden in subclass implementations. As a result, these changes may impact subclasses of KernelManager or AsyncKernelManager provided those implementations also implement or call these methods, but should not affect applications that call only the formally public methods.
KernelManager#
The following internal methods had signature changes:
def pre_start_kernel(self, **kwargs) -> Tuple[List[str], Dict[str, Any]]:pre_start_kernelnow returns a tuple consisting of the formatted kernel startup list and an updated set of keyword arguments.
def _launch_kernel(self, kernel_cmd: List[str], **kw) -> None:_launch_kernelnow returnsNoneinstead of thePopeninstance
These methods now take the keyword argument
restartindicating the shutdown was on behalf of a kernel restart (whenTrue).def finish_shutdown(self, restart: bool = False):def _kill_kernel(self, restart: bool = False):def _send_kernel_sigterm(self, restart: bool = False):
Attribute
kernelhas been removed and logically replaced withprovisioner- which is an instance ofKernelProvisionerBaseand can be viewed as an abstractPopeninstance.
AsyncKernelManager#
Besides the signature and attribute changes described above, the following internal methods were made async for AsyncKernelManager:
async def pre_start_kernel(self, **kwargs) -> Tuple[List[str], Dict[str, Any]]:async def post_start_kernel(self, **kwargs):async def request_shutdown(self, restart: bool = False):async def cleanup_resources(self, restart: bool = False):
AsyncKernelClient#
We dropped the block: bool = True keyword argument for the following methods:
async def get_shell_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:async def get_iopub_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:async def get_stdin_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:async def get_control_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:
Calling these methods with block=False previously translates to calling them with timeout=0 now.
Calling these methods with block=True previously translates to calling them with a non-zero timeout value now.
BlockingKernelClient#
We dropped the block: bool = True keyword argument for the following methods:
def get_shell_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:def get_iopub_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:def get_stdin_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:def get_control_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:
Calling these methods with block=False previously translates to calling them with timeout=0 now.
Calling these methods with block=True previously translates to calling them with a non-zero timeout value now.
BlockingKernelClient#
ZMQSocketChannel#
We dropped the block: bool = True keyword argument for the following method:
async def get_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]::
Calling this method with block=False previously translates to calling it with timeout=0 now.
Calling this method with block=True previously translates to calling it with a non-zero timeout value now.
Note
Prefer calling e.g. client.get_shell_msg() over client.shell_channel.get_msg().
Deprecations removed#
Method KernelManager.cleanup()#
The cleanup() method on KernelManager has been removed. cleanup_resources(restart: bool = False) should be used.
Attribute KernelManager.kernel_cmd#
This attribute had been marked for deprecation for 4 years. The command used to start the kernel is derived from the argv stanza of the kernel specification file (kernel.json).