superkernel-adapter 0.9.7__tar.gz → 0.10.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.
Potentially problematic release.
This version of superkernel-adapter might be problematic. Click here for more details.
- {superkernel_adapter-0.9.7/src/superkernel_adapter.egg-info → superkernel_adapter-0.10.0}/PKG-INFO +16 -20
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/README.md +14 -18
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/pyproject.toml +2 -5
- {superkernel_adapter-0.9.7/src/superkernel_adapter → superkernel_adapter-0.10.0/src/superkernel}/__init__.py +2 -2
- {superkernel_adapter-0.9.7/src/superkernel_adapter → superkernel_adapter-0.10.0/src/superkernel}/kernel.py +20 -8
- superkernel_adapter-0.10.0/src/superkernel/launcher.py +27 -0
- {superkernel_adapter-0.9.7/src/superkernel_adapter → superkernel_adapter-0.10.0/src/superkernel}/logfile.py +1 -1
- {superkernel_adapter-0.9.7/src/superkernel_adapter → superkernel_adapter-0.10.0/src/superkernel}/schema.py +1 -1
- {superkernel_adapter-0.9.7/src/superkernel_adapter → superkernel_adapter-0.10.0/src/superkernel}/state.py +1 -1
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0/src/superkernel_adapter.egg-info}/PKG-INFO +16 -20
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/src/superkernel_adapter.egg-info/SOURCES.txt +6 -7
- superkernel_adapter-0.10.0/src/superkernel_adapter.egg-info/top_level.txt +1 -0
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/tests/test_adapter.py +49 -2
- superkernel_adapter-0.10.0/tests/test_packaging.py +93 -0
- superkernel_adapter-0.9.7/src/superkernel_adapter/launcher.py +0 -40
- superkernel_adapter-0.9.7/src/superkernel_adapter.egg-info/entry_points.txt +0 -2
- superkernel_adapter-0.9.7/src/superkernel_adapter.egg-info/top_level.txt +0 -1
- superkernel_adapter-0.9.7/tests/test_packaging.py +0 -79
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/LICENSE +0 -0
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/setup.cfg +0 -0
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/src/superkernel_adapter.egg-info/dependency_links.txt +0 -0
- {superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0}/src/superkernel_adapter.egg-info/requires.txt +0 -0
{superkernel_adapter-0.9.7/src/superkernel_adapter.egg-info → superkernel_adapter-0.10.0}/PKG-INFO
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: superkernel-adapter
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: SuperKernel Adapter: a shared local Jupyter kernel for remote compute.
|
|
5
5
|
Author-email: Leo Li <leoustc@icloud.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
7
|
Project-URL: Homepage, https://superkernel.leoustc.com
|
|
8
8
|
Project-URL: Source, https://github.com/leoustc/superkernel/tree/main/superkernel-adapter
|
|
9
|
-
Classifier: Development Status ::
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -56,12 +56,6 @@ SuperKernel Adapter requires Python 3.10 or newer.
|
|
|
56
56
|
uv pip install superkernel-adapter
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Until this renamed distribution is published, install a provided wheel instead:
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
uv pip install superkernel_adapter-0.9.7-py3-none-any.whl
|
|
63
|
-
```
|
|
64
|
-
|
|
65
59
|
The JupyterLab or VS Code SuperKernel integration normally installs and
|
|
66
60
|
configures the notebook kernels for you. A configured kernel can then be
|
|
67
61
|
selected from the standard Jupyter kernel picker like any other kernel.
|
|
@@ -71,7 +65,7 @@ creation, and local kernel registration are handled by a compatible
|
|
|
71
65
|
SuperKernel client integration.
|
|
72
66
|
|
|
73
67
|
The distribution is `superkernel-adapter`, the Python import is
|
|
74
|
-
`
|
|
68
|
+
`superkernel`, the module launcher is `python -m superkernel.kernel`, and the kernel
|
|
75
69
|
class remains `SuperKernel`.
|
|
76
70
|
|
|
77
71
|
## Python API
|
|
@@ -80,21 +74,21 @@ The kernel class is available for integrations that need to inspect or extend
|
|
|
80
74
|
the local runtime:
|
|
81
75
|
|
|
82
76
|
```python
|
|
83
|
-
from
|
|
77
|
+
from superkernel import SuperKernel
|
|
84
78
|
```
|
|
85
79
|
|
|
86
80
|
The supported process entry point for a configured Jupyter kernelspec is:
|
|
87
81
|
|
|
88
82
|
```text
|
|
89
|
-
superkernel
|
|
83
|
+
python -m superkernel.kernel
|
|
90
84
|
```
|
|
91
85
|
|
|
92
86
|
Its connection and authentication arguments are generated by the client
|
|
93
87
|
integration and are not intended to be entered manually.
|
|
94
|
-
Clients use the selected Python environment's absolute
|
|
95
|
-
`/opt/jupyterhub/bin/
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
Clients use the selected Python environment's absolute executable, such as
|
|
89
|
+
`/opt/jupyterhub/bin/python`, followed by `-m superkernel.kernel`. No standalone
|
|
90
|
+
`superkernel` or `sk-adapter` command is installed. Picker labels append
|
|
91
|
+
`(SuperKernel)` while their language remains Python.
|
|
98
92
|
|
|
99
93
|
## Upgrading from superkernels
|
|
100
94
|
|
|
@@ -105,8 +99,8 @@ Restart notebook kernels and reload the VS Code window after installation.
|
|
|
105
99
|
The retired distribution/import has no runtime alias; the root local install
|
|
106
100
|
workflow removes it after installing the new adapter. An already-running old
|
|
107
101
|
process may be recognized only for explicit, identity-checked shutdown.
|
|
108
|
-
The
|
|
109
|
-
|
|
102
|
+
The Python module launches a notebook adapter, not a Gateway or infrastructure
|
|
103
|
+
management CLI. Retired module/console identities are cleanup-only; no import aliases.
|
|
110
104
|
|
|
111
105
|
## Security
|
|
112
106
|
|
|
@@ -125,8 +119,10 @@ read or modify saved user credentials.
|
|
|
125
119
|
|
|
126
120
|
## Project status
|
|
127
121
|
|
|
128
|
-
Version 0.
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
Version 0.10.0 is an alpha release for trusted teams. It hardens restart
|
|
123
|
+
confirmations and reports output replay gaps. It uses the
|
|
124
|
+
`superkernel.kernel` module with no console CLI. The integration contract may
|
|
125
|
+
still evolve before 1.0. Backend source is private and is not distributed in
|
|
126
|
+
this package.
|
|
131
127
|
|
|
132
128
|
Learn more at [superkernel.leoustc.com](https://superkernel.leoustc.com).
|
|
@@ -35,12 +35,6 @@ SuperKernel Adapter requires Python 3.10 or newer.
|
|
|
35
35
|
uv pip install superkernel-adapter
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Until this renamed distribution is published, install a provided wheel instead:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
uv pip install superkernel_adapter-0.9.7-py3-none-any.whl
|
|
42
|
-
```
|
|
43
|
-
|
|
44
38
|
The JupyterLab or VS Code SuperKernel integration normally installs and
|
|
45
39
|
configures the notebook kernels for you. A configured kernel can then be
|
|
46
40
|
selected from the standard Jupyter kernel picker like any other kernel.
|
|
@@ -50,7 +44,7 @@ creation, and local kernel registration are handled by a compatible
|
|
|
50
44
|
SuperKernel client integration.
|
|
51
45
|
|
|
52
46
|
The distribution is `superkernel-adapter`, the Python import is
|
|
53
|
-
`
|
|
47
|
+
`superkernel`, the module launcher is `python -m superkernel.kernel`, and the kernel
|
|
54
48
|
class remains `SuperKernel`.
|
|
55
49
|
|
|
56
50
|
## Python API
|
|
@@ -59,21 +53,21 @@ The kernel class is available for integrations that need to inspect or extend
|
|
|
59
53
|
the local runtime:
|
|
60
54
|
|
|
61
55
|
```python
|
|
62
|
-
from
|
|
56
|
+
from superkernel import SuperKernel
|
|
63
57
|
```
|
|
64
58
|
|
|
65
59
|
The supported process entry point for a configured Jupyter kernelspec is:
|
|
66
60
|
|
|
67
61
|
```text
|
|
68
|
-
superkernel
|
|
62
|
+
python -m superkernel.kernel
|
|
69
63
|
```
|
|
70
64
|
|
|
71
65
|
Its connection and authentication arguments are generated by the client
|
|
72
66
|
integration and are not intended to be entered manually.
|
|
73
|
-
Clients use the selected Python environment's absolute
|
|
74
|
-
`/opt/jupyterhub/bin/
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
Clients use the selected Python environment's absolute executable, such as
|
|
68
|
+
`/opt/jupyterhub/bin/python`, followed by `-m superkernel.kernel`. No standalone
|
|
69
|
+
`superkernel` or `sk-adapter` command is installed. Picker labels append
|
|
70
|
+
`(SuperKernel)` while their language remains Python.
|
|
77
71
|
|
|
78
72
|
## Upgrading from superkernels
|
|
79
73
|
|
|
@@ -84,8 +78,8 @@ Restart notebook kernels and reload the VS Code window after installation.
|
|
|
84
78
|
The retired distribution/import has no runtime alias; the root local install
|
|
85
79
|
workflow removes it after installing the new adapter. An already-running old
|
|
86
80
|
process may be recognized only for explicit, identity-checked shutdown.
|
|
87
|
-
The
|
|
88
|
-
|
|
81
|
+
The Python module launches a notebook adapter, not a Gateway or infrastructure
|
|
82
|
+
management CLI. Retired module/console identities are cleanup-only; no import aliases.
|
|
89
83
|
|
|
90
84
|
## Security
|
|
91
85
|
|
|
@@ -104,8 +98,10 @@ read or modify saved user credentials.
|
|
|
104
98
|
|
|
105
99
|
## Project status
|
|
106
100
|
|
|
107
|
-
Version 0.
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
Version 0.10.0 is an alpha release for trusted teams. It hardens restart
|
|
102
|
+
confirmations and reports output replay gaps. It uses the
|
|
103
|
+
`superkernel.kernel` module with no console CLI. The integration contract may
|
|
104
|
+
still evolve before 1.0. Backend source is private and is not distributed in
|
|
105
|
+
this package.
|
|
110
106
|
|
|
111
107
|
Learn more at [superkernel.leoustc.com](https://superkernel.leoustc.com).
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "superkernel-adapter"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.10.0"
|
|
8
8
|
description = "SuperKernel Adapter: a shared local Jupyter kernel for remote compute."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -14,7 +14,7 @@ authors = [
|
|
|
14
14
|
{ name = "Leo Li", email = "leoustc@icloud.com" }
|
|
15
15
|
]
|
|
16
16
|
classifiers = [
|
|
17
|
-
"Development Status ::
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
18
|
"Programming Language :: Python :: 3",
|
|
19
19
|
"Programming Language :: Python :: 3 :: Only",
|
|
20
20
|
"Operating System :: OS Independent",
|
|
@@ -30,9 +30,6 @@ dependencies = [
|
|
|
30
30
|
Homepage = "https://superkernel.leoustc.com"
|
|
31
31
|
Source = "https://github.com/leoustc/superkernel/tree/main/superkernel-adapter"
|
|
32
32
|
|
|
33
|
-
[project.scripts]
|
|
34
|
-
superkernel = "superkernel_adapter.kernel:main"
|
|
35
|
-
|
|
36
33
|
[tool.setuptools]
|
|
37
34
|
package-dir = { "" = "src" }
|
|
38
35
|
|
|
@@ -7,13 +7,13 @@ from importlib.metadata import PackageNotFoundError, version
|
|
|
7
7
|
try:
|
|
8
8
|
__version__ = version("superkernel-adapter")
|
|
9
9
|
except PackageNotFoundError:
|
|
10
|
-
__version__ = "0.
|
|
10
|
+
__version__ = "0.10.0"
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def __getattr__(name: str):
|
|
14
14
|
"""Load the local ipykernel only when a client explicitly requests it."""
|
|
15
15
|
if name == "SuperKernel":
|
|
16
|
-
from
|
|
16
|
+
from superkernel.kernel import SuperKernel
|
|
17
17
|
|
|
18
18
|
return SuperKernel
|
|
19
19
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -31,15 +31,15 @@ from requests.exceptions import (
|
|
|
31
31
|
ConnectionError as RequestsConnectionError,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
|
-
from
|
|
35
|
-
from
|
|
36
|
-
from
|
|
34
|
+
from superkernel import __version__
|
|
35
|
+
from superkernel.logfile import DEFAULT_LOG_FILE, append_log
|
|
36
|
+
from superkernel.schema import (
|
|
37
37
|
CodeExecutionRequest,
|
|
38
38
|
CodeExecutionResumeRequest,
|
|
39
39
|
ControlRequest,
|
|
40
40
|
ControlResponse,
|
|
41
41
|
)
|
|
42
|
-
from
|
|
42
|
+
from superkernel.state import (
|
|
43
43
|
_delete_runtime_status,
|
|
44
44
|
_normalize_gateway_url,
|
|
45
45
|
_read_auth_token,
|
|
@@ -61,7 +61,7 @@ AdmissionState = Literal["idle", "waiting", "admitting", "admitted"]
|
|
|
61
61
|
class SuperKernel(Kernel):
|
|
62
62
|
"""Forward notebook execution to one gateway-provisioned Super Kernel."""
|
|
63
63
|
|
|
64
|
-
implementation = "
|
|
64
|
+
implementation = "superkernel"
|
|
65
65
|
implementation_version = __version__
|
|
66
66
|
language = "python"
|
|
67
67
|
language_version = f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
@@ -120,7 +120,7 @@ class SuperKernel(Kernel):
|
|
|
120
120
|
self._publish_runtime_status()
|
|
121
121
|
self._runtime_status_thread = threading.Thread(
|
|
122
122
|
target=self._runtime_status_heartbeat,
|
|
123
|
-
name=f"
|
|
123
|
+
name=f"superkernel-status-{self.session_id}",
|
|
124
124
|
daemon=True,
|
|
125
125
|
)
|
|
126
126
|
self._runtime_status_thread.start()
|
|
@@ -301,6 +301,11 @@ class SuperKernel(Kernel):
|
|
|
301
301
|
return "completed" if succeeded else "failed", not succeeded
|
|
302
302
|
|
|
303
303
|
if event_type == "error":
|
|
304
|
+
if payload.get("code") == "output_gap":
|
|
305
|
+
self._write_stream(
|
|
306
|
+
"stderr", "[Super Kernel] Output history was trimmed while disconnected. "
|
|
307
|
+
"Execution may still be running; no code was replayed.\n",
|
|
308
|
+
)
|
|
304
309
|
return "failed", True
|
|
305
310
|
|
|
306
311
|
raise RuntimeError(f"Gateway sent unsupported SSE event: {event_type}")
|
|
@@ -442,7 +447,11 @@ class SuperKernel(Kernel):
|
|
|
442
447
|
timeout=(10.0, min(30.0, self.timeout)),
|
|
443
448
|
)
|
|
444
449
|
response.raise_for_status()
|
|
445
|
-
|
|
450
|
+
result = ControlResponse.model_validate(response.json())
|
|
451
|
+
expected = {"restarted"} if action == "restart" else {"interrupted", "idle"}
|
|
452
|
+
if result.kernel_id != self.remote_kernel_id or result.action != action or result.status not in expected:
|
|
453
|
+
raise RuntimeError("Remote control confirmation does not match the request")
|
|
454
|
+
return result
|
|
446
455
|
|
|
447
456
|
def _interrupt_pending_execution(self, execution_id: str) -> None:
|
|
448
457
|
"""Cancel a local wait or best-effort interrupt possible remote work."""
|
|
@@ -578,6 +587,9 @@ class SuperKernel(Kernel):
|
|
|
578
587
|
self._post_control("restart")
|
|
579
588
|
except Exception as exc: # noqa: BLE001 - shutdown must complete
|
|
580
589
|
self._log(f"Super Kernel restart failed: {type(exc).__name__}: {exc}")
|
|
590
|
+
self._write_stream("stderr", "[Super Kernel] Remote restart failed; notebook memory was not confirmed reset. Retry Restart.\n")
|
|
591
|
+
self._set_runtime_status("error")
|
|
592
|
+
return {"status": "error", "restart": False, "ename": "RestartFailed", "evalue": "Remote restart was not confirmed"}
|
|
581
593
|
self._clear_pending_execution()
|
|
582
594
|
try:
|
|
583
595
|
with self._runtime_status_lock:
|
|
@@ -596,7 +608,7 @@ class SuperKernel(Kernel):
|
|
|
596
608
|
|
|
597
609
|
def _build_arg_parser() -> argparse.ArgumentParser:
|
|
598
610
|
parser = argparse.ArgumentParser(
|
|
599
|
-
prog="superkernel",
|
|
611
|
+
prog="python -m superkernel.kernel",
|
|
600
612
|
description="Launch a local Jupyter kernel bound to one Super Kernel ID.",
|
|
601
613
|
)
|
|
602
614
|
parser.add_argument(
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Module/process identity checks without loading the ipykernel."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def is_adapter_invocation(
|
|
10
|
+
arguments: Sequence[str], *, allow_previous: bool = False
|
|
11
|
+
) -> bool:
|
|
12
|
+
"""Recognize the module launcher; old launch forms are cleanup-only."""
|
|
13
|
+
for index in range(len(arguments) - 1):
|
|
14
|
+
if arguments[index] == "-m":
|
|
15
|
+
module = arguments[index + 1]
|
|
16
|
+
if module == "superkernel.kernel":
|
|
17
|
+
return True
|
|
18
|
+
if allow_previous and module in {
|
|
19
|
+
"superkernels.kernel",
|
|
20
|
+
"superkernel_adapter.kernel",
|
|
21
|
+
}:
|
|
22
|
+
return True
|
|
23
|
+
return allow_previous and any(
|
|
24
|
+
Path(executable).is_absolute()
|
|
25
|
+
and Path(executable).name in {"superkernel", "superkernel.exe"}
|
|
26
|
+
for executable in arguments[:2]
|
|
27
|
+
)
|
|
@@ -158,7 +158,7 @@ class CodeExecutionResumeRequest(BaseModel):
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
class ControlRequest(BaseModel):
|
|
161
|
-
"""Body sent by ``
|
|
161
|
+
"""Body sent by ``superkernel.kernel`` to ``POST /kernel/control``."""
|
|
162
162
|
|
|
163
163
|
model_config = ConfigDict(extra="forbid")
|
|
164
164
|
|
{superkernel_adapter-0.9.7 → superkernel_adapter-0.10.0/src/superkernel_adapter.egg-info}/PKG-INFO
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: superkernel-adapter
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
4
4
|
Summary: SuperKernel Adapter: a shared local Jupyter kernel for remote compute.
|
|
5
5
|
Author-email: Leo Li <leoustc@icloud.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
7
7
|
Project-URL: Homepage, https://superkernel.leoustc.com
|
|
8
8
|
Project-URL: Source, https://github.com/leoustc/superkernel/tree/main/superkernel-adapter
|
|
9
|
-
Classifier: Development Status ::
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -56,12 +56,6 @@ SuperKernel Adapter requires Python 3.10 or newer.
|
|
|
56
56
|
uv pip install superkernel-adapter
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Until this renamed distribution is published, install a provided wheel instead:
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
uv pip install superkernel_adapter-0.9.7-py3-none-any.whl
|
|
63
|
-
```
|
|
64
|
-
|
|
65
59
|
The JupyterLab or VS Code SuperKernel integration normally installs and
|
|
66
60
|
configures the notebook kernels for you. A configured kernel can then be
|
|
67
61
|
selected from the standard Jupyter kernel picker like any other kernel.
|
|
@@ -71,7 +65,7 @@ creation, and local kernel registration are handled by a compatible
|
|
|
71
65
|
SuperKernel client integration.
|
|
72
66
|
|
|
73
67
|
The distribution is `superkernel-adapter`, the Python import is
|
|
74
|
-
`
|
|
68
|
+
`superkernel`, the module launcher is `python -m superkernel.kernel`, and the kernel
|
|
75
69
|
class remains `SuperKernel`.
|
|
76
70
|
|
|
77
71
|
## Python API
|
|
@@ -80,21 +74,21 @@ The kernel class is available for integrations that need to inspect or extend
|
|
|
80
74
|
the local runtime:
|
|
81
75
|
|
|
82
76
|
```python
|
|
83
|
-
from
|
|
77
|
+
from superkernel import SuperKernel
|
|
84
78
|
```
|
|
85
79
|
|
|
86
80
|
The supported process entry point for a configured Jupyter kernelspec is:
|
|
87
81
|
|
|
88
82
|
```text
|
|
89
|
-
superkernel
|
|
83
|
+
python -m superkernel.kernel
|
|
90
84
|
```
|
|
91
85
|
|
|
92
86
|
Its connection and authentication arguments are generated by the client
|
|
93
87
|
integration and are not intended to be entered manually.
|
|
94
|
-
Clients use the selected Python environment's absolute
|
|
95
|
-
`/opt/jupyterhub/bin/
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
Clients use the selected Python environment's absolute executable, such as
|
|
89
|
+
`/opt/jupyterhub/bin/python`, followed by `-m superkernel.kernel`. No standalone
|
|
90
|
+
`superkernel` or `sk-adapter` command is installed. Picker labels append
|
|
91
|
+
`(SuperKernel)` while their language remains Python.
|
|
98
92
|
|
|
99
93
|
## Upgrading from superkernels
|
|
100
94
|
|
|
@@ -105,8 +99,8 @@ Restart notebook kernels and reload the VS Code window after installation.
|
|
|
105
99
|
The retired distribution/import has no runtime alias; the root local install
|
|
106
100
|
workflow removes it after installing the new adapter. An already-running old
|
|
107
101
|
process may be recognized only for explicit, identity-checked shutdown.
|
|
108
|
-
The
|
|
109
|
-
|
|
102
|
+
The Python module launches a notebook adapter, not a Gateway or infrastructure
|
|
103
|
+
management CLI. Retired module/console identities are cleanup-only; no import aliases.
|
|
110
104
|
|
|
111
105
|
## Security
|
|
112
106
|
|
|
@@ -125,8 +119,10 @@ read or modify saved user credentials.
|
|
|
125
119
|
|
|
126
120
|
## Project status
|
|
127
121
|
|
|
128
|
-
Version 0.
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
Version 0.10.0 is an alpha release for trusted teams. It hardens restart
|
|
123
|
+
confirmations and reports output replay gaps. It uses the
|
|
124
|
+
`superkernel.kernel` module with no console CLI. The integration contract may
|
|
125
|
+
still evolve before 1.0. Backend source is private and is not distributed in
|
|
126
|
+
this package.
|
|
131
127
|
|
|
132
128
|
Learn more at [superkernel.leoustc.com](https://superkernel.leoustc.com).
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
|
-
src/
|
|
5
|
-
src/
|
|
6
|
-
src/
|
|
7
|
-
src/
|
|
8
|
-
src/
|
|
9
|
-
src/
|
|
4
|
+
src/superkernel/__init__.py
|
|
5
|
+
src/superkernel/kernel.py
|
|
6
|
+
src/superkernel/launcher.py
|
|
7
|
+
src/superkernel/logfile.py
|
|
8
|
+
src/superkernel/schema.py
|
|
9
|
+
src/superkernel/state.py
|
|
10
10
|
src/superkernel_adapter.egg-info/PKG-INFO
|
|
11
11
|
src/superkernel_adapter.egg-info/SOURCES.txt
|
|
12
12
|
src/superkernel_adapter.egg-info/dependency_links.txt
|
|
13
|
-
src/superkernel_adapter.egg-info/entry_points.txt
|
|
14
13
|
src/superkernel_adapter.egg-info/requires.txt
|
|
15
14
|
src/superkernel_adapter.egg-info/top_level.txt
|
|
16
15
|
tests/test_adapter.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
superkernel
|
|
@@ -7,8 +7,8 @@ from concurrent.futures import ThreadPoolExecutor
|
|
|
7
7
|
|
|
8
8
|
import pytest
|
|
9
9
|
|
|
10
|
-
from
|
|
11
|
-
from
|
|
10
|
+
from superkernel import kernel as runtime
|
|
11
|
+
from superkernel import state
|
|
12
12
|
|
|
13
13
|
GATEWAY = "https://example.test"
|
|
14
14
|
|
|
@@ -191,3 +191,50 @@ def test_different_code_preserves_unresolved_handle(adapter):
|
|
|
191
191
|
assert adapter._pending_reply_id == "skr_previous"
|
|
192
192
|
assert adapter._pending_cursor_id == "12-0"
|
|
193
193
|
assert adapter._execution_id("original") == execution_id
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def test_failed_restart_preserves_identity_and_reports_error(adapter):
|
|
197
|
+
identity = adapter._execution_id("original")
|
|
198
|
+
adapter._pending_reply_id = "skr_unresolved"
|
|
199
|
+
adapter._post_control = lambda action: (_ for _ in ()).throw(RuntimeError("offline"))
|
|
200
|
+
response = adapter.do_shutdown(restart=True)
|
|
201
|
+
assert response["status"] == "error"
|
|
202
|
+
assert response["restart"] is False
|
|
203
|
+
assert adapter._pending_execution_id == identity
|
|
204
|
+
assert adapter._pending_reply_id == "skr_unresolved"
|
|
205
|
+
assert adapter._runtime_status == "error"
|
|
206
|
+
assert not adapter._runtime_status_stop.is_set()
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def test_successful_restart_clears_identity_and_status(adapter):
|
|
210
|
+
adapter._execution_id("original")
|
|
211
|
+
adapter._post_control = lambda action: None
|
|
212
|
+
assert adapter.do_shutdown(restart=True) == {"status": "ok", "restart": True}
|
|
213
|
+
assert adapter._pending_execution_id is None
|
|
214
|
+
assert adapter._runtime_status_stop.is_set()
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def test_replay_gap_is_visible_without_success_or_replay(adapter):
|
|
218
|
+
output = []
|
|
219
|
+
adapter._write_stream = lambda name, text: output.append(text)
|
|
220
|
+
status, failed = adapter._handle_sse_frame({"event": "error", "data": '{"code":"output_gap"}'})
|
|
221
|
+
assert status == "failed" and failed
|
|
222
|
+
assert "no code was replayed" in "".join(output)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@pytest.mark.parametrize("field,value", [("kernel_id", "rk_wrong"), ("action", "interrupt"), ("status", "idle")])
|
|
226
|
+
def test_restart_requires_matching_confirmation(adapter, monkeypatch, field, value):
|
|
227
|
+
adapter.control_endpoint = GATEWAY + "/kernel/control"
|
|
228
|
+
adapter.auth_file = "unused-test-auth"
|
|
229
|
+
adapter.timeout = 300
|
|
230
|
+
body = {"kernel_id": adapter.remote_kernel_id, "action": "restart", "status": "restarted"}
|
|
231
|
+
body[field] = value
|
|
232
|
+
monkeypatch.setattr(runtime, "_read_auth_token", lambda *args: "sks_test")
|
|
233
|
+
class Reply:
|
|
234
|
+
def raise_for_status(self):
|
|
235
|
+
pass
|
|
236
|
+
def json(self):
|
|
237
|
+
return body
|
|
238
|
+
monkeypatch.setattr(runtime.requests, "post", lambda *args, **kwargs: Reply())
|
|
239
|
+
with pytest.raises(RuntimeError):
|
|
240
|
+
adapter._post_control("restart")
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Adapter namespace, module entry point and no-console contract."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
from superkernel import launcher
|
|
11
|
+
from superkernel.kernel import SuperKernel, main
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_module_entry_and_class_are_preserved(capsys):
|
|
15
|
+
with pytest.raises(SystemExit) as exit_info:
|
|
16
|
+
main(["--help"])
|
|
17
|
+
assert exit_info.value.code == 0
|
|
18
|
+
assert "usage: python -m superkernel.kernel" in capsys.readouterr().out
|
|
19
|
+
assert SuperKernel.__name__ == "SuperKernel"
|
|
20
|
+
assert SuperKernel.implementation == "superkernel"
|
|
21
|
+
assert SuperKernel.banner.startswith("SuperKernel Adapter")
|
|
22
|
+
with pytest.raises(SystemExit) as exit_info:
|
|
23
|
+
main(["--version"])
|
|
24
|
+
assert exit_info.value.code == 0
|
|
25
|
+
from superkernel import __version__
|
|
26
|
+
assert capsys.readouterr().out.strip() == f"SuperKernel Adapter {__version__}"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_distribution_declares_no_console_entry():
|
|
30
|
+
project = Path(__file__).resolve().parents[1]
|
|
31
|
+
text = (project / "pyproject.toml").read_text()
|
|
32
|
+
assert 'name = "superkernel-adapter"' in text
|
|
33
|
+
assert "[project.scripts]" not in text
|
|
34
|
+
assert not (project / "src" / "superkernels").exists()
|
|
35
|
+
assert not (project / "src" / "superkernel_adapter").exists()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_alpha_release_versions_and_adapter_requirements_are_aligned():
|
|
39
|
+
import json
|
|
40
|
+
import re
|
|
41
|
+
|
|
42
|
+
root = Path(__file__).resolve().parents[2]
|
|
43
|
+
for component in ("superkernel-adapter", "plugins/jupyter-superkernel"):
|
|
44
|
+
metadata = (root / component / "pyproject.toml").read_text()
|
|
45
|
+
assert re.search(r'^version = "0\.10\.0"$', metadata, re.MULTILINE)
|
|
46
|
+
assert "Development Status :: 3 - Alpha" in metadata
|
|
47
|
+
for relative in (
|
|
48
|
+
"plugins/vs-superkernel/package.json",
|
|
49
|
+
"plugins/vs-superkernel/package-lock.json",
|
|
50
|
+
"plugins/jupyter-superkernel/labextension/package.json",
|
|
51
|
+
"plugins/jupyter-superkernel/src/jupyter_superkernel/labextension/package.json",
|
|
52
|
+
):
|
|
53
|
+
assert json.loads((root / relative).read_text())["version"] == "0.10.0"
|
|
54
|
+
jupyter = (root / "plugins/jupyter-superkernel/pyproject.toml").read_text()
|
|
55
|
+
assert '"superkernel-adapter>=0.10.0"' in jupyter
|
|
56
|
+
runtime = (root / "plugins/vs-superkernel/src/pythonRuntime.ts").read_text()
|
|
57
|
+
assert "superkernel-adapter>=0.10.0" in runtime
|
|
58
|
+
assert ">= (0, 10, 0)" in runtime
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_shared_models_still_import_without_ipykernel():
|
|
62
|
+
source = Path(__file__).resolve().parents[1] / "src"
|
|
63
|
+
result = subprocess.run(
|
|
64
|
+
[
|
|
65
|
+
sys.executable,
|
|
66
|
+
"-c",
|
|
67
|
+
"import sys; import superkernel.schema; assert 'ipykernel' not in sys.modules",
|
|
68
|
+
],
|
|
69
|
+
env={**os.environ, "PYTHONPATH": str(source)},
|
|
70
|
+
capture_output=True,
|
|
71
|
+
text=True,
|
|
72
|
+
timeout=15,
|
|
73
|
+
)
|
|
74
|
+
assert result.returncode == 0, result.stderr
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@pytest.mark.parametrize(
|
|
78
|
+
"previous",
|
|
79
|
+
[
|
|
80
|
+
["/env/bin/python", "-m", "superkernels.kernel"],
|
|
81
|
+
["/env/bin/python", "-m", "superkernel_adapter.kernel"],
|
|
82
|
+
["/env/bin/python", "/env/bin/superkernel", "-f", "kernel-a.json"],
|
|
83
|
+
],
|
|
84
|
+
)
|
|
85
|
+
def test_prior_process_identity_is_cleanup_only(previous):
|
|
86
|
+
assert launcher.is_adapter_invocation(
|
|
87
|
+
["/env/bin/python", "-m", "superkernel.kernel"]
|
|
88
|
+
)
|
|
89
|
+
assert not launcher.is_adapter_invocation(previous)
|
|
90
|
+
assert launcher.is_adapter_invocation(previous, allow_previous=True)
|
|
91
|
+
assert not launcher.is_adapter_invocation(
|
|
92
|
+
["/env/bin/python", "/env/bin/not-superkernel"]
|
|
93
|
+
)
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"""Environment-local launcher discovery without loading the ipykernel."""
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
import os
|
|
6
|
-
import sysconfig
|
|
7
|
-
from collections.abc import Sequence
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def adapter_executable() -> Path:
|
|
12
|
-
"""Return this Python environment's installed, executable console script."""
|
|
13
|
-
scripts = sysconfig.get_path("scripts")
|
|
14
|
-
if not scripts:
|
|
15
|
-
raise RuntimeError("Python scripts directory is unavailable")
|
|
16
|
-
launcher = Path(scripts) / ("superkernel.exe" if os.name == "nt" else "superkernel")
|
|
17
|
-
if not launcher.is_file() or not os.access(launcher, os.X_OK):
|
|
18
|
-
raise RuntimeError(
|
|
19
|
-
"Install superkernel-adapter in the selected Python environment"
|
|
20
|
-
)
|
|
21
|
-
return launcher.absolute()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def is_adapter_invocation(
|
|
25
|
-
arguments: Sequence[str], *, allow_previous: bool = False
|
|
26
|
-
) -> bool:
|
|
27
|
-
"""Recognize console processes; previous identities are cleanup-only."""
|
|
28
|
-
for executable in arguments[:2]:
|
|
29
|
-
if Path(executable).is_absolute() and Path(executable).name in {
|
|
30
|
-
"superkernel",
|
|
31
|
-
"superkernel.exe",
|
|
32
|
-
}:
|
|
33
|
-
return True
|
|
34
|
-
if allow_previous:
|
|
35
|
-
# Explicit shutdown of pre-migration adapters only, never a launch alias.
|
|
36
|
-
return any(
|
|
37
|
-
arguments[index] == "-m" and arguments[index + 1] == "superkernels.kernel"
|
|
38
|
-
for index in range(len(arguments) - 1)
|
|
39
|
-
)
|
|
40
|
-
return False
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
superkernel_adapter
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"""Adapter naming, console entry point and environment-local launch contract."""
|
|
2
|
-
|
|
3
|
-
import os
|
|
4
|
-
import subprocess
|
|
5
|
-
import sys
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
|
|
8
|
-
import pytest
|
|
9
|
-
|
|
10
|
-
from superkernel_adapter import launcher
|
|
11
|
-
from superkernel_adapter.kernel import SuperKernel, main
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def test_launcher_is_in_the_selected_environment_scripts_directory(
|
|
15
|
-
monkeypatch, tmp_path
|
|
16
|
-
):
|
|
17
|
-
scripts = tmp_path / "selected-environment" / "bin"
|
|
18
|
-
scripts.mkdir(parents=True)
|
|
19
|
-
executable = scripts / ("superkernel.exe" if os.name == "nt" else "superkernel")
|
|
20
|
-
executable.touch(mode=0o700)
|
|
21
|
-
monkeypatch.setattr(launcher.sysconfig, "get_path", lambda name: str(scripts))
|
|
22
|
-
assert launcher.adapter_executable() == executable
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def test_missing_launcher_fails_closed(monkeypatch, tmp_path):
|
|
26
|
-
monkeypatch.setattr(launcher.sysconfig, "get_path", lambda name: str(tmp_path))
|
|
27
|
-
with pytest.raises(RuntimeError, match="superkernel-adapter"):
|
|
28
|
-
launcher.adapter_executable()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def test_console_name_and_class_are_preserved(capsys):
|
|
32
|
-
with pytest.raises(SystemExit) as exit_info:
|
|
33
|
-
main(["--help"])
|
|
34
|
-
assert exit_info.value.code == 0
|
|
35
|
-
assert "usage: superkernel" in capsys.readouterr().out
|
|
36
|
-
assert SuperKernel.__name__ == "SuperKernel"
|
|
37
|
-
assert SuperKernel.implementation == "superkernel_adapter"
|
|
38
|
-
assert SuperKernel.banner.startswith("SuperKernel Adapter")
|
|
39
|
-
with pytest.raises(SystemExit) as exit_info:
|
|
40
|
-
main(["--version"])
|
|
41
|
-
assert exit_info.value.code == 0
|
|
42
|
-
assert capsys.readouterr().out.startswith("SuperKernel Adapter 0.9.7")
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def test_distribution_declares_one_public_console_entry():
|
|
46
|
-
project = Path(__file__).resolve().parents[1]
|
|
47
|
-
text = (project / "pyproject.toml").read_text()
|
|
48
|
-
assert 'name = "superkernel-adapter"' in text
|
|
49
|
-
assert 'superkernel = "superkernel_adapter.kernel:main"' in text
|
|
50
|
-
assert "sk-adapter =" not in text
|
|
51
|
-
assert not (project / "src" / "superkernels").exists()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def test_shared_models_still_import_without_ipykernel():
|
|
55
|
-
source = Path(__file__).resolve().parents[1] / "src"
|
|
56
|
-
result = subprocess.run(
|
|
57
|
-
[
|
|
58
|
-
sys.executable,
|
|
59
|
-
"-c",
|
|
60
|
-
"import sys; import superkernel_adapter.schema; assert 'ipykernel' not in sys.modules",
|
|
61
|
-
],
|
|
62
|
-
env={**os.environ, "PYTHONPATH": str(source)},
|
|
63
|
-
capture_output=True,
|
|
64
|
-
text=True,
|
|
65
|
-
timeout=15,
|
|
66
|
-
)
|
|
67
|
-
assert result.returncode == 0, result.stderr
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def test_prior_process_identity_is_cleanup_only():
|
|
71
|
-
previous = ["/env/bin/python", "-m", "superkernels.kernel"]
|
|
72
|
-
assert not launcher.is_adapter_invocation(previous)
|
|
73
|
-
assert launcher.is_adapter_invocation(previous, allow_previous=True)
|
|
74
|
-
assert launcher.is_adapter_invocation(
|
|
75
|
-
["/env/bin/python", "/env/bin/superkernel", "-f", "kernel-a.json"]
|
|
76
|
-
)
|
|
77
|
-
assert not launcher.is_adapter_invocation(
|
|
78
|
-
["/env/bin/python", "/env/bin/not-superkernel"]
|
|
79
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|