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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.39+ x86-64

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

Uploaded Python 3macOS 11.0+ ARM64

ipso-0.1.5-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.5.tar.gz.

File metadata

  • Download URL: ipso-0.1.5.tar.gz
  • Upload date:
  • Size: 294.8 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.5.tar.gz
Algorithm Hash digest
SHA256 f9988c84f0b9b0a47843211a386907c9804b09f2651ffaaee8e99a24534ed598
MD5 7fead48382f8b68105372fc826374a07
BLAKE2b-256 95e35db1d53f43197cb57b4cc03db4e3dcebc6c8132c85e93702d1938dc03560

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ipso-0.1.5-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.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d1e52ddb3bfaddc0f9aedbc71c207154fe7d65fffe9f4b02b17621d6796d2624
MD5 f0199446dac77a2a7c27d3988136b217
BLAKE2b-256 5ade2163300424b43f998c1b34d586e603ed56a0d9e45e8a82db53a0964a408d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ipso-0.1.5-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.5-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 55bc4db44c4b55477a8bd9f90b61165f07a47972ccfb0a15ce4df9043afbae06
MD5 3dc2b1296601866bed83413777829725
BLAKE2b-256 041fc2d22a346fce137a8b9d3e57c754b48eb1cee0308521d682b7efdd50509b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ipso-0.1.5-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.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f1ac9d1232bcfcfa8e05429c07af713e9e8ee6f37a30acbbb53d7da36798e46e
MD5 4f7ab3666dfb366d6723fe640d810edb
BLAKE2b-256 bc81de037fd03522dfddd94ecda5a545a4462c7317d419d519a9d1855d70be34

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ipso-0.1.5-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b8fc5a3df7a729f5e388f03958743025c4e8654a8b9db531664b85eec4577c78
MD5 55c38859c448a6059bb8771abbeb67e8
BLAKE2b-256 6bbf90358218f4aa013b7bfedb39539efd73c11571ae4498c2ca315aeda1909d

See more details on using hashes here.

Provenance

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