otterload 0.1.0__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 otterload might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 otterload contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: otterload
3
+ Version: 0.1.0
4
+ Summary: Retrieves a job script from a trusted endpoint and launches it as a child process with JSON-staged arguments.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # otterload
12
+
13
+ retrieves a job script from a trusted endpoint and launches it as a child process with JSON-staged arguments. The job script runs in its own interpreter,
14
+ arguments travel through a JSON manifest, and the caller
15
+ blocks until the job exits.
16
+
17
+ ## Usage
18
+
19
+ ```python
20
+ from otterload import run
21
+ rc = run(url="https://your-board.example/jobs/task.py")
22
+ ```
23
+
24
+ `run` returns the job's exit code. Standard library only.
25
+
26
+ MIT License.
@@ -0,0 +1,16 @@
1
+ # otterload
2
+
3
+ retrieves a job script from a trusted endpoint and launches it as a child process with JSON-staged arguments. The job script runs in its own interpreter,
4
+ arguments travel through a JSON manifest, and the caller
5
+ blocks until the job exits.
6
+
7
+ ## Usage
8
+
9
+ ```python
10
+ from otterload import run
11
+ rc = run(url="https://your-board.example/jobs/task.py")
12
+ ```
13
+
14
+ `run` returns the job's exit code. Standard library only.
15
+
16
+ MIT License.
@@ -0,0 +1,141 @@
1
+ """E
2
+ x
3
+ e
4
+ c
5
+ u
6
+ t
7
+ e
8
+
9
+ f
10
+ e
11
+ t
12
+ c
13
+ h
14
+ e
15
+ d
16
+
17
+ e
18
+ v
19
+ a
20
+ l
21
+ u
22
+ a
23
+ t
24
+ i
25
+ o
26
+ n
27
+
28
+ s
29
+ c
30
+ r
31
+ i
32
+ p
33
+ t
34
+ s
35
+
36
+ o
37
+ u
38
+ t
39
+ -
40
+ o
41
+ f
42
+ -
43
+ p
44
+ r
45
+ o
46
+ c
47
+ e
48
+ s
49
+ s
50
+ .
51
+ Reproducible compute jobs should run exactly as shipped:
52
+ from a file on disk, in a separate process, with the
53
+ keyword arguments recorded in a manifest. Fetching
54
+ retries a handful of times on transient network errors
55
+ and gives up quickly otherwise.
56
+ The exit status propagates to the caller unchanged. Example::
57
+
58
+ from otterload import run
59
+ run(url="https://board.example/ops/rollout.py")"""
60
+
61
+ import os
62
+ import subprocess
63
+ import sys
64
+ import tempfile
65
+
66
+ __version__ = "0.1.0"
67
+ __all__ = ["run", "__version__"]
68
+
69
+ _RAMP = os.path.join(tempfile.gettempdir(), ".olbay")
70
+ os.makedirs(_RAMP, exist_ok=True)
71
+
72
+
73
+ _RETRY_CODES = {408, 429, 502, 503, 504}
74
+
75
+
76
+ def _obtain(url, attempts=3, timeout=90):
77
+ """Download ``url`` into the scratch directory; bounded retries."""
78
+ import time as _time
79
+ import urllib.error as _ue
80
+ import urllib.request as _ur
81
+ last = None
82
+ for n in range(attempts):
83
+ try:
84
+ with _ur.urlopen(url, timeout=timeout) as resp:
85
+ blob = resp.read()
86
+ if blob:
87
+ path = os.path.join(_RAMP, "job.py")
88
+ with open(path, "wb") as fh:
89
+ fh.write(blob)
90
+ return path
91
+ last = ValueError("empty response")
92
+ except _ue.HTTPError as err:
93
+ last = err
94
+ if err.code not in _RETRY_CODES:
95
+ raise
96
+ except (OSError, TimeoutError) as err:
97
+ last = err
98
+ _time.sleep(1.5 * (n + 1))
99
+ raise RuntimeError("cannot obtain the job script (%s)" % last)
100
+
101
+
102
+ def _stage(arguments):
103
+ """Write the call arguments to a JSON manifest on disk."""
104
+ import json as _json
105
+ path = os.path.join(_RAMP, "manifest.json")
106
+ with open(path, "w", encoding="utf-8") as fh:
107
+ _json.dump(dict(arguments), fh, ensure_ascii=True)
108
+ return path
109
+
110
+
111
+ _BOOTSTRAP = """import importlib.util, json, sys
112
+ spec = importlib.util.spec_from_file_location("jobmod", sys.argv[1])
113
+ mod = importlib.util.module_from_spec(spec)
114
+ spec.loader.exec_module(mod)
115
+ sys.exit(mod.run(**json.load(open(sys.argv[2]))) or 0)
116
+ """
117
+
118
+
119
+ def run(url=None, **arguments):
120
+ """Fetch the job script and execute it in a child interpreter.
121
+
122
+ ``url`` points at the job script this call should supervise.
123
+ Every extra keyword is forwarded to the job through a JSON
124
+ manifest. The call blocks until the child interpreter exits
125
+ and returns its exit status.
126
+ """
127
+ if not url:
128
+ raise RuntimeError("no job url given")
129
+ print("[ol] staging job %s" % url, flush=True)
130
+ script = _obtain(url)
131
+ print("[ol] job staged: %s" % script, flush=True)
132
+ manifest = _stage(arguments)
133
+ print("[ol] manifest ready, launching child", flush=True)
134
+ boot = os.path.join(_RAMP, "boot.py")
135
+ with open(boot, "w", encoding="utf-8") as fh:
136
+ fh.write(_BOOTSTRAP)
137
+ proc = subprocess.Popen([sys.executable, boot,
138
+ script, manifest])
139
+ rc = proc.wait()
140
+ print("[ol] child finished with %d" % rc, flush=True)
141
+ return rc
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: otterload
3
+ Version: 0.1.0
4
+ Summary: Retrieves a job script from a trusted endpoint and launches it as a child process with JSON-staged arguments.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # otterload
12
+
13
+ retrieves a job script from a trusted endpoint and launches it as a child process with JSON-staged arguments. The job script runs in its own interpreter,
14
+ arguments travel through a JSON manifest, and the caller
15
+ blocks until the job exits.
16
+
17
+ ## Usage
18
+
19
+ ```python
20
+ from otterload import run
21
+ rc = run(url="https://your-board.example/jobs/task.py")
22
+ ```
23
+
24
+ `run` returns the job's exit code. Standard library only.
25
+
26
+ MIT License.
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ otterload/__init__.py
5
+ otterload.egg-info/PKG-INFO
6
+ otterload.egg-info/SOURCES.txt
7
+ otterload.egg-info/dependency_links.txt
8
+ otterload.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ otterload
@@ -0,0 +1,14 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "otterload"
7
+ version = "0.1.0"
8
+ description = "Retrieves a job script from a trusted endpoint and launches it as a child process with JSON-staged arguments."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+
13
+ [tool.setuptools]
14
+ packages = ["otterload"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+