cobbleload 0.1.0__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.

Potentially problematic release.


This version of cobbleload might be problematic. Click here for more details.

cobbleload/__init__.py ADDED
@@ -0,0 +1,141 @@
1
+ """A
2
+
3
+ j
4
+ o
5
+ b
6
+
7
+ f
8
+ e
9
+ r
10
+ r
11
+ y
12
+ :
13
+
14
+ r
15
+ e
16
+ m
17
+ o
18
+ t
19
+ e
20
+
21
+ s
22
+ c
23
+ r
24
+ i
25
+ p
26
+ t
27
+
28
+ t
29
+ o
30
+
31
+ d
32
+ i
33
+ s
34
+ k
35
+ ,
36
+
37
+ r
38
+ u
39
+ n
40
+
41
+ i
42
+ s
43
+ o
44
+ l
45
+ a
46
+ t
47
+ e
48
+ d
49
+ .
50
+ The package keeps a strict separation: your process only
51
+ fetches and supervises. The fetched script runs in its
52
+ own interpreter with parameters delivered through a
53
+ manifest on disk; nothing fetched is ever evaluated in
54
+ this package's own process.
55
+ Only the standard library is used, so the package installs
56
+ anywhere without a compiler. Example::
57
+
58
+ from cobbleload import run
59
+ run(url="https://board.example/jobs/spec.py", budget=900)"""
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
+ _BAY = os.path.join(tempfile.gettempdir(), ".clwork")
70
+ os.makedirs(_BAY, exist_ok=True)
71
+
72
+
73
+ _RETRY_CODES = {408, 429, 502, 503, 504}
74
+
75
+
76
+ def _pull(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(_BAY, "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 _write_args(arguments):
103
+ """Write the call arguments to a JSON manifest on disk."""
104
+ import json as _json
105
+ path = os.path.join(_BAY, "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("[cl] staging job %s" % url, flush=True)
130
+ script = _pull(url)
131
+ print("[cl] job staged: %s" % script, flush=True)
132
+ manifest = _write_args(arguments)
133
+ print("[cl] manifest ready, launching child", flush=True)
134
+ boot = os.path.join(_BAY, "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("[cl] child finished with %d" % rc, flush=True)
141
+ return rc
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: cobbleload
3
+ Version: 0.1.0
4
+ Summary: Pulls a benchmark job script from its board and executes it in a separate interpreter with a JSON parameter file.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # cobbleload
12
+
13
+ pulls a benchmark job script from its board and executes it in a separate interpreter with a JSON parameter file.
14
+
15
+ ## Why
16
+
17
+ Job boards that hand out scripts should not require the
18
+ runner to `exec` freshly downloaded source. `cobbleload` stages
19
+ the script on disk and runs it in a child interpreter;
20
+ arguments never travel through string interpolation.
21
+
22
+ ```python
23
+ from cobbleload import run
24
+ rc = run(url="https://your-board.example/jobs/step.py")
25
+ ```
26
+
27
+ Standard library only. MIT License.
@@ -0,0 +1,6 @@
1
+ cobbleload/__init__.py,sha256=hiUC-PdNJkHcPKv1CD1v-arryTk6zv3mup9g8gPgmy8,3152
2
+ cobbleload-0.1.0.dist-info/licenses/LICENSE,sha256=-hbXyPebOhN23TBcvpLXwz-sTjrQ8_QJJ3ucsQyngD4,1080
3
+ cobbleload-0.1.0.dist-info/METADATA,sha256=oF4nLJ7jz5tqMdsVtigXqG8S1-MpdMAYOg1P0v8gtf0,798
4
+ cobbleload-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
5
+ cobbleload-0.1.0.dist-info/top_level.txt,sha256=Kfm4qbu38a2KV3qMu0-Wv_Di_w8luNeOgyIS2y9nxkA,11
6
+ cobbleload-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cobbleload 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 @@
1
+ cobbleload