|
| 1 | +# aima-python in the browser (JupyterLite proof-of-concept) |
| 2 | + |
| 3 | +This folder builds a **JupyterLite** site that runs a few `aima` notebooks |
| 4 | +entirely in the browser via [Pyodide](https://pyodide.org) — no server, no |
| 5 | +local install. It is the first concrete step of the "Python web companion" |
| 6 | +discussed in [issue #1072](https://github.com/aimacode/aima-python/issues/1072). |
| 7 | + |
| 8 | +When deployed, it lives next to the API docs on GitHub Pages: |
| 9 | + |
| 10 | +- API docs: <https://aimacode.github.io/aima-python/> |
| 11 | +- Try in browser: <https://aimacode.github.io/aima-python/lite/> |
| 12 | + |
| 13 | +## What runs (and what does not) |
| 14 | + |
| 15 | +Pyodide ships scientific-Python wheels (numpy, scipy, matplotlib, networkx, |
| 16 | +pandas, …), so the *lightweight* parts of `aima` work in the browser. The |
| 17 | +heavy native dependencies in `requirements.txt` — TensorFlow/Keras, OpenCV |
| 18 | +(`cv2`), `cvxopt`, `qpsolvers` — are **not** available in Pyodide, so notebooks |
| 19 | +that need them (deep learning, parts of perception, LP-based game theory) |
| 20 | +cannot run here. The `aima` wheel is therefore installed with `deps=False` and |
| 21 | +the demo notebooks are restricted to modules that import only Pyodide-provided |
| 22 | +packages. |
| 23 | + |
| 24 | +The proof-of-concept ships two such notebooks: |
| 25 | + |
| 26 | +- `content/search.ipynb` — BFS / A* on the Romania map (`aima.search`, numpy only). |
| 27 | +- `content/games.ipynb` — minimax / alpha-beta on Tic-Tac-Toe (`aima.games`, numpy only). |
| 28 | + |
| 29 | +`content/Welcome.ipynb` shows the one-cell install pattern used by every notebook. |
| 30 | + |
| 31 | +## Build locally |
| 32 | + |
| 33 | +```bash |
| 34 | +cd lite |
| 35 | +./build.sh # builds the aima wheel + runs `jupyter lite build` |
| 36 | +python -m http.server -d _output 8000 # then open http://localhost:8000 |
| 37 | +``` |
| 38 | + |
| 39 | +`build.sh` installs the build toolchain from `requirements-lite.txt`, builds an |
| 40 | +`aima` wheel from the repo root, and bundles it into the JupyterLite site so the |
| 41 | +notebooks can `piplite.install("aima", deps=False)` offline. |
| 42 | + |
| 43 | +## Status / next steps |
| 44 | + |
| 45 | +This is a **proof of concept** (issue #1072 stays open until it is a complete |
| 46 | +companion). Remaining work: |
| 47 | + |
| 48 | +- Verify in-browser execution across browsers (Pyodide runs only in a real |
| 49 | + browser, so this cannot be checked in headless CI — the CI job only proves the |
| 50 | + static site *builds*). |
| 51 | +- Port more lightweight notebooks (logic, csp, planning, probability) once their |
| 52 | + in-browser behaviour is confirmed; csp needs `sortedcontainers`, logic needs |
| 53 | + `networkx` (both pure-Python, installable in Pyodide). |
| 54 | +- Decide whether to grow this into a full MyST / Jupyter Book textbook companion. |
0 commit comments