Skip to main content

Make cells read-only in JupyterLab.

Project description

JupyterLab Freeze Improved

This is an opinionated fork of the JupyterLab Freeze extension (DataDog/jupyterlab-freeze).

It has made the following changes:

  1. Cells do not change colour when in Read Only or Frozen mode. The state icons remain however, so that you know each cell's freeze state.
  2. Markdown source cannot be viewed in Markdown cells when in Frozen mode, only in Read Only mode.

What Make These Changes?

As our use case is teaching using Jupyter, we wished to make these changes and therefore this fork was created.

Synopsis

This extension allows you to make cells read-only or frozen. It provides three buttons:

  • Unlock
  • Read-Only
  • Frozen

For code cells:

  • Read Only: the call can be executed, but its input cannot be changed.
  • Frozen: the cell cannot be either altered or executed.

For Markdown cells:

  • Read Only: The cell's Markdown source can viewed by double-clicking on it, but it cannot be changed.
  • Frozen: The cell's Markdown source can not be viewed when double-clicking on it.

To change the state of a selected cell, press the corresponding button.

The individual cell's state is stored in its metadata and is applied to the cell if the extension is loaded.

Requirements

  • JupyterLab >= 4.0.0

Install

NOTE! The package is not yet on PyPI and currently cannot be installed. This will be fixed in due course, when testing is complete.

To install the extension, execute:

pip install jupyterlab_freeze_improved

Uninstall

To remove the extension, execute:

pip uninstall jupyterlab_freeze_improved

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
# Change directory to the project's root directory
# Install package in development mode
pip install -e "."
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
# Run JupyterLab in another terminal
jupyter lab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the jlpm build command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

jupyter lab build --minimize=False

Development uninstall

pip uninstall jupyterlab_freeze_improved

In development mode, you will also need to remove the symlink created by jupyter labextension develop command. To find its location, you can run jupyter labextension list to figure out where the labextensions folder is located. Then you can remove the symlink named jupyterlab_freeze_improved within that folder.

Testing the extension

Frontend tests

This extension is using Jest for JavaScript code testing.

To execute them, execute:

jlpm
jlpm test

Integration tests

This extension uses Playwright for the integration tests (aka user level tests). More precisely, the JupyterLab helper Galata is used to handle testing the extension in JupyterLab.

More information are provided within the ui-tests README.

Packaging the extension

See RELEASE

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

jupyterlab_freeze_improved-0.2.1.tar.gz (890.6 kB view details)

Uploaded Source

Built Distribution

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

jupyterlab_freeze_improved-0.2.1-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_freeze_improved-0.2.1.tar.gz.

File metadata

File hashes

Hashes for jupyterlab_freeze_improved-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7752a0c1e1f95d5fa6f1b7d236fa4305fc06d52c61fa8798af1c616ffefcb7d3
MD5 2dba0164936048199f0a88486f040c72
BLAKE2b-256 3b7cde3df5662ae6eea7b133ce47566a731da4835db6954a6f34eeedd7316a39

See more details on using hashes here.

File details

Details for the file jupyterlab_freeze_improved-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_freeze_improved-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82b487165315b7df790efa24ec44dfc20fb4f04782abd979a9acebc1e25ed4ab
MD5 d964f95afa7b6f955681498eac7b42a1
BLAKE2b-256 516cb2b3654514d2ee3c093584bc7badf99a7e16a108b349fadb666ed0ae9c39

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