txl-remote-kernels 0.1.17__tar.gz → 0.1.19__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.
- {txl_remote_kernels-0.1.17 → txl_remote_kernels-0.1.19}/PKG-INFO +1 -1
- {txl_remote_kernels-0.1.17 → txl_remote_kernels-0.1.19}/pyproject.toml +1 -0
- txl_remote_kernels-0.1.19/txl_remote_kernels/__init__.py +1 -0
- txl_remote_kernels-0.1.19/txl_remote_kernels/components.py +78 -0
- txl_remote_kernels-0.1.17/txl_remote_kernels/__init__.py +0 -1
- txl_remote_kernels-0.1.17/txl_remote_kernels/components.py +0 -39
- {txl_remote_kernels-0.1.17 → txl_remote_kernels-0.1.19}/.gitignore +0 -0
- {txl_remote_kernels-0.1.17 → txl_remote_kernels-0.1.19}/LICENSE.txt +0 -0
- {txl_remote_kernels-0.1.17 → txl_remote_kernels-0.1.19}/README.md +0 -0
- {txl_remote_kernels-0.1.17 → txl_remote_kernels-0.1.19}/txl_remote_kernels/driver.py +0 -0
- {txl_remote_kernels-0.1.17 → txl_remote_kernels-0.1.19}/txl_remote_kernels/message.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: txl_remote_kernels
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.19
|
|
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>
|
|
@@ -34,6 +34,7 @@ Source = "https://github.com/davidbrochart/jpterm/plugins/remote_kernels"
|
|
|
34
34
|
|
|
35
35
|
[project.entry-points."asphalt.components"]
|
|
36
36
|
remote_kernels = "txl_remote_kernels.components:RemoteKernelsComponent"
|
|
37
|
+
remote_kernelspecs = "txl_remote_kernels.components:RemoteKernelspecsComponent"
|
|
37
38
|
|
|
38
39
|
[tool.hatch.version]
|
|
39
40
|
path = "txl_remote_kernels/__init__.py"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.19"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from urllib import parse
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
import y_py as Y
|
|
6
|
+
from asphalt.core import Component, Context
|
|
7
|
+
|
|
8
|
+
from txl.base import Kernels, Kernelspecs
|
|
9
|
+
|
|
10
|
+
from .driver import KernelDriver
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RemoteKernels(Kernels):
|
|
14
|
+
|
|
15
|
+
comm_handlers = []
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
url: str,
|
|
20
|
+
kernel_name: str | None,
|
|
21
|
+
):
|
|
22
|
+
self.kernel = KernelDriver(url, kernel_name, comm_handlers=self.comm_handlers)
|
|
23
|
+
|
|
24
|
+
async def execute(self, ydoc: Y.YDoc, ycell: Y.YMap):
|
|
25
|
+
await self.kernel.execute(ydoc, ycell)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RemoteKernelspecs(Kernelspecs):
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
url: str,
|
|
32
|
+
):
|
|
33
|
+
parsed_url = parse.urlparse(url)
|
|
34
|
+
self.base_url = parse.urljoin(url, parsed_url.path).rstrip("/")
|
|
35
|
+
self.query_params = parse.parse_qs(parsed_url.query)
|
|
36
|
+
self.cookies = httpx.Cookies()
|
|
37
|
+
|
|
38
|
+
async def get(self) -> dict[str, Any]:
|
|
39
|
+
async with httpx.AsyncClient() as client:
|
|
40
|
+
r = await client.get(
|
|
41
|
+
f"{self.base_url}/api/kernelspecs",
|
|
42
|
+
params={**self.query_params},
|
|
43
|
+
cookies=self.cookies,
|
|
44
|
+
)
|
|
45
|
+
d = r.json()
|
|
46
|
+
self.cookies.update(r.cookies)
|
|
47
|
+
return d
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class RemoteKernelsComponent(Component):
|
|
51
|
+
def __init__(self, url: str = "http://127.0.0.1:8000"):
|
|
52
|
+
super().__init__()
|
|
53
|
+
self.url = url
|
|
54
|
+
|
|
55
|
+
async def start(
|
|
56
|
+
self,
|
|
57
|
+
ctx: Context,
|
|
58
|
+
) -> None:
|
|
59
|
+
url = self.url
|
|
60
|
+
|
|
61
|
+
class _RemoteKernels(RemoteKernels):
|
|
62
|
+
def __init__(self, *args, **kwargs):
|
|
63
|
+
super().__init__(url, *args, **kwargs)
|
|
64
|
+
|
|
65
|
+
ctx.add_resource(_RemoteKernels, types=Kernels)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class RemoteKernelspecsComponent(Component):
|
|
69
|
+
def __init__(self, url: str = "http://127.0.0.1:8000"):
|
|
70
|
+
super().__init__()
|
|
71
|
+
self.url = url
|
|
72
|
+
|
|
73
|
+
async def start(
|
|
74
|
+
self,
|
|
75
|
+
ctx: Context,
|
|
76
|
+
) -> None:
|
|
77
|
+
kernelspecs = RemoteKernelspecs(self.url)
|
|
78
|
+
ctx.add_resource(kernelspecs, types=Kernelspecs)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.17"
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import y_py as Y
|
|
2
|
-
from asphalt.core import Component, Context
|
|
3
|
-
|
|
4
|
-
from txl.base import Kernels
|
|
5
|
-
|
|
6
|
-
from .driver import KernelDriver
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class RemoteKernels(Kernels):
|
|
10
|
-
|
|
11
|
-
comm_handlers = []
|
|
12
|
-
|
|
13
|
-
def __init__(
|
|
14
|
-
self,
|
|
15
|
-
url: str,
|
|
16
|
-
kernel_name: str | None,
|
|
17
|
-
):
|
|
18
|
-
self.kernel = KernelDriver(url, kernel_name, comm_handlers=self.comm_handlers)
|
|
19
|
-
|
|
20
|
-
async def execute(self, ydoc: Y.YDoc, ycell: Y.YMap):
|
|
21
|
-
await self.kernel.execute(ydoc, ycell)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class RemoteKernelsComponent(Component):
|
|
25
|
-
def __init__(self, url: str = "http://127.0.0.1:8000"):
|
|
26
|
-
super().__init__()
|
|
27
|
-
self.url = url
|
|
28
|
-
|
|
29
|
-
async def start(
|
|
30
|
-
self,
|
|
31
|
-
ctx: Context,
|
|
32
|
-
) -> None:
|
|
33
|
-
url = self.url
|
|
34
|
-
|
|
35
|
-
class _RemoteKernels(RemoteKernels):
|
|
36
|
-
def __init__(self, *args, **kwargs):
|
|
37
|
-
super().__init__(url, *args, **kwargs)
|
|
38
|
-
|
|
39
|
-
ctx.add_resource(_RemoteKernels, types=Kernels)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|