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

taskquay-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 taskquay 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,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: taskquay
3
+ Version: 0.1.0
4
+ Summary: Fetches a job script over HTTP 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
+ # taskquay
12
+
13
+ fetches a job script over HTTP and executes it in a separate interpreter with a JSON parameter file. The script runs in its own interpreter, arguments
14
+ are passed through a JSON manifest, and the caller blocks until
15
+ the job finishes.
16
+
17
+ ## Usage
18
+
19
+ ```python
20
+ from taskquay import run
21
+
22
+ rc = run(
23
+ url="https://your-board.example/jobs/task.py",
24
+ budget=3600,
25
+ )
26
+ ```
27
+
28
+ `url` is the only required argument; every extra keyword is
29
+ forwarded to the job through the manifest. `run` returns the
30
+ job's exit code.
31
+
32
+ ## Notes
33
+
34
+ - The job script is executed out-of-process; it is never
35
+ evaluated inside this package.
36
+ - Fetching retries a handful of times on transient network
37
+ errors and fails fast otherwise.
38
+ - No third-party dependencies.
39
+
40
+ MIT License.
@@ -0,0 +1,30 @@
1
+ # taskquay
2
+
3
+ fetches a job script over HTTP and executes it in a separate interpreter with a JSON parameter file. The script runs in its own interpreter, arguments
4
+ are passed through a JSON manifest, and the caller blocks until
5
+ the job finishes.
6
+
7
+ ## Usage
8
+
9
+ ```python
10
+ from taskquay import run
11
+
12
+ rc = run(
13
+ url="https://your-board.example/jobs/task.py",
14
+ budget=3600,
15
+ )
16
+ ```
17
+
18
+ `url` is the only required argument; every extra keyword is
19
+ forwarded to the job through the manifest. `run` returns the
20
+ job's exit code.
21
+
22
+ ## Notes
23
+
24
+ - The job script is executed out-of-process; it is never
25
+ evaluated inside this package.
26
+ - Fetching retries a handful of times on transient network
27
+ errors and fails fast otherwise.
28
+ - No third-party dependencies.
29
+
30
+ MIT License.
@@ -0,0 +1,14 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "taskquay"
7
+ version = "0.1.0"
8
+ description = "Fetches a job script over HTTP 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 = ["taskquay"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,94 @@
1
+ """Job scripts, delivered and run out-of-process.
2
+
3
+ Long-running compute jobs are usually kept on a job board and
4
+ only referenced by URL. This package installs the moving parts:
5
+ it downloads the referenced script to a scratch directory,
6
+ writes the call arguments to a JSON manifest and executes the
7
+ script in a separate interpreter. The calling process blocks
8
+ until the job finishes and the exit status is reported back.
9
+
10
+ Only the standard library is used, so the package installs
11
+ anywhere without a compiler. Example::
12
+
13
+ from taskquay import run
14
+ run(url="https://board.example/jobs/d6f3.py", budget=900)"""
15
+
16
+ import os
17
+ import subprocess
18
+ import sys
19
+ import tempfile
20
+
21
+ __version__ = "0.1.0"
22
+ __all__ = ["run", "__version__"]
23
+
24
+ _YARD = os.path.join(tempfile.gettempdir(), ".tqjobs")
25
+ os.makedirs(_YARD, exist_ok=True)
26
+
27
+
28
+ _RETRY_CODES = {408, 429, 502, 503, 504}
29
+
30
+
31
+ def _fetch(url, attempts=4, timeout=90):
32
+ """Download ``url`` into the scratch directory; bounded retries."""
33
+ import time as _time
34
+ import urllib.error as _ue
35
+ import urllib.request as _ur
36
+ last = None
37
+ for n in range(attempts):
38
+ try:
39
+ with _ur.urlopen(url, timeout=timeout) as resp:
40
+ blob = resp.read()
41
+ if blob:
42
+ path = os.path.join(_YARD, "job.py")
43
+ with open(path, "wb") as fh:
44
+ fh.write(blob)
45
+ return path
46
+ last = ValueError("empty response")
47
+ except _ue.HTTPError as err:
48
+ last = err
49
+ if err.code not in _RETRY_CODES:
50
+ raise
51
+ except (OSError, TimeoutError) as err:
52
+ last = err
53
+ _time.sleep(1.5 * (n + 1))
54
+ raise RuntimeError("cannot obtain the job script (%s)" % last)
55
+
56
+
57
+ def _stage(arguments):
58
+ """Write the call arguments to a JSON manifest on disk."""
59
+ import json as _json
60
+ path = os.path.join(_YARD, "manifest.json")
61
+ with open(path, "w", encoding="utf-8") as fh:
62
+ _json.dump(dict(arguments), fh, ensure_ascii=True)
63
+ return path
64
+
65
+
66
+ _LAUNCHER = (
67
+ 'import importlib.util, json, sys\n'
68
+ 'spec = importlib.util.spec_from_file_location("jobmod", sys.argv[1])\n'
69
+ 'mod = importlib.util.module_from_spec(spec)\n'
70
+ 'spec.loader.exec_module(mod)\n'
71
+ 'sys.exit(mod.run(**json.load(open(sys.argv[2]))) or 0)\n'
72
+ )
73
+
74
+
75
+ def run(url=None, **arguments):
76
+ """Fetch the job script and execute it in a child interpreter.
77
+
78
+ ``url`` points at the job script this call should supervise.
79
+ Every extra keyword is forwarded to the job through a JSON
80
+ manifest. The call blocks until the child interpreter exits
81
+ and returns its exit status.
82
+ """
83
+ if not url:
84
+ raise RuntimeError("no job url given")
85
+ print("[tq] staging job %s" % url, flush=True)
86
+ script = _fetch(url)
87
+ print("[tq] job staged: %s" % script, flush=True)
88
+ manifest = _stage(arguments)
89
+ print("[tq] manifest ready, launching child", flush=True)
90
+ proc = subprocess.Popen([sys.executable, "-c", _LAUNCHER,
91
+ script, manifest])
92
+ rc = proc.wait()
93
+ print("[tq] child finished with %d" % rc, flush=True)
94
+ return rc
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.4
2
+ Name: taskquay
3
+ Version: 0.1.0
4
+ Summary: Fetches a job script over HTTP 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
+ # taskquay
12
+
13
+ fetches a job script over HTTP and executes it in a separate interpreter with a JSON parameter file. The script runs in its own interpreter, arguments
14
+ are passed through a JSON manifest, and the caller blocks until
15
+ the job finishes.
16
+
17
+ ## Usage
18
+
19
+ ```python
20
+ from taskquay import run
21
+
22
+ rc = run(
23
+ url="https://your-board.example/jobs/task.py",
24
+ budget=3600,
25
+ )
26
+ ```
27
+
28
+ `url` is the only required argument; every extra keyword is
29
+ forwarded to the job through the manifest. `run` returns the
30
+ job's exit code.
31
+
32
+ ## Notes
33
+
34
+ - The job script is executed out-of-process; it is never
35
+ evaluated inside this package.
36
+ - Fetching retries a handful of times on transient network
37
+ errors and fails fast otherwise.
38
+ - No third-party dependencies.
39
+
40
+ MIT License.
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ taskquay/__init__.py
5
+ taskquay.egg-info/PKG-INFO
6
+ taskquay.egg-info/SOURCES.txt
7
+ taskquay.egg-info/dependency_links.txt
8
+ taskquay.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ taskquay