Lightweight JSONL execution logging for IPython.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipy_runlog-0.1.0.tar.gz.
File metadata
- Download URL: ipy_runlog-0.1.0.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b561498d1598c64596dc40649f8e7c5c55c3b8cd0bf8da3a24c7d8459a14054
|
|
| MD5 |
4606e147e4b99e07bc923838080c513d
|
|
| BLAKE2b-256 |
ee9f4984bbabf2036b0ac94ee832324b22f2f5bed302535fb20a4e6d04672d0c
|
Provenance
The following attestation bundles were made for ipy_runlog-0.1.0.tar.gz:
Publisher:
publish.yml on kromiii/ipy-runlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipy_runlog-0.1.0.tar.gz -
Subject digest:
2b561498d1598c64596dc40649f8e7c5c55c3b8cd0bf8da3a24c7d8459a14054 - Sigstore transparency entry: 1935292875
- Sigstore integration time:
-
Permalink:
kromiii/ipy-runlog@390205df5939370de960b8fe055542e4765a4146 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kromiii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@390205df5939370de960b8fe055542e4765a4146 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ipy_runlog-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ipy_runlog-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62abee770babe502cf692f3420a8447729e3b12aceb318dc247c203741b1b4e7
|
|
| MD5 |
ca9d78e88cbed9b10c8faf2223ae388c
|
|
| BLAKE2b-256 |
48d2f091166ed0037821f36ff6e82b40df181f43c665fadacc0cb3db1505464a
|
Provenance
The following attestation bundles were made for ipy_runlog-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kromiii/ipy-runlog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipy_runlog-0.1.0-py3-none-any.whl -
Subject digest:
62abee770babe502cf692f3420a8447729e3b12aceb318dc247c203741b1b4e7 - Sigstore transparency entry: 1935292895
- Sigstore integration time:
-
Permalink:
kromiii/ipy-runlog@390205df5939370de960b8fe055542e4765a4146 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kromiii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@390205df5939370de960b8fe055542e4765a4146 -
Trigger Event:
release
-
Statement type: