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
31 changes: 11 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,29 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [ '3.8', '3.9', '3.10.0', '3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup conda
uses: mamba-org/setup-micromamba@v1
- name: Setup Python
uses: actions/setup-python@v5
with:
init-shell: bash powershell
cache-environment: true
post-cleanup: 'all'
environment-name: test-env
create-args: >-
python=${{ matrix.python-version }}
pip
python-version: ${{ matrix.python-version }}

- name: Install akernel
run: |
micromamba activate test-env
pip install .[test]
pip install . --group test

- name: Check style and types
run: |
micromamba activate test-env
black --check akernel
ruff check akernel
mypy akernel
ruff check --show-fixes
ruff format --check
mypy src

- name: Run tests
run: |
micromamba activate test-env
akernel --help
test -f ${CONDA_PREFIX}/share/jupyter/kernels/akernel/kernel.json
pytest akernel/tests -v --reruns 5
test -f ${pythonLocation}/../share/jupyter/kernels/akernel/kernel.json
pytest -v --reruns 5
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
hooks:
- id: ruff-check
args: [--fix, --show-fixes]
- id: ruff-format
1 change: 0 additions & 1 deletion akernel/__init__.py

This file was deleted.

41 changes: 0 additions & 41 deletions akernel/akernel.py

This file was deleted.

21 changes: 21 additions & 0 deletions plugins/akernel_task/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2025 David Brochart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions plugins/akernel_task/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# fps-akernel-task

An FPS plugin for the kernel task API.
6 changes: 6 additions & 0 deletions plugins/akernel_task/fps_akernel_task/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import importlib.metadata

try:
__version__ = importlib.metadata.version("fps_akernel_task")
except importlib.metadata.PackageNotFoundError:
__version__ = "unknown"
49 changes: 49 additions & 0 deletions plugins/akernel_task/fps_akernel_task/akernel_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from __future__ import annotations

from anyio import TASK_STATUS_IGNORED, create_task_group, sleep_forever
from anyio.abc import TaskStatus
from jupyverse_api.kernel import Kernel as _Kernel

from akernel.kernel import Kernel


class AKernelTask(_Kernel):
def __init__(self, *args, **kwargs):
super().__init__()

async def start(self, *, task_status: TaskStatus[None] = TASK_STATUS_IGNORED) -> None:
async with (
create_task_group() as self.task_group,
self._to_shell_send_stream,
self._to_shell_receive_stream,
self._from_shell_send_stream,
self._from_shell_receive_stream,
self._to_control_send_stream,
self._to_control_receive_stream,
self._from_control_send_stream,
self._from_control_receive_stream,
self._to_stdin_send_stream,
self._to_stdin_receive_stream,
self._from_stdin_send_stream,
self._from_stdin_receive_stream,
self._from_iopub_send_stream,
self._from_iopub_receive_stream,
):
self.kernel = Kernel(
self._to_shell_receive_stream,
self._from_shell_send_stream,
self._to_control_receive_stream,
self._from_control_send_stream,
self._to_stdin_receive_stream,
self._from_stdin_send_stream,
self._from_iopub_send_stream,
)
self.task_group.start_soon(self.kernel.start)
task_status.started()
await sleep_forever()

async def stop(self) -> None:
self.task_group.cancel_scope.cancel()

async def interrupt(self) -> None:
pass
14 changes: 14 additions & 0 deletions plugins/akernel_task/fps_akernel_task/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import annotations

from fps import Module

from jupyverse_api.kernel import KernelFactory
from jupyverse_api.kernels import Kernels

from .akernel_task import AKernelTask


class AKernelTaskModule(Module):
async def prepare(self) -> None:
kernels = await self.get(Kernels)
kernels.register_kernel_factory("akernel", KernelFactory(AKernelTask))
32 changes: 32 additions & 0 deletions plugins/akernel_task/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "fps_akernel_task"
version = "0.1.0"
description = "An FPS plugin for the kernel task API"
keywords = ["jupyter", "server", "fastapi", "plugins"]
requires-python = ">=3.9"
dependencies = [
"jupyverse-api >=0.10.0,<0.11.0",
"anyio",
]

[[project.authors]]
name = "David Brochart"
email = "[email protected]"

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.license]
text = "MIT"

[project.urls]
Homepage = "https://github.com/davidbrochart/akernel"

[project.entry-points]
"fps.modules" = {akernel_task = "fps_akernel_task.main:AKernelTaskModule"}
"jupyverse.modules" = {akernel_task = "fps_akernel_task.main:AKernelTaskModule"}
32 changes: 20 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,35 @@ build-backend = "hatchling.build"

[project]
name = "akernel"
dynamic = ["version"]
version = "0.2.1"
description = "An asynchronous Python Jupyter kernel"
readme = "README.md"
license = {text = "MIT"}
requires-python = ">=3.8"
requires-python = ">=3.9"
authors = [{name = "David Brochart", email = "[email protected]"}]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
keywords = [ "jupyter" ]
dependencies = [
"pyzmq",
"typer >=0.4.0",
"click",
"python-dateutil",
"colorama",
"gast >=0.5.3",
"gast >=0.6.0, <0.7.0",
"comm >=0.1.3,<1",
]

[project.optional-dependencies]
[dependency-groups]
test = [
"mypy",
"ruff",
"black",
"pytest",
"pytest-asyncio",
"pytest-rerunfailures",
Expand All @@ -45,6 +42,12 @@ test = [
"zict",
]

[project.optional-dependencies]
subprocess = [
"zmq-anyio >=0.3.9,<0.4.0",
"typer >=0.4.0",
]

react = [
"ipyx >=0.1.7",
]
Expand All @@ -56,14 +59,19 @@ cache = [
[project.scripts]
akernel = "akernel.akernel:cli"

[tool.hatch.build.targets.wheel]
ignore-vcs = true
packages = ["src/akernel"]

[tool.hatch.build.targets.wheel.shared-data]
"share/jupyter/kernels/akernel/kernel.json" = "share/jupyter/kernels/akernel/kernel.json"

[project.urls]
Homepage = "https://github.com/davidbrochart/akernel"

[tool.hatch.version]
path = "akernel/__init__.py"

[tool.ruff]
line-length = 100
exclude = ["examples"]

[tool.uv.sources]
fps-akernel-task = { workspace = true }
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/akernel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import importlib.metadata

try:
__version__ = importlib.metadata.version("akernel")
except importlib.metadata.PackageNotFoundError:
__version__ = "unknown"
Loading
Loading