innovationOUtside / nbev3devsim

Ev3DevSim ipywidget in Jupyter notebooks
Apache License 2.0
5 stars 0 forks source link

Pure Browser based / Javascript Version? #51

Closed psychemedia closed 1 year ago

psychemedia commented 4 years ago

The original ev3devsim ran purely in the browser, but I've pulled things out into a Jupyter notebook environment that passes things via the Jupyter py kernel, even though the code then all executes in the browser.

The Jupyter notebook environment has the advantage of providing various extensions and UI tools that can enhance the presentation of the materials, but in principle a lot of this stuff is just javascript UI stuff.

The Jupyter python environment allows us to run eg data analysis stuff on data logged from the simulator in a full python environment, but a lot of the analysis could be done just in the browser eg using js charts etc.

It would be interesting to redo everything just in the browser (i.e. not in a Jupyter context); the materials are written in markdown (and converted to notebooks using Jupytext), so the source is pretty simple and things like the simulator code magic could be easily found and replaced by some other stub code.

Possible UI environments that already exist include the spacy course format (example template, but we wouldn't need the py support?) which is built out using Gatsby.

It would be generally useful/interesting to see what sort of conversion might be required to convert Jupytext markdown to the markdown used in the spacy course?

SimonBiggs commented 4 years ago

@psychemedia you may be interested in my work with PyOdide:

https://libreapp.net/

That's an app where the Python runs completely client side. You can even press image

and you can edit the code that is run.

That code editor is using VSCode's Monaco editor.

The code for that page is all contained within the following directory:

https://github.com/libreapp/libreapp/tree/master/legacy

Primary downsides, no easy access to the local file system, so that's why I have passed it by for the time being.

psychemedia commented 4 years ago

@SimonBiggs Ah, interesting... thanks... One of the ways round not having access to the file system that could be handy as a quick around could be saving to browser persistent storage? eg https://github.com/manics/jupyter-offlinenotebook is an extension used in Binderhub to allow you to save a notebook into browser persistent storage from a(n expired) Binderhub session and then reload it in a new session. I'm not sure if there's then a way of interrogating / extracting files from browser storage into the local file system other than loading them into a browser client and downloading them etc?

psychemedia commented 4 years ago

@simonbiggs Related to pyodide, https://epiphany.pub/ (no public repo) is a notebook style UI in a browser running code against pyodide, and jtpio/p5-notebook, a notebook that uses the Jupyter js UI libraries and a js implemented jupyter kernel shim (I think...) to wrap a p5 kernel, that made me wonder whether the same approach could be used to wrap a wasm/pyodide style Python kernel purely in the browser.

SimonBiggs commented 4 years ago

This -- https://jtp.io/p5-notebook-demo/ is pretty cool! :).

Here is a proof of concept of pyodide kernel running within JupyterLab pureley client side:

http://jyve.simonbiggs.net/

Click the following to use the pyodide kernel: image

It's littered with issues though. See https://github.com/deathbeds/jyve/issues/33.

psychemedia commented 4 years ago

@simonbiggs Thanks.. I keep checking back on jyve but never had much joy getting things working quickly (I try a lot of things out and my triage routine pretty much extends only as far as "does the demo work? can I quickly tweak a binder config to get it working? Else: revisit in a few weeks/months."

SimonBiggs commented 4 years ago

Yup, makes sense :)

psychemedia commented 1 year ago

JupyterLite now a viable option for WASM/in-browser distribution.