tuneplane-node 0.3.15__py3-none-any.whl

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.
tuneplane_node/wire.py ADDED
@@ -0,0 +1,85 @@
1
+ """Node wire protocol: JSON encoding of ContainerSpec / ContainerState.
2
+
3
+ Its own module because the daemon (node side) and NodeExecutor (console side) must share one
4
+ codec; two copies of it drift. The protocol carries an explicit version so that a console and a
5
+ node daemon at different versions fail closed instead of guessing.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ from typing import TYPE_CHECKING, Any
10
+
11
+ if TYPE_CHECKING:
12
+ from tuneplane_node.runtime import ContainerSpec, ContainerState
13
+
14
+ #: Wire protocol version. Bumped on a breaking change; both sides check it on every request.
15
+ PROTOCOL = 1
16
+
17
+
18
+ def spec_to_dict(spec: "ContainerSpec") -> dict[str, Any]:
19
+ return {
20
+ "name": spec.name,
21
+ "image": spec.image,
22
+ "command": list(spec.command),
23
+ "env": dict(spec.env),
24
+ "gpus": list(spec.gpus),
25
+ "mounts": [[host, cont, ro] for host, cont, ro in spec.mounts],
26
+ "labels": dict(spec.labels),
27
+ "workdir": spec.workdir,
28
+ "shm_size": spec.shm_size,
29
+ "cpu_limit": spec.cpu_limit,
30
+ "memory_limit": spec.memory_limit,
31
+ "network": spec.network,
32
+ "user": spec.user,
33
+ }
34
+
35
+
36
+ def spec_from_dict(data: dict[str, Any]) -> "ContainerSpec":
37
+ from tuneplane_node.runtime import ContainerSpec
38
+
39
+ return ContainerSpec(
40
+ name=str(data["name"]),
41
+ image=str(data["image"]),
42
+ command=[str(x) for x in data["command"]],
43
+ env={str(k): str(v) for k, v in (data.get("env") or {}).items()},
44
+ gpus=[int(x) for x in (data.get("gpus") or [])],
45
+ mounts=[
46
+ (str(host), str(cont), bool(ro))
47
+ for host, cont, ro in (data.get("mounts") or [])
48
+ ],
49
+ labels={str(k): str(v) for k, v in (data.get("labels") or {}).items()},
50
+ workdir=str(data.get("workdir") or ""),
51
+ shm_size=str(data.get("shm_size") or ""),
52
+ cpu_limit=str(data.get("cpu_limit") or ""),
53
+ memory_limit=str(data.get("memory_limit") or ""),
54
+ network=str(data.get("network") or "host"),
55
+ user=str(data.get("user") or ""),
56
+ )
57
+
58
+
59
+ def state_to_dict(state: "ContainerState") -> dict[str, Any]:
60
+ return {
61
+ "name": state.name,
62
+ "exists": state.exists,
63
+ "status": state.status,
64
+ "exit_code": state.exit_code,
65
+ "labels": dict(state.labels),
66
+ "started_at": state.started_at,
67
+ "finished_at": state.finished_at,
68
+ "oom_killed": state.oom_killed,
69
+ }
70
+
71
+
72
+ def state_from_dict(data: dict[str, Any]) -> "ContainerState":
73
+ from tuneplane_node.runtime import ContainerState
74
+
75
+ exit_code = data.get("exit_code")
76
+ return ContainerState(
77
+ name=str(data["name"]),
78
+ exists=bool(data.get("exists")),
79
+ status=str(data.get("status") or ""),
80
+ exit_code=None if exit_code is None else int(exit_code),
81
+ labels={str(k): str(v) for k, v in (data.get("labels") or {}).items()},
82
+ started_at=str(data.get("started_at") or ""),
83
+ finished_at=str(data.get("finished_at") or ""),
84
+ oom_killed=bool(data.get("oom_killed")),
85
+ )
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.5
2
+ Name: tuneplane-node
3
+ Version: 0.3.15
4
+ Summary: TunePlane node daemon: runs job containers on one machine and reports it to a console.
5
+ License-Expression: AGPL-3.0-only
6
+ Requires-Python: >=3.12
7
+ Requires-Dist: fastapi>=0.110
8
+ Requires-Dist: httpx>=0.28.1
9
+ Requires-Dist: pydantic-settings>=2.0
10
+ Requires-Dist: tuneplane
11
+ Requires-Dist: typer>=0.12
12
+ Requires-Dist: uvicorn>=0.29
@@ -0,0 +1,13 @@
1
+ tuneplane_node/__init__.py,sha256=Byymvzjv-JXH5kbRUcChRlpr1d9fDq69N0DLnqR2w_U,69
2
+ tuneplane_node/allocator.py,sha256=JviCsvpyhEEmk4H6ahZ-dOjlchmgfzccJIb7AFsqh7M,28783
3
+ tuneplane_node/cli.py,sha256=fCTrWz9XygzeBLXARtElPI7PziwmoJxp3Jda_-Btyhg,7272
4
+ tuneplane_node/daemon.py,sha256=n3X0H4TGvGcxTgWLUpao_IAAzMDRJNHq5d67eomND78,25516
5
+ tuneplane_node/inventory.py,sha256=PXcc8qTshbQX0_D-qOqmsmZ8tr7nII8aykP1WtJwyTc,6729
6
+ tuneplane_node/join.py,sha256=Bu9CAvi9VQPso_3IFQ_AnK52_mx3-JC5-7QZU7IOo80,6834
7
+ tuneplane_node/runtime.py,sha256=U4mi0gCvx7LVhU9mAlXKCRuzqhODodF4nNekd1ubRHs,26656
8
+ tuneplane_node/settings.py,sha256=DJd49Ap8HpjRA5k7yl3_bd_MQERtl-pD61I5IwElBek,3541
9
+ tuneplane_node/wire.py,sha256=z8uHfR9Y5e6sraxiNUiAVutwfYjtu-R6hTn1mv_j39k,3058
10
+ tuneplane_node-0.3.15.dist-info/METADATA,sha256=rGCgjON6VXiUH-kI09AEUyNpbEEhXePnLTFsMeW4v9A,391
11
+ tuneplane_node-0.3.15.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
12
+ tuneplane_node-0.3.15.dist-info/entry_points.txt,sha256=Fk7kqMVHU8AzJQN8XUHrQs3cUs2GVd8Pc83jjL1ILRU,58
13
+ tuneplane_node-0.3.15.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tuneplane-node = tuneplane_node.cli:app