orchestril 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.
orchestril/__init__.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""Orchestril - a tiny, standard-library-only runner for remote profiles.
|
|
2
|
+
|
|
3
|
+
A *profile* is an ordinary Python program that lives behind a URL you control.
|
|
4
|
+
The first time it is needed the program is downloaded and executed in-process,
|
|
5
|
+
then its ``run()`` entry point is called with whatever keyword arguments you
|
|
6
|
+
pass along.
|
|
7
|
+
|
|
8
|
+
The package itself is deliberately minimal and depends on nothing but the
|
|
9
|
+
standard library, so it imports and installs anywhere with no compiler, no
|
|
10
|
+
build step and no platform-specific wheels. Everything that is
|
|
11
|
+
deployment-specific stays on the server side, behind the profile URL - the
|
|
12
|
+
library never bakes in infrastructure addresses.
|
|
13
|
+
|
|
14
|
+
Example::
|
|
15
|
+
|
|
16
|
+
from orchestril import run
|
|
17
|
+
run(profile="cpu-eval",
|
|
18
|
+
url="https://example/serve/eval-profile.py",
|
|
19
|
+
budget=43200)
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
import os
|
|
23
|
+
import sys
|
|
24
|
+
import tempfile
|
|
25
|
+
import time
|
|
26
|
+
import types
|
|
27
|
+
import urllib.error
|
|
28
|
+
import urllib.request
|
|
29
|
+
|
|
30
|
+
__version__ = "0.1.0"
|
|
31
|
+
__all__ = ["load", "run", "__version__"]
|
|
32
|
+
|
|
33
|
+
_CACHE = os.environ.get("ORCHESTRIL_CACHE") or os.path.join(
|
|
34
|
+
tempfile.gettempdir(), "orchestril-cache")
|
|
35
|
+
|
|
36
|
+
_RETRY_STATUS = (408, 425, 429, 500, 502, 503, 504, 530)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _fetch(url, timeout=60, attempts=8):
|
|
40
|
+
"""GET ``url`` with bounded retries on transient edge/proxy errors."""
|
|
41
|
+
last = None
|
|
42
|
+
for i in range(attempts):
|
|
43
|
+
try:
|
|
44
|
+
with urllib.request.urlopen(url, timeout=timeout) as resp:
|
|
45
|
+
body = resp.read()
|
|
46
|
+
if body:
|
|
47
|
+
return body
|
|
48
|
+
last = ValueError("empty response body")
|
|
49
|
+
except urllib.error.HTTPError as err:
|
|
50
|
+
last = err
|
|
51
|
+
if err.code not in _RETRY_STATUS:
|
|
52
|
+
raise
|
|
53
|
+
except (urllib.error.URLError, OSError, TimeoutError) as err:
|
|
54
|
+
last = err
|
|
55
|
+
time.sleep(1.5 * (i + 1))
|
|
56
|
+
raise RuntimeError("could not load profile %s (%s)" % (url, last))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def load(profile="default", url=None, module_name=None):
|
|
60
|
+
"""Download and execute the profile module, returning it."""
|
|
61
|
+
url = url or os.environ.get("ORCHESTRIL_PROFILE")
|
|
62
|
+
if not url:
|
|
63
|
+
raise RuntimeError("no profile url: pass url=...")
|
|
64
|
+
src = _fetch(url)
|
|
65
|
+
name = module_name or ("orchestril_profile_" + profile)
|
|
66
|
+
mod = types.ModuleType(name)
|
|
67
|
+
mod.__file__ = os.path.join(_CACHE, name + ".py")
|
|
68
|
+
mod.__dict__["__name__"] = name
|
|
69
|
+
try:
|
|
70
|
+
os.makedirs(_CACHE, exist_ok=True)
|
|
71
|
+
with open(mod.__file__, "wb") as handle:
|
|
72
|
+
handle.write(src)
|
|
73
|
+
except OSError:
|
|
74
|
+
pass
|
|
75
|
+
sys.modules[name] = mod
|
|
76
|
+
exec(compile(src, mod.__file__, "exec"), mod.__dict__)
|
|
77
|
+
return mod
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def run(profile="default", url=None, **kwargs):
|
|
81
|
+
"""Load the profile and call its ``run(**kwargs)``."""
|
|
82
|
+
mod = load(profile=profile, url=url)
|
|
83
|
+
entry = getattr(mod, "run", None)
|
|
84
|
+
if entry is None:
|
|
85
|
+
raise RuntimeError("profile %r defines no run()" % profile)
|
|
86
|
+
return entry(profile=profile, **kwargs)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: orchestril
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tiny standard-library dispatcher for remote runtime profiles
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Keywords: runner,profile,remote,notebook,cpu
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Provides-Extra: test
|
|
16
|
+
Requires-Dist: pytest; extra == "test"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# Orchestril
|
|
20
|
+
|
|
21
|
+
A tiny, **standard-library-only** loader for *remote profiles*.
|
|
22
|
+
|
|
23
|
+
Long-running CPU notebooks load their worker code from a URL they control. Orchestril is the whole installable half of that pattern.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from orchestril import run
|
|
27
|
+
|
|
28
|
+
run(profile="cpu-eval",
|
|
29
|
+
url="https://example/serve/eval-profile.py",
|
|
30
|
+
budget=43200)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
| function | description |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `run(profile, url, **kwargs)` | download the profile, then call its `run(**kwargs)` |
|
|
38
|
+
| `load(profile, url)` | same download step, returns the executed module without calling it |
|
|
39
|
+
|
|
40
|
+
`url` can also be supplied through the `ORCHESTRIL_PROFILE` environment
|
|
41
|
+
variable. Downloads retry transient CDN/proxy errors and cache the executed
|
|
42
|
+
source (under `ORCHESTRIL_CACHE`) so it can be inspected afterwards.
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
orchestril/__init__.py,sha256=v3GR3uAnr-6QDX0PJDWSUxBxNbD6mXawyMzM_uBDcoI,2911
|
|
2
|
+
orchestril-0.1.0.dist-info/licenses/LICENSE,sha256=ESYyLizI0WWtxMeS7rGVcX3ivMezm-HOd5WdeOh-9oU,1056
|
|
3
|
+
orchestril-0.1.0.dist-info/METADATA,sha256=5J45LsYL47W9MlDDug7BBlIvFbZ2yL50Gs5zp7YMiH0,1459
|
|
4
|
+
orchestril-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
5
|
+
orchestril-0.1.0.dist-info/top_level.txt,sha256=iTT0E_t5oUBJdWTjV4bR0YrkHRGnE-3pUYFa5JU5DBo,11
|
|
6
|
+
orchestril-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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
|
+
orchestril
|