Repository navigation
Expand file tree
/
Copy pathconfig.python.toml
More file actions
346 lines (316 loc) · 16.1 KB
/
Copy pathconfig.python.toml
File metadata and controls
346 lines (316 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# Python toolchain + tasks (uv, Pyodide, the codegen CLIs).
# Loaded when MISE_ENV includes `python`. The bare `pipx` tool stays in the
# default config; the `pipx:*` entries below resolve through it.
[tools]
"pipx:componentize-py" = "latest"
"pipx:datamodel-code-generator" = { version = "latest", extras = "ruff" }
"pipx:openapi-python-client" = "0.29.1"
"pipx:pyrefly" = "latest"
"pipx:pytest" = "latest"
# PyTorch, for the et-ws-pyo3-runner `torch_inference` test.
# Python-only (not in the always-loaded config) -- it's a large optional dependency, and the test skips itself
# when torch isn't among the mise-installed packages on sys.path. Skipped on macos/x64: PyTorch dropped macOS
# Intel wheels after 2.2.x, and 2.2.2's macOS x86_64 wheels stop at Python 3.12 (no cp313), so no version on
# PyPI satisfies both macos/x64 and our Python 3.13 pin.
"pipx:torch" = { version = "latest", os = ["linux", "macos/arm64", "windows"] }
ruff = "latest"
# Both pyodide distributions are pinned, because a deployment needs one or the other depending on its modules.
# The npm package is only the runtime (pyodide.js, .wasm, stdlib, micropip) -- it's designed for JS apps that
# fetch the rest from JsDelivr's Pyodide custom-CDN namespace (https://www.jsdelivr.com/oss-cdn) at runtime, so
# it suffices for a module that imports the stdlib and nothing more. A module calling `micropip.install` pulls a
# non-stdlib wheel and needs the "full" distribution served locally to work offline; that is published only as a
# tarball on GitHub releases. This workspace serves the full one by default; `et-cli` picks between them per
# scenario. The extracted tarball contains a top-level `pyodide/` directory the modules service picks up -- see
# `default_modules_folders` in libs/edge-toolkit/src/config.rs.
#
# Hold both rows on the same pyodide release when bumping. Note the npm package renumbered after 0.29.x: its
# `latest` is now 314.x, tracking the bundled CPython (314 = Python 3.14) rather than continuing the 0.29 line,
# so an unpinned `latest` here would silently cross a major boundary the http row has not.
"npm:pyodide" = "0.29.3"
[tools."http:pyodide"]
# Keep every pyodide executable OFF the task PATH.
# The dist root carries `python` / `python.bat` / `python.exe` wrapper scripts, and with no bin_path set
# mise's http backend falls back to putting the whole install root on PATH (no bin/ dir, executables at the
# root). On the Windows CI lane the GHCR tool store restores http:pyodide before core python exists -- the
# store excludes python as non-relocatable, and preinstall's own bootstrap install list doesn't include it --
# so preinstall's `command -v python` pipx bootstrap found pyodide's wrapper and died with
#
# Cannot find pyodide pip. Make a pyodide venv first?
#
# on commit https://github.com/edge-toolkit/core/commit/5fb4626293685ee13b2da3b19686830ec5833cbb at
# https://github.com/edge-toolkit/core/actions/runs/31864076908/job/94962233487, passing only on the retry
# step once the full `mise install` had put real CPython on PATH. Nothing runs pyodide from PATH (the modules
# service reads the install dir straight off disk), so point bin_path at a deliberately nonexistent subdir --
# the http backend returns it without an existence check, which yields an inert PATH entry. Setting bin_path
# also disables the backend's single-top-level-directory auto-strip detection, so strip_components is pinned
# to keep the flat extract layout the modules service reads.
bin_path = "no-bins-on-path"
strip_components = "1"
url = "https://github.com/pyodide/pyodide/releases/download/{{ version }}/pyodide-{{ version }}.tar.bz2"
version = "0.29.3"
[vars]
# Wheel build every Python ws-module and generated package shares.
# Stale wheels go first because uv build leaves prior versions in place, and the whole pkg/ dir is what
# et-modules-service mounts -- an old wheel left beside the new one would be served alongside it.
#
# The `et-cli module-package-json` step that follows this stays in each task rather than joining it here:
# `vars.et_cli` is overridden per compiler env (config.msvc.toml, config.mingw.toml) and a var referenced
# from inside another var does not pick that override up, so nesting it silently produced the default
# gnullvm path on the msvc lane -- `target/x86_64-pc-windows-gnullvm/debug/et-cli.exe: not found`.
py_wheel_sh = """
coreutils rm -f pkg/*.whl
uv build --wheel --out-dir pkg
"""
# Shared WIT dir for the wasi-graphics-info componentize-py build.
# It is relative to that module's dir; used by both the bindings and componentize steps.
wit_dir = "../../../generated/specs/wit"
[env]
# Keep ruff's cache under target/ (gitignored) instead of a repo-root .ruff_cache.
RUFF_CACHE_DIR = "{{ config_root }}/target/ruff-cache"
[tasks]
# No path args, so ruff walks from the repo root and discovers files itself.
# It honours .gitignore (so target/ is skipped) and ruff.toml's `exclude`/`extend-exclude`. Every tracked *.py
# already lives under a dir we want linted, so discovery covers them without an explicit include list -- scope
# is narrowed by excludes only.
pyrefly-check = "pyrefly check -c config/pyrefly.toml"
ruff-check = "ruff check"
ruff-fix = "ruff check --fix"
ruff-fmt = "ruff format"
ruff-fmt-check = "ruff format --check"
# Namespaced aggregators picked up by the default config's globbed tasks.
# Those are its `check`/`fmt`/`test`.
[tasks."check:python"]
depends = ["pyrefly-check", "ruff-check", "ruff-fmt-check"]
description = "Run Python checks (ruff lint + format-check, Pyrefly type-check)"
[tasks."fmt:python"]
depends = ["ruff-fmt"]
description = "Format Python sources"
[tasks."fix:python"]
depends = ["ruff-fix"]
description = "Apply Python lint-fix passes"
[tasks."test:python"]
depends = [
"test-edge-toolkit",
"test-et-org",
"test-pydemo1",
"test-pyeye1",
"test-pyface1",
"test-pyo3-mlflow",
"test-pyspeech1",
]
description = "Run Python tests"
[tasks.test-pyo3-mlflow]
dir = "services/ws-modules/pyo3-mlflow"
run = "python -m unittest discover -p 'test_*.py'"
[tasks.test-edge-toolkit]
dir = "libs/python-edge-toolkit"
env = { UV_PYTHON = "{% if os() == 'windows' %}{{ vars.py3_win }}{% else %}{{ vars.py3_unix }}{% endif %}" }
run = "uv run pytest"
[tasks.test-et-org]
dir = "libs/python-org"
env = { UV_PYTHON = "{% if os() == 'windows' %}{{ vars.py3_win }}{% else %}{{ vars.py3_unix }}{% endif %}" }
run = "uv run pytest"
[tasks.test-pyeye1]
dir = "services/ws-modules/pyeye1"
# Same uv-interpreter pin as `[tasks."prefetch:python".env]`; see there.
env = { UV_PYTHON = "{% if os() == 'windows' %}{{ vars.py3_win }}{% else %}{{ vars.py3_unix }}{% endif %}" }
run = "uv run pytest"
[tasks.test-pyface1]
dir = "services/ws-modules/pyface1"
# Same uv-interpreter pin as `[tasks."prefetch:python".env]`; see there.
env = { UV_PYTHON = "{% if os() == 'windows' %}{{ vars.py3_win }}{% else %}{{ vars.py3_unix }}{% endif %}" }
run = "uv run pytest"
[tasks.test-pydemo1]
dir = "services/ws-modules/pydemo1"
env = { UV_PYTHON = "{% if os() == 'windows' %}{{ vars.py3_win }}{% else %}{{ vars.py3_unix }}{% endif %}" }
run = "uv run pytest"
[tasks.test-pyspeech1]
dir = "services/ws-modules/pyspeech1"
env = { UV_PYTHON = "{% if os() == 'windows' %}{{ vars.py3_win }}{% else %}{{ vars.py3_unix }}{% endif %}" }
run = "uv run pytest"
[tasks.build-et-ws-wheel]
depends = ["build-et-cli"]
description = "Build the generated et-ws Python package as a wheel + ws-module pkg/"
dir = "generated/python-ws"
# Wheel goes straight into pkg/ alongside the committed et_ws.js shim.
# The whole dir is what et-modules-service mounts at /modules/et-ws/. Delete
# stale wheels first -- uv build leaves prior versions in place.
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-et-org-wheel]
depends = ["build-et-cli"]
description = "Build the et-org Python package as a wheel + ws-module pkg/"
dir = "libs/python-org"
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-edge-toolkit-wheel]
# The wheels it installs beside its own at runtime: its shim borrows et-org's installer, and it imports et-ws.
depends = ["build-et-org-wheel", "build-et-ws-wheel"]
description = "Build the edge-toolkit Python package as a wheel + ws-module pkg/"
dir = "libs/python-edge-toolkit"
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-et-rest-client-wheel]
depends = ["build-et-cli"]
description = "Build the generated et-rest-client Python package as a wheel + ws-module pkg/"
dir = "generated/python-rest"
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-ws-pymath1-module]
depends = ["build-et-cli"]
description = "Build the pymath1 FedAvg module"
dir = "services/ws-modules/pymath1"
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-ws-pydata1-module]
depends = ["build-et-rest-client-wheel"]
description = "Build the pydata1 Python workflow module"
dir = "services/ws-modules/pydata1"
# et-rest-client is its own ws-module mounted at /modules/et-rest-client/.
# pydata1 declares it under [tool.ws-module.dependencies] and loads the wheel at runtime from that mount via
# the shim's `installWheel` helper -- no need to copy the wheel here.
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-ws-pyface1-module]
depends = ["build-edge-toolkit-wheel"]
description = "Build the pyface1 Python face detection workflow module"
dir = "services/ws-modules/pyface1"
# et-ws is its own ws-module mounted at /modules/et-ws/.
# pyface1 declares it under [tool.ws-module.dependencies] and loads the wheel at runtime from that mount via
# the shim's `installWheel` helper -- no need to copy the wheel here.
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-ws-pyeye1-module]
depends = ["build-edge-toolkit-wheel"]
description = "Build the pyeye1 Python MediaPipe eye detection workflow module"
dir = "services/ws-modules/pyeye1"
# et-ws is its own ws-module mounted at /modules/et-ws/, loaded at runtime, so only pyeye1's wheel builds here.
# pyeye1 loads the et-ws wheel at runtime from that mount. The MediaPipe FaceLandmarker runtime
# (@mediapipe/tasks-vision) and the model bundle (et-model-eye1) are served separately -- not part of this build.
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-ws-pyspeech1-module]
depends = ["build-edge-toolkit-wheel"]
description = "Build the pyspeech1 Python Silero VAD workflow module"
dir = "services/ws-modules/pyspeech1"
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-ws-pydemo1-module]
depends = ["build-ws-pyeye1-module", "build-ws-pyspeech1-module"]
description = "Build the combined pydemo1 Python eye and speech workflow module"
dir = "services/ws-modules/pydemo1"
run = """
{{ vars.py_wheel_sh }}
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks.build-ws-wasi-graphics-info-module]
depends = ["build-et-cli"]
description = "Build the WASI graphics-info Python module as a WASI Preview 2 component"
dir = "services/ws-modules/wasi-graphics-info"
# WIT lives once at generated/specs/wit/.
# The runner's `runner` world is what its bindgen consumes; the `module` world (which `include`s `runner` and
# adds wasi-nn) is what guest modules target. `mnist-12.onnx` is fetched into `pkg/` by `mise run download-models`
# (see `fetch-mnist-rclone`); componentize-py 0.23 doesn't bundle arbitrary data files inside the component
# image, so the guest fetches it via the `wasi:keyvalue/store` host import from the ws-server at runtime.
# componentize-py 0.23's `bindings` subcommand refuses to overwrite an existing output dir, so we wipe it first.
run = """
coreutils rm -rf wit_world
componentize-py -d {{ vars.wit_dir }} -w module bindings .
componentize-py -d {{ vars.wit_dir }} -w module componentize wasi_graphics_info -o pkg/et_ws_wasi_graphics_info.wasm
{{ vars.et_cli }} module-package-json
"""
shell = "{{ vars.task_shell }}"
[tasks."prefetch:python"]
description = "Prefetch Python (uv) dependencies"
# Pin uv to the mise-managed regular CPython, not Pyodide's interpreter.
# Pyodide's is an emscripten-wasm32 interpreter; uv's auto-discovery otherwise finds and prefers the `python`
# wrapper mise's `http:pyodide` install ships (it reports CPython 3.13.2, so bare version requests like `3.13`
# / `python3.13` don't disambiguate). Point uv straight at the absolute interpreter path via the py3_unix /
# py3_win vars -- the same interpreter PYO3_PYTHON resolves to -- so the pyodide wrapper never enters discovery
# and no `mise` subprocess runs per task. Windows needs its own var because python-build-standalone lays the
# binary out at the install root (`python.exe`), not under `bin/`.
env = { UV_PYTHON = "{% if os() == 'windows' %}{{ vars.py3_win }}{% else %}{{ vars.py3_unix }}{% endif %}" }
run = """
uv sync --directory services/ws-modules/pydata1
uv sync --directory services/ws-modules/pydemo1
uv sync --directory services/ws-modules/pyeye1
uv sync --directory services/ws-modules/pyface1
uv sync --directory services/ws-modules/pyspeech1
"""
shell = "{{ vars.task_shell }}"
[tasks."gen:python-rest"]
depends = ["gen:ws-spec"]
description = "Emit the typed Python REST client via openapi-python-client (consumes generated/specs/rest.yaml)"
run = """
coreutils mkdir -p generated/python-rest/et_rest_client
# None of these args move into config/openapi-python-client.yaml.
# path / meta / overwrite / output-path are CLI-only `generate` options. Build
# them up in a shell var (split over two lines) so neither line needs a backslash
# continuation or runs past the line length; unquoted $args word-splits into argv.
args="--config config/openapi-python-client.yaml --path generated/specs/rest.yaml"
args="$args --meta none --overwrite --output-path generated/python-rest/et_rest_client"
# $args is a space-separated CLI flag list; word-splitting is intentional.
# shellcheck disable=SC2086
openapi-python-client generate $args
# Remove the .ruff_cache that openapi-python-client / our follow-up ruff drop.
# It lands next to the generated source; we don't want that committed.
coreutils rm -rf generated/python-rest/et_rest_client/.ruff_cache
# Run both ruff passes ourselves from the workspace's `ruff` install.
# openapi-python-client's built-in post-hooks (`ruff check --fix-only` + `ruff format`) are disabled via
# config/openapi-python-client.yaml because they emit "ruff is not in PATH" on Windows where ruff doesn't sit
# alongside openapi-python-client in pipx's venv. So: check first to apply fixable lints (including isort's
# "I" rules from ruff.toml), then format so the final output stays canonical.
ruff check --fix generated/python-rest/et_rest_client
ruff format generated/python-rest/et_rest_client
"""
shell = "{{ vars.task_shell }}"
[tasks."gen:python-ws"]
depends = ["gen:ws-spec"]
description = "Emit Pydantic models for the WS protocol via datamodel-code-generator"
# Runs from generated/python-ws/ for datamodel-codegen's config discovery.
# It discovers that dir's pyproject.toml [tool.datamodel-codegen] (model-shape +
# style flags); only the input/output paths are passed on the CLI.
dir = "generated/python-ws"
run = """
coreutils mkdir -p et_ws
datamodel-codegen --input ../../target/int-gen/ws.schema.json --output et_ws/messages.py
# Drop the 2-line header that custom-file-header = "#" emits, so the file starts cleanly.
# That header is a lone `#` + the blank after it. tail, not sed: datamodel-codegen always emits exactly those
# two lines, so a fixed offset is safe.
coreutils tail -n +3 et_ws/messages.py >et_ws/messages.py.tmp
coreutils mv et_ws/messages.py.tmp et_ws/messages.py
# Re-run repo ruff because datamodel-codegen's bundled ruff uses its own defaults.
# Those defaults aren't our repo ruff.toml, so re-run repo ruff: `check --fix`
# for import sorting ("I" rules), then `format` for whitespace/line-length.
ruff check --fix et_ws/messages.py
ruff format et_ws/messages.py
"""
shell = "{{ vars.task_shell }}"