Slide 1

Slide 1 text


 Jupyter Frontends: From the classic Jupyter Notebook, to JupyterLab, nteract and beyond Brian Granger, Cal Poly Kyle Kelley, Netflix Project Jupyter JupyterCon 2017

Slide 2

Slide 2 text

• User Testing @ JupyterCon •What is interactive computing? • User interfaces for interactive computing • The terminal as a UI for interactive computing • Jupyter Notebook: successes and challenges • Foundations of Jupyter frontends: • Jupyter Message Specification • Survey of different Jupyter frontends/UIs Outline

Slide 3

Slide 3 text

• We are doing extensive, in person user experience testing here at JupyterCon • We need your help to improve our software! • Thursday+Friday all day • Location: Gramercy room on level 2 • Drop in or sign up: • http://bit.ly/jupytercon-usertesting User Testing @ JupyterCon

Slide 4

Slide 4 text

Interactive Computing An interactive computation is a persistent computer program that runs with a "human in the loop," where the primary mode of steering the program is through the human iteratively writing/running blocks of code and looking at the result. Human Centered Computing

Slide 5

Slide 5 text

Interactive Computing: Breakdown Compose A UI to compose blocks of code Submit A UI to submit code to the running program Run A method to run code in a persistent namespace Output A method to return output to the user View A UI to view the output Repeat A method to repeat the process Frontend = User Interface = UI

Slide 6

Slide 6 text

IPython: The Terminal as a UI IPython was released in 2001 and provided a UI for interactive computing Tab completion, extended syntax (!, %, ?), plotting integration

Slide 7

Slide 7 text

IPython: The Terminal as a UI Compose Type at the Terminal Submit Run eval(code, globals, local) Output print(output, file=sys.stdout) View Look at the Terminal Repeat while True: IPython was released in 2001 and provided a UI for interactive computing:

Slide 8

Slide 8 text

• No narrative: code without narrative is empty of meaning • Narrative text/documentation • Images, Visualizations, Equations • No memory: wasteful and frustrating • Everything you type is lost when you exit IPython • Only memory was hitting the up arrow after restarting to cycle through previous commands • Python’s runtime effectively requires you to restart often • code, exit, ipython, up, up, code, exit, ipython, up, up, up, code, … • No reproducibility and communication: your own private dead end • No way to record/reproduce an interactive computation and its results • No way share a session with others and communicate results Usability Challenges of the Terminal In spite of this, Python, IPython, NumPy, Matplotlib, etc. were revolutionary

Slide 9

Slide 9 text

Why is the classic IPython/ Jupyter Notebook so useful?

Slide 10

Slide 10 text

The IPython/Jupyter Notebook maintains the full interactive computing workflow while adding narrative, memory, reproducibility, communication

Slide 11

Slide 11 text

File = reproducible, communication, memory equations narrative images memory Narrative, Memory, Reproducible, Communication compose repeat submit/run output IPython Notebook 2011: “Computational Narrative”

Slide 12

Slide 12 text

Jupyter Notebook 2017

Slide 13

Slide 13 text

Jupyter Notebook: Successes

Slide 14

Slide 14 text

>6-8M??? Users https://github.com/jupyter/design/blob/master/surveys/2015-notebook-ux/analysis/report_dashboard.ipynb

Slide 15

Slide 15 text

~100 Languages https://github.com/jupyter/jupyter/wiki/Jupyter-kernels

Slide 16

Slide 16 text

Highly International Community Google Analytics for jupyter.org, July 2017

Slide 17

Slide 17 text

Over 1M Notebooks on GitHub

Slide 18

Slide 18 text

An Amazing Community: Emergent Behaviors

Slide 19

Slide 19 text

Jupyter Notebook: Challenges

Slide 20

Slide 20 text

• Built with web technology of 2011 (jQuery, Bootstrap, require.js) • In contrast to core server/architecture in Python, which has been relatively stable • Important features became difficult to implement: • Real-time collaboration: models and views are welded together • Collapsing input/ouput: DOM/CSS had become pseudo-public APIs • No distinction between public/private APIs - anything breaks everything • Difficult to extend • Code base is large enough that you miss static typing • No dependency injection for runtime dependency resolution Jupyter Notebook: Challenges

Slide 21

Slide 21 text

• Leaky foundations: • Message spec and notebook format had become “polluted” with implementation specific details • Libraries such as ipywidgets were welded to the classic notebook implementation details • Other non-notebook workflows: • QTConsole: interactive computing with rich output • Hydrogen/RStudio: Python/R scripts with interactive computing and rich output • Emergent behaviors: • Exciting, but unexpected usage cases • An ecosystem that has become an abundant, fertile, rich garden • With a codebase that is difficult to scale or maintain to span those usage Jupyter Notebook: Challenges

Slide 22

Slide 22 text

Frontend Foundations

Slide 23

Slide 23 text

Exploring the Protocol

Slide 24

Slide 24 text

Exploring the Protocol { "msg_type": "execute_request", "content": { "code": "print('hey')" } }

Slide 25

Slide 25 text

Exploring the Protocol { "msg_type": "status", "content": { "execution_state": "busy" } }

Slide 26

Slide 26 text

Exploring the Protocol { "msg_type": "status", … } { "msg_type": "stream", "content": { "text":"hey\n", "name":"stdout" } }

Slide 27

Slide 27 text

Exploring the Protocol { "msg_type": "status", … } { "msg_type": "stream", … } { "msg_type": "status", "content": { "execution_state": "idle" } }

Slide 28

Slide 28 text

Exploring the Protocol Two types of messages so far • Execution status - busy or idle • A stream of “stdout”

Slide 29

Slide 29 text

Exploring the Protocol How about longer computations?

Slide 30

Slide 30 text

Exploring the Protocol { "msg_type": "status", "content" { "execution_state": "busy" } } { "msg_type": "stream", "content": { "text":"hey\n", "name":"stdout" } } { "msg_type": “stream", "content": { "text":"sup\n", "name":"stdout" } } { "msg_type": "status", “content" { "execution_state": "idle" } }

Slide 31

Slide 31 text

Exploring the Protocol - Rich Media How are tables, plots, and rich media shown?

Slide 32

Slide 32 text

Exploring the Protocol - Rich Media "content": { "code": "pd.read_csv('temps.csv').sample(n=5)" }

Slide 33

Slide 33 text

Exploring the Protocol - Rich Media { "msg_type": "execute_result", "content": { "data": { // Full payloads below "text/plain": ..., "text/html": ..., } } }

Slide 34

Slide 34 text

Exploring the Protocol - Rich Media temp date 4851 56.4 2010/07/22 04:00:00 6232 65.9 2010/09/17 17:00:00 8497 47.0 2010/12/21 02:00:00 5875 60.9 2010/09/02 20:00:00 5625 65.7 2010/08/23 10:00:00 text/plain

Slide 35

Slide 35 text

Exploring the Protocol - Rich Media … text/html tempdate 4851 56.4 2010/07/22 04:00:00

Slide 36

Slide 36 text

Exploring the Protocol - Rich Media HTML Payload

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Building a Notebook Document

Slide 40

Slide 40 text

Building a Notebook Document We’ve witnessed • How code is sent to the runtime • What we receive as a frontend

Slide 41

Slide 41 text

Building a Notebook Document How do we form a notebook? How do we associate messages to the cells they originated from?

Slide 42

Slide 42 text

Building a Notebook Document • Send message with a msg_id (message id) • Responses refer to originating message as the parent Message IDs

Slide 43

Slide 43 text

Building a Notebook Document { "msg_type": "execute_request", "msg_id": "0001", "content": { "code": "print('hey')" } } We send the execute_request as message 0001 code: "print('hey')" And initialize our state

Slide 44

Slide 44 text

{ "msg_type": "status", "msg_id": "0002", "parent_id": "0001", "content": { "execution_state": "busy" } } Building a Notebook Document Responses show originating msg_id is parent_id 0001

Slide 45

Slide 45 text

Building a Notebook Document { "msg_type": "status", "msg_id": "0002", "parent_id": "0001", "content": { "execution_state": "busy" } } Message code: "print('hey')" status: "busy" Cell State

Slide 46

Slide 46 text

Building a Notebook Document { "msg_type": "stream", "msg_id": "0003", "parent_id": "0001", "content": { “text": "hey\n", “name”: "stdout" } } Message code: "print('hey')" status: “busy" outputs: - type: "stream" text: "hey\n" name: "stdout" Cell State

Slide 47

Slide 47 text

Building a Notebook Document { "msg_type": "status", "msg_id": "0004", "parent_id": "0001", "content": { "execution_state": "idle" } } Message code: "print('hey')" status: “idle" outputs: - type: "stream" text: "hey\n" name: "stdout" Cell State

Slide 48

Slide 48 text

Building a Notebook Document Final State code: "print('hey')" status: “idle" outputs: - type: "stream" text: "hey\n" name: "stdout"

Slide 49

Slide 49 text

Building a Notebook Document Final State code: "print('hey')" status: “idle" outputs: - type: "stream" text: "hey\n" name: "stdout"

Slide 50

Slide 50 text

Building a Notebook Document That’s just one cell though —what would an entire notebook structure look like? What’s a notebook? • A rolling work log of computations • A linear list of cells

Slide 51

Slide 51 text

cells: - text: "# Now with markdown!" - code: "from IPython.display import HTML" - code: "print('hey')" outputs: - type: "stream" text: "hey\n" name: "stdout" - code: "HTML('WHOA')" outputs: - type: "execute_result" data: - "text/html": "WHOA"

Slide 52

Slide 52 text

cells: - text: "# Now with markdown!" - code: "from IPython.display import HTML" - code: "print('hey')" outputs: - type: "stream" text: "hey\n" name: "stdout" - code: "HTML('WHOA')" outputs: - type: "execute_result" data: - "text/html": "WHOA"

Slide 53

Slide 53 text

Summarizing the Notebook send code → … run , run … → get result(s) →

Slide 54

Slide 54 text

Callouts For more in-depth on protocols and formats, check out these talks: Jupyter: Kernels, protocols, and the IPython reference implementation The Jupyter Notebook as document: From structure to application

Slide 55

Slide 55 text

Survey of Frontends

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

hydrogen

Slide 58

Slide 58 text

hydrogen

Slide 59

Slide 59 text

nteract

Slide 60

Slide 60 text

Spyder

Slide 61

Slide 61 text

Callouts For more in-depth on alternative frontends, check out these talks: Lessons learned from tens of thousands of Kaggle notebooks JupyterLab: The next-generation Jupyter frontend

Slide 62

Slide 62 text

Questions