Debian Codegraph @

docs/migration.md

raw
1 # Migration Guide
2
3 ## Jupyter Client 6.0 to 7.0
4
5 ### API Changes
6
7 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.
8
9 #### `KernelManager`
10
11 The following internal methods had signature changes:
12
13 - `def pre_start_kernel(self, **kwargs) -> Tuple[List[str], Dict[str, Any]]:`
14
15 - `pre_start_kernel` now returns a tuple consisting of the formatted kernel startup list and an updated set of keyword arguments.
16
17 - `def _launch_kernel(self, kernel_cmd: List[str], **kw) -> None:`
18
19 - `_launch_kernel` now returns `None` instead of the `Popen` instance
20
21 - These methods now take the keyword argument `restart` indicating the shutdown was on behalf of a kernel restart (when `True`).
22
23 - `def finish_shutdown(self, restart: bool = False):`
24 - `def _kill_kernel(self, restart: bool = False):`
25 - `def _send_kernel_sigterm(self, restart: bool = False):`
26
27 - Attribute `kernel` has been removed and _logically_ replaced with `provisioner` - which is an instance of `KernelProvisionerBase` and can be viewed as an abstract `Popen` instance.
28
29 #### `AsyncKernelManager`
30
31 Besides the signature and attribute changes described above, the following internal methods were made `async` for `AsyncKernelManager`:
32
33 - `async def pre_start_kernel(self, **kwargs) -> Tuple[List[str], Dict[str, Any]]:`
34 - `async def post_start_kernel(self, **kwargs):`
35 - `async def request_shutdown(self, restart: bool = False):`
36 - `async def cleanup_resources(self, restart: bool = False):`
37
38 #### `AsyncKernelClient`
39
40 We dropped the `block: bool = True` keyword argument for the following methods:
41
42 - `async def get_shell_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
43 - `async def get_iopub_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
44 - `async def get_stdin_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
45 - `async def get_control_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
46
47 Calling these methods with `block=False` previously translates to calling them with `timeout=0` now.
48 Calling these methods with `block=True` previously translates to calling them with a non-zero `timeout` value now.
49
50 #### `BlockingKernelClient`
51
52 We dropped the `block: bool = True` keyword argument for the following methods:
53
54 - `def get_shell_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
55 - `def get_iopub_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
56 - `def get_stdin_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
57 - `def get_control_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`
58
59 Calling these methods with `block=False` previously translates to calling them with `timeout=0` now.
60 Calling these methods with `block=True` previously translates to calling them with a non-zero `timeout` value now.
61
62 #### `BlockingKernelClient`
63
64 #### `ZMQSocketChannel`
65
66 We dropped the `block: bool = True` keyword argument for the following method:
67
68 - `async def get_msg(self, timeout: Optional[float] = None) -> Dict[str, Any]:`:
69
70 Calling this method with `block=False` previously translates to calling it with `timeout=0` now.
71 Calling this method with `block=True` previously translates to calling it with a non-zero `timeout` value now.
72
73 ```{admonition} Note
74 Prefer calling e.g. `client.get_shell_msg()` over `client.shell_channel.get_msg()`.
75 ```
76
77 ### Deprecations removed
78
79 #### Method `KernelManager.cleanup()`
80
81 The `cleanup()` method on `KernelManager` has been removed. `cleanup_resources(restart: bool = False)` should be used.
82
83 #### Attribute `KernelManager.kernel_cmd`
84
85 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`).