-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python in the browser as a solution to pickling #83
Comments
Another solution is to just use something other than the App Engine that supports a persistent session. |
Just played with PyPy.js. It will probably also be extremely slow. It's only faster for certain things, and then only if the jit is warmed up. It is also missing a lot of the standard library (e.g., I couldn't import random). |
It is possible to run Sympy in the browser using Pyodide. I've already attempted that for one of my projects and it works reasonably well. Another option would be improving Sympy until it can reasonably be executed in the browser using Brython |
Yes, I've tested sympy in the pyodide shell and it works fine. Typing Overall this could be a way forward to remove or reduce the need for a backend for sympy live shell (and docs shell), for devices with good internet connection (where 10MB download is not an issue) and modern browsers (capable of running wasm). |
Just tested SymPy with Pyodide, and experienced similar performance / latency to the SymPy Live implementation. It would be awesome to see Pyodide-enabled code samples in SymPy documentation. |
I agree, this is definitely worth pursuing further! I suppose the absolutely simplest option would be serving a single, static |
Moving SymPy Live and SymPy Gamma to Pyodide would be great if it works, and would save us a lot of money. |
I'm interested in contributing to and helping out any effort towards a pyodide-backed Gamma and Live. I've been following this thread and this pull request on the jupyter-book thiebe project, which I hope can be helpful as a "source of inspiration." JupyterLite is another code base worth watching [see exectute method]. |
So, taking another look at the code, if I understand it correctly
Though, I suppose "replaced" might be the wrong word to use, since it might be worthwhile to keep the current App Engine backend around for now. |
Hi all, Just landed here from jupyter-book/thebe#465.
Actually we have an example in the JupyterLite notebooks, if you want to try it out in the browser: https://jupyterlite.readthedocs.io/en/latest/_static/retro/notebooks/?path=pyolite.ipynb It also renders nicely just like with a regular Jupyter Notebook or with JupyterLab: As well as in the code consoles: |
I would expect if we switch to pyiodide the entire backend should be refactored. Right now it tries to persist variables to fake a session, since the App Engine doesn't persist a real session. But with pyiodide we can have a real persistent session on the client's computer. What I would love to see is a community supported Sphinx extension that lets you run examples in pyiodide, that is not tied to SymPy. That way we can have the same functionality we currently have in our docs, but without the burden of having to maintain it ourselves, which doesn't work so well given that most SymPy developers are not web developers. The same thing with the Live shell. We should look at converting SymPy Gamma to use pyiodide as well. |
Please take a look of the port of SymPy Gamma: https://github.com/eagleoflqj/sympy_beta |
@eagleoflqj This is very impressive work on sympy_beta. The Vue-fication makes the code very easy to read and understand. I suppose a similar approach for the live shell would be good, although we'd need a new "interactive shell" component like you said. One thing to keep in mind is sympy-live shell is used both as a standalone webapp (https://live.sympy.org/) and also as a component in the docs, example include hook, and src1 src2. As you will see in src1 src2 there is a lot of extra functionality bundled into the current live shell component, which would be really nice to keep if re-implementing in Vue. There is also some logic in the Python code for evaluating expressions worth looking into @eagleoflqj Could you please setup a barebones shell component (e.g. based on https://pyodide.org/en/stable/console.html ) and share it so we can start experimenting with stuff? First thing I will expriment is how to run python "middleware" on each exec/eval code, because these might be needed for post-processors like PRINTERS and exception handlers. Also probably for debugging too... |
@asmeurer said:
What you're describing is very close to this: https://github.com/executablebooks/sphinx-thebe if it had a pyodide backend. example book, use the Live Code option to enable
Thebe backed runnable code in the docs would be a good option in terms of low maintenance, but break with the current UI:
If we could have something like a thebe-shell component in additinon to the inline code blocks that would be the best, with sympy-live being powered by the same thebe-shell component. |
I just took the first step to integrate pyodide shell into sympy beta eagleoflqj/sympy_beta@1ee37be |
FYI I opened #198 to switch to using JupyterLite for the REPL on https://live.sympy.org: JupyterLite comes with the Pyodide (currently at version 0.19.0) based Python kernel, and supports for rich output rendering and |
Pickling is a problem for SymPy Live as it can lead to strange errors (not everything is picklable); running Python in the browser could avoid this. There are three options here:
import random
leads to an error)I'm leaving this here mostly to record ideas/options.
The text was updated successfully, but these errors were encountered: