Skip to main content

Automatically reload modified Python modules in notebooks and scripts.

Project description

PyPI Version Test Coverage Read the Docs Status View on GitHub

Overview

LiveImport reliably and automatically reloads Python modules in Jupyter notebooks. Unlike IPython's autoreload extension, LiveImport reloads are well-defined, deterministic operations that follow the semantics of a developer's import statements exactly. It maintains consistency between modules by automatically reloading dependent modules as needed, ensuring up-to-date references across a notebook and its modules.

LiveImport is designed for developers who interactively build Jupyter notebooks together with external Python code, and who want predictable reloading with minimal mystery.

Given a cell like

%%liveimport
from common import *
from nets import ConvNet, ResidualNet as ResNet
import hyperparam as hp

LiveImport will execute the import statements, then automatically reload common, nets, or hyperparam whenever their source files change. When LiveImport reloads, it will rebind names in the notebook as described by the import statements. If nets imports from hyperparam, then when hyperparam is modified, LiveImport will automatically reload nets after hyperparam.

To make the cell above transparent to IDEs like Visual Studio Code, you can hide the cell magic:

#_%%liveimport
from common import *
from nets import ConvNet, ResidualNet as ResNet
import hyperparam as hp

Hidden cell magic is a user experience feature tailored for modern notebook development. Others include tracking indirectly imported modules, protection against reloading in the middle of multi-cell runs, and optional reload notification.

If you currently use autoreload, you might consider comparing LiveImport to autoreload.

Documentation

See liveimport.readthedocs.io for a user guide and an API reference.

Installation

You can install LiveImport from PyPI with

$ pip install liveimport

You can also clone the repository and install it directly.

$ git clone https://github.com/escreven/liveimport.git
$ cd liveimport
$ pip install .

LiveImport requires Python 3.10 or greater and IPython 7.23.1 or greater.

Reliability

LiveImport includes automated tests with 100% code coverage, which are run on MacOS, Linux, and Windows with Python 3.10, 3.11, 3.12, 3.13, and 3.14 using both the oldest supported and latest versions of IPython. Notebook integration features are tested using notebook 5.7.0 and notebook latest. See the GitHub workflow for details.

If you have a copy of the source, you can run the tests yourself with

$ python test/main.py

Questions or Issues

If you have any questions or encounter any issues, please submit them on GitHub.

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

liveimport-1.2.3.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

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

liveimport-1.2.3-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file liveimport-1.2.3.tar.gz.

File metadata

  • Download URL: liveimport-1.2.3.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for liveimport-1.2.3.tar.gz
Algorithm Hash digest
SHA256 12f99c73d575bf587b2e8df38492519d9ea2e408e4ac06304d4d3b7878ad340b
MD5 82088cfda3638c961e2eff32314b06fd
BLAKE2b-256 87ffe626c9c7b28e0f631f77d8546fb1392b324b1ce05c9d9b8279c87625d2ba

See more details on using hashes here.

File details

Details for the file liveimport-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: liveimport-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for liveimport-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4174097b7d31f6d0a4e1fa5af29e3b9034648cccf78258d715b9dc0d3a1f91d0
MD5 0e121d4ae9f4bb6d2f53d81859760a6c
BLAKE2b-256 da72ba111a9f6ec163d15a82e04efbac65297fe4a7e0dd1b1f591f97b32ac2c0

See more details on using hashes here.

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