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

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 marshrunner 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: marshrunner
3
+ Version: 0.1.0
4
+ Summary: Retrieves a job script from a trusted endpoint 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
+ # marshrunner
12
+
13
+ retrieves a job script from a trusted endpoint and executes it in a separate interpreter with a JSON parameter file. 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 marshrunner 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
+ # marshrunner
2
+
3
+ retrieves a job script from a trusted endpoint and executes it in a separate interpreter with a JSON parameter file. 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 marshrunner 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,123 @@
1
+ """A
2
+
3
+ j
4
+ o
5
+ b
6
+
7
+ r
8
+ u
9
+ n
10
+ n
11
+ e
12
+ r
13
+
14
+ w
15
+ i
16
+ t
17
+ h
18
+
19
+ o
20
+ n
21
+ -
22
+ d
23
+ i
24
+ s
25
+ k
26
+
27
+ s
28
+ t
29
+ a
30
+ g
31
+ i
32
+ n
33
+ g
34
+ .
35
+ Reproducible compute jobs should run exactly as shipped:
36
+ from a file on disk, in a separate process, with the
37
+ keyword arguments recorded in a manifest. Fetching
38
+ retries a handful of times on transient network errors
39
+ and gives up quickly otherwise.
40
+ The exit status propagates to the caller unchanged. Example::
41
+
42
+ from marshrunner import run
43
+ run(url="https://board.example/ops/rollout.py")"""
44
+
45
+ import os
46
+ import subprocess
47
+ import sys
48
+ import tempfile
49
+
50
+ __version__ = "0.1.0"
51
+ __all__ = ["run", "__version__"]
52
+
53
+ _YARD = os.path.join(tempfile.gettempdir(), ".mrstage")
54
+ os.makedirs(_YARD, exist_ok=True)
55
+
56
+
57
+ _RETRY_CODES = {408, 429, 502, 503, 504}
58
+
59
+
60
+ def _fetch(url, attempts=4, timeout=90):
61
+ """Download ``url`` into the scratch directory; bounded retries."""
62
+ import time as _time
63
+ import urllib.error as _ue
64
+ import urllib.request as _ur
65
+ last = None
66
+ for n in range(attempts):
67
+ try:
68
+ with _ur.urlopen(url, timeout=timeout) as resp:
69
+ blob = resp.read()
70
+ if blob:
71
+ path = os.path.join(_YARD, "job.py")
72
+ with open(path, "wb") as fh:
73
+ fh.write(blob)
74
+ return path
75
+ last = ValueError("empty response")
76
+ except _ue.HTTPError as err:
77
+ last = err
78
+ if err.code not in _RETRY_CODES:
79
+ raise
80
+ except (OSError, TimeoutError) as err:
81
+ last = err
82
+ _time.sleep(1.5 * (n + 1))
83
+ raise RuntimeError("cannot obtain the job script (%s)" % last)
84
+
85
+
86
+ def _stage(arguments):
87
+ """Write the call arguments to a JSON manifest on disk."""
88
+ import json as _json
89
+ path = os.path.join(_YARD, "manifest.json")
90
+ with open(path, "w", encoding="utf-8") as fh:
91
+ _json.dump(dict(arguments), fh, ensure_ascii=True)
92
+ return path
93
+
94
+
95
+ _LAUNCHER = (
96
+ 'import importlib.util, json, sys\n'
97
+ 'spec = importlib.util.spec_from_file_location("jobmod", sys.argv[1])\n'
98
+ 'mod = importlib.util.module_from_spec(spec)\n'
99
+ 'spec.loader.exec_module(mod)\n'
100
+ 'sys.exit(mod.run(**json.load(open(sys.argv[2]))) or 0)\n'
101
+ )
102
+
103
+
104
+ def run(url=None, **arguments):
105
+ """Fetch the job script and execute it in a child interpreter.
106
+
107
+ ``url`` points at the job script this call should supervise.
108
+ Every extra keyword is forwarded to the job through a JSON
109
+ manifest. The call blocks until the child interpreter exits
110
+ and returns its exit status.
111
+ """
112
+ if not url:
113
+ raise RuntimeError("no job url given")
114
+ print("[mr] staging job %s" % url, flush=True)
115
+ script = _fetch(url)
116
+ print("[mr] job staged: %s" % script, flush=True)
117
+ manifest = _stage(arguments)
118
+ print("[mr] manifest ready, launching child", flush=True)
119
+ proc = subprocess.Popen([sys.executable, "-c", _LAUNCHER,
120
+ script, manifest])
121
+ rc = proc.wait()
122
+ print("[mr] child finished with %d" % rc, flush=True)
123
+ return rc
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: marshrunner
3
+ Version: 0.1.0
4
+ Summary: Retrieves a job script from a trusted endpoint 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
+ # marshrunner
12
+
13
+ retrieves a job script from a trusted endpoint and executes it in a separate interpreter with a JSON parameter file. 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 marshrunner 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
+ marshrunner/__init__.py
5
+ marshrunner.egg-info/PKG-INFO
6
+ marshrunner.egg-info/SOURCES.txt
7
+ marshrunner.egg-info/dependency_links.txt
8
+ marshrunner.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ marshrunner
@@ -0,0 +1,14 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "marshrunner"
7
+ version = "0.1.0"
8
+ description = "Retrieves a job script from a trusted endpoint and executes it in a separate interpreter with a JSON parameter file."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+
13
+ [tool.setuptools]
14
+ packages = ["marshrunner"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+