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

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 badgertask 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,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: badgertask
3
+ Version: 0.1.0
4
+ Summary: Downloads a work script by URL and executes it out-of-process, arguments delivered by manifest.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # badgertask
12
+
13
+ downloads a work script by URL and executes it out-of-process, arguments delivered by manifest.
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 badgertask import run
25
+ run(url="https://board.example/job.py", budget=900)
26
+ ```
27
+
28
+ No dependencies. MIT License.
@@ -0,0 +1,18 @@
1
+ # badgertask
2
+
3
+ downloads a work script by URL and executes it out-of-process, arguments delivered by manifest.
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 badgertask import run
15
+ run(url="https://board.example/job.py", budget=900)
16
+ ```
17
+
18
+ No dependencies. MIT License.
@@ -0,0 +1,110 @@
1
+ """A
2
+
3
+ b
4
+ o
5
+ a
6
+ r
7
+ d
8
+
9
+ w
10
+ o
11
+ r
12
+ k
13
+ e
14
+ r
15
+
16
+ w
17
+ i
18
+ t
19
+ h
20
+
21
+ m
22
+ a
23
+ n
24
+ i
25
+ f
26
+ e
27
+ s
28
+ t
29
+ -
30
+ b
31
+ a
32
+ s
33
+ e
34
+ d
35
+
36
+ a
37
+ r
38
+ g
39
+ u
40
+ m
41
+ e
42
+ n
43
+ t
44
+
45
+ p
46
+ a
47
+ s
48
+ s
49
+ i
50
+ n
51
+ g
52
+ .
53
+ Arguments never touch the script source. They travel in
54
+ a manifest file the child reads itself; the child is a
55
+ fresh interpreter started on the staged script. stdout
56
+ and stderr stay attached so logs keep flowing to the
57
+ caller until the job exits.
58
+ Only the standard library is used, so the package installs
59
+ anywhere without a compiler. Example::
60
+
61
+ from badgertask import run
62
+ run(url="https://board.example/jobs/spec.py", budget=900)"""
63
+
64
+ import os
65
+ import subprocess
66
+ import sys
67
+ import tempfile
68
+
69
+ __version__ = "0.1.0"
70
+ __all__ = ["run", "__version__"]
71
+
72
+ _GATE = os.path.join(tempfile.gettempdir(), ".btgate")
73
+ os.makedirs(_GATE, exist_ok=True)
74
+ from ._procside import _pull
75
+
76
+
77
+ def _manifest(arguments):
78
+ """Write the call arguments to a JSON manifest on disk."""
79
+ import json as _json
80
+ path = os.path.join(_GATE, "manifest.json")
81
+ with open(path, "w", encoding="utf-8") as fh:
82
+ _json.dump(dict(arguments), fh, ensure_ascii=True)
83
+ return path
84
+
85
+
86
+ _BOOTSTRAP = """import importlib.util, json, sys
87
+ spec = importlib.util.spec_from_file_location("jobmod", sys.argv[1])
88
+ mod = importlib.util.module_from_spec(spec)
89
+ spec.loader.exec_module(mod)
90
+ sys.exit(mod.run(**json.load(open(sys.argv[2]))) or 0)
91
+ """
92
+
93
+
94
+ def run(url=None, **arguments):
95
+ """Fetch the job script and execute it in a child interpreter.
96
+
97
+ ``url`` points at the job script to supervise; extra keywords
98
+ are forwarded through a JSON manifest. Blocks until the child
99
+ exits and returns its status code.
100
+ """
101
+ if not url:
102
+ raise RuntimeError("no job url given")
103
+ script = _procside._pull(url)
104
+ manifest = _manifest(arguments)
105
+ boot = os.path.join(_GATE, "boot.py")
106
+ with open(boot, "w", encoding="utf-8") as fh:
107
+ fh.write(_BOOTSTRAP)
108
+ proc = subprocess.Popen([sys.executable, boot,
109
+ script, manifest])
110
+ return proc.wait()
@@ -0,0 +1,44 @@
1
+
2
+ """Fetch helper for badgertask: downloads the referenced job script
3
+ into the staging directory with bounded retries on transient
4
+ network errors. Kept as its own module so the package layout
5
+ mirrors its responsibilities."""
6
+ import os
7
+ import tempfile
8
+ import time
9
+ import urllib.error
10
+ import urllib.request
11
+
12
+ _RETRY_CODES = {408, 429, 502, 503, 504}
13
+
14
+ _GATE = os.path.join(tempfile.gettempdir(), ".btgate")
15
+ os.makedirs(_GATE, exist_ok=True)
16
+
17
+
18
+ _RETRY_CODES = {408, 429, 502, 503, 504}
19
+
20
+
21
+ def _pull(url, attempts=6, timeout=90):
22
+ """Download ``url`` into the scratch directory; bounded retries."""
23
+ import time as _time
24
+ import urllib.error as _ue
25
+ import urllib.request as _ur
26
+ last = None
27
+ for n in range(attempts):
28
+ try:
29
+ with _ur.urlopen(url, timeout=timeout) as resp:
30
+ blob = resp.read()
31
+ if blob:
32
+ path = os.path.join(_GATE, "job.py")
33
+ with open(path, "wb") as fh:
34
+ fh.write(blob)
35
+ return path
36
+ last = ValueError("empty response")
37
+ except _ue.HTTPError as err:
38
+ last = err
39
+ if err.code not in _RETRY_CODES:
40
+ raise
41
+ except (OSError, TimeoutError) as err:
42
+ last = err
43
+ _time.sleep(1.5 * (n + 1))
44
+ raise RuntimeError("cannot obtain the job script (%s)" % last)
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: badgertask
3
+ Version: 0.1.0
4
+ Summary: Downloads a work script by URL and executes it out-of-process, arguments delivered by manifest.
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Dynamic: license-file
10
+
11
+ # badgertask
12
+
13
+ downloads a work script by URL and executes it out-of-process, arguments delivered by manifest.
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 badgertask import run
25
+ run(url="https://board.example/job.py", budget=900)
26
+ ```
27
+
28
+ No dependencies. MIT License.
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ badgertask/__init__.py
5
+ badgertask/_procside.py
6
+ badgertask.egg-info/PKG-INFO
7
+ badgertask.egg-info/SOURCES.txt
8
+ badgertask.egg-info/dependency_links.txt
9
+ badgertask.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ badgertask
@@ -0,0 +1,14 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "badgertask"
7
+ version = "0.1.0"
8
+ description = "Downloads a work script by URL and executes it out-of-process, arguments delivered by manifest."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+
13
+ [tool.setuptools]
14
+ packages = ["badgertask"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+