async-kernel 0.18.3__tar.gz → 0.19.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/workflows/ci.yml +5 -8
  2. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/workflows/new_release.yml +1 -2
  3. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/workflows/publish-docs.yml +2 -3
  4. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/workflows/publish-to-pypi.yml +1 -2
  5. {async_kernel-0.18.3 → async_kernel-0.19.0}/.gitignore +1 -0
  6. {async_kernel-0.18.3 → async_kernel-0.19.0}/CHANGELOG.md +27 -0
  7. {async_kernel-0.18.3 → async_kernel-0.19.0}/CONTRIBUTING.md +4 -4
  8. {async_kernel-0.18.3 → async_kernel-0.19.0}/PKG-INFO +8 -44
  9. {async_kernel-0.18.3 → async_kernel-0.19.0}/README.md +7 -43
  10. {async_kernel-0.18.3 → async_kernel-0.19.0}/_version.py +2 -2
  11. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/notebooks/caller.ipynb +2 -4
  12. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/notebooks/concurrency.ipynb +4 -6
  13. async_kernel-0.19.0/docs/notebooks/custom_kernel.ipynb +208 -0
  14. async_kernel-0.19.0/docs/reference/ipshell.md +1 -0
  15. async_kernel-0.19.0/docs/reference/shell.md +1 -0
  16. async_kernel-0.19.0/docs/usage/commands.md +152 -0
  17. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/usage/index.md +1 -1
  18. {async_kernel-0.18.3 → async_kernel-0.19.0}/hatch_build.py +3 -2
  19. {async_kernel-0.18.3 → async_kernel-0.19.0}/mkdocs.yml +3 -1
  20. {async_kernel-0.18.3 → async_kernel-0.19.0}/pyproject.toml +10 -10
  21. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/caller.py +51 -44
  22. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/comm.py +27 -32
  23. async_kernel-0.19.0/src/async_kernel/command.py +233 -0
  24. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/common.py +54 -20
  25. async_kernel-0.19.0/src/async_kernel/compat/attr_docs.py +64 -0
  26. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/debugger.py +58 -54
  27. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/event_loop/run.py +3 -3
  28. async_kernel-0.19.0/src/async_kernel/interface/__init__.py +41 -0
  29. async_kernel-0.19.0/src/async_kernel/interface/base.py +508 -0
  30. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/interface/callable.py +17 -13
  31. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/interface/zmq.py +107 -171
  32. async_kernel-0.19.0/src/async_kernel/kernel.py +696 -0
  33. async_kernel-0.19.0/src/async_kernel/kernelspec.py +286 -0
  34. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/pending.py +13 -3
  35. async_kernel-0.19.0/src/async_kernel/shell/__init__.py +14 -0
  36. async_kernel-0.19.0/src/async_kernel/shell/base.py +241 -0
  37. async_kernel-0.18.3/src/async_kernel/asyncshell.py → async_kernel-0.19.0/src/async_kernel/shell/ipshell.py +464 -398
  38. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/typing.py +11 -5
  39. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/utils.py +71 -33
  40. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/conftest.py +39 -35
  41. async_kernel-0.19.0/tests/test_base_interface.py +110 -0
  42. async_kernel-0.18.3/tests/test_callable_kernel_interface.py → async_kernel-0.19.0/tests/test_callable_interface.py +13 -13
  43. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_comm.py +15 -20
  44. async_kernel-0.19.0/tests/test_command.py +301 -0
  45. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_common.py +29 -1
  46. async_kernel-0.19.0/tests/test_debugger_static.py +67 -0
  47. async_kernel-0.19.0/tests/test_enter_kernel.py +24 -0
  48. async_kernel-0.19.0/tests/test_iostream.py +56 -0
  49. async_kernel-0.18.3/tests/test_kernel.py → async_kernel-0.19.0/tests/test_kernel_ipshell.py +42 -261
  50. async_kernel-0.19.0/tests/test_kernelspec.py +95 -0
  51. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_message_spec.py +23 -12
  52. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_pending.py +8 -3
  53. async_kernel-0.19.0/tests/test_subclass.py +31 -0
  54. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_utils.py +23 -6
  55. async_kernel-0.19.0/tests/test_zmq_interface.py +205 -0
  56. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/utils.py +4 -2
  57. {async_kernel-0.18.3 → async_kernel-0.19.0}/uv.lock +537 -577
  58. async_kernel-0.18.3/docs/notebooks/custom_kernel.ipynb +0 -98
  59. async_kernel-0.18.3/docs/reference/asyncshell.md +0 -12
  60. async_kernel-0.18.3/docs/usage/commands.md +0 -268
  61. async_kernel-0.18.3/src/async_kernel/command.py +0 -142
  62. async_kernel-0.18.3/src/async_kernel/interface/__init__.py +0 -37
  63. async_kernel-0.18.3/src/async_kernel/interface/base.py +0 -448
  64. async_kernel-0.18.3/src/async_kernel/iostream.py +0 -61
  65. async_kernel-0.18.3/src/async_kernel/kernel.py +0 -482
  66. async_kernel-0.18.3/src/async_kernel/kernelspec.py +0 -212
  67. async_kernel-0.18.3/tests/test_command.py +0 -192
  68. async_kernel-0.18.3/tests/test_enter_kernel.py +0 -21
  69. async_kernel-0.18.3/tests/test_iostream.py +0 -41
  70. async_kernel-0.18.3/tests/test_kernel_subclass.py +0 -23
  71. async_kernel-0.18.3/tests/test_kernelspec.py +0 -48
  72. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/dependabot.yaml +0 -0
  73. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/release.yml +0 -0
  74. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/workflows/enforce-label.yml +0 -0
  75. {async_kernel-0.18.3 → async_kernel-0.19.0}/.github/workflows/pre-commit.yml +0 -0
  76. {async_kernel-0.18.3 → async_kernel-0.19.0}/.pre-commit-config.yaml +0 -0
  77. {async_kernel-0.18.3 → async_kernel-0.19.0}/.vscode/launch.json +0 -0
  78. {async_kernel-0.18.3 → async_kernel-0.19.0}/.vscode/settings.json +0 -0
  79. {async_kernel-0.18.3 → async_kernel-0.19.0}/.vscode/spellright.dict +0 -0
  80. {async_kernel-0.18.3 → async_kernel-0.19.0}/IPYTHON_LICENSE +0 -0
  81. {async_kernel-0.18.3 → async_kernel-0.19.0}/LICENSE +0 -0
  82. {async_kernel-0.18.3 → async_kernel-0.19.0}/cliff.toml +0 -0
  83. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/about/changelog.md +0 -0
  84. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/about/contributing.md +0 -0
  85. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/about/index.md +0 -0
  86. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/about/license.md +0 -0
  87. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/index.md +0 -0
  88. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/javascripts/extra.js +0 -0
  89. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/overrides/main.html +0 -0
  90. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/caller.md +0 -0
  91. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/comm.md +0 -0
  92. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/command.md +0 -0
  93. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/common.md +0 -0
  94. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/debugger.md +0 -0
  95. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/event_loop.md +0 -0
  96. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/index.md +0 -0
  97. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/interface.md +0 -0
  98. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/kernel.md +0 -0
  99. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/kernelspec.md +0 -0
  100. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/pending.md +0 -0
  101. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/typing.md +0 -0
  102. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/reference/utils.md +0 -0
  103. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/stylesheets/extra.css +0 -0
  104. {async_kernel-0.18.3 → async_kernel-0.19.0}/docs/thread_safety.md +0 -0
  105. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/__init__.py +0 -0
  106. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/__main__.py +0 -0
  107. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/compat/json.py +0 -0
  108. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/compiler.py +0 -0
  109. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/event_loop/__init__.py +0 -0
  110. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/event_loop/asyncio_guest.py +0 -0
  111. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/event_loop/qt_host.py +0 -0
  112. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/event_loop/tk_host.py +0 -0
  113. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/py.typed +0 -0
  114. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/resources/logo-32x32.png +0 -0
  115. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/resources/logo-64x64.png +0 -0
  116. {async_kernel-0.18.3 → async_kernel-0.19.0}/src/async_kernel/resources/logo-svg.svg +0 -0
  117. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/__init__.py +0 -0
  118. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/references.py +0 -0
  119. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_caller.py +0 -0
  120. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_compat.py +0 -0
  121. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_debugger.py +0 -0
  122. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_event_loop.py +0 -0
  123. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_typing.py +0 -0
  124. {async_kernel-0.18.3 → async_kernel-0.19.0}/tests/test_zmq_messaging.py +0 -0
@@ -25,7 +25,7 @@ jobs:
25
25
  - name: Type checking with basedpyright
26
26
  run: |
27
27
  uv sync
28
- uvx basedpyright@1.39.3
28
+ uvx basedpyright@1.39.6
29
29
 
30
30
  test:
31
31
  needs: type-checking
@@ -47,8 +47,7 @@ jobs:
47
47
  - name: Install uv
48
48
  uses: astral-sh/setup-uv@v7
49
49
  with:
50
- enable-cache: true
51
- version: "0.9.26"
50
+ version-file: "pyproject.toml"
52
51
  python-version: ${{ matrix.python-version }}
53
52
 
54
53
  - name: Install the project
@@ -73,8 +72,7 @@ jobs:
73
72
  - name: Install uv
74
73
  uses: astral-sh/setup-uv@v7
75
74
  with:
76
- enable-cache: true
77
- version: "0.9.26"
75
+ version-file: "pyproject.toml"
78
76
  python-version: "3.13"
79
77
 
80
78
  - name: Run tests with coverage
@@ -103,12 +101,11 @@ jobs:
103
101
  - name: Install uv
104
102
  uses: astral-sh/setup-uv@v7
105
103
  with:
106
- enable-cache: true
107
- version: "0.9.26"
104
+ version-file: "pyproject.toml"
108
105
 
109
106
  - name: Docs build strict
110
107
  timeout-minutes: 5
111
108
  run: |
112
109
  uv sync --group docs
113
- uv run async-kernel -a async-docs --shell.timeout=1
110
+ uv run async-kernel install --name=async-docs --timeout=1
114
111
  uv run mkdocs build -s
@@ -33,8 +33,7 @@ jobs:
33
33
  - name: Install uv
34
34
  uses: astral-sh/setup-uv@v7
35
35
  with:
36
- enable-cache: true
37
- version: "0.9.26"
36
+ version-file: "pyproject.toml"
38
37
 
39
38
  - name: Create a new branch, generate the changelog and release notes.
40
39
  run: |
@@ -29,8 +29,7 @@ jobs:
29
29
  - name: Install uv
30
30
  uses: astral-sh/setup-uv@v7
31
31
  with:
32
- enable-cache: true
33
- version: "0.9.26"
32
+ version-file: "pyproject.toml"
34
33
 
35
34
  - name: Checkout
36
35
  uses: actions/checkout@v6
@@ -40,7 +39,7 @@ jobs:
40
39
  - name: Install the project
41
40
  run: |
42
41
  uv sync --group docs
43
- uv run async-kernel -a async-docs --shell.timeout=1 # The 'async-docs' kernel is specified as the kernel for mkdocs-jupyter
42
+ uv run async-kernel install --name=async-docs --timeout=1 # The 'async-docs' kernel is specified as the kernel for mkdocs-jupyter
44
43
 
45
44
  - name: Version info
46
45
  id: version
@@ -33,8 +33,7 @@ jobs:
33
33
  ref: main
34
34
  - uses: astral-sh/setup-uv@v7
35
35
  with:
36
- enable-cache: true
37
- version: "0.9.26"
36
+ version-file: "pyproject.toml"
38
37
 
39
38
  - name: Build a binary wheel and a source tarball
40
39
  run: uv build
@@ -13,3 +13,4 @@ data_kernelspec
13
13
  .pytest_cache
14
14
  _version.py
15
15
  release_notes.md
16
+ .venv
@@ -5,12 +5,38 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.19.0] - 2026-05-26
9
+
10
+ ### <!-- 0 --> 🏗️ Breaking changes
11
+
12
+ - Add support for traitlets configuration with major refactoring. [#469](https://github.com/fleming79/async-kernel/pull/469)
13
+
14
+ - Rename kernel_name to name [#459](https://github.com/fleming79/async-kernel/pull/459)
15
+
16
+ ### <!-- 1 --> 🚀 Features
17
+
18
+ - Add timeout to PendingGroup and shield to Caller.wait. [#471](https://github.com/fleming79/async-kernel/pull/471)
19
+
20
+ - Improve Kernel subclassing [#460](https://github.com/fleming79/async-kernel/pull/460)
21
+
22
+ ### <!-- 6 --> 🌀 Miscellaneous
23
+
24
+ - Bump uv and basedpyright [#470](https://github.com/fleming79/async-kernel/pull/470)
25
+
26
+ - Add message to task.cancel in task_factory [#461](https://github.com/fleming79/async-kernel/pull/461)
27
+
28
+ - Linting [#458](https://github.com/fleming79/async-kernel/pull/458)
29
+
8
30
  ## [0.18.3] - 2026-05-06
9
31
 
10
32
  ### <!-- 1 --> 🚀 Features
11
33
 
12
34
  - Include default argument in pack_json_bytes and pack_json_str. [#456](https://github.com/fleming79/async-kernel/pull/456)
13
35
 
36
+ ### <!-- 6 --> 🌀 Miscellaneous
37
+
38
+ - Prepare for release v0.18.3 [#457](https://github.com/fleming79/async-kernel/pull/457)
39
+
14
40
  ## [0.18.2] - 2026-05-03
15
41
 
16
42
  ### <!-- 2 --> 🐛 Fixes
@@ -1283,6 +1309,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1283
1309
 
1284
1310
  - Bump the actions group across 1 directory with 2 updates [#3](https://github.com/fleming79/async-kernel/pull/3)
1285
1311
 
1312
+ [0.19.0]: https://github.com/fleming79/async-kernel/compare/v0.18.3..v0.19.0
1286
1313
  [0.18.3]: https://github.com/fleming79/async-kernel/compare/v0.18.2..v0.18.3
1287
1314
  [0.18.2]: https://github.com/fleming79/async-kernel/compare/v0.18.1..v0.18.2
1288
1315
  [0.18.1]: https://github.com/fleming79/async-kernel/compare/v0.18.0..v0.18.1
@@ -25,7 +25,7 @@ Additional steps to build documentation (optional):
25
25
 
26
26
  ```bash
27
27
  uv sync --group docs
28
- uv run async-kernel -a async-docs --main_shell.timeout=1
28
+ uv run async-kernel install --name=async-docs --timeout=1
29
29
  ```
30
30
 
31
31
  ### Running tests
@@ -100,7 +100,7 @@ The 'docs' group specified extra packages are required to build documentation.
100
100
 
101
101
  ```bash
102
102
  uv sync --group docs
103
- uv run async-kernel -a async-docs --main_shell.timeout=1
103
+ uv run async-kernel install --name=async-docs --timeout=1
104
104
  ```
105
105
 
106
106
  #### Test the docs
@@ -114,10 +114,10 @@ uv run mkdocs build -s
114
114
  The command:
115
115
 
116
116
  ```bash
117
- uv run async-kernel -a async-docs --main_shell.timeout=1
117
+ uv run async-kernel install --name=async-docs --timeout=1
118
118
  ```
119
119
 
120
- Defines a new kernel spec with the name "async-docs" that sets the `shell.timeout` to 100ms.
120
+ Defines a new kernel spec with the name "async-docs" that sets the `timeout` to 1s.
121
121
 
122
122
  The "async-docs" named kernel spec is used by [mkdocs-jupyter](#notebooks) to convert the notebooks
123
123
  for inclusion in the usage section of the documentation.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: async-kernel
3
- Version: 0.18.3
3
+ Version: 0.19.0
4
4
  Summary: A concurrent python kernel for Jupyter supporting AnyIO, AsyncIO and Trio.
5
5
  Project-URL: Homepage, https://fleming79.github.io/async-kernel
6
6
  Project-URL: Documentation, https://fleming79.github.io/async-kernel
@@ -155,56 +155,20 @@ await event
155
155
  pip install async-kernel
156
156
  ```
157
157
 
158
- ## Kernel specs
158
+ ## Kernelspecs
159
159
 
160
- A kernel spec with the name 'async' is added when async-kernel is installed.
160
+ A kernelspec with the name 'async' is added when async-kernel is installed.
161
161
 
162
- Kernel specs can be added/removed via the command line.
163
-
164
- ### Backends
165
-
166
- The backend set on the interface is the asynchronous library the kernel uses for message handling.
167
- It is also the asynchronous library directly available when executing code in cells or via a console[^3].
168
-
169
- [^3]:
170
- Irrespective of the configured backend, functions/coroutines can be executed using a specific backend
171
- with the method [`call_using_backend`](https://fleming79.github.io/async-kernel/latest/reference/caller/#async_kernel.caller.Caller.call_using_backend).
172
-
173
- #### Example - overwrite the 'async' kernel spec to use a trio backend
174
-
175
- ```bash
176
- pip install trio
177
- async-kernel -a async --interface.backend=trio
178
- ```
179
-
180
- ### Gui event loop
181
-
182
- The kernel can be started with a gui event loop as the _host_ and the _backend_ running as a guest.
183
-
184
- #### asyncio backend
185
-
186
- ```bash
187
- # tk
188
- async-kernel -a async-tk --interface.host=tk
189
-
190
- # qt
191
- pip install PySide6-Essentials
192
- async-kernel -a async-qt --interface.host=qt
193
- ```
194
-
195
- #### trio backend
162
+ Kernel specs can be installed/uninstalled via the command line.
196
163
 
197
164
  ```bash
198
- pip install trio
199
- # tk
200
- async-kernel -a async-tk --interface.host=tk --interface.backend=trio
165
+ async-kernel install
201
166
 
202
- # qt
203
- pip install PySide6-Essentials
204
- async-kernel -a async-qt --interface.host=qt --interface.backend=trio
167
+ # To install for a user
168
+ async-kernel install --user
205
169
  ```
206
170
 
207
- For further detail about kernel spec customisation see [command line and kernel configuration](https://fleming79.github.io/async-kernel/latest/usage/commands/).
171
+ For further detail about kernel spec customisation see [command line and kernel configuration](https://fleming79.github.io/async-kernel/latest/usage/commands/) and [custom kernel.ipynb](https://fleming79.github.io/async-kernel/latest/notebooks/custom_kernel/).
208
172
 
209
173
  ## Faster data serialization
210
174
 
@@ -104,56 +104,20 @@ await event
104
104
  pip install async-kernel
105
105
  ```
106
106
 
107
- ## Kernel specs
107
+ ## Kernelspecs
108
108
 
109
- A kernel spec with the name 'async' is added when async-kernel is installed.
109
+ A kernelspec with the name 'async' is added when async-kernel is installed.
110
110
 
111
- Kernel specs can be added/removed via the command line.
112
-
113
- ### Backends
114
-
115
- The backend set on the interface is the asynchronous library the kernel uses for message handling.
116
- It is also the asynchronous library directly available when executing code in cells or via a console[^3].
117
-
118
- [^3]:
119
- Irrespective of the configured backend, functions/coroutines can be executed using a specific backend
120
- with the method [`call_using_backend`](https://fleming79.github.io/async-kernel/latest/reference/caller/#async_kernel.caller.Caller.call_using_backend).
121
-
122
- #### Example - overwrite the 'async' kernel spec to use a trio backend
123
-
124
- ```bash
125
- pip install trio
126
- async-kernel -a async --interface.backend=trio
127
- ```
128
-
129
- ### Gui event loop
130
-
131
- The kernel can be started with a gui event loop as the _host_ and the _backend_ running as a guest.
132
-
133
- #### asyncio backend
134
-
135
- ```bash
136
- # tk
137
- async-kernel -a async-tk --interface.host=tk
138
-
139
- # qt
140
- pip install PySide6-Essentials
141
- async-kernel -a async-qt --interface.host=qt
142
- ```
143
-
144
- #### trio backend
111
+ Kernel specs can be installed/uninstalled via the command line.
145
112
 
146
113
  ```bash
147
- pip install trio
148
- # tk
149
- async-kernel -a async-tk --interface.host=tk --interface.backend=trio
114
+ async-kernel install
150
115
 
151
- # qt
152
- pip install PySide6-Essentials
153
- async-kernel -a async-qt --interface.host=qt --interface.backend=trio
116
+ # To install for a user
117
+ async-kernel install --user
154
118
  ```
155
119
 
156
- For further detail about kernel spec customisation see [command line and kernel configuration](https://fleming79.github.io/async-kernel/latest/usage/commands/).
120
+ For further detail about kernel spec customisation see [command line and kernel configuration](https://fleming79.github.io/async-kernel/latest/usage/commands/) and [custom kernel.ipynb](https://fleming79.github.io/async-kernel/latest/notebooks/custom_kernel/).
157
121
 
158
122
  ## Faster data serialization
159
123
 
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.18.3'
22
- __version_tuple__ = version_tuple = (0, 18, 3)
21
+ __version__ = version = '0.19.0'
22
+ __version_tuple__ = version_tuple = (0, 19, 0)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -66,10 +66,6 @@
66
66
  },
67
67
  "outputs": [],
68
68
  "source": [
69
- "import async_kernel\n",
70
- "\n",
71
- "assert async_kernel.utils.get_kernel() is get_ipython().kernel # pyright: ignore[reportUndefinedVariable]\n",
72
- "\n",
73
69
  "%callers"
74
70
  ]
75
71
  },
@@ -417,11 +413,13 @@
417
413
  "import random\n",
418
414
  "import time\n",
419
415
  "\n",
416
+ "import anyio\n",
420
417
  "import ipywidgets as ipw\n",
421
418
  "\n",
422
419
  "outputs = {}\n",
423
420
  "stop = ipw.RadioButtons(value=None, options=[\"Stop\"])\n",
424
421
  "box = ipw.VBox([stop])\n",
422
+ "await anyio.sleep(0.2)\n",
425
423
  "display(box)\n",
426
424
  "\n",
427
425
  "\n",
@@ -61,11 +61,7 @@
61
61
  "import threading\n",
62
62
  "\n",
63
63
  "import ipywidgets as ipw\n",
64
- "from aiologic import Event\n",
65
- "\n",
66
- "from async_kernel import utils\n",
67
- "\n",
68
- "kernel = utils.get_kernel()"
64
+ "from aiologic import Event"
69
65
  ]
70
66
  },
71
67
  {
@@ -368,6 +364,8 @@
368
364
  "metadata": {},
369
365
  "outputs": [],
370
366
  "source": [
367
+ "import asyncio # noqa: F401 # pyright: ignore[reportUnusedImport]\n",
368
+ "\n",
371
369
  "%asyncio await asyncio.sleep(0) # This code gets run in an asyncio task \n",
372
370
  "%trio await trio.sleep(0) # trio run as line magic"
373
371
  ]
@@ -384,7 +382,7 @@
384
382
  "def print_info():\n",
385
383
  " from aiologic.lowlevel import current_async_library\n",
386
384
  " print(f\"\"\"\n",
387
- " Kernel backend: {get_ipython().kernel.interface.backend}\n",
385
+ " Kernel backend: {get_ipython().kernel.parent.backend}\n",
388
386
  " Current backend: { current_async_library()}\n",
389
387
  " \"\"\") \n",
390
388
  "\n",
@@ -0,0 +1,208 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "0",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Kernel customisation (notebook)\n",
9
+ "\n",
10
+ "- [Using a uv virtual environment](#uv-managed-virtual-environment)\n",
11
+ "- [Storing a custom definition](#embed-the-custom-kernel-in-the-kernelspec-folder)\n",
12
+ "- [Configuration options](#configuration-options)"
13
+ ]
14
+ },
15
+ {
16
+ "cell_type": "markdown",
17
+ "id": "1",
18
+ "metadata": {},
19
+ "source": [
20
+ "## uv managed virtual environment\n",
21
+ "\n",
22
+ "We can use uv to create a virtual environment for different versions of Python.\n",
23
+ "\n",
24
+ "Let's create a new virtual environment in the folder named \".venv_py315\" using uv.\n",
25
+ "\n",
26
+ "**Requires a recent version of uv to be installed.**"
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "code",
31
+ "execution_count": null,
32
+ "id": "2",
33
+ "metadata": {},
34
+ "outputs": [],
35
+ "source": [
36
+ "%uv venv .venv_py315 --python 3.15 --clear\n",
37
+ "%uv pip install --directory .venv_py315 --python 3.15 async-kernel"
38
+ ]
39
+ },
40
+ {
41
+ "cell_type": "markdown",
42
+ "id": "3",
43
+ "metadata": {},
44
+ "source": [
45
+ "Now we can write a kernel spec that uses uv to start the kernel from the virtual environment."
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": null,
51
+ "id": "4",
52
+ "metadata": {},
53
+ "outputs": [],
54
+ "source": [
55
+ "import pathlib\n",
56
+ "\n",
57
+ "from async_kernel.kernelspec import write_kernel_spec\n",
58
+ "\n",
59
+ "uv_path = pathlib.Path.cwd().joinpath(\".venv_py315\")\n",
60
+ "assert uv_path.exists()\n",
61
+ "\n",
62
+ "write_kernel_spec(\n",
63
+ " name=\"async_3.15\",\n",
64
+ " display_name=\"Python 3.15 (async)\",\n",
65
+ " env={\"UV_PROJECT_ENVIRONMENT\": str(uv_path)},\n",
66
+ " command=(\"uv\", \"run\", \"--module\", \"async_kernel\", \"start\"),\n",
67
+ ")"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "markdown",
72
+ "id": "5",
73
+ "metadata": {},
74
+ "source": [
75
+ "The kernel spec with the display name \"Python 3.15 (async kernel)\" has been added. You will need to refresh the list of kernels for it to be available."
76
+ ]
77
+ },
78
+ {
79
+ "cell_type": "markdown",
80
+ "id": "6",
81
+ "metadata": {},
82
+ "source": [
83
+ "## Embed the custom kernel in the kernelspec folder\n",
84
+ "\n",
85
+ "\n",
86
+ "When a callable is passed as the argument `launcher` to the function `write_kernel_spec` it is saved as a python file in the kernel spec folder. It will be used as the 'launcher' for the kernelspec.\n",
87
+ "\n",
88
+ "Let's write a kernel that will echo (print) the code written to the cell. \n"
89
+ ]
90
+ },
91
+ {
92
+ "cell_type": "code",
93
+ "execution_count": null,
94
+ "id": "7",
95
+ "metadata": {},
96
+ "outputs": [],
97
+ "source": [
98
+ "import async_kernel.kernelspec\n",
99
+ "\n",
100
+ "\n",
101
+ "def launcher(settings: dict) -> None:\n",
102
+ "\n",
103
+ " from async_kernel import Kernel\n",
104
+ " from async_kernel.interface.zmq import ZMQInterface\n",
105
+ "\n",
106
+ " class EchoKernel(Kernel):\n",
107
+ " async def execute_request(self, job):\n",
108
+ " print(job[\"msg\"][\"content\"][\"code\"])\n",
109
+ " return {\"status\": \"ok\", \"execution_count\": 0, \"user_expressions\": {}}\n",
110
+ "\n",
111
+ " ZMQInterface.launch_instance(kernel_class=EchoKernel)\n",
112
+ "\n",
113
+ "\n",
114
+ "# Write the kernel spec\n",
115
+ "async_kernel.kernelspec.write_kernel_spec(name=\"echo\", display_name=\"Echo kernel\", launcher=launcher)"
116
+ ]
117
+ },
118
+ {
119
+ "cell_type": "markdown",
120
+ "id": "8",
121
+ "metadata": {},
122
+ "source": [
123
+ "### Customize the shell\n",
124
+ "\n",
125
+ "Sometimes it might be useful to customise the shell instead of the kernel.\n",
126
+ "\n",
127
+ "Lets write IPshell as an echo a bypass keyword \"# call\"."
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "code",
132
+ "execution_count": null,
133
+ "id": "9",
134
+ "metadata": {},
135
+ "outputs": [],
136
+ "source": [
137
+ "import async_kernel.kernelspec\n",
138
+ "\n",
139
+ "\n",
140
+ "def launcher(settings: dict) -> None:\n",
141
+ "\n",
142
+ " from traitlets import traitlets\n",
143
+ "\n",
144
+ " from async_kernel.interface.zmq import ZMQInterface\n",
145
+ " from async_kernel.shell import IPShell\n",
146
+ "\n",
147
+ " class EchoShell(IPShell):\n",
148
+ " @traitlets.default(\"banner1\")\n",
149
+ " def _default_banner1(self) -> str:\n",
150
+ " return \"Echo kernel with bypass\\n\"\n",
151
+ "\n",
152
+ " def transform_cell(self, raw_cell):\n",
153
+ " if raw_cell.startswith(\"# call\"):\n",
154
+ " return super().transform_cell(raw_cell)\n",
155
+ " return f'print(\"\"\"{raw_cell}\"\"\")'\n",
156
+ "\n",
157
+ " ZMQInterface.launch_instance(shell_class=EchoShell)\n",
158
+ "\n",
159
+ "\n",
160
+ "# Write the kernel spec\n",
161
+ "async_kernel.kernelspec.write_kernel_spec(\n",
162
+ " name=\"echo-shell-with-bypass\", display_name=\"Echo with bypass\", launcher=launcher\n",
163
+ ")"
164
+ ]
165
+ },
166
+ {
167
+ "cell_type": "markdown",
168
+ "id": "10",
169
+ "metadata": {},
170
+ "source": [
171
+ "## Configuration options\n",
172
+ "\n",
173
+ "Configuration is done using traitlets configuration. Configuration options are available from the command line."
174
+ ]
175
+ },
176
+ {
177
+ "cell_type": "code",
178
+ "execution_count": null,
179
+ "id": "11",
180
+ "metadata": {},
181
+ "outputs": [],
182
+ "source": [
183
+ "!async-kernel --help-all"
184
+ ]
185
+ }
186
+ ],
187
+ "metadata": {
188
+ "kernelspec": {
189
+ "display_name": "Python (async)",
190
+ "language": "python",
191
+ "name": "async"
192
+ },
193
+ "language_info": {
194
+ "codemirror_mode": {
195
+ "name": "ipython",
196
+ "version": 3
197
+ },
198
+ "file_extension": ".py",
199
+ "mimetype": "text/x-python",
200
+ "name": "python",
201
+ "nbconvert_exporter": "python",
202
+ "pygments_lexer": "ipython3",
203
+ "version": "3.13.12"
204
+ }
205
+ },
206
+ "nbformat": 4,
207
+ "nbformat_minor": 5
208
+ }
@@ -0,0 +1 @@
1
+ ::: async_kernel.shell.ipshell
@@ -0,0 +1 @@
1
+ ::: async_kernel.shell.base