Serverless Jupyter github.com/drola Matja Drolc 1 2 Example - - PowerPoint PPT Presentation

serverless jupyter
SMART_READER_LITE
LIVE PREVIEW

Serverless Jupyter github.com/drola Matja Drolc 1 2 Example - - PowerPoint PPT Presentation

LyPyMeetup, 2019-04-24 Serverless Jupyter github.com/drola Matja Drolc 1 2 Example Jupyter notebook https://nbviewer.jupyter.org/github/rlabb e/Kalman-and-Bayesian-Filters-in-Python /blob/master/02-Discrete-Bayes.ipynb Collection


slide-1
SLIDE 1

1

Serverless Jupyter

Matjaž Drolc github.com/drola LyPyMeetup, 2019-04-24

slide-2
SLIDE 2

2

slide-3
SLIDE 3

3

  • Example Jupyter notebook

https://nbviewer.jupyter.org/github/rlabb e/Kalman-and-Bayesian-Filters-in-Python /blob/master/02-Discrete-Bayes.ipynb

  • Collection of other notebooks

https://github.com/jupyter/jupyter/wiki/ A-gallery-of-interesting-Jupyter-Noteboo ks

slide-4
SLIDE 4

4

Development process

1) Prototype in Jupyter 2) Integrate into our product: backend and frontend 3) Repeat

slide-5
SLIDE 5

5

Python in browser

  • Transpiler (Python to JS)

– https://transcrypt.org/

  • Interpreters

– https://brython.info/ – http://www.skulpt.org/

slide-6
SLIDE 6
slide-7
SLIDE 7

7

Python in browser

  • Worst option: manually rewrite to JS
  • Risk of mistakes
  • No good numpy, Pandas alternative
  • Problems with data types
  • Ongoing cost of maintaining two

implementations

slide-8
SLIDE 8

8

v

slide-9
SLIDE 9
slide-10
SLIDE 10

10

WebAssembly

  • A binary instruction format
  • High level language → compiler → WASM
  • On clients and servers
  • From 2017: Chrome, MS Edge, Firefox,

Safari

slide-11
SLIDE 11

11

JavaScript WebAssembly Web browser Compiler

slide-12
SLIDE 12

12

https://mbebenita.github.io/WasmExplorer

slide-13
SLIDE 13

13

Python in browser

  • Offjcial Python interpreter is written in C
  • So are Numpy, Scipy and Pandas
  • Pyodide

https://github.com/iodide-project/pyodide

  • Python 3.7, Numpy, Pandas, Matplotlib

https://github.com/iodide-project/pyodide /tree/master/packages

slide-14
SLIDE 14

14

Jupyter http://localhost:8888 Pyodide https://alpha.iodide.io/notebooks/300

slide-15
SLIDE 15

15

Pyodide API

https://github.com/iodide-project/pyodide/ blob/master/docs/api_reference.md

slide-16
SLIDE 16

16

Pyodide advantages

  • Easy to host
  • Server doesn’t need to handle

computations

  • Security and client isolation by design
  • Running inside browser sandbox
  • Decently fast. 1-12x slowdown

compared to regular Python

slide-17
SLIDE 17

17

Performance

  • One of key goals for WebAssembly
  • Video efgects

https://d2jta7o2zej4pf.cloudfront.net/

  • WebM video codec

https://github.com/GoogleChromeLabs/ webm-wasm

  • Gaming: Unreal Engine and Unity both

support WASM https://s3.amazonaws.com/mozilla-gam es/ZenGarden/EpicZenGarden.html

slide-18
SLIDE 18

18

Challenges

  • Running in browser’s sandbox

– Limited access to network and fjles – Networking limited to HTTP(S) and

WebSockets

  • Python+scientifjc stack takes ~50MB of

space (partially mitigated by browser cache)

  • “import threading” doesn’t work yet
slide-19
SLIDE 19

19

Useful resources

  • https://wasi.dev/ WASM System

Interface

  • https://wasmer.io/ Universal WASM

runtime

  • https://github.com/mohanson/pywasm

Run WebAssembly inside Python

slide-20
SLIDE 20

20

Future

  • New interactive web applications for

data exploration and education https://alpha.iodide.io/

  • Richer documentation for Python and

programming languages with inline demos

  • Transition of multimedia editors, CAD,

scientifjc computation to web browsers

slide-21
SLIDE 21

21

Questions?

Matjaž Drolc github.com/drola LyPyMeetup, 2019-04-24

slide-22
SLIDE 22

22

References

https://hacks.mozilla.org/2019/04/pyodide

  • bringing-the-scientifjc-python-stack-to-th

e-browser/ https://github.com/takenobu-hs/WebAsse mbly-illustrated