# notebook

> A Jupyter notebook of weekly sales with tax whose cells record their own steps with ormaos.record().

A Jupyter notebook, `report.ipynb`, that reads the sales of the week from `sales.csv`, leaves out single sales above 1000 (the key-account team handles those), adds tax and sums the week. Four of its cells run their step inside `with ormaos.record():`, so each step of a session is recorded as it runs.

- Source: [`ormaos-examples/use-cases/notebook`](https://github.com/ormaos/ormaos-examples/tree/6e27be59220856263a6a5905400d8630dafe73dd/use-cases/notebook)
- Guide: [Notebook](/python/guides/notebook.md)

## Run it

`run_notebook.py` runs the cells from top to bottom in a new kernel with nbclient, writes the result to `report.executed.ipynb` and prints what the last cell printed. Or open `report.ipynb` in Jupyter and run the cells by hand.

```bash
pip install -r requirements.txt
pip install git+https://github.com/ormaos/ormaos-python
python run_notebook.py
```

```console
$ python run_notebook.py
week total with tax: 47498.40
[IPKernelApp] WARNING | Kernel is running over TCP without encryption. All communication (including code and outputs) is sent in plain text and is susceptible to eavesdropping. Use IPC transport or launch with kernel manager-provisioned CurveZMQ keys to enable transport encryption.
```

## Recorded

The cells record themselves: there is no `ormaos run`. Each block is one recording.

```console
$ ormaos list
4 recordings in .ormaos, newest first
r4  2026-11-27 12:00:00  complete  record() block  …  1 process, 2 calls, 0 exceptions (0 swallowed)  /tmp/ormaos-docs-generate/venv/bin/python ipykernel_launcher
r3  2026-11-27 12:00:00  complete  record() block  …  1 process, 1 call, 0 exceptions (0 swallowed)  /tmp/ormaos-docs-generate/venv/bin/python ipykernel_launcher
r2  2026-11-27 12:00:00  complete  record() block  …  1 process, 1 call, 0 exceptions (0 swallowed)  /tmp/ormaos-docs-generate/venv/bin/python ipykernel_launcher
r1  2026-11-27 12:00:00  complete  record() block  …  1 process, 1 call, 1 exception (0 swallowed), 1 io  /tmp/ormaos-docs-generate/venv/bin/python ipykernel_launcher
next: ormaos show r4 | ormaos show r3 | ormaos show r2 | ormaos diff r3 r4
```

```console
$ ormaos tree r2
r2:c1 drop_key_accounts(rows: list[40 dict]) -> list[34 dict]  /tmp/ipykernel_…/1887773198.py:17  …  task 1
next: ormaos exceptions r2
```

---

Source: https://docs.ormaos.com/examples/notebook/ · ormaos 0.0.1 · ormaos-python 968f69776c · ormaos-examples 6e27be5922
