workbox 0.2.1__tar.gz → 0.2.2__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.
- {workbox-0.2.1 → workbox-0.2.2}/PKG-INFO +1 -1
- {workbox-0.2.1 → workbox-0.2.2}/pyproject.toml +3 -3
- {workbox-0.2.1 → workbox-0.2.2}/workbox/box.py +1 -2
- {workbox-0.2.1 → workbox-0.2.2}/workbox/runner.py +0 -21
- workbox-0.2.2/workbox/start.py +44 -0
- {workbox-0.2.1 → workbox-0.2.2}/.gitignore +0 -0
- {workbox-0.2.1 → workbox-0.2.2}/README.md +0 -0
- {workbox-0.2.1 → workbox-0.2.2}/workbox/__init__.py +0 -0
- {workbox-0.2.1 → workbox-0.2.2}/workbox/cli.py +0 -0
- {workbox-0.2.1 → workbox-0.2.2}/workbox/gateway.py +0 -0
- {workbox-0.2.1 → workbox-0.2.2}/workbox/ws.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "workbox"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2"
|
|
4
4
|
description = "Workbox: SSH into your GPU boxes, and log metrics and samples from training jobs."
|
|
5
5
|
requires-python = ">=3.10"
|
|
6
6
|
readme = "README.md"
|
|
@@ -13,8 +13,8 @@ dependencies = []
|
|
|
13
13
|
|
|
14
14
|
[project.scripts]
|
|
15
15
|
workbox = "workbox.cli:main"
|
|
16
|
-
workbox-runner = "workbox.runner
|
|
17
|
-
workbox-box = "workbox.box
|
|
16
|
+
workbox-runner = "workbox.start:runner"
|
|
17
|
+
workbox-box = "workbox.start:box"
|
|
18
18
|
|
|
19
19
|
[build-system]
|
|
20
20
|
requires = ["hatchling"]
|
|
@@ -20,7 +20,7 @@ from pathlib import Path
|
|
|
20
20
|
from typing import Any
|
|
21
21
|
|
|
22
22
|
from workbox.gateway import Gateway, Tool
|
|
23
|
-
from workbox.runner import Workbox,
|
|
23
|
+
from workbox.runner import Workbox, download, fetch_input, gpu_metrics, sh, upload
|
|
24
24
|
|
|
25
25
|
HOME = Path.home()
|
|
26
26
|
WORK = HOME / "work"
|
|
@@ -259,7 +259,6 @@ def main() -> None:
|
|
|
259
259
|
if len(sys.argv) == 3 and sys.argv[1] == "input":
|
|
260
260
|
fetch_input(sys.argv[2], Log())
|
|
261
261
|
return
|
|
262
|
-
become_learner()
|
|
263
262
|
asyncio.run(agent())
|
|
264
263
|
|
|
265
264
|
|
|
@@ -41,26 +41,6 @@ MAX_REPORT_SAMPLES = 50
|
|
|
41
41
|
TENSORBOARD_SCAN_SECONDS = 10
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
def become_learner() -> None:
|
|
45
|
-
"""Some providers (Modal) start the container as root whatever the image's USER says. Everything a person uses
|
|
46
|
-
runs as `learner`, so files they make in Jupyter are theirs over SSH too: as root, hand the home folder to
|
|
47
|
-
learner and drop to it, before anything else starts."""
|
|
48
|
-
if os.name != "posix" or os.geteuid() != 0:
|
|
49
|
-
return
|
|
50
|
-
import pwd
|
|
51
|
-
|
|
52
|
-
try:
|
|
53
|
-
user = pwd.getpwnam("learner")
|
|
54
|
-
except KeyError:
|
|
55
|
-
return
|
|
56
|
-
subprocess.run(["chown", "-R", f"{user.pw_uid}:{user.pw_gid}", user.pw_dir], check=False)
|
|
57
|
-
os.setgroups([])
|
|
58
|
-
os.setgid(user.pw_gid)
|
|
59
|
-
os.setuid(user.pw_uid)
|
|
60
|
-
os.environ.update(HOME=user.pw_dir, USER=user.pw_name, LOGNAME=user.pw_name)
|
|
61
|
-
os.chdir(user.pw_dir)
|
|
62
|
-
|
|
63
|
-
|
|
64
44
|
class Failure(Exception):
|
|
65
45
|
"""A failure the runner can name (specs/jobs.md §9): Workbox turns its kind into advice."""
|
|
66
46
|
|
|
@@ -507,7 +487,6 @@ def attach(gateway: dict[str, Any]) -> None:
|
|
|
507
487
|
|
|
508
488
|
|
|
509
489
|
def main() -> None:
|
|
510
|
-
become_learner()
|
|
511
490
|
workbox = Workbox()
|
|
512
491
|
output = Output()
|
|
513
492
|
events = Events()
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Where `workbox-runner` and `workbox-box` start (specs/boxes.md §5).
|
|
2
|
+
|
|
3
|
+
Some providers (Modal) start the container as root, with HOME=/root, whatever the image's USER says. Everything a
|
|
4
|
+
person uses runs as `learner`, so files they make in Jupyter are theirs over SSH too. The runner and the agent work
|
|
5
|
+
out their paths (~/work, ~/.workbox) when they are imported, so this drops to learner first, and only then imports
|
|
6
|
+
them. Standard library only.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import subprocess
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def become_learner() -> None:
|
|
16
|
+
"""As root, hand the learner's home folder to them and drop to them, with their HOME."""
|
|
17
|
+
if os.name != "posix" or os.geteuid() != 0:
|
|
18
|
+
return
|
|
19
|
+
import pwd
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
user = pwd.getpwnam("learner")
|
|
23
|
+
except KeyError:
|
|
24
|
+
return
|
|
25
|
+
subprocess.run(["chown", "-R", f"{user.pw_uid}:{user.pw_gid}", user.pw_dir], check=False)
|
|
26
|
+
os.setgroups([])
|
|
27
|
+
os.setgid(user.pw_gid)
|
|
28
|
+
os.setuid(user.pw_uid)
|
|
29
|
+
os.environ.update(HOME=user.pw_dir, USER=user.pw_name, LOGNAME=user.pw_name)
|
|
30
|
+
os.chdir(user.pw_dir)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def runner() -> None:
|
|
34
|
+
become_learner()
|
|
35
|
+
from workbox.runner import main
|
|
36
|
+
|
|
37
|
+
main()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def box() -> None:
|
|
41
|
+
become_learner()
|
|
42
|
+
from workbox.box import main
|
|
43
|
+
|
|
44
|
+
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|