6 ms·
Show HN: WASM-powered codespaces for Python notebooks on GitHub
Hi HN!
Last year, we shared marimo [1], an open-source reactive notebook for Python with support for execution through WebAssembly [2].
We wanted to share something new: you can now run marimo and Jupyter notebooks directly from GitHub in a Wasm-powered, codespace-like environment. What makes this powerful is that we mount the GitHub repository's contents as a filesystem in the notebook, making it really easy to share notebooks with data.
All you need to do is prepend 'marimo.app' to any Python notebook on GitHub. Some examples:
- Jupyter Notebook: https://marimo.app/github.com/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/02.08-Sorting.ipynb https://marimo.app/github.com/jakevdp/PythonDataScienceHandb...
- marimo notebook: https://marimo.app/github.com/marimo-team/marimo/blob/07e8d14109f7312f19916fd13e4046a561a740f8/examples/third_party/polars/polars_example.py https://marimo.app/github.com/marimo-team/marimo/blob/07e8d1...
Jupyter notebooks are automatically converted into marimo notebooks using basic static analysis and source code transformations. Our conversion logic assumes the notebook was meant to be run top-down, which is usually but not always true [3]. It can convert many notebooks, but there are still some edge cases.
We implemented the filesystem mount using our own FUSE-like adapter that links the GitHub repository’s contents to the Python filesystem, leveraging Emscripten’s filesystem API. The file tree is loaded on startup to avoid waterfall requests when reading many directories deep, but loading the file contents is lazy. For example, when you write Python that looks like
```python
with open("./data/cars.csv") as f:
print(f.read())
# or
import pandas as pd
pd.read_csv("./data/cars.csv")
```
behind the scenes, you make a request [4] to https://raw.githubusercontent.com/<org>/<repo>/main/data/cars.csv https://raw.githubusercontent.com/<org>/<repo>/main/data/car....
Docs: https://docs.marimo.io/guides/publishing/playground/#open-notebooks-hosted-on-github https://docs.marimo.io/guides/publishing/playground/#open-no...
[1] https://github.com/marimo-team/marimo https://github.com/marimo-team/marimo
[2] https://news.ycombinator.com/item?id=39552882 https://news.ycombinator.com/item?id=39552882
[3] https://blog.jetbrains.com/datalore/2020/12/17/we-downloaded-10-000-000-jupyter-notebooks-from-github-this-is-what-we-learned/ https://blog.jetbrains.com/datalore/2020/12/17/we-downloaded...
[4] We technically proxy it through the playground https://marimo.app https://marimo.app to fix CORS issues and GitHub rate-limiting.
- deleted 2y ago[deleted]
- hzuo 2y agoSuper cool to see a real use-case of WASM outside of just game dev and nerding out.
- PKop 2y agoBlazor is another example
- pjmlp 2y agoWe also have Flash, Java Applets, ActiveX and Silverlight back, running on top of WebAssembly.
- mring33621 2y agoi hope this is true
- pjmlp 2y agoIt is, and it is quite easy to find where those implementations are available, not going to do the search engine work.
- dhbradshaw 2y agoThis is really cool -- going to show it off to my team. I love the fact that you opened it up so that it will work with Jupyter notebooks as well.
- ge96 2y agowow a python interpreter is "only" 100MB not sure if that's what's happening here
- bagels 2y agoIs that too small or too large in your estimation?