ipy-runlog
A lightweight IPython extension that records code cell execution history as JSON Lines (JSONL).
Motivation
Experiments are shaped by failed attempts as well as successful ones. Recording both preserves the trial-and-error process, giving an experiment notebook a coherent story instead of showing only its final results.
Installation
With pip:
pip install ipy-runlog
In a uv project:
uv add ipy-runlog
Usage
Load the extension — recording starts automatically:
%load_ext ipy_runlog
The log is written to .ipy_runlog/ in the current working directory. The
file name is generated from the current date and time, for example:
.ipy_runlog/20260611-123456.jsonl
Recording stops automatically when the IPython session ends.
Commands
Check the current status:
%runlog status
Switch to a new log file mid-session (closes the current log):
%runlog new experiment-01
%runlog new experiment-01 --output # also record cell output
%runlog new experiment-01 -d ./logs # custom output directory
Rename the current log file without interrupting recording:
%runlog rename feature-extraction
Stop recording manually:
%runlog stop
Show help:
%runlog help
%runlog new --help
Configuration
You can set defaults in pyproject.toml:
[tool.ipy-runlog]
directory = "./logs"
output = true
Or in .ipy_runlog.toml at the project root (used as a fallback when
pyproject.toml is absent or has no [tool.ipy-runlog] section):
directory = "./logs"
output = true
Available config keys:
| Key | Type | Default | Description |
|---|---|---|---|
directory |
string | .ipy_runlog/ |
Output directory |
output |
bool | false |
Record cell output |
name |
string | current timestamp | Default log file name |
Note: Python 3.11+ uses the built-in
tomllib. For Python 3.9–3.10, installtomlito enable config file support:pip install tomli.
How It Works
The extension uses IPython event handlers to monitor cell execution:
pre_run_cell: Triggered before a cell is executed. The extension captures the source code of the cell at this point.post_run_cell: Triggered after a cell finishes executing. The extension calculates the elapsed time, determines if it was successful or failed (including error details), and optionally captures the output.
Each event is appended as a single JSON line to the log file. On normal
session exit, a final recording_stopped event is written automatically via
atexit.
Log Format
Logs use UTF-8 encoded JSON Lines, with one event per line. New events are appended when the target file already exists.
Event types:
recording_started: recording startedcell_executed: a cell finished executingrecording_renamed: log file was renamed with%runlog renamerecording_stopped: recording stopped (includes"reason": "session_ended"on automatic stop)
A cell_executed event contains:
started_atandended_at: local timestamps in ISO 8601 formatelapsed_sec: execution time in secondsstatus:successorfailedexecution_count: the IPython execution countcode: the cell source codeoutput: the cell result when--outputis enabled; non-JSON values are stored usingrepr()error: error type, message, and traceback (always recorded on failure)
Development
Install this repository in editable mode:
python -m pip install -e .
With uv:
uv pip install -e .
Run the test suite:
uv run pytest
Metadata
Release files for ipy-runlog 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ipy_runlog-0.1.0.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ipy_runlog-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.9 kB
Release files / ipy_runlog-0.1.0.tar.gz
| Download URL | ipy_runlog-0.1.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b561498d1598c64596dc40649f8e7c5c55c3b8cd0bf8da3a24c7d8459a14054
|
|
BLAKE2b-256 checksum How to use checksums |
ee9f4984bbabf2036b0ac94ee832324b22f2f5bed302535fb20a4e6d04672d0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / ipy_runlog-0.1.0-py3-none-any.whl
| Download URL | ipy_runlog-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62abee770babe502cf692f3420a8447729e3b12aceb318dc247c203741b1b4e7
|
|
BLAKE2b-256 checksum How to use checksums |
48d2f091166ed0037821f36ff6e82b40df181f43c665fadacc0cb3db1505464a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency log