Skip to content

Commit da751db

Browse files
authored
Merge pull request #5 from fideus-labs/package-description
Add PyPI descriptions and metadata for pyodide-pool and wasm-multiprocessing
2 parents ea87eee + 53a2a05 commit da751db

7 files changed

Lines changed: 156 additions & 15 deletions

File tree

‎demos/jupyterlite/files/01-pool-basics.ipynb‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@
3737
"source": [
3838
"## Install the wheel\n",
3939
"\n",
40-
"The site ships the driver-side Python package as a wheel under\n",
41-
"`files/wheels/`. The path below is absolute because the kernel worker\n",
42-
"resolves relative URLs against its own script URL, not against the notebook;\n",
43-
"this site is served at the domain root (see `scripts/serve-lite.mjs`)."
40+
"The site ships the driver-side Python package as a wheel in its own\n",
41+
"piplite index, so it installs by name. piplite checks that index before\n",
42+
"PyPI, so the notebook runs the wheel built with this site."
4443
]
4544
},
4645
{

‎demos/jupyterlite/files/04-multiprocessing.ipynb‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@
3535
"source": [
3636
"## Install both wheels\n",
3737
"\n",
38-
"`wasm_multiprocessing` depends on `pyodide_pool` (which is not on PyPI),\n",
39-
"so the pool wheel installs first. The paths are absolute for the same\n",
40-
"reason as in `01-pool-basics.ipynb`: the kernel worker resolves relative\n",
41-
"URLs against its own script URL, and this site is served at the domain\n",
42-
"root."
38+
"Both install by name from this site's piplite index, as in\n",
39+
"`01-pool-basics.ipynb`; `wasm_multiprocessing`'s `pyodide_pool`\n",
40+
"dependency resolves from the same index before PyPI."
4341
]
4442
},
4543
{

‎python/README.md‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# 🐍⚡ pyodide-pool
2+
3+
Run Python callables and dask graphs in parallel on a pool of
4+
[Pyodide](https://pyodide.org) Web Workers.
5+
6+
🔗 [Live Demo](https://fideus-labs.github.io/python-wasm-parallelism/) ·
7+
[Source](https://github.com/fideus-labs/python-wasm-parallelism)
8+
9+
A single Pyodide interpreter is strictly single-threaded (no `-pthread`, no
10+
`fork`), so parallelism means *many interpreters*. `pyodide-pool` is the
11+
driver-side Python API for a pool of Web Workers (browser) or
12+
`worker_threads` (Node), each hosting its own Pyodide interpreter:
13+
14+
- **`submit`** — run one cloudpickled call on a worker and await its result.
15+
- **`compute` / `get`** — an async dask scheduler that executes
16+
`dask.delayed` / `dask.bag` / dask-array graphs in parallel on the pool.
17+
- **Package mirroring** — packages loaded in the driver (e.g. numpy) are
18+
installed on each worker on first use.
19+
- **Remote errors** — the original Python exception is re-raised on the
20+
driver with the worker traceback chained.
21+
22+
The package runs only in the driver Pyodide instance; workers never install
23+
it. It is async-first: blocking the driver would starve the event loop the
24+
pool lives on.
25+
26+
## Usage
27+
28+
```python
29+
import dask
30+
import pyodide_pool
31+
32+
# In JupyterLite: import the JS bundle and start 4 nested workers
33+
pool = await pyodide_pool.create_pool(pool_size=4)
34+
35+
value = await pyodide_pool.submit(fn, *args, **kwargs) # one remote call
36+
total = await pyodide_pool.compute(dask.delayed(sum)([...])) # dask collections
37+
```
38+
39+
`create_pool` loads the self-contained JS bundle from the JupyterLite site by
40+
default; pass `js_url=` to load it from elsewhere. A web app that embeds
41+
Pyodide can instead create the JS `PyodidePool` itself and register it with
42+
`pyodide.registerJsModule('js_pyodide_pool', { pool })`.
43+
44+
Install `pyodide-pool[dask]` for `compute` / `get`.
45+
46+
For the multiprocessing-style API, see
47+
[`wasm-multiprocessing`](https://github.com/fideus-labs/python-wasm-parallelism/tree/main/python/wasm_multiprocessing).
48+
49+
## Documentation
50+
51+
- [Project README](https://github.com/fideus-labs/python-wasm-parallelism#readme)
52+
- [dask scheduler design](https://github.com/fideus-labs/python-wasm-parallelism/blob/main/docs/architecture/dask-scheduler-design.md)
53+
- [Benchmarks](https://github.com/fideus-labs/python-wasm-parallelism/tree/main/docs/benchmarks)
54+
55+
## License
56+
57+
MIT

‎python/pyproject.toml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,33 @@ build-backend = "hatchling.build"
55
[project]
66
name = "pyodide-pool"
77
description = "Run Python callables and dask graphs on a pool of Pyodide Web Workers (driver-side API)"
8+
readme = "README.md"
89
license = "MIT"
910
requires-python = ">=3.11"
11+
keywords = ["pyodide", "webassembly", "wasm", "web-workers", "parallel", "dask", "jupyterlite"]
12+
classifiers = [
13+
"Development Status :: 3 - Alpha",
14+
"Environment :: WebAssembly :: Emscripten",
15+
"Framework :: Jupyter",
16+
"Intended Audience :: Developers",
17+
"Intended Audience :: Science/Research",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3 :: Only",
20+
"Topic :: Scientific/Engineering",
21+
"Topic :: System :: Distributed Computing",
22+
]
1023
# cloudpickle is the wire format of every submitted task (_bridge); dask is
1124
# only needed for compute/get and stays an extra. Both resolve in Pyodide:
1225
# cloudpickle ships in the distribution, dask installs from PyPI via
1326
# micropip/piplite.
1427
dependencies = ["cloudpickle"]
1528
dynamic = ["version"]
1629

30+
[project.urls]
31+
Homepage = "https://github.com/fideus-labs/python-wasm-parallelism"
32+
Demo = "https://fideus-labs.github.io/python-wasm-parallelism/"
33+
Issues = "https://github.com/fideus-labs/python-wasm-parallelism/issues"
34+
1735
[project.optional-dependencies]
1836
dask = ["dask"]
1937

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# 🧩 wasm-multiprocessing
2+
3+
`multiprocessing.Pool` for [Pyodide](https://pyodide.org): same API, Web
4+
Workers underneath.
5+
6+
🔗 [Live Demo](https://fideus-labs.github.io/python-wasm-parallelism/) ·
7+
[Source](https://github.com/fideus-labs/python-wasm-parallelism)
8+
9+
Stdlib `multiprocessing` cannot run under WebAssembly (no `fork`, no
10+
`-pthread`). `wasm-multiprocessing` provides stdlib-shaped
11+
`Pool`/`AsyncResult` over a pool of Pyodide Web Workers, so existing
12+
`Pool`-based code runs after changing one import line, within the limits
13+
below.
14+
15+
## Usage
16+
17+
```python
18+
import pyodide_pool
19+
20+
await pyodide_pool.create_pool(pool_size=4) # start the worker pool
21+
22+
# was: from multiprocessing import Pool
23+
from wasm_multiprocessing import Pool
24+
25+
with Pool(4) as pool:
26+
counts = await pool.amap(count_primes, ranges) # portable everywhere
27+
# or, where JSPI is available, block for real:
28+
# counts = pool.map(count_primes, ranges)
29+
```
30+
31+
- **Async-native everywhere** — `amap`, `astarmap`, `aapply`, … .
32+
- **Blocking where safe** — `map`/`starmap`/`apply`/`join` and
33+
`AsyncResult.get`/`wait` truly block where JSPI stack switching is
34+
available; elsewhere they raise a `RuntimeError` naming the async
35+
replacement.
36+
- **Honest limits** — fork-shaped APIs (`Process`, `Queue`, `Manager`,
37+
shared memory, locks) raise `NotImplementedError`: WebAssembly workers
38+
share nothing.
39+
40+
Built on [`pyodide-pool`](https://github.com/fideus-labs/python-wasm-parallelism/tree/main/python),
41+
which handles cloudpickle transport, package mirroring, and the JS bridge.
42+
Like `pyodide-pool`, it runs only in the driver Pyodide instance.
43+
44+
## Documentation
45+
46+
- [Project README](https://github.com/fideus-labs/python-wasm-parallelism#readme)
47+
- [multiprocessing shim design](https://github.com/fideus-labs/python-wasm-parallelism/blob/main/docs/architecture/multiprocessing-shim-design.md)
48+
— full API mapping
49+
- [dask vs multiprocessing](https://github.com/fideus-labs/python-wasm-parallelism/blob/main/docs/architecture/dask-vs-multiprocessing.md)
50+
51+
## License
52+
53+
MIT

‎python/wasm_multiprocessing/pyproject.toml‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,32 @@ build-backend = "hatchling.build"
55
[project]
66
name = "wasm-multiprocessing"
77
description = "multiprocessing.Pool-compatible API over a pool of Pyodide Web Workers (driver-side shim)"
8+
readme = "README.md"
89
license = "MIT"
910
requires-python = ">=3.11"
11+
keywords = ["pyodide", "webassembly", "wasm", "web-workers", "parallel", "multiprocessing", "jupyterlite"]
12+
classifiers = [
13+
"Development Status :: 3 - Alpha",
14+
"Environment :: WebAssembly :: Emscripten",
15+
"Framework :: Jupyter",
16+
"Intended Audience :: Developers",
17+
"Intended Audience :: Science/Research",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3 :: Only",
20+
"Topic :: Scientific/Engineering",
21+
"Topic :: System :: Distributed Computing",
22+
]
1023
# pyodide-pool is the single choke point for cloudpickle + JS bridging
1124
# (_bridge.submit / submit_batch); the shim adds no second copy — it only
12-
# needs cloudpickle itself for the pickle-by-value registration. pyodide-pool
13-
# is not on PyPI: install both wheels together (JupyterLite ships both).
25+
# needs cloudpickle itself for the pickle-by-value registration.
1426
dependencies = ["pyodide-pool", "cloudpickle"]
1527
dynamic = ["version"]
1628

29+
[project.urls]
30+
Homepage = "https://github.com/fideus-labs/python-wasm-parallelism"
31+
Demo = "https://fideus-labs.github.io/python-wasm-parallelism/"
32+
Issues = "https://github.com/fideus-labs/python-wasm-parallelism/issues"
33+
1734
[tool.hatch.version]
1835
path = "wasm_multiprocessing/__init__.py"
1936

‎scripts/build-lite-assets.mjs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
// python/pyodide_pool/loader.py)
77
// 2. the pyodide_pool and wasm_multiprocessing wheels (python/pyproject.toml
88
// and python/wasm_multiprocessing/pyproject.toml, built with uv)
9-
// -> demos/jupyterlite/files/wheels/ (installed by the notebooks'
10-
// first piplite cell; wasm_multiprocessing depends on pyodide_pool,
11-
// which is not on PyPI, so the notebooks install the pool wheel first)
9+
// -> demos/jupyterlite/files/wheels/ (checked by `npm run check:wheel`)
1210
// 3. the same wheels -> demos/jupyterlite/pypi/, where `jupyter lite build`
1311
// indexes them into a local piplite index — so notebooks can
1412
// `%pip install pyodide-pool` by NAME, which resolves correctly even
1513
// when the site is hosted under a subpath (GitHub Pages), unlike the
16-
// root-absolute /files/wheels/ URLs.
14+
// root-absolute /files/wheels/ URLs. piplite prefers this index over
15+
// PyPI, so the site runs this checkout's wheels, not the PyPI releases.
1716
//
1817
// All output directories are generated (gitignored); this script is the
1918
// only writer.

0 commit comments

Comments
 (0)