Skip to main content

An IPython Kernel that automatically saves and restores Jupyter Notebook execution states.

Project description

ElasticKernel

Never lose your Jupyter variables to a kernel restart again.

ElasticKernel is a custom IPython kernel that automatically checkpoints your notebook's execution state and restores it after a restart or crash โ€” no manual pickle.dump required. Pick up exactly where you left off.

PyPI version Python versions Downloads Downloads/month License

๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž็‰ˆใฏ README.ja.md ใ‚’ๅ‚็…งใ—ใฆใใ ใ•ใ„ใ€‚

Demo

The same workflow in both clips: define a variable a = 1, then restart the kernel. The difference is what happens next.

Standard kernel (ipykernel) ElasticKernel
โŒ After the restart, a is gone โ€” %whos reports "Interactive namespace is empty." โœ… After the restart, a is automatically restored โ€” %whos still shows aย ย intย ย 1.

If the videos don't play inline, click them to view: ipykernel ยท ElasticKernel.

Why ElasticKernel?

Every Jupyter user has been there: a long computation finishes, then an accidental kernel restart (or an out-of-memory crash) wipes every variable in your session. The usual workaround is scattering pickle.dump / joblib.dump calls everywhere and remembering to reload them by hand.

ElasticKernel removes that chore entirely:

  • ๐Ÿ”„ Automatic state recovery โ€” your variables survive kernel restarts and shutdowns, with zero changes to your code.
  • ๐Ÿง  Dependency-aware โ€” tracks how cells and variables depend on one another to restore a consistent state.
  • โšก Cost-optimized checkpoints โ€” for each variable it decides whether to serialize it or recompute it on restore, based on serialization size vs. recomputation cost (a min-cut optimization).
  • ๐Ÿช„ Drop-in โ€” just pick the Python 3 (ElasticKernel) kernel; the rest of your workflow is unchanged.

Installation & Usage

Local

  1. Install the package:

    $ pip install elastic-kernel
    
  2. Install the kernel:

    $ elastic-kernel install
    Elastic Kernel installed from: /path/to/elastic_kernel
    
  3. Verify the kernel is installed:

    $ jupyter kernelspec list
    Available kernels:
      elastic_kernel    /path/to/Jupyter/kernels/elastic_kernel
    
  4. Launch JupyterLab:

    $ jupyter lab --ip=0.0.0.0
    
  5. Open JupyterLab in your browser.

  6. Select the Python 3 (ElasticKernel) kernel.

Docker

  1. Pull the image:

    docker pull ghcr.io/mryutaro/elastickernel
    
  2. Start a container:

    docker run -p 8888:8888 ghcr.io/mryutaro/elastickernel
    
  3. Open JupyterLab in your browser.

  4. Select the Python 3 (ElasticKernel) kernel.

Supported versions

ElasticKernel is tested on every push and pull request against a CI matrix of Python versions. The checkpoint save โ†’ restore round trip (record_event โ†’ checkpoint โ†’ load_checkpoint) is verified on each of them.

Component Verified versions
Python 3.9, 3.10, 3.11, 3.12, 3.13
ipykernel / jupyterlab latest release compatible with each Python above (resolved by uv sync)

Python 3.8 reached end-of-life in October 2024 and is no longer tested. The version matrix lives in .github/workflows/test.yml.

Supported libraries

ElasticKernel can restore a checkpointed object two ways, and a cost optimizer (min-cut) picks one per object at checkpoint time โ€” neither is merely a fallback:

  • Migrate โ€” serialize the object with dill and reload it.
  • Recompute โ€” re-run the cell that produced it.

CI verifies several representative object types per library below โ€” a library exposes many types, so this is a sample rather than a whole-library guarantee โ€” and reports whether each restore path reproduces each one.

Legend:

  • โœ… โ€” restored correctly via this path.
  • โž– โ€” not serializable, so the Migrate path does not apply (ElasticKernel uses Recompute instead).
  • โŒ โ€” failed: the object could not be restored, or it is a known limitation.

The table is generated by scripts/library_coverage.py and kept in sync by the library-coverage workflow.

Library Object Migrate Recompute Verified version
numpy ndarray โœ… โœ… 2.3.4
structured array โœ… โœ… 2.3.4
masked array โœ… โœ… 2.3.4
datetime64 array โœ… โœ… 2.3.4
pandas DataFrame โœ… โœ… 3.0.3
Series โœ… โœ… 3.0.3
Series (category) โœ… โœ… 3.0.3
DataFrame (DatetimeIndex) โœ… โœ… 3.0.3
scipy csr_matrix (sparse) โœ… โœ… 1.17.1
csc_matrix (sparse) โœ… โœ… 1.17.1
stats frozen distribution โœ… โœ… 1.17.1
scikit-learn LinearRegression (fitted) โœ… โœ… 1.9.0
StandardScaler (fitted) โœ… โœ… 1.9.0
RandomForestClassifier (fitted) โœ… โœ… 1.9.0
matplotlib Figure (line plot) โœ… โœ… 3.11.0
Figure (imshow) โœ… โœ… 3.11.0
seaborn FacetGrid โœ… โœ… 0.13.2
Axes (scatterplot) โœ… โœ… 0.13.2
opencv (cv2) ndarray (grayscale image) โœ… โœ… 4.13.0.92
ndarray (color image) โœ… โœ… 4.13.0.92
requests Response โœ… โœ… 2.32.5
Session โœ… โœ… 2.32.5

How It Works

ElasticKernel extends the IPython kernel to observe each cell execution. As you run cells it builds a dependency graph of variables and the cell executions that produce them. When the kernel shuts down or restarts, it profiles serialization speed, runs a cost optimizer to split variables into a migrate set (serialized to disk) and a recompute set (regenerated by re-running cells), and writes a checkpoint. On the next start it loads the checkpoint, injects the migrated variables back into your namespace, and recomputes the rest.

Documentation

Publication

This project was presented in the following paper. If you use ElasticKernel in your research, please cite:

R. Matsumoto, K. Taniguchi, T. Hayami, K. Takahashi, and S. Date. "ElasticHub: A Cost-Efficient JupyterHub Platform via Automated Scaling with Kubernetes on Hybrid Cloud." Proceedings of the 16th International Conference on Cloud Computing and Services Science, pp. 261โ€“268, 2026. DOI: 10.5220/0014840200004039

@inproceedings{matsumoto2026elastichub,
  author    = {Matsumoto, R. and Taniguchi, K. and Hayami, T. and Takahashi, K. and Date, S.},
  title     = {ElasticHub: A Cost-Efficient JupyterHub Platform via Automated Scaling with Kubernetes on Hybrid Cloud},
  booktitle = {Proceedings of the 16th International Conference on Cloud Computing and Services Science},
  year      = {2026},
  pages     = {261--268},
  isbn      = {978-989-758-829-7},
  issn      = {2184-5042},
  doi       = {10.5220/0014840200004039}
}

Acknowledgments

This project includes code from ElasticNotebook, developed at the University of Illinois. ElasticNotebook is licensed under the Apache License 2.0.

Zhaoheng Li, Pranav Gor, Rahul Prabhu, Hui Yu, Yuzhou Mao, Yongjoo Park. "ElasticNotebook: Enabling Live Migration for Computational Notebooks." Proceedings of the VLDB Endowment, Vol. 17, No. 2, pp. 119-133, 2023.

License

Licensed under the Apache License 2.0.

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

elastic_kernel-0.2.2.tar.gz (72.0 kB view details)

Uploaded Source

Built Distribution

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

elastic_kernel-0.2.2-py3-none-any.whl (66.1 kB view details)

Uploaded Python 3

File details

Details for the file elastic_kernel-0.2.2.tar.gz.

File metadata

  • Download URL: elastic_kernel-0.2.2.tar.gz
  • Upload date:
  • Size: 72.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for elastic_kernel-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8efb9a73fae64f0aa0e729b107c2ed0834323633091653db12c48cfca7b597e2
MD5 076efeb34abcf5dc773dcfbce0fe0b67
BLAKE2b-256 1116c38ccc88beb2b0c81dcdaf2cd05cdc4fdfe42711ace27785e8cc509acb9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for elastic_kernel-0.2.2.tar.gz:

Publisher: publish-to-pypi.yml on MRyutaro/ElasticKernel

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

File details

Details for the file elastic_kernel-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: elastic_kernel-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 66.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for elastic_kernel-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db1a862d045db31ecd7202b23ea20d6e39724456d3086b0420edd9e9b1aa2ff6
MD5 7a1033c50aa256ac4f34c709b8c5e587
BLAKE2b-256 d9a6755d824dc1ac9f20b8592eb159e7b58d4ccde189ec0f5173f1239b291316

See more details on using hashes here.

Provenance

The following attestation bundles were made for elastic_kernel-0.2.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on MRyutaro/ElasticKernel

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