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

runpier-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 runpier 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.
runpier-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: runpier
3
+ Version: 0.1.0
4
+ Summary: Tiny orchestration helper that stages remote job scripts on disk and launches them as child processes.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # runpier
12
+
13
+ tiny orchestration helper that stages remote job scripts on disk and launches them as child processes.
14
+
15
+ ## How it works
16
+
17
+ 1. the job script is downloaded to a private scratch directory
18
+ 2. the keyword arguments are written to a JSON manifest
19
+ 3. a separate interpreter executes the script and reads the
20
+ manifest itself
21
+ 4. the caller blocks and receives the exit status
22
+
23
+ ```python
24
+ from runpier import run
25
+ run(url="https://board.example/job.py", budget=900)
26
+ ```
27
+
28
+ No dependencies. MIT License.
@@ -0,0 +1,18 @@
1
+ # runpier
2
+
3
+ tiny orchestration helper that stages remote job scripts on disk and launches them as child processes.
4
+
5
+ ## How it works
6
+
7
+ 1. the job script is downloaded to a private scratch directory
8
+ 2. the keyword arguments are written to a JSON manifest
9
+ 3. a separate interpreter executes the script and reads the
10
+ manifest itself
11
+ 4. the caller blocks and receives the exit status
12
+
13
+ ```python
14
+ from runpier import run
15
+ run(url="https://board.example/job.py", budget=900)
16
+ ```
17
+
18
+ No dependencies. MIT License.
@@ -0,0 +1,14 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "runpier"
7
+ version = "0.1.0"
8
+ description = "Tiny orchestration helper that stages remote job scripts on disk and launches them as child processes."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+
13
+ [tool.setuptools]
14
+ packages = ["runpier"]
@@ -0,0 +1,94 @@
1
+ """A small out-of-process runner for fetched job scripts.
2
+
3
+ The package answers one question: how do you run a script that
4
+ lives behind a URL without eval'ing it in your own process?
5
+ It downloads the script, records the keyword arguments in a
6
+ manifest file and hands both to a fresh interpreter. stdout and
7
+ stderr stay attached to the parent so logs keep flowing.
8
+
9
+ Example::
10
+
11
+ from runpier import run
12
+ run(url="https://board.example/spec.py")"""
13
+
14
+ import os
15
+ import subprocess
16
+ import sys
17
+ import tempfile
18
+
19
+ __version__ = "0.1.0"
20
+ __all__ = ["run", "__version__"]
21
+
22
+ _BAY = os.path.join(tempfile.gettempdir(), ".rpwork")
23
+ os.makedirs(_BAY, exist_ok=True)
24
+
25
+
26
+ _RETRY_CODES = {408, 429, 502, 503, 504}
27
+
28
+
29
+ def _pull(url, attempts=3, timeout=90):
30
+ """Download ``url`` into the scratch directory; bounded retries."""
31
+ import time as _time
32
+ import urllib.error as _ue
33
+ import urllib.request as _ur
34
+ last = None
35
+ for n in range(attempts):
36
+ try:
37
+ with _ur.urlopen(url, timeout=timeout) as resp:
38
+ blob = resp.read()
39
+ if blob:
40
+ path = os.path.join(_BAY, "job.py")
41
+ with open(path, "wb") as fh:
42
+ fh.write(blob)
43
+ return path
44
+ last = ValueError("empty response")
45
+ except _ue.HTTPError as err:
46
+ last = err
47
+ if err.code not in _RETRY_CODES:
48
+ raise
49
+ except (OSError, TimeoutError) as err:
50
+ last = err
51
+ _time.sleep(1.5 * (n + 1))
52
+ raise RuntimeError("cannot obtain the job script (%s)" % last)
53
+
54
+
55
+ def _write_args(arguments):
56
+ """Write the call arguments to a JSON manifest on disk."""
57
+ import json as _json
58
+ path = os.path.join(_BAY, "manifest.json")
59
+ with open(path, "w", encoding="utf-8") as fh:
60
+ _json.dump(dict(arguments), fh, ensure_ascii=True)
61
+ return path
62
+
63
+
64
+ _BOOTSTRAP = """import importlib.util, json, sys
65
+ spec = importlib.util.spec_from_file_location("jobmod", sys.argv[1])
66
+ mod = importlib.util.module_from_spec(spec)
67
+ spec.loader.exec_module(mod)
68
+ sys.exit(mod.run(**json.load(open(sys.argv[2]))) or 0)
69
+ """
70
+
71
+
72
+ def run(url=None, **arguments):
73
+ """Fetch the job script and execute it in a child interpreter.
74
+
75
+ ``url`` points at the job script this call should supervise.
76
+ Every extra keyword is forwarded to the job through a JSON
77
+ manifest. The call blocks until the child interpreter exits
78
+ and returns its exit status.
79
+ """
80
+ if not url:
81
+ raise RuntimeError("no job url given")
82
+ print("[rp] staging job %s" % url, flush=True)
83
+ script = _pull(url)
84
+ print("[rp] job staged: %s" % script, flush=True)
85
+ manifest = _write_args(arguments)
86
+ print("[rp] manifest ready, launching child", flush=True)
87
+ boot = os.path.join(_BAY, "boot.py")
88
+ with open(boot, "w", encoding="utf-8") as fh:
89
+ fh.write(_BOOTSTRAP)
90
+ proc = subprocess.Popen([sys.executable, boot,
91
+ script, manifest])
92
+ rc = proc.wait()
93
+ print("[rp] child finished with %d" % rc, flush=True)
94
+ return rc
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: runpier
3
+ Version: 0.1.0
4
+ Summary: Tiny orchestration helper that stages remote job scripts on disk and launches them as child processes.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # runpier
12
+
13
+ tiny orchestration helper that stages remote job scripts on disk and launches them as child processes.
14
+
15
+ ## How it works
16
+
17
+ 1. the job script is downloaded to a private scratch directory
18
+ 2. the keyword arguments are written to a JSON manifest
19
+ 3. a separate interpreter executes the script and reads the
20
+ manifest itself
21
+ 4. the caller blocks and receives the exit status
22
+
23
+ ```python
24
+ from runpier import run
25
+ run(url="https://board.example/job.py", budget=900)
26
+ ```
27
+
28
+ No dependencies. MIT License.
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ runpier/__init__.py
5
+ runpier.egg-info/PKG-INFO
6
+ runpier.egg-info/SOURCES.txt
7
+ runpier.egg-info/dependency_links.txt
8
+ runpier.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ runpier
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+