txl-remote-kernels 0.1.24__tar.gz → 0.2.1__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 txl-remote-kernels might be problematic. Click here for more details.

@@ -0,0 +1,3 @@
1
+ __pycache__
2
+ # pixi environments
3
+ .pixi
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txl_remote_kernels
3
- Version: 0.1.24
3
+ Version: 0.2.1
4
4
  Summary: TXL plugin for remote kernels
5
5
  Project-URL: Source, https://github.com/davidbrochart/jpterm/plugins/remote_kernels
6
6
  Author-email: David Brochart <david.brochart@gmail.com>
@@ -10,14 +10,15 @@ Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Programming Language :: Python
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
13
14
  Classifier: Programming Language :: Python :: Implementation :: CPython
14
15
  Classifier: Programming Language :: Python :: Implementation :: PyPy
15
16
  Requires-Python: >=3.10
16
17
  Requires-Dist: httpx-ws>=0.4.2
17
18
  Requires-Dist: httpx>=0.23.1
19
+ Requires-Dist: pycrdt<0.8.0,>=0.7.2
18
20
  Requires-Dist: txl
19
21
  Requires-Dist: txl-kernel
20
- Requires-Dist: y-py<1,>=0.6.0
21
22
  Description-Content-Type: text/markdown
22
23
 
23
24
  # TXL plugin for remote kernels
@@ -17,6 +17,7 @@ classifiers = [
17
17
  "Programming Language :: Python",
18
18
  "Programming Language :: Python :: 3.10",
19
19
  "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
20
21
  "Programming Language :: Python :: Implementation :: CPython",
21
22
  "Programming Language :: Python :: Implementation :: PyPy",
22
23
  ]
@@ -25,16 +26,16 @@ dependencies = [
25
26
  "txl_kernel",
26
27
  "httpx >=0.23.1",
27
28
  "httpx-ws >=0.4.2",
28
- "y-py >=0.6.0,<1",
29
+ "pycrdt >=0.7.2,<0.8.0",
29
30
  ]
30
31
  dynamic = ["version"]
31
32
 
32
33
  [project.urls]
33
34
  Source = "https://github.com/davidbrochart/jpterm/plugins/remote_kernels"
34
35
 
35
- [project.entry-points."asphalt.components"]
36
- remote_kernels = "txl_remote_kernels.components:RemoteKernelsComponent"
37
- remote_kernelspecs = "txl_remote_kernels.components:RemoteKernelspecsComponent"
36
+ [project.entry-points]
37
+ "asphalt.components" = {remote_kernels = "txl_remote_kernels.components:RemoteKernelsComponent", remote_kernelspecs = "txl_remote_kernels.components:RemoteKernelspecsComponent"}
38
+ "txl.components" = {remote_kernels = "txl_remote_kernels.components:RemoteKernelsComponent", remote_kernelspecs = "txl_remote_kernels.components:RemoteKernelspecsComponent"}
38
39
 
39
40
  [tool.hatch.version]
40
41
  path = "txl_remote_kernels/__init__.py"
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"
@@ -1,9 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  from typing import Any
2
4
  from urllib import parse
3
5
 
4
6
  import httpx
5
- import y_py as Y
6
7
  from asphalt.core import Component, Context
8
+ from pycrdt import Map
7
9
 
8
10
  from txl.base import Kernels, Kernelspecs
9
11
 
@@ -20,8 +22,8 @@ class RemoteKernels(Kernels):
20
22
  ):
21
23
  self.kernel = KernelDriver(url, kernel_name, comm_handlers=self.comm_handlers)
22
24
 
23
- async def execute(self, ydoc: Y.YDoc, ycell: Y.YMap):
24
- await self.kernel.execute(ydoc, ycell)
25
+ async def execute(self, ycell: Map):
26
+ await self.kernel.execute(ycell)
25
27
 
26
28
 
27
29
  class RemoteKernelspecs(Kernelspecs):
@@ -35,15 +37,19 @@ class RemoteKernelspecs(Kernelspecs):
35
37
  self.cookies = httpx.Cookies()
36
38
 
37
39
  async def get(self) -> dict[str, Any]:
38
- async with httpx.AsyncClient() as client:
39
- r = await client.get(
40
- f"{self.base_url}/api/kernelspecs",
41
- params={**self.query_params},
42
- cookies=self.cookies,
43
- )
44
- d = r.json()
45
- self.cookies.update(r.cookies)
46
- return d
40
+ url = f"{self.base_url}/api/kernelspecs"
41
+ try:
42
+ async with httpx.AsyncClient() as client:
43
+ r = await client.get(
44
+ url,
45
+ params={**self.query_params},
46
+ cookies=self.cookies,
47
+ )
48
+ d = r.json()
49
+ self.cookies.update(r.cookies)
50
+ return d
51
+ except httpx.ConnectError:
52
+ raise RuntimeError(f"Could not connect to a Jupyter server at {url}")
47
53
 
48
54
 
49
55
  class RemoteKernelsComponent(Component):
@@ -43,6 +43,7 @@ class KernelDriver(KernelMixin):
43
43
  self.control_channel = "control"
44
44
  self.iopub_channel = "iopub"
45
45
  self.send_lock = asyncio.Lock()
46
+ self.kernel_id = None
46
47
 
47
48
  async def start(self):
48
49
  i = str(uuid.uuid4())
@@ -62,15 +63,15 @@ class KernelDriver(KernelMixin):
62
63
  d = r.json()
63
64
  self.cookies.update(r.cookies)
64
65
  self.session_id = d["id"]
65
- kernel_id = d["kernel"]["id"]
66
+ self.kernel_id = d["kernel"]["id"]
66
67
  r = await client.get(
67
- f"{self.base_url}/api/kernels/{kernel_id}",
68
+ f"{self.base_url}/api/kernels/{self.kernel_id}",
68
69
  cookies=self.cookies,
69
70
  )
70
- if r.status_code != 200 or kernel_id != r.json()["id"]:
71
+ if r.status_code != 200 or self.kernel_id != r.json()["id"]:
71
72
  return
72
73
  async with aconnect_ws(
73
- f"{self.ws_url}/api/kernels/{kernel_id}/channels",
74
+ f"{self.ws_url}/api/kernels/{self.kernel_id}/channels",
74
75
  params={"session_id": self.session_id},
75
76
  cookies=self.cookies,
76
77
  subprotocols=["v1.kernel.websocket.jupyter.org"],
@@ -1 +0,0 @@
1
- __pycache__
@@ -1 +0,0 @@
1
- __version__ = "0.1.24"