Skip to main content

Save and load notebooks to local-storage

Project description

Jupyter Offline Notebook

Binder PyPI Build Status

Save and load notebooks to browser storage, even if you've lost your connection to the server.

Installation

pip install jupyter-offlinenotebook

This should automatically enable the extension. If it is not listed in jupyter nbextension list or jupyter serverextension list install and enable it:

jupyter nbextension install --py jupyter_offlinenotebook --sys-prefix
jupyter nbextension enable --py jupyter_offlinenotebook --sys-prefix

jupyter serverextension install --py jupyter_offlinenotebook --sys-prefix
jupyter serverextension enable --py jupyter_offlinenotebook --sys-prefix

Usage

Offline notebook buttons

You should see up to five new buttons depending on your configuration and where you are running the notebook:

  • download the in-memory (browser) state of the notebook
  • save the in-memory state of the notebook to local-storage
  • load a notebook from local-storage
  • open the permanent URL of the repository containing this notebook
  • copy the permanent mybinder URL to share this repository

Saving and loading uses the repository ID and the path of the current notebook.

You should always see the Download button. If you are running this on mybinder all buttons should be visible. See the configuration section below to enable the other buttons on other systems.

If you don't see the buttons check the Javascript console log.

See example.ipynb

Configuration

This extension can be configured in jupyter_notebook_config.py by setting the following properties of c.OfflineNotebookConfig:

  • repository_id: A callable that returns the repository ID. This is used when storing and retrieving notebooks. Default is the value of the BINDER_REPO_URL environment variable.
  • repository_ref_url: A callable that returns the repository reference URL. Default is the value of the BINDER_REF_URL environment variable.
  • binder_persistent_url: A callable that returns the repository reference URL. Default is the values of the BINDER_LAUNCH_HOST and BINDER_PERSISTENT_REQUEST environment variables.
  • binder_repo_label: A callable that returns the label used to link to the repository.

JupyterLab Extension

The JupyterLab extension is still under development. To try it out:

Binder npm

Installation (JupyterLab 2)

pip install jupyter-offlinenotebook
jupyter labextension install jupyter-offlinenotebook

JupyterLab 3 support is available in the master branch but is not yet released.

Warning

This extension is still in development. It is only tested on Firefox. Breaking changes may occur in future.

There are several major limitations including:

  • Local-storage is limited by quotas imposed by the browser.
  • A repository ID and path of the notebook within Jupyter Notebook are used, joined by a . This may change in future.

Development notes

This extension stores notebooks in browser storage using the IndexedDB API, wrapped with Dexie.js.

One server API call is made during initialisation to obtain the storage configuration. Everything else is done client-side so should work even if the server is disconnected.

The master branch supports both JupyterLab 2 and 3 as well as Jupyter Notebook, but it must be built using JupyterLab 3. This is because the JavaScript assets are compiled using JupyterLab's jlpm command. Install the development dependencies:

pip install -r dev-requirements-jl3.txt

To build and install the development version on Jupyter Notebook and JupyterLab 3:

pip install .

This automatically runs jlpm. JupyterLab 3 supports the installation of extensions as a static package so no further steps are required.

If you are using JupyterLab 2 you must manually install the JavaScript component of the extension:

pip install .
jupyter labextension link

Tagged releases of this repository are automatically published to Pypi and NPM by Travis.

To test that the binder and repo buttons work when developing locally set some placeholder environment variables, e.g.:

BINDER_LAUNCH_HOST=http://localhost BINDER_REPO_URL=http://localhost BINDER_PERSISTENT_REQUEST=v2/gh/repo BINDER_REF_URL=http://localhost jupyter-lab --debug

If you make any changes remember to run all linters and auto-formaters:

  • pre-commit run -a
  • jlpm run eslint
  • jlpm run prettier

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

jupyter_offlinenotebook-0.2.0rc0.tar.gz (181.6 kB view details)

Uploaded Source

Built Distribution

jupyter_offlinenotebook-0.2.0rc0-py3-none-any.whl (350.6 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_offlinenotebook-0.2.0rc0.tar.gz.

File metadata

  • Download URL: jupyter_offlinenotebook-0.2.0rc0.tar.gz
  • Upload date:
  • Size: 181.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.7

File hashes

Hashes for jupyter_offlinenotebook-0.2.0rc0.tar.gz
Algorithm Hash digest
SHA256 d3ef2ba30b79c333300d0f19f538cebcc469f5c7ce92be84ecf58262624a95b1
MD5 7f9cff3af708247f994123d852e1d131
BLAKE2b-256 b18a174af91b9632dbfca85bce47f70f529988e0ad9b0e917d3d1e2822989559

See more details on using hashes here.

File details

Details for the file jupyter_offlinenotebook-0.2.0rc0-py3-none-any.whl.

File metadata

  • Download URL: jupyter_offlinenotebook-0.2.0rc0-py3-none-any.whl
  • Upload date:
  • Size: 350.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.7

File hashes

Hashes for jupyter_offlinenotebook-0.2.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 e17dc0f46bd14c0145611bd96b750cb6d3e067980460f03935540cb4e8754bfe
MD5 48fb2c1dc534135cf91e0db33b82241a
BLAKE2b-256 3e3da325add3f530a32b3b10bff1227868a19d96e8fa1736456f67e9644a0707

See more details on using hashes here.

Supported by

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