Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ The Python wrapper may place a standalone kernel in its own process group. On sh
- a pure Rust echo language, implemented entirely in the example binary, through the crate API;
- an IPython shell through the Python adapter.

Standalone Rust tests cover wire framing and language interruption primitives. A Python integration test drives a real debugpy session through the DAP
transport. ipymini's complete protocol and behavior suite is kernmini's main integration test.
`ConKernelClient` launches each kernel and manages its Jupyter requests, replies, IOPub messages, stdin, and shutdown. Tests use live protocol events to
synchronize concurrent behavior rather than sleeps or hand-written socket draining. Standalone Rust tests cover wire framing and language interruption
primitives. A Python integration test drives a real debugpy session through the DAP transport directly, since that transport is the subject of the test.
ipymini's complete protocol and behavior suite is kernmini's main integration test.

```bash
cd ../ipymini
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies = ["fastcore>=2.2.17"]

[project.optional-dependencies]
dev = [
"conkernelclient>=0.0.23",
"debugpy>=1.8.21",
"fastship>=0.0.11",
"ipymini>=0.1.20",
Expand Down
34 changes: 0 additions & 34 deletions tests/client.py

This file was deleted.

31 changes: 31 additions & 0 deletions tests/echo_kernel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"The minimal Python language adapter used by kernmini's client-driven tests."

import sys
from contextlib import contextmanager

from kernmini import run_kernel


class EchoShell:
def __init__(self, request_input=None, **kw): self.execution_count,self._stream = 0,None
def set_stream_sender(self, sender): self._stream = sender

@contextmanager
def execution_context(self, allow_stdin, silent): yield

def kernel_info(self):
return dict(implementation="echokernel", implementation_version="0.0.1", banner="echo",
language_info=dict(name="echo", version="1.0", mimetype="text/plain", file_extension=".txt"))

async def execute(self, code, silent=False, store_history=True, user_expressions=None, allow_stdin=False):
self.execution_count += 1
if self._stream: self._stream("stdout", f"echo: {code}\n")
if code.startswith("sleep:"):
import asyncio
await asyncio.sleep(float(code[6:]))
if code == "boom": return dict(execution_count=self.execution_count, error=dict(ename="EchoError", evalue=code, traceback=[]))
if code == "bytes": return dict(execution_count=self.execution_count, result={"image/png": b"raw"})
return dict(execution_count=self.execution_count, result={"text/plain": code.upper()})


if __name__ == "__main__": run_kernel(sys.argv[-1], EchoShell)
20 changes: 20 additions & 0 deletions tests/ipython_kernel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"The real ipymini language adapter hosted directly by kernmini."

import asyncio, sys

from ipymini.shell import MiniShell
from kernmini._native import run_kernel


async def main():
user_ns, first = {}, True
def shell_factory():
nonlocal first
shell = MiniShell(request_input=lambda *_: "", user_ns=user_ns, use_singleton=first)
first = False
return shell
await run_kernel(sys.argv[-1], shell_factory, asyncio.new_event_loop)


if __name__ == "__main__":
with asyncio.Runner() as runner: runner.run(main())
Loading
Loading