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
Cvdl-hw2 - Find Contour, Camera Calibration, Augmented Reality and Stereo Disparity Map

opevcvdl-hw2 This project uses openCV and Qt to achieve the requirements. Version Python 3.7 opencv-contrib-python 3.4.2.17 Matplotlib 3.1.1 pyqt5 5.1

Kenny Cheng 3 Aug 17, 2022
A simply dashboard to view commodities position data based on CFTC reports

commodities-dashboard A simply dashboard to view commodities position data based on CFTC reports This is a python project using Dash and plotly to con

71 Dec 19, 2022
CDM Device Checker for python

CDM Device Checker for python

zackmark29 79 Dec 14, 2022
Plugins for Agisoft Metashape

Данные плагины предназначены для расширения функциональных возможностей Agisoft Metashape. Плагины представляют собой отдельные программы с собственным интерфейсом, которые запускаются внутри Agisoft

GeoScan 17 Dec 10, 2022
A simple and usefull python calculator.

simplepy-calculator Your simple and fresh calculator. Getting Started Install python3 from the oficial python website or via terminal. Clone this repo

Felix Sanchez 1 Jan 18, 2022
Project Guide for ASAM OpenX standards

ASAM Project Guide Important This guide is a work in progress and subject to change! Hosted version available at: ASAM Project Guide (Link) Includes:

ASAM e.V. 2 Mar 17, 2022
Skull shaped MOSFET cells for the Efabless's 130nm process

SkullFET Skull shaped MOSFET cells for the Efabless's 130nm process List of cells Inverter Copyright (C) 2021 Uri Shaked

Wokwi 3 Dec 14, 2022
Online-update est un programme python permettant de mettre a jour des dossier et de fichier depuis une adresse web.

Démarrage rapide Online-update est un programme python permettant de mettre a jour des dossier et de fichier depuis une adresse web. Mode préconfiguré

pf4 2 Nov 26, 2021
Controller state monitor plugin for EVA ICS

eva-plugin-cmon Controller status monitor plugin for EVA ICS Monitors connected controllers status in SFA and pushes measurements into an external Inf

Altertech 1 Nov 06, 2021
Pymon is like nodemon but it is for python,

Pymon is like nodemon but it is for python,

Swaraj Puppalwar 2 Jun 11, 2022
Get a list of all offline/online members in a discord server

Discord server insights Get a list of all offline/online members in a discord server. Uses Selenium to crawl invite links. Config Download Chrome driv

Prakhar Gurunani 3 Oct 21, 2022
Tools I'm building in order to help my investments decisions

b3-tools Tools I'm building in order to help my investments decisions. Based in the REITs I've in my personal portifolio I ran a script that scrapy th

Rafael Cassau 2 Jan 21, 2022
ASCII-Wordle - A port of the game Wordle to terminal emulators/CMD

ASCII-Wordle A 'port' of Wordle to text-based interfaces A near-feature complete

32 Jun 11, 2022
A python program, imitating functionalities of a banking system

A python program, imitating functionalities of a banking system, in order for users to perform certain operations in a bank.

Moyosore Weke 1 Nov 26, 2021
Inspect the resources of your android projects and understand which ones are not being used and could potentially be removed.

Android Resources Checker What This program will inspect the resources of your app and help you understand which ones are not being used and could pot

Fábio Carballo 39 Feb 08, 2022
Project5 Data processing system

Project5-Data-processing-system User just needed to copy both these file to a folder and open Project5.py using cmd or using any python ide. It is to

1 Nov 23, 2021
Gives criticality score for an open source project

Open Source Project Criticality Score (Beta) This project is maintained by members of the Securing Critical Projects WG. Goals Generate a criticality

Open Source Security Foundation (OpenSSF) 1.1k Dec 23, 2022
thonny plugin for gitonic

thonny-gitonic thonny plugin for gitonic open gitonic in thonny by pressing Control+Shift+g, or via tools menu press ESC key to minimize gitonic windo

karl 1 Apr 12, 2022
Script to produce `.tex` files of example GAP sessions

Introduction The main file GapToTex.py in this directory is used to produce .tex files of example GAP sessions. Instructions Run python GapToTex.py [G

Friedrich Rober 2 Oct 06, 2022
A project to work with databases in 4 worksheets, insert, update, select, delete using Python and MySqI

A project to work with databases in 4 worksheets, insert, update, select, delete using Python and MySqI As a small project for school or college hope it is useful

Sina Org 1 Jan 11, 2022