Git Product home page Git Product logo

jupyterlite-webr-kernel's Introduction

WebR kernel for JupyterLite

This repository contains a JupyterLite kernel that uses webR to execute R code. When the kernel is started, the webR WebAssembly binaries are downloaded from CDN and loaded into the page.

Demonstration instance

A demo instance of JupyterLite including the webR kernel and a sample Jupyter notebook containing R code can be found at https://jupyter.r-wasm.org.

Install

This package is not yet available on PyPI. You can install it from GitHub:

pip install git+https://github.com/r-wasm/jupyterlite-webr-kernel.git

or from a local clone:

git clone https://github.com/r-wasm/jupyterlite-webr-kernel
cd jupyterlite-webr-kernel
pip install .

Then build your JupyterLite site:

jupyter lite build

Limitations

Headers

To use the webR kernel with JupyterLite, the page must be served with certain security-related HTTP headers so that it is cross-origin isolated. By setting these headers webR's SharedArrayBuffer based communication channel can be used:

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

Virtual file system storage

Due to limitations in the way the webR worker thread is implemented, the persistent JupyterLite file storage and the Emscripten VFS used by webR are not accessible to one another. The simplest way to import data into a webR notebook at the time of writing is by using R functions such as read.csv() with a publicly accessible URL.

Interruption

While webR supports interrupting long running computations, interrupting cell execution has not yet been implemented in JupyterLite. An infinite looping cell can only be recovered by restarting the kernel.

Contributing

Development install

Note: You will need NodeJS and Python 3.8+ to build the extension package. There is an environment.yml file for conda/mamba/micromamba users to create a conda environment with the required dependencies.

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 jupyterlite-webr-kernel directory
# Install package in development mode
python -m pip install -e ".[dev]"

# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite

# Rebuild extension Typescript source after making changes
jlpm run build

# Rebuild JupyterLite after making changes
jupyter lite clean && jupyter lite build

To serve the extension with the JupyterLite server, you will need to set the required HTTP headers. The config.json file in this repository contains the required headers. You can start the JupyterLite server with the following command:

jupyter lite serve --config=config.json

Note that making changes to the extension will not automatically re-install the extension in the JupyterLite server. You will need to re-build and restart the server to see changes in the extension.

jupyter lite clean && jupyter lite build && jupyter lite serve --config=config.json

Development uninstall

pip uninstall jupyterlite-webr-kernel

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 jupyterlite-webr-kernel within that folder.

jupyterlite-webr-kernel's People

Contributors

georgestagg avatar adamblake avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.