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
Add any Program in any language you like or add a hello world Program ❣️ if you like give us :star:

Welcome to the Hacktoberfest 2018 Hello-world 📋 This Project aims to help you to get started with using Github. You can find a tutorial here What is

Aniket Sharma 1.5k Nov 16, 2022
Script para generar automatización de registro de formularios IEEH

Formularios_IEEH Script para generar automatización de registro de formularios IEEH Corresponde a un conjunto de script en python que permiten la auto

vhevia11 1 Jan 06, 2022
🟥This is an overview of how to set up and use DataStore3 in your Roblox experiences

Welcome to DataStore3 👋 This is an overview of how to set up and use DataStore3 in your Roblox experiences What is it? 🤔 DataStore3 is a service tha

Reece Harris 7 Aug 19, 2022
A community-driven python bot that aims to be as simple as possible to serve humans with their everyday tasks

JARVIS on Messenger Just A Rather Very Intelligent System, now on Messenger! Messenger is now used by 1.2 billion people every month. With the launch

Swapnil Agarwal 1.3k Jan 07, 2023
Python Osmium Examples

Python Osmium Examples This is a set (currently of size 1) of examples showing practical usage of PyOsmium, a thin wrapper around the osmium library.

Martijn van Exel 1 Jan 26, 2022
Euler 021 Py - Euler Problem 021 solved in Python

Euler_021_Py Euler Problem 021 solved in Python Let d(n) be defined as the sum o

Ariel Tynan 1 Jan 24, 2022
Urban Big Data Centre Housing Sensor Project

Housing Sensor Project The Urban Big Data Centre is conducting a study of indoor environmental data in Scottish houses. We are using Raspberry Pi devi

Jeremy Singer 2 Dec 13, 2021
Built with Python programming language and QT library and Guess the number in three easy, medium and hard rolls

password-generator Built with Python programming language and QT library and Guess the number in three easy, medium and hard rolls Password generator

Amir Hussein Sharifnezhad 3 Oct 09, 2021
If Google News had a Python library

pygooglenews If Google News had a Python library Created by Artem from newscatcherapi.com but you do not need anything from us or from anyone else to

Artem Bugara 1.1k Jan 08, 2023
This repository containing cross-section cut and fill calculations using Python programming language.

cross-section This repository is containing cut and fill calculations for cross-section using Python programming language. This codes is made to calcu

3 Jun 15, 2022
This is a Saleae Logic custom high level analyzer that allows you to search and mark specific packets.

SaleaePacketParser This is a Saleae Logic custom high level analyzer that allows you to search and mark specific packets. Field "Search For" is used f

1 Dec 16, 2021
A good Tool to comment on xmw

A good Tool to comment on xmw

1 Feb 10, 2022
Leveraging pythonic forces to defeat different coding challenges 🐍

Pyforces Leveraging pythonic forces to defeat different coding challenges! Table of Contents Pyforces Tests Pyforces Pyforces is a study repo with a c

Igor Grillo Peternella 8 Dec 14, 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
Customisable coding font with alternates, ligatures and contextual positioning

Guide Ligature Support Links Log License Guide Live Preview + Download larsenwork.com/monoid Install Quit your editor/program. Unzip and open the fold

Andreas Larsen 7.6k Dec 30, 2022
A python tool used for hacking WhatsApp by diverting otp

W-HACK A python tool used for hacking WhatsApp by diverting otp You can hack WhatsApp easily with this tool Note:OTP expires after 5 seconds HOW TO IN

Spider Anongreyhat 3 Oct 17, 2021
Simple Wayland HotKey Daemon

swhkd Simple Wayland HotKey Daemon This project is still very new and I'm making new decisions everyday as to where I should drive this project. I'm u

Aakash Sen Sharma 407 Dec 30, 2022
The presented desktop application was made to solve 1d schrodinger eqation

schrodinger_equation_1d_solver The presented desktop application was made to solve 1d schrodinger eqation. It implements Numerov's algorithm (step by

Artem Kashapov 2 Dec 29, 2021
Linux Security and Monitoring Scripts

Linux Security and Monitoring Scripts These are a collection of security and monitoring scripts you can use to monitor your Linux installation for sec

Andre Pawlowski 65 Aug 27, 2022
Your Google Recon is Now Automated

GRecon : GRecon (Greei-Conn) is a simple python tool that automates the process of Google Based Recon AKA Google Dorking The current Version 1.0 Run 7

adnane-tebbaa 189 Dec 21, 2022