sympy / sympy-live

The source for the code at live.sympy.org
https://live.sympy.org
Other
116 stars 65 forks source link

Use JupyterLite for the interactive REPL #198

Closed jtpio closed 2 years ago

jtpio commented 2 years ago

Fixes https://github.com/sympy/sympy-live/issues/83

Similar to https://github.com/numpy/numpy.org/pull/547

JupyterLite is a JupyterLab distribution that runs entirely in the web browser, backed by in-browser language kernels including the WebAssembly powered Pyodide kernel.

The embeddable code console is currently deployed as a static website on Vercel, and the source code is currently living in the following repository: https://github.com/jtpio/replite

It supports rich rendering of outputs just like in Jupyter Notebook and JupyterLab, for example:

image

TODO

>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
jtpio commented 2 years ago

This also has the nice side-effect of bringing Python 3.9.5:

image

jtpio commented 2 years ago

Remove previous shell from the code base

Briefly looking at the code base, it looks like almost everything in the repo could be removed, to only keep a couple of static HTML / CSS / JS assets. Probably there is no need to deploy to Google App Engine anymore.

If anyone more familiar with the code would like to help with this that would be great, thanks!

certik commented 2 years ago

@jtpio thank you so much for this! That's exactly what we need.

CC @asmeurer, @oscarbenjamin

asmeurer commented 2 years ago

Since this is loading code from somewhere else, what will the process be to update SymPy when we do a release? Will it automatically get the latest version from PyPI?

asmeurer commented 2 years ago

We should remove the old app. However, we also need to make sure that the Sphinx extension in docs.sympy.org doesn't break. Ideally, we should update them both, so that we can completely shutdown the app engine server.

asmeurer commented 2 years ago

It also means we need to completely change the site to be static only. We should be able to just host it on GitHub pages.

certik commented 2 years ago

Yes, we should host it on github pages.

oscarbenjamin commented 2 years ago

Looks great!

jtpio commented 2 years ago

Since this is loading code from somewhere else, what will the process be to update SymPy when we do a release? Will it automatically get the latest version from PyPI?

JupyterLite uses Pyodide for the Python kernel. Right now it's Pyodide 0.19 which includes sympy version 1.9:

image

To update to a new version the process would then be to:

Also the iframe currently points to a deployment from this repo: https://github.com/jtpio/replite. But it's also possible to make a custom static deployment that you own (docs coming soon: https://github.com/jtpio/replite#create-your-custom-deployment).

jtpio commented 2 years ago

Yes, we should host it on github pages.

Absolutely, this repo is an example of a lite website deployed to GitHub Pages: https://github.com/jupyterlite/demo. So both the full website and the embedded shell could live on GitHub Pages if you want to have your own lite deployment.

jtpio commented 2 years ago

@certik @asmeurer I opened the following PR in the https://github.com/sympy/sympy.github.com repo, as an alternative to making the changes here: https://github.com/sympy/sympy.github.com/pull/169

This means the sympy-live repo could then be archived and the Google App Engine deployment be destroyed.

SylvainCorlay commented 2 years ago

Quick update: the Numpy.org PR went through!

SylvainCorlay commented 2 years ago

Since this is loading code from somewhere else, what will the process be to update SymPy when we do a release? Will it automatically get the latest version from PyPI?

Some side comments on this: we are currently making strides towards making conda packages for Wasm (emscripten more specifically) - alongside the OS X, Windows, and Linux platforms. The goal is to make it so that one would merely need to update a feedstock to get the emscripten package released as the same time as the other ones.

asmeurer commented 2 years ago

@jtpio that's a good idea. We will also need to figure out what to do with the shell in docs.sympy.org. Is there a jupyterlite extension for Sphinx that we can use, instead of our custom SymPy Live shell (we would love to move completely towards something that is maintained by others, as we in the SymPy community have had a hard time keeping SymPy Live maintained).

jtpio commented 2 years ago

@asmeurer this would indeed be very useful for docs.sympy.org.

Some related work has been started in https://github.com/martinRenou/jupyterlite-sphinx. But it's still the beginning and not usable yet.

There is also @stevejpurves who started working on the JupyterLite integration with TheBe in https://github.com/stevejpurves/thebe/pull/40. This looks promising and we should look intro resuming work on this too.

certik commented 2 years ago

What needs to be done to move this PR forward? I would like this functionality in sympy-live. This should allow us to also just host sympy-live on github pages, no need for a cloud server.

CC @asmeurer.

asmeurer commented 2 years ago

I think the most recent version of this is at https://github.com/sympy/sympy.github.com/pull/169. With this, there is no need to keep this on a separate repo from the website.

I think what's left for that PR is we just need to clean up the text on the main page.

Once that is done, we can add a note to this repo that it is no longer active (should we archive it?). After https://github.com/sympy/sympy/pull/23159 the docs no longer use the SymPy Live extension, so with this there would be no need to keep it around. We should also shut down SymPy Live itself on the App Engine once we make a SymPy release with those changes, as there would no longer be a live docs site with it.

jtpio commented 2 years ago

I think the most recent version of this is at sympy/sympy.github.com#169. With this, there is no need to keep this on a separate repo from the website.

Yes, With https://github.com/sympy/sympy.github.com/pull/169 it means the https://github.com/sympy/sympy-live repo could then be archived.

jtpio commented 2 years ago

Closing as fixed by https://github.com/sympy/sympy.github.com/pull/174

Thanks all!