pyodide scienti c python compiled in webassembly
play

Pyodide: scientic Python compiled in WebAssembly Roman Yurchak - PowerPoint PPT Presentation

Pyodide: scientic Python compiled in WebAssembly Roman Yurchak FOSDEM 2019 1 / 26 Iodide An interactive programming environment for scientists in the browser iodide.io Examples Lorenz Attractor World Happiness Eviction Notices in SF


  1. Pyodide: scienti�c Python compiled in WebAssembly Roman Yurchak FOSDEM 2019 1 / 26

  2. Iodide An interactive programming environment for scientists in the browser iodide.io Examples Lorenz Attractor World Happiness Eviction Notices in SF Report 2 / 26

  3. Iodide overview iodide.io 3 / 26

  4. Architecture Jupyter-like model Data Browser Server Kernel UI User Adapted from: jupyter.readthedocs.io/en/latest/architecture/how_jupyter_ipython_work.html#notebooks 4 / 26

  5. Architecture Iodide Jupyter-like model Data Browser Browser UI Server Kernel UI Kernel Data User User Adapted from: jupyter.readthedocs.io/en/latest/architecture/how_jupyter_ipython_work.html#notebooks 5 / 26

  6. Sharing of notebooks Jupyter like model Local Install conda, Jupyter, then project-speci�c dependencies Remote Deploy in a container (binder etc.) 6 / 26

  7. Sharing of notebooks Jupyter like model Iodide model Local Local Install conda, Jupyter, then Deploy to a static webserver project-speci�c dependencies Just open it in your browser Remote Remote Deploy in a container (binder etc.) Share a single �le containing data, report, code and dependencies Just open it in your browser 7 / 26

  8. Pyodide Python scienti�c stack, compiled to WebAssembly created by Michael Droettboom language plugin for Iodide CPython interpreter numpy, pandas, matplotlib WebAssembly A fast way to run compiled code in the browser Related projects PyPy.js, brython, RustPython github.com/iodide-project/pyodide 8 / 26

  9. Pyodide example 9 / 26

  10. Supported packages supported experimental planned numpy CPython pandas matplotlib 10 / 26

  11. Supported packages supported experimental BLAS / LAPACK planned Fortran scikit-image scipy scikit-learn numpy CPython pandas matplotlib 11 / 26

  12. Supported packages supported experimental BLAS / LAPACK planned Fortran scikit-image scipy scikit-learn numpy CPython pandas matplotlib Pure python wheels on PyPi 12 / 26

  13. Performance Firefox: 4-8 slower for pure Python, 1-2 times slower for C-ext. Ideal scaling with the number of users. 13 / 26 github.com/iodide-project/pyodide/tree/master/benchmark

  14. Build process CPython Python files C extensions interpreter Emscripten compiler / toolchain Browser .py .wasm .wasm engine In memory filesystem, lz4 compressed Browser emscripten.org 14 / 26

  15. System calls For example, ↓ os.open in Python ↓ CPython: call os_open_impl C function 15 / 26

  16. System calls For example, ↓ os.open in Python ↓ CPython: call os_open_impl C function Linux ↓ open system call to glibc ↓ Linux kernel 16 / 26

  17. System calls For example, ↓ os.open in Python ↓ CPython: call os_open_impl C function Linux Emscripten / WebAssembly ↓ open system call to glibc ↓ Emscripten ↓ system call to musl libc ↓ Linux kernel ↓ WebAssembly engine 17 / 26

  18. System calls (sometimes) For example, ↓ os.statvfs in Python (disk space usage) ↓ CPython: call os_statvfs_impl C function Linux Emscripten / WebAssembly ↓ statvfs system call to glibc ↓ Emscripten : not implemented; return "safe ↓ Linux kernel and sane values" ✗ system call to musl libc ✗ WebAssembly engine Most system calls work, but there are some edge cases. 18 / 26

  19. What doesn't work Di�cult network sockets multiprocessing host �lesystem access Should work someday threads async 19 / 26

  20. Testing Pytest is supported: test collection and execution in the browser 20 / 26

  21. Testing Pytest is supported: test collection and execution in the browser Test suites CPython: 380 test �les / 497 pass (increasing, but some will never pass due to WebAssembly environment) numpy: 3145 passed, 42 failed (+ some collection failures), 47 skipped scikit-learn: WIP, looks promising. Some remaining issues with Fortran / LAPACK calls in scipy. 21 / 26

  22. Planned language interoperability 22 / 26

  23. Future work increase the percentage of passing tests dynamic linking of BLAS/LAPACK in scipy possible in Emscripten 1.38.22 thanks to Kirill Smelkov optimize download sizes threading and async support more packages Contributors welcome! 23 / 26

  24. Application: in-browser data analytics challenges of multi-user notebooks deployment running notebooks on the edge with uncertain/limited connectivity Iodide and Pyodide integrated into the O�ceJS apps store online / o�ine usage, synchronization in Dropbox etc 24 / 26

  25. Development team Brendan Colloran Hamilton Ulmer William Lachance Michael Droettboom Teon Brooks ... 25 / 26

  26. Thank you! Questions? github.com/iodide-project/pyodide @RomanYurchak 26 / 26

Recommend


More recommend