Replite - An embeddable REPL powered by JupyterLite

Overview

replite

An embeddable REPL, powered by JupyterLite.

replite-numpy

Usage

To embed the code console in your website:

<iframe src="https://replite.vercel.app/retro/consoles/index.html" width="100%" height="100%">
</iframe>

Configuration

The behavior and the look of the REPL can be configured via URL parameters.

Select a kernel by default

To avoid the kernel selection dialog and choose a given kernel by default:

<iframe src="https://replite.vercel.app/retro/consoles?kernel=python" width="100%" height="100%">
</iframe>

Enable the toolbar

The toolbar can be enabled (opt-in) to add a couple of useful buttons:

<iframe src="https://replite.vercel.app/retro/consoles?toolbar=1" width="100%" height="100%">
</iframe>

toolbar

Auto execute code on startup

Custom starter code can automatically be executed on startup:

<iframe src="https://replite.vercel.app/retro/consoles?kernel=python&code=import numpy as np" width="100%" height="100%">
</iframe>
auto-execute.mp4

Create your custom deployment

TBD

Development

# create a new environment
mamba create -n replite -c conda-forge jupyterlab=3 jupyter-packaging python nodejs -y
conda activate replite

# Install JupyterLite
python -m pip install jupyterlite

# Install package in development mode
python -m pip install -e .

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

# Rebuild extension TypeScript source after making changes
jlpm run build
Comments
  • Allow some code to be silently pre-run

    Allow some code to be silently pre-run

    Hi,

    Just found this repository and it looks great! Inspired by your PRs to numpy and sympy to use this REPL to allow people to try out code in documentation pages, I was interested in using this for some of my code. However, for packages that aren't part of pyodide directly, users would have to first do something like

    import micropip
    await micropip.install('PACKAGE')
    

    before they can import PACKAGE. That would be confusing for users who don't know pyodide. My understanding is that pyodide does not want to include Python packages that have pure Python wheels available on PyPI, so this would be an issue for many packages.

    This quick PR allows for an install URL parameter that lists a set of packages to quietly install with micropip (I wasn't sure whether I should use micropip or piplite, but both work). It works both with lists of packages (&install=kimmy,scipy) or with wheel URLS (&install=https://astro.utoronto.ca/~bovy/galpywheels/galpy-1.8.0.dev0-py3-none-any.whl&code=import%20galpy) .

    I don't have any prior experience with TypeScript or the Jupyter backend, so there might be better ways to do this, but injecting the code and removing the cell seems to do what I want (I couldn't figure out how to just have the kernel execute a bit of code...).

    This works locally, but I could push a version somewhere to illustrate use better if necessary (and can add to CHANGELOG and what not if you're inclined to accept this PR).

    Thanks!

    Edit: Full example using my galaxy chemical evolution code kimmy on the Vercel deployment here.

    opened by jobovy 7
  • Add optional toolbar buttons

    Add optional toolbar buttons

    Fixes #8

    • [x] Add toolbar buttons
    • [x] Control toolbar visibility via a query string parameter (opt-in)

    https://user-images.githubusercontent.com/591645/152146676-dc93489a-11f4-4cc9-88e0-e2075ae5c331.mp4

    Opt-in toolbar

    https://user-images.githubusercontent.com/591645/152147186-f23be261-14c3-4553-b2e3-37db60e675c2.mp4

    enhancement 
    opened by jtpio 3
  • Setup the JupyterLab extension

    Setup the JupyterLab extension

    Fixes #2 Fixes #1

    So it's easier to customize the app than patching the CSS.

    Populate code via query string parameters

    https://user-images.githubusercontent.com/591645/152044572-af203c12-9328-4e48-8ed9-11de2e8f82ec.mp4

    enhancement 
    opened by jtpio 3
  • Add a postMessage API

    Add a postMessage API

    Problem

    The URL api is robust for one-off solutions, but makes it harder to integrate.

    Proposed Solution

    In addition to a well-documented URL param scheme, offer a postMessage API that allows for basic things like "run some code", arbitrary lumino commands, or anything that an extender can imagine.

    Background

    Having fought with more than a few IFrames, it can be nice to offer both a bare-minimum, fire-and-mostly-forget URL api, as well as a well-structured, message-based API. A good (counter-)example is the drawio embed mode:

    • hooray! it can do lots of things!
    • boo! that's pretty much it for docs!
      • a robust API in a JSON schema and typings would go a long way to helping implementers who wanted to build e.g. replite-react or replite-vue or whatever they want
        • indeed, as a low-effort integrator demo, it could use rjsf to draw a message builder/viewer

    Why both?

    By splitting "long term" URL params and "on-demand" postMessage an integrator can then get interesting interplay effects: pass ?ui=0&input=0 and then have the host take over firing all of the execute methods with their own buttons

    For e.g. wasm-based kernels, until we can figure out a SharedWorker worker kernels it's particularly important to not add 10s of 100mb kernels, even if in iframes. In a long-form document, a more feasible approach one would be to have a single iframe/kernel/cell, fixed in the viewport, that gets updated as the reader scrolls/clicks on things.

    Design Considerations

    As for what actually goes in this API: a really quick win is the app.commands.execute... while no a-priori schema exists, a running lab could at least enumerate what commands it has.

    opened by bollwyvl 2
  • Update to the latest JupyterLite

    Update to the latest JupyterLite

    The repl app is now part of the main JupyterLite distribution: https://jupyterlite.readthedocs.io/en/latest/applications/repl.html

    Added in https://github.com/jupyterlite/jupyterlite/pull/498

    This PR updates to using the upstream app:

    • [x] Update to jupyterlite>=0.1.0a24
    • [x] Strip source maps (pending upstream release)
    • [x] Ship only the repl app (pending upstream release)
    enhancement 
    opened by jtpio 1
  • Distribute in JupyterLite by default

    Distribute in JupyterLite by default

    Eventually this minimal REPL should be one of the apps distributed by default in JupyterLite.

    For now lite ships lab and retro by default: https://jupyterlite.readthedocs.io/en/latest/api/py/jupyterlite.html#jupyterlite.constants.JUPYTERLITE_APPS

    There could be a new app called cell.

    If this is a standalone app like retro, the look and UX could be different and not limited to the JupyterLab code console.

    We'll want to fix https://github.com/jupyterlite/jupyterlite/issues/118 first though.

    The cell app could be either in core, or as a third-party app under the jupyterlite org. The latter might require some work in the jupyterlite CLI to allow apps as (federated) plugins.

    Related to https://github.com/jupyterlite/jupyterlite/issues/148

    opened by jtpio 1
  • Automated Changelog Entry for 0.1.1 on main

    Automated Changelog Entry for 0.1.1 on main

    Automated Changelog Entry for 0.1.1 on main

    After merging this PR run the "Full Release" Workflow on your fork of jupyter_releaser with the following inputs | Input | Value | | ------------- | ------------- | | Target | jtpio/replite | | Branch | main | | Version Spec | 0.1.1 | | Since | first-commit |

    documentation 
    opened by jtpio 1
  • Disable `jupyterlab-plotly` (widgets) plugin

    Disable `jupyterlab-plotly` (widgets) plugin

    Widgets are not supported in code consoles yet (https://github.com/jupyter-widgets/ipywidgets/pull/3004).

    This should help fix the following errors logged in the dev tools console:

    image

    enhancement 
    opened by jtpio 1
  • Inject code directly

    Inject code directly

    As discussed in https://github.com/numpy/numpy.org/pull/547#issuecomment-1028066613.

    Instead of just populating the cell, we execute the code lines directly by injecting them in the console.

    https://user-images.githubusercontent.com/591645/152204519-7980e9f6-ef56-4263-bb79-4fcf3e4fd2be.mp4

    enhancement 
    opened by jtpio 1
  • Fix CSS on mobile layout

    Fix CSS on mobile layout

    Right now the cell prompt is stacked on top of the cell when the width is less than 760px:

    image

    Based on this CSS in JupyterLab: https://github.com/jupyterlab/jupyterlab/blob/3.2.x/packages/cells/style/inputarea.css#L52-L68

    For the console, we should override that or maybe even remove the prompt?

    opened by jtpio 0
  • Choose the theme via a query string parameter

    Choose the theme via a query string parameter

    It would be great to be able to choose the default theme via a command line parameter.

    For example the JupyterLab light and dark themes. But this would also work with other third-party themes distributed as prebuilt extensions.

    opened by jtpio 0
  • Choose the display language (locale) via a query string parameter

    Choose the display language (locale) via a query string parameter

    Similar to #10

    It should be possible to choose a different language than English via a query string parameter. For example French or Simplified Chinese.

    The deployments would need to include the language packs.

    opened by jtpio 1
Releases(v0.1.1)
Owner
Jeremy Tuloup
Scientific Software Engineer, @jupyter Core Developer and Distinguished Contributor
Jeremy Tuloup
Basic Clojure REPL for Sublime Text

Basic Clojure REPL for Sublime Text Goals: Decomplected: just REPL, nothing more Zero dependencies: works directly with pREPL Compact: Display code ev

Nikita Prokopov 23 Dec 24, 2021
Implements a polyglot REPL which supports multiple languages and shared meta-object protocol scope between REPLs.

MetaCall Polyglot REPL Description This repository implements a Polyglot REPL which shares the state of the meta-object protocol between the REPLs. Us

MetaCall 10 Dec 28, 2022
Calc.py - A powerful Python REPL calculator

Calc - A powerful Python REPL calculator This is a calculator with a complex sou

Alejandro 8 Oct 22, 2022
An AI-powered device to stop people from stealing my packages.

Package Theft Prevention Device An AI-powered device to stop people from stealing my packages. Installation To install on a raspberry pi, clone the re

rydercalmdown 157 Nov 24, 2022
A Pythonic Data Catalog powered by Ray that brings exabyte-level scalability and fast, ACID-compliant, change-data-capture to your big data workloads.

DeltaCAT DeltaCAT is a Pythonic Data Catalog powered by Ray. Its data storage model allows you to define and manage fast, scalable, ACID-compliant dat

null 45 Oct 15, 2022
A server shell for you to play with Powered by Django + Nginx + Postgres + Bootstrap + Celery.

A server shell for you to play with Powered by Django + Nginx + Postgres + Bootstrap + Celery.

Mengting Song 1 Jan 10, 2022
Clackety Keyboards Powered by Python

KMK: Clackety Keyboards Powered by Python KMK is a feature-rich and beginner-friendly firmware for computer keyboards written and configured in Circui

KMK Firmware 780 Jan 3, 2023
📽 Streamlit application powered by a PyScaffold project setup

streamlit-demo Streamlit application powered by a PyScaffold project setup. Work in progress: The idea of this repo is to demonstrate how to package a

PyScaffold 2 Oct 10, 2022
Runtime profiler for Streamlit, powered by pyinstrument

streamlit-profiler ???? Runtime profiler for Streamlit, powered by pyinstrument. streamlit-profiler is a Streamlit component that helps you find out w

Johannes Rieke 23 Nov 30, 2022
Pixelarticons - Pixel Art Icons made simple for Flutter, powered by pixelarticons and fontify

Pixelarticons - Pixel Art Icons made simple for Flutter, powered by pixelarticons and fontify

lask 16 Dec 12, 2022
India's own RPA Platform Python Powered

Welcome to My-AutoPylot , Made in India with ❤️ What is My-AutoPylot? PyBots is an Indian firm based in Vadodara, Gujarat. My-AutoPylot is a product d

PyBots Pvt Ltd 28 Sep 12, 2022
JupyterLite is a JupyterLab distribution that runs entirely in the browser power by wasm

JupyterLite is a JupyterLab distribution that runs entirely in the browser built from the ground-up using JupyterLab components and extensions.

Jeremy Tuloup 76 Dec 13, 2022
JupyterLite as a Datasette plugin

datasette-jupyterlite JupyterLite as a Datasette plugin Installation Install this plugin in the same environment as Datasette. $ datasette install dat

Simon Willison 11 Sep 19, 2022
A better Python REPL

ptpython A better Python REPL pip install ptpython Ptpython is an advanced Python REPL. It should work on all Python versions from 2.6 up to 3.9 and

prompt-toolkit 4.6k Dec 31, 2022
Visualize tensors in a plain Python REPL using Sparklines

Visualize tensors in a plain Python REPL using Sparklines

Shawn Presser 43 Sep 3, 2022
Basic Clojure REPL for Sublime Text

Basic Clojure REPL for Sublime Text Goals: Decomplected: just REPL, nothing more Zero dependencies: works directly with pREPL Compact: Display code ev

Nikita Prokopov 23 Dec 24, 2021
a simple REPL display lib for circuitpython

Circuitpython-termio-lib a simple REPL display lib for circuitpython Fonctions cls clear terminal screen and set cursor on top left : coords 0,0 usage

BeBoXoS 1 Nov 17, 2021
A cool little repl-based simulation written in Python

A cool little repl-based simulation written in Python planned to integrate machine-learning into itself to have AI battle to the death before your eye

Em 6 Sep 17, 2022
Implements a polyglot REPL which supports multiple languages and shared meta-object protocol scope between REPLs.

MetaCall Polyglot REPL Description This repository implements a Polyglot REPL which shares the state of the meta-object protocol between the REPLs. Us

MetaCall 10 Dec 28, 2022
Calc.py - A powerful Python REPL calculator

Calc - A powerful Python REPL calculator This is a calculator with a complex sou

Alejandro 8 Oct 22, 2022