strata-pool 0.7.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.
- strata_pool-0.7.0/.gitignore +251 -0
- strata_pool-0.7.0/PKG-INFO +279 -0
- strata_pool-0.7.0/README.md +257 -0
- strata_pool-0.7.0/pyproject.toml +57 -0
- strata_pool-0.7.0/src/strata_pool/__init__.py +31 -0
- strata_pool-0.7.0/src/strata_pool/api.py +217 -0
- strata_pool-0.7.0/src/strata_pool/backend.py +56 -0
- strata_pool-0.7.0/src/strata_pool/backends/__init__.py +6 -0
- strata_pool-0.7.0/src/strata_pool/backends/docker.py +188 -0
- strata_pool-0.7.0/src/strata_pool/backends/runpod.py +264 -0
- strata_pool-0.7.0/src/strata_pool/pool.py +625 -0
- strata_pool-0.7.0/src/strata_pool/store.py +431 -0
- strata_pool-0.7.0/src/strata_pool/types.py +215 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
# macOS
|
|
210
|
+
.DS_Store
|
|
211
|
+
|
|
212
|
+
# Rust build artifacts
|
|
213
|
+
rust/target/
|
|
214
|
+
|
|
215
|
+
# Strata demo data (generated)
|
|
216
|
+
demo-warehouse/
|
|
217
|
+
benchmarks/results/
|
|
218
|
+
site/
|
|
219
|
+
|
|
220
|
+
# Internal design and planning docs — kept local only.
|
|
221
|
+
docs/internal/
|
|
222
|
+
|
|
223
|
+
# Auto-generated example renderings produced by the export hook
|
|
224
|
+
# (docs_hooks/export_examples.py). Regenerated on every `mkdocs build`.
|
|
225
|
+
docs/examples/
|
|
226
|
+
|
|
227
|
+
# Per-notebook runtime state — artifacts, blobs, console output,
|
|
228
|
+
# environment lockfiles, example DuckDB files. Generated whenever a
|
|
229
|
+
# notebook runs; never meant to be shared.
|
|
230
|
+
examples/*/.strata/
|
|
231
|
+
examples/*/uv.lock
|
|
232
|
+
examples/*/*.db
|
|
233
|
+
examples/*/*.duckdb
|
|
234
|
+
experiments/**/.strata/
|
|
235
|
+
experiments/**/uv.lock
|
|
236
|
+
experiments/**/*.db
|
|
237
|
+
experiments/**/*.duckdb
|
|
238
|
+
# Experiment runtime/scratch: per-server cache + artifact blobs (named
|
|
239
|
+
# .strata-server-<thing>/, not .strata/) and the Arrow blobs they hold —
|
|
240
|
+
# hundreds of MB, GitHub-rejected. Experiment *code* (e.g. circle_packing_26/)
|
|
241
|
+
# stays tracked; only this generated state is ignored.
|
|
242
|
+
experiments/**/.strata-server*/
|
|
243
|
+
experiments/**/*.arrow
|
|
244
|
+
experiments/**/*.arrowstream
|
|
245
|
+
|
|
246
|
+
# Frontend build output, copied into the package by the release
|
|
247
|
+
# workflow. Source of truth lives at frontend/dist/.
|
|
248
|
+
src/strata/_frontend/
|
|
249
|
+
|
|
250
|
+
# Claude Code session state
|
|
251
|
+
.claude/
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: strata-pool
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Worker pool for dispatching Strata jobs to ephemeral machines.
|
|
5
|
+
Project-URL: Homepage, https://github.com/bearing-research/strata
|
|
6
|
+
Project-URL: Repository, https://github.com/bearing-research/strata
|
|
7
|
+
Author-email: Fangchen Li <fangchen.li@outlook.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Requires-Dist: httpx>=0.28.0
|
|
18
|
+
Provides-Extra: server
|
|
19
|
+
Requires-Dist: fastapi>=0.115.0; extra == 'server'
|
|
20
|
+
Requires-Dist: uvicorn>=0.30.0; extra == 'server'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# strata-pool
|
|
24
|
+
|
|
25
|
+
<!-- --8<-- [start:body] -->
|
|
26
|
+
Worker pool for dispatching Strata jobs to ephemeral machines. This is the
|
|
27
|
+
bring-your-own-hardware path: it manages machines *you* own. It is complete and
|
|
28
|
+
tested rather than growing — if you want a provider to autoscale for you,
|
|
29
|
+
register a serverless executor as a Strata worker instead.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install strata-pool # library
|
|
33
|
+
pip install "strata-pool[server]" # plus the HTTP service
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Jobs arrive with a machine type. The pool hands each one to a warm worker of
|
|
37
|
+
that type, starts a machine when there is none, forwards the payload over
|
|
38
|
+
HTTP, records the result, and meters the execution. A backend provides start /
|
|
39
|
+
stop / health and nothing else, so the pool does not know which it is talking
|
|
40
|
+
to. Two ship: local Docker and RunPod. Anything satisfying the `Backend`
|
|
41
|
+
protocol works.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from strata_pool import DockerBackend, MachineType, Pool, PoolStore
|
|
45
|
+
|
|
46
|
+
pool = Pool(
|
|
47
|
+
store=PoolStore("pool.sqlite"),
|
|
48
|
+
backend=DockerBackend(),
|
|
49
|
+
machine_types=[MachineType(name="cpu-4x", image="strata-worker:latest")],
|
|
50
|
+
)
|
|
51
|
+
await pool.recover() # reconcile after a restart
|
|
52
|
+
pool.start_scaler() # stop paying for machines that finished
|
|
53
|
+
|
|
54
|
+
job = await pool.submit(tenant_id="acme", machine_type="cpu-4x", payload=bundle)
|
|
55
|
+
done = await pool.wait(job.id)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Isolation
|
|
59
|
+
|
|
60
|
+
A machine belongs to **one tenant for its life** and is destroyed rather than
|
|
61
|
+
handed to another. Even scrubbed of files, a process that ran one tenant's
|
|
62
|
+
code is not a boundary the next tenant should have to trust, and GPU memory is
|
|
63
|
+
not reliably zeroed between processes at all. `max_workers` is therefore a
|
|
64
|
+
per-tenant cap.
|
|
65
|
+
|
|
66
|
+
`MachineType.cpus` and `memory_mb` bound what a container may consume; unset,
|
|
67
|
+
it may take the whole host. Both are enforced by the daemon, asserted against
|
|
68
|
+
a real one in `test_docker_live.py`.
|
|
69
|
+
|
|
70
|
+
What that buys is process-level isolation, which is **not** a boundary for
|
|
71
|
+
untrusted code — a shared kernel is one CVE away from a cross-tenant escape.
|
|
72
|
+
A deployment running untrusted work wants a VM-backed runtime (Kata, gVisor)
|
|
73
|
+
or a backend whose machines are already microVMs. The `Backend` protocol is
|
|
74
|
+
where that choice lives.
|
|
75
|
+
|
|
76
|
+
`Pool(max_workers_total=...)` caps the whole fleet across every tenant.
|
|
77
|
+
`MachineType.max_workers` caps one tenant, so without it the fleet is that
|
|
78
|
+
number times however many tenants show up. Unset means no ceiling, which is
|
|
79
|
+
right for a single-tenant pool and wrong for a hosted one. Hitting the
|
|
80
|
+
ceiling logs a warning: a capped fleet looks exactly like a slow queue from
|
|
81
|
+
the outside.
|
|
82
|
+
|
|
83
|
+
Still missing: any restriction on the container's own network access.
|
|
84
|
+
|
|
85
|
+
## What it is not
|
|
86
|
+
|
|
87
|
+
**It is not a cache.** The pool has no idea Strata deduplicates work.
|
|
88
|
+
Submitting a job whose result already exists boots a machine and recomputes
|
|
89
|
+
it — so the caller checks `find_by_provenance` *before* submitting. Getting
|
|
90
|
+
that order wrong bills customers for cache hits.
|
|
91
|
+
|
|
92
|
+
**It is not the metering layer.** The pool records one `UsageEvent` per
|
|
93
|
+
terminal job, including failures, with a monotonic duration. What is billable,
|
|
94
|
+
and at what price, is decided above it.
|
|
95
|
+
|
|
96
|
+
**It does not keep machines warm on purpose.** `start_scaler()` stops
|
|
97
|
+
machines idle past their type's `cool_down_seconds`, and nothing else in the
|
|
98
|
+
pool ever ends a machine that finished its work — a deployment that forgets
|
|
99
|
+
that call bills for every machine it ever started. A warm floor is
|
|
100
|
+
deliberately absent: per tenant it means paying for everyone who ever showed
|
|
101
|
+
up, per machine type it means choosing whose latency to subsidise, and
|
|
102
|
+
pre-warming belongs with the layer that knows a user just opened a
|
|
103
|
+
notebook.
|
|
104
|
+
|
|
105
|
+
## Layout
|
|
106
|
+
|
|
107
|
+
| Module | What lives there |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `types.py` | `Worker`, `Job`, `MachineType`, `UsageEvent` and their states |
|
|
110
|
+
| `backend.py` | The `Backend` protocol — start / stop / health |
|
|
111
|
+
| `backends/docker.py` | Containers on the local Docker daemon |
|
|
112
|
+
| `store.py` | SQLite persistence; the pool process keeps no authoritative state |
|
|
113
|
+
| `pool.py` | Submission, dispatch, boot, execution, metering, restart recovery |
|
|
114
|
+
|
|
115
|
+
## Running it as a service
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pip install 'strata-pool[server]'
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from strata_pool.api import create_app
|
|
123
|
+
|
|
124
|
+
app = create_app(pool, api_token=os.environ["STRATA_POOL_TOKEN"])
|
|
125
|
+
# uvicorn strata_pool_service:app
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The app's lifespan calls `recover()` and `start_scaler()` itself, so a
|
|
129
|
+
deployment cannot forget the call that stops it paying for idle machines.
|
|
130
|
+
|
|
131
|
+
| Route | |
|
|
132
|
+
|---|---|
|
|
133
|
+
| `POST /v1/jobs` | Queue a job; body is the payload, verbatim. 202 with an id |
|
|
134
|
+
| `POST /v1/jobs/sync` | Queue and block. 200 with the result bytes, or 202 and an id if `wait_seconds` runs out |
|
|
135
|
+
| `GET /v1/jobs/{id}` | Status, without the payload or result |
|
|
136
|
+
| `GET /v1/jobs/{id}/result` | The raw result bytes; 409 while the job is not finished |
|
|
137
|
+
| `GET /v1/machine-types` | What a caller may ask for — the catalogue an annotation resolves against |
|
|
138
|
+
| `GET /v1/workers` | The fleet, without machine credentials |
|
|
139
|
+
| `GET /v1/usage` | The billing feed, filterable by tenant |
|
|
140
|
+
| `GET /health` | Outside the token check, for load balancers |
|
|
141
|
+
|
|
142
|
+
A job that fails **on the worker** comes back as 502, and one that times out
|
|
143
|
+
as 504 — the caller has to be able to tell "your code raised" from "we could
|
|
144
|
+
not run it".
|
|
145
|
+
|
|
146
|
+
Every route but `/health` requires `Authorization: Bearer <api_token>`, and
|
|
147
|
+
job routes require `X-Strata-Tenant`. **The caller is trusted for tenant
|
|
148
|
+
identity**: it authenticates as itself and asserts whose work this is. The
|
|
149
|
+
pool does not authenticate end users and must never be reachable from
|
|
150
|
+
anywhere but the proxy.
|
|
151
|
+
|
|
152
|
+
## The RunPod backend
|
|
153
|
+
|
|
154
|
+
Rents real hardware. `MachineType.gpu_type` is the provider's own string —
|
|
155
|
+
`"NVIDIA H100 80GB PCIe"` — deliberately not a normalised label, because one
|
|
156
|
+
that maps cleanly across providers does not exist and inventing it would put a
|
|
157
|
+
lossy translation between a user and the hardware they asked for.
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
RunPodBackend(os.environ["RUNPOD_API_KEY"])
|
|
161
|
+
MachineType(
|
|
162
|
+
name="h100-80gb",
|
|
163
|
+
image="strata-worker:latest",
|
|
164
|
+
gpu_type="NVIDIA H100 80GB PCIe",
|
|
165
|
+
boot_timeout_seconds=600, # pulling an image onto a fresh pod is minutes
|
|
166
|
+
cool_down_seconds=60, # an idle H100 is the expensive mistake
|
|
167
|
+
)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Verified against a live account** on 2026-09-02: the base URL, `POST /pods`
|
|
171
|
+
with `imageName` / `ports` / `env` / `containerDiskInGb` / `name`, the `id` in
|
|
172
|
+
the create response, the proxy endpoint, health through that proxy, and
|
|
173
|
+
`DELETE /pods/{id}` including a second delete of the same pod. A CPU pod
|
|
174
|
+
booted, answered, and terminated with nothing left running.
|
|
175
|
+
|
|
176
|
+
**Two things that run stayed silent on**, because a CPU pod does not exercise
|
|
177
|
+
them: `gpuTypeIds` + `gpuCount`, and reading a region from `machine`. Every pod
|
|
178
|
+
in the account listing carried `machine: {}` with no `dataCenterId`, so `region`
|
|
179
|
+
is probably always `None` today — harmless, being metadata, but do not trust it.
|
|
180
|
+
|
|
181
|
+
RunPod has moved its API surface before. Every field lives in `_create_body`
|
|
182
|
+
and is asserted by a test, so a wrong one is a one-line fix; `provider_options`
|
|
183
|
+
overrides anything in the body, so a deployment can correct a field without
|
|
184
|
+
waiting for a release; and `base_url` can be repointed. To re-verify, or to
|
|
185
|
+
close the GPU gap with `STRATA_POOL_RUNPOD_GPU`:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
export RUNPOD_API_KEY=...
|
|
189
|
+
STRATA_POOL_RUNPOD_LIVE=1 pytest packages/strata-pool/tests/test_runpod_live.py -v -s
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
That **starts a billed pod**, which is why it is opt-in and never runs in CI.
|
|
193
|
+
It terminates what it starts, but a crashed interpreter can still leave a pod
|
|
194
|
+
running — check the console. Pods are named `strata-{machine_type}-{id}` so an
|
|
195
|
+
orphan is findable.
|
|
196
|
+
|
|
197
|
+
A pod's port is published on the public internet through RunPod's proxy. The
|
|
198
|
+
per-machine credential is what stands between that URL and anyone who finds
|
|
199
|
+
it.
|
|
200
|
+
|
|
201
|
+
## The worker contract
|
|
202
|
+
|
|
203
|
+
`strata-worker`, shipped in `strata-notebook`, satisfies this contract as of
|
|
204
|
+
0.7.0 — build it with the Dockerfile in the Strata repo and the pool can drive
|
|
205
|
+
it unmodified:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
docker build -f worker.Dockerfile -t strata-worker:latest .
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The image installs `strata-notebook` from PyPI and needs **0.7.0 or newer** —
|
|
212
|
+
`POST /execute`, the path the pool dispatches to, ships in that release. It
|
|
213
|
+
also means building inside a checkout does not pick up local worker changes;
|
|
214
|
+
build a wheel for that.
|
|
215
|
+
|
|
216
|
+
Layer your cells' dependencies on top (`FROM strata-worker:latest`). The image
|
|
217
|
+
binds 8080 because that is `DockerBackend`'s default `worker_port`; the
|
|
218
|
+
worker's own default is 9000, so the two are made to agree explicitly rather
|
|
219
|
+
than by luck. The pool does not pull, so build on the host that will run it.
|
|
220
|
+
It runs as a non-root user and **refuses to start without
|
|
221
|
+
`STRATA_WORKER_TOKEN`** — the pool mints one per machine, so this only bites
|
|
222
|
+
when running it by hand.
|
|
223
|
+
|
|
224
|
+
**Local Docker needs the SSRF guard relaxed.** The worker rejects manifest
|
|
225
|
+
URLs that resolve to loopback or private addresses — a real defense, since a
|
|
226
|
+
buggy or compromised orchestrator could otherwise point it at internal
|
|
227
|
+
services. With `DockerBackend` on a local daemon the Strata server *is* at a
|
|
228
|
+
private address, so the first job fails with `resolves to non-routable
|
|
229
|
+
address` until the worker starts with `STRATA_WORKER_ALLOW_LOCAL_HOSTS=1`.
|
|
230
|
+
That is a local-development setting: leave it unset anywhere the server is
|
|
231
|
+
reachable at a routable address, which is every real deployment.
|
|
232
|
+
|
|
233
|
+
The payload the pool forwards is a **build manifest** — the same JSON document
|
|
234
|
+
`/v1/execute-manifest` takes, carrying signed URLs for the inputs, the output,
|
|
235
|
+
and finalization. The worker fetches its own inputs and uploads its own result,
|
|
236
|
+
so the bytes never flow through the pool. That is also why the payload has to
|
|
237
|
+
be self-describing: the pool forwards it verbatim and sets no content type.
|
|
238
|
+
|
|
239
|
+
The pool remains image-agnostic — anything holding up these four points works:
|
|
240
|
+
|
|
241
|
+
| | |
|
|
242
|
+
|---|---|
|
|
243
|
+
| Listen on the worker port | 8080 by default; the backend publishes it |
|
|
244
|
+
| `GET /health` → 200 when ready | No auth. It is polled before the machine is trusted with anything, and it reveals nothing |
|
|
245
|
+
| `POST /execute` → 200 with the result body | The request body is the job payload, opaque to the pool |
|
|
246
|
+
| Require `Authorization: Bearer $STRATA_WORKER_TOKEN` on `/execute` | Reject anything else with 401 |
|
|
247
|
+
|
|
248
|
+
The token is minted per machine before it boots and passed in its
|
|
249
|
+
environment. Without that check, `/execute` is an unauthenticated
|
|
250
|
+
remote-code-execution endpoint — survivable only while the machine is bound to
|
|
251
|
+
loopback, which stops being true the moment a backend hands out a routable
|
|
252
|
+
address.
|
|
253
|
+
|
|
254
|
+
## The Docker backend
|
|
255
|
+
|
|
256
|
+
Talks to the Docker Engine API over its UNIX socket with httpx, so the pool
|
|
257
|
+
needs no Docker SDK and every request shape is testable without a daemon. It
|
|
258
|
+
starts the image, publishes the worker port on loopback only, and reports the
|
|
259
|
+
host port Docker picked. It does not care what runs inside the container.
|
|
260
|
+
|
|
261
|
+
It does not pull. An image that is not on the host fails with the daemon's own
|
|
262
|
+
"No such image" message.
|
|
263
|
+
|
|
264
|
+
## Tests
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
pytest packages/strata-pool/tests -v
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
The tests in `test_docker_live.py` run the whole path against real containers
|
|
271
|
+
and skip when no daemon is reachable. Set `STRATA_POOL_DOCKER_SOCKET` if yours
|
|
272
|
+
is not at `/var/run/docker.sock` (Docker Desktop on macOS puts it in
|
|
273
|
+
`~/.docker/run/docker.sock`), and `STRATA_POOL_REQUIRE_DOCKER=1` to make a
|
|
274
|
+
missing daemon an error instead of a skip — CI sets that, so a runner whose
|
|
275
|
+
socket moved fails loudly rather than reporting coverage it never ran.
|
|
276
|
+
|
|
277
|
+
CI additionally installs the package into a venv with only its own
|
|
278
|
+
dependencies, to keep it from quietly growing a dependency on the server.
|
|
279
|
+
<!-- --8<-- [end:body] -->
|