Skip to main content

Notebook testing with fixtures, patches, and AI-generated tests

Project description

Ipso - Closing the loop for AI-powered jupyter notebooks

AI works best with a feedback loop - make a change, verify the syntax, run the tests, and iterate.

Notebooks don't really work that way. There are no functions, everything is a global variable, and there's no place to put tests, even if you wanted to.

Ipso connects these worlds by using AI to mantain shadow metadata within a notebook to hardcode, setup, and otherwise mock any setup needed for cells to run, along with tests to ensure the cells behave properly.

This works continuously behind the scenes as you & your agents work on a notebook together. The Ipso LSP server notifies AI when the metadata has gone stale. Next, the MCP server guides the AI to make the appropriate changes, to create and ensure the cells work correctly. Finally, Ipso will run the tests in an independent kernel, to ensure that the code works correctly, without messing with your actual work.

Installing Ipso

Ipso needs to be installed in the python environment that your kernel is running in. pip install ipso will work, and pip install pytest-ipso is also needed if you want to be able to run pytest and have it automatically detect and run any ipso tests (optional)

Next, for the AI loop to work properly, you need to enable the LSP and MCP servers for your AI application. You can either point your AI to the python environment you created, or you can use something like uvx or pipx to create a global instance. For example:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "ipso": {
      "type": "local",
      "command": ["uvx", "ipso", "mcp"]
    }
  },
  "lsp": {
    "ipso": {
      "command": ["uvx", "ipso", "lsp"],
      "extensions": [".ipynb"]
    }
  }
}

Using Ipso

Just use your notebook how you normally would! As you make changes, the LSP will inform the AI to keep the metadata in sync, and it will use the MCP tool to investigate and fix any errors. Hopefully, this will allow the AI to catch any mistakes in the code it generates, or prompt further discussion as to the desired behavior (especially when changing existing logic)

To see the tests yourself, you can just run pytest "path/to/notebook", or you can use the ipso CLI to investigate, run, and edit the tests.

The CLI

The CLI lets you inspect, edit, and run the metadata that ipso attaches to each cell (fixtures, patches, and tests) without needing an AI in the loop.

Checking notebook health

# Quick check: are any cells out of date?
ipso status notebook.ipynb

# See everything ipso knows about your cells
ipso view notebook.ipynb

# Narrow it down — only cells that have tests
ipso view notebook.ipynb --filter "test:not null"

# Only show the fields you care about
ipso view notebook.ipynb --fields source,status

status exits non-zero when something needs attention, so it works well in CI or pre-commit hooks.

Running tests

# Run all cell tests
ipso test notebook.ipynb

# Run tests for specific cells
ipso test notebook.ipynb --filter "cell:abc123"

# Use a specific python environment
ipso test notebook.ipynb --python .venv/bin/python

Each cell's test runs in its own isolated kernel, so it never interferes with your live notebook state.

Editing metadata by hand

The easiest way to edit fixtures and tests directly is with the editor notebook:

# Open a side-by-side editor notebook
ipso edit notebook.ipynb

# ... make changes in notebook.ipso.ipynb ...

# Apply your edits back to the source notebook
ipso edit --continue notebook.ipynb

The editor notebook lays out each cell's fixtures, patched source, and tests as editable cells you can work with in Jupyter. When you're done, --continue folds everything back into the source notebook's metadata.

If you prefer working with JSON directly, update lets you apply changes programmatically:

# Set a fixture and test on a cell
ipso update notebook.ipynb --data '{
  "cell_id": "abc123",
  "fixtures": {"setup_db": {"description": "mock database", "source": "db = MockDB()"}},
  "test": {"name": "test_query", "source": "assert query(db) == expected"}
}'

# scaffold well-formed JSON fragments to avoid typos
ipso scaffold fixture --name setup_db --source "db = MockDB()"
ipso scaffold test --name test_query --source "assert query(db) == expected"

Accepting changes

When you've reviewed a cell and are satisfied that its metadata is correct despite the diagnostics, you can accept it to clear the warnings:

# Accept all cells
ipso accept notebook.ipynb --all

# Accept only specific cells
ipso accept notebook.ipynb --filter "cell:abc123"

Filtering

Most commands support --filter to target specific cells. Filters can match on cell ID, index, presence of metadata, validity status, and diagnostic type or severity. Multiple filters are AND-ed together; comma-separated values within a filter are OR-ed. Run ipso docs filters for the full reference.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipso-0.1.2.tar.gz (284.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ipso-0.1.2-py3-none-win_amd64.whl (3.3 MB view details)

Uploaded Python 3Windows x86-64

ipso-0.1.2-py3-none-manylinux_2_39_x86_64.whl (3.8 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

ipso-0.1.2-py3-none-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ipso-0.1.2-py3-none-macosx_10_12_x86_64.whl (3.6 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file ipso-0.1.2.tar.gz.

File metadata

  • Download URL: ipso-0.1.2.tar.gz
  • Upload date:
  • Size: 284.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ipso-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5ae60b26c64973eaf77e9d95d3b692eb69c47bacb32c20b2affebc48d659901c
MD5 d792ea3f42f60b92cd360d239ef7bdf9
BLAKE2b-256 2d6e68c3a07810ac240618c342f98d57e72d824fa4ca157d429eb8a8851cec17

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.2.tar.gz:

Publisher: ipso-publish.yaml on susu-dot-dev/ipso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipso-0.1.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: ipso-0.1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ipso-0.1.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b30c5e137c0c6250dd5ad8ef0bb2d52751e4803f4ea458564fb8b553251adf63
MD5 7cb76e4fb49d733c88505ba1d9cfc81e
BLAKE2b-256 6011c646f8766c4c28c0ce12d5d63d8b62223fbc897b76ac29e872187d61422b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.2-py3-none-win_amd64.whl:

Publisher: ipso-publish.yaml on susu-dot-dev/ipso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipso-0.1.2-py3-none-manylinux_2_39_x86_64.whl.

File metadata

  • Download URL: ipso-0.1.2-py3-none-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: Python 3, manylinux: glibc 2.39+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ipso-0.1.2-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c9b928600ff0a39cf07666532b98d33eb8e4bc498c93edd1b2ef28cb5b1fa9ac
MD5 d69867737bcffe762dd0c97bb4375781
BLAKE2b-256 8c7495374437eba121023ae2f1dfaba2ea1a86db86634ece1d3470d33da3560a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.2-py3-none-manylinux_2_39_x86_64.whl:

Publisher: ipso-publish.yaml on susu-dot-dev/ipso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipso-0.1.2-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ipso-0.1.2-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ipso-0.1.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b99e1f140502169d7223f1264b16547eae3558831116f6a5ae3e926992857f4c
MD5 498c5c693554fda884f6fda8291aa38f
BLAKE2b-256 3a8050304e3fc29b7a1f8f6a956ba8f89a63a448e3fe2884de40ea32f7b9fe7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.2-py3-none-macosx_11_0_arm64.whl:

Publisher: ipso-publish.yaml on susu-dot-dev/ipso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipso-0.1.2-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ipso-0.1.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 af09f30a44e57039d7690c7c7f0669f6ee67fd045202f745f861f436ca7f962b
MD5 c43180e35fe82db87f017b7db37b437a
BLAKE2b-256 554042d38e15f4def49c30ad011fb44fa3190bbe2bca98475507c91deb7ac268

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.2-py3-none-macosx_10_12_x86_64.whl:

Publisher: ipso-publish.yaml on susu-dot-dev/ipso

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page