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.4.tar.gz (293.7 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.4-py3-none-win_amd64.whl (3.2 MB view details)

Uploaded Python 3Windows x86-64

ipso-0.1.4-py3-none-manylinux_2_39_x86_64.whl (3.7 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

ipso-0.1.4-py3-none-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ipso-0.1.4-py3-none-macosx_10_12_x86_64.whl (3.5 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: ipso-0.1.4.tar.gz
  • Upload date:
  • Size: 293.7 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.4.tar.gz
Algorithm Hash digest
SHA256 a3796f73efba99504aab537e3460409ad5a8badc1650bc3a3c2a00cba6471a86
MD5 8df656c97e8f7b2172b90ad5033dde6d
BLAKE2b-256 0f955006b2939bf1ca80e1f7daa83d366402f35d6ff331bc37b5751cebd530a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.4.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.4-py3-none-win_amd64.whl.

File metadata

  • Download URL: ipso-0.1.4-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6921c246fbec6c304bd05fa8b8b59dba7da8e0b6b783d24e6f377e40074113e3
MD5 70cb008465829f66070d7a488e809500
BLAKE2b-256 c7f52315d88cfef4bf9c5b219ad0dd1e2d29c3954f1de2be59815cb4f52e44f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.4-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.4-py3-none-manylinux_2_39_x86_64.whl.

File metadata

  • Download URL: ipso-0.1.4-py3-none-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 3.7 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.4-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ddcd17f977d75dce5b62d2824e1b92e8581e3885d787b4387acc9aeb7c79a5f2
MD5 8d2b2b928ddfb34dc5cf2e8872b4352a
BLAKE2b-256 60944dc989af1d9b31982fb3f3c7ba23c219279f1239c55ff75f058e7875b511

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.4-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.4-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: ipso-0.1.4-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.4 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.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ef6a2b91d46955bb8196f4d0132b6d1226c313fc841d2eab817f93726b773b6
MD5 3a4ad0c1f497f270d191cea526619c2b
BLAKE2b-256 79faa5ad5f72ed42b1acfcaf19980e007dc7fe46e2d46f4da4a2a9a2ea2c4911

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.4-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.4-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ipso-0.1.4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4cacbeac7980747bc1007bdc78a1a44e0e609e0c9497a59c312f9dfe231b97ee
MD5 d81491acd36cb3da36a5d4dedbd3bf9f
BLAKE2b-256 c4c1d82cdd39f25cc2b39d295fff4776aaea9ef88b80ecdce7cf016467842dec

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipso-0.1.4-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