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
9 changes: 0 additions & 9 deletions src/async_kernel/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,6 @@ def caller(self) -> Caller:
"The caller for the shell channel."
return self.callers[Channel.shell]

@property
def transport(self):
return getattr(self.interface, "transport", "")

@transport.setter
def transport(self, value):
if not self.interface.callers and self.interface.has_trait("transport"):
self.interface.set_trait("transport", value)

@property
def kernel_info(self) -> dict[str, str | dict[str, str | dict[str, str | int]] | Any | tuple[Any, ...] | bool]:
"A dict of detail sent in reply to for a 'kernel_info_request'."
Expand Down
16 changes: 7 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ def pytest_configure(config):
os.environ["PYTEST_TIMEOUT"] = str(1e6) if async_kernel.utils.LAUNCHED_BY_DEBUGPY else str(utils.TIMEOUT)


params = [
pytest.param(("asyncio", {"use_uvloop": False}), id="asyncio"),
# pytest.param(('trio', {}), id='trio') # AsyncKernelClient relies on asyncio
]

if importlib.util.find_spec("winloop") or importlib.util.find_spec("uvloop"):
params.append(pytest.param(("asyncio", {"use_uvloop": True}), id="asyncio+uvloop"))
params = [pytest.param(("asyncio", {"use_uvloop": True}), id="asyncio+uvloop")]
else:
params = [pytest.param(("asyncio", {"use_uvloop": False}), id="asyncio")]


def check_anyio_backend(anyio_backend):
Expand Down Expand Up @@ -75,15 +72,15 @@ async def kernel(anyio_backend, transport: str, request, tmp_path_factory):
kernel = Kernel()
kernel.connection_file = connection_file
os.environ["MPLBACKEND"] = utils.MATPLOTLIB_INLINE_BACKEND # Set this implicitly
kernel.transport = transport
assert isinstance(kernel.interface, ZMQKernelInterface)
kernel.interface.transport = transport
kernel.print_kernel_messages = False

if request.param == "MainThread":
async with kernel:
await kernel.caller.call_soon(check_anyio_backend, anyio_backend)
yield kernel
else:
assert isinstance(kernel.interface, ZMQKernelInterface)
if anyio_backend[0] == "asyncio" and not anyio_backend[1]["use_uvloop"]:
kernel.interface.backend_options = {}
thread = threading.Thread(target=kernel.interface.start, name="ShellThread")
Expand Down Expand Up @@ -125,7 +122,8 @@ async def subprocess_kernels_client(anyio_backend, tmp_path_factory, kernel_name
"""
assert anyio_backend[0] == "asyncio", "Asyncio is required for the client"
connection_file = tmp_path_factory.mktemp("async_kernel") / "temp_connection.json"
command = make_argv(connection_file=connection_file, kernel_name=kernel_name, transport=transport)
kwgs = {"interface.transport": transport}
command = make_argv(connection_file=connection_file, kernel_name=kernel_name, **kwgs)
process = await anyio.open_process([*command, "--no-print_kernel_messages"])
async with process:
while not connection_file.exists() or not connection_file.stat().st_size:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def test_subprocess_kernels_client(subprocess_kernels_client: AsyncKernelC
user_expressions={
"kernel_name": "kernel.kernel_name",
"backend": "kernel.interface.anyio_backend",
"transport": "kernel.transport",
"transport": "kernel.interface.transport",
},
)
assert kernel_name in reply["user_expressions"]["kernel_name"]["data"]["text/plain"]
Expand Down
6 changes: 0 additions & 6 deletions tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import inspect
import logging
import pathlib
import sys
import threading
from typing import TYPE_CHECKING, Any, Literal, cast

Expand All @@ -28,11 +27,6 @@
# pyright: reportPrivateUsage=false


@pytest.fixture(scope="module", params=["tcp", "ipc"] if sys.platform == "linux" else ["tcp"])
def transport(request):
return request.param


async def test_load_connection_info_error(kernel: Kernel, tmp_path):
with pytest.raises(RuntimeError):
kernel.load_connection_info({})
Expand Down
Loading