Skip to main content

Code, explanation, and output
in the same notebook.

JupyterLab brings notebooks, text editors, and terminals into the same browser window, runs code in kernels, and, with PySpark, takes processing to a Spark application. Follow a cell from execution to the output saved in the notebook.

This feature is only available starting from version 3.0.

A notebook is a shareable document that combines code, natural-language descriptions, data, and the results of execution.

JupyterLab is the TDP environment for Jupyter notebooks. In TDP Datacenter, Zeppelin is another notebook environment.

One document

Code, text, and output together

Each cell holds code or text, and the outputs of execution are saved with it, in the same file.

Who runs it

The code runs in a kernel

The kernel is a separate, language-specific process that receives only the code of the cells. With PySpark, it is the driver of a Spark application.

One window

Notebooks, editors, and terminals side by side

Documents and activities are arranged in tabs and splitters, and extensions extend any part of the interface.

On this page

Watch a cell run​

A code cell creates a Spark session and shows the result of a calculation. Press Play or step through it. Underlined names lead to the Glossary.

BrowserWho writes and reads
CellA code cell of the open notebook
Jupyter ServerWho bridges
Jupyter ServerRelays messages and saves files
.ipynb fileThe notebook saved as JSON
KernelWho runs
KernelPython process, with PySpark
Spark applicationWho computes in parallel
Cluster managerGrants the resources
ExecutorRuns tasks
ExecutorRuns tasks
Step 1 of 6

1 The cell is run

In the notebook open in the browser, a code cell is run. The browser does not talk directly to the kernel or to the notebook file: everything goes through the Jupyter Server, to which the interface is connected by a WebSocket.

  1. The cell is run. In the notebook open in the browser, a code cell is run. The browser does not talk directly to the kernel or to the notebook file: everything goes through the Jupyter Server, to which the interface is connected by a WebSocket.
  2. The server hands the code to the kernel. The Jupyter Server relays the execution request to the kernel of that notebook's session. On the kernel side, the conversation uses ZeroMQ sockets, one per channel. The server multiplexes all of them into a single WebSocket for the browser.
  3. The kernel runs the code. The kernel reports that it is busy and runs the code. It knows nothing about the notebook: it receives only the code of the cell. Each execution increments the kernel's execution counter, which is recorded in the cell.
  4. With PySpark, the kernel is the driver. The code creates a Spark session, and the kernel process becomes the driver of a Spark application: it obtains executors from the cluster manager and sends them the tasks. In TDP Datacenter, the application runs on YARN. In TDP Kubernetes, on a standalone Spark cluster or inside the user's own server.
  5. The outputs return to the cell. The executors return the results to the driver. Everything the execution produces, the printed text, the charts, and the final result, or the error, the kernel publishes on the IOPub channel. The server carries the messages to the browser, and the outputs appear below the cell. At the end, the kernel reports that it is idle.
  6. The server saves the notebook. The server, not the kernel, saves the notebook. The browser sends the document to the Jupyter Server, which writes the .ipynb file, in JSON, with the code, the Markdown text, and the outputs of each cell.
Figure 1 - A cell in JupyterLab. The browser talks only to the Jupyter Server. The kernel runs the code and, with PySpark, is the driver of a Spark application.

Architecture​

The interface in the browser, the Jupyter Server, and the kernels: three pieces that talk to each other only through the server.

JupyterLab architecture: browser interface, Jupyter Server, kernels and Spark applicationThe JupyterLab interface runs in the browser, with notebooks, code consoles, a text editor, a terminal and extensions, and talks to the Jupyter Server over HTTP and WebSocket. The Jupyter Server brings together the REST APIs, the Session Manager, the Kernel Manager, the Kernel Spec Manager and the Contents Manager, which reads and writes the .ipynb files. The server exchanges ZeroMQ messages with the kernels, such as ipykernel. With PySpark, the kernel is the driver of a Spark application, with executors in the cluster.BrowserJupyterLab interfaceNotebookCode consoleText editorTerminalExtensionsJupyter ServerInterface backendREST APIsSession ManagerKernel ManagerKernel Spec ManagerContents Manager.ipynb filesNotebooks saved as JSONKernelsProcesses that run the codeipykernelPython, with PySparkKernelOther languagesSpark applicationThe kernel is the driverExecutorExecutorHTTP and WebSocketKernel messages, over ZeroMQReading and writing notebooksTasks and results
Figure 2 - JupyterLab architecture: the interface in the browser, the Jupyter Server with its managers, the notebook files, the kernels, and the Spark application. Underlined terms lead to the Glossary.

What the figure shows:

  1. The JupyterLab interface runs in the browser, with notebooks, code consoles, a text editor, a terminal, and extensions, and talks to the Jupyter Server over HTTP and WebSocket.
  2. The Jupyter Server is the backend that provides the core services, APIs, and REST endpoints. Each manager handles a part of the work: the Contents Manager reads and writes the files; the Session Manager keeps a session for each open notebook; the Kernel Manager handles the kernel of each notebook; and the Kernel Spec Manager lists the available kernelspecs.
  3. The .ipynb files are the notebooks saved in JSON, which the Contents Manager reads and writes.
  4. The kernels are independent processes, each for one language, that exchange JSON messages with the server over ZeroMQ. The reference one is the ipykernel, for Python.
  5. The Spark application: with PySpark, the kernel is the application driver, and the executors are on the cluster.

From notebook to output​

What a notebook stores: three levels, each inside the other.

Level 1 of 3

Notebook

The whole document, saved as an .ipynb file in JSON: metadata and a list of cells. The format is the same as in the classic Jupyter Notebook.

  • KernelspecIn the metadata, the notebook stores the specification of the kernel it works with.
  1. Notebook. The whole document, saved as an .ipynb file in JSON: metadata and a list of cells. The format is the same as in the classic Jupyter Notebook.
    • Kernelspec. In the metadata, the notebook stores the specification of the kernel it works with.
  2. Cell. The unit of content. The code cell holds the source code and the outputs; the Markdown cell, the explanatory text; the raw cell, content that passes unchanged into notebook conversions.
    • Execution counter. Each code cell records the number of the execution that produced it, taken from the kernel's counter, or has no number until it is run.
  3. Output. What the execution produces: stream text, such as what the program prints; rich displays, such as charts; the execution result; or the error, with the traceback.
    • Mime-bundle. In rich outputs, the data is organized by MIME type in a single dictionary, the mime-bundle.
Figure 3 - Each level contains the next: a notebook holds cells, and a code cell holds its outputs. Kernelspec, execution counter, and mime-bundle go along with the levels.

The work area​

Documents and activities side by side, in the same window, in tabs and splitters.

Notebooks

Code, text, and outputs

The central document: code and text cells, run in a kernel.

Code consoles

A log of the computations

A code console can be linked to a notebook's kernel, as a log of the computations made from it.

Text editor

Any file, executable

Code in a text file, whether Markdown, Python, R, or LaTeX, can be run interactively in any Jupyter kernel.

Terminal

The command line alongside

Terminals open in the same work area as notebooks and editors.

Sidebar

Files, kernels, and table of contents

The file browser, the list of running kernels and terminals, the document's table of contents, and the extension manager. The command palette opens with a keyboard shortcut.

Extensions

Any part, extended

Extensions bring themes, editors, output renderers, menu items, shortcuts, and settings.

Why JupyterLab​

Integrated

Documents that talk to each other

Notebooks, consoles, editors, and terminals integrate with each other and enable new workflows for interactive computing.

Extensible

Designed to be extended

JupyterLab is designed as an extensible environment, in which extensions customize or extend any part of the interface.

Many languages

One kernel per language

Besides the reference Python kernel, the community maintains kernels for many other languages, and any of them serves the documents.

Open format

The same notebook everywhere

The notebook format is the same as in the classic Jupyter Notebook and in the newer versions of Notebook, and files move from one tool to another.

More complete

Beyond Jupyter Notebook

A more advanced, more feature-rich, and more customizable experience than that of Jupyter Notebook.

Open source

Free for all

Open-source software, free to use, released under the modified BSD license.

Where it comes from

JupyterLab is one of the notebook authoring applications of Project Jupyter, a non-profit, open-source project born out of the IPython project in 2014 to support interactive data science and scientific computing across all programming languages. Project Jupyter is hosted by LF Charities.

In the TDP editions​

Available in the TDP editions
EditionVersionDocumentation
TDP Datacenter4.4.5TDP Datacenter components
TDP Kubernetes · JupyterHub5.3.0 · chart tdp-jupyter 3.0.3Configuration in TDP Kubernetes

In TDP Datacenter​

In TDP Datacenter, JupyterLab is the Jupyterlab Notebook service of the stack, installed and managed by Ambari.

Service components

JUPYTERLAB (master, one or more). The JUPYTERLAB requires SPARK3_CLIENT (Spark) and YARN_CLIENT (YARN). Component category.

Spark and Flink

The jupyterlab-env configuration points SPARK_HOME to the Spark3 Client, PYTHONPATH to PySpark, and FLINK_HOME to the Flink client. With PySpark, the kernel is the driver of an application that runs on YARN. See Apache Spark and Apache Flink.

Where the notebooks are stored

Saving notebooks to an HDFS directory can be enabled in use_hdfs.enabled, in the jupyterlab_config configuration: the HDFS Contents Manager writes to the directory in c.HDFSContentsManager.root_dir.

Example notebooks

Notebooks with examples of integration and use of various components, which can be enabled in load_examples.enabled.

Dask

Configurable in dask_config: depending on deploy_mode, the Dask workers run in YARN containers, in the queue given in queue, or on the server itself.

Access and security

Authentication is set in the jupyterhub configuration of the service, with the type in type_authentication, LDAP among them. SSL and Kerberos can be enabled in Ambari. See Security in TDP Datacenter.

Dependencies

Ambari requires in the cluster HDFS and YARN.

In TDP Kubernetes​

In TDP Kubernetes, JupyterLab is delivered by JupyterHub, installed by the tdp-jupyter chart: each user works in their own JupyterLab server, in a Pod. See JupyterHub.

Server and kernel

The JupyterLab server runs in the base environment of the image, and the kernel in an isolated Python environment, registered by ipykernel. Each user's server offers a single kernelspec: the one for the Python kernel with PySpark.

First login

The notebook image is large, and the chart pre-pulls it on the nodes that run notebooks. See JupyterHub.

Spark in the notebooks

By default, with tdpSparkIntegration.enabled turned off, Spark runs inside the user's own Pod, in local[*]. When turned on, the notebooks connect to an external standalone Spark cluster. See Apache Spark.

Network

The NetworkPolicy of the user servers, in tdp-jupyter.singleuser.networkPolicy, allows egress to the Spark Master, Trino, the Hive Metastore, Kafka, and the Ozone S3 Gateway. With the external Spark cluster, inbound traffic from the Spark Workers to the driver requires an ingress rule.

What the TDP Kubernetes kernel already includes

Spark and lakehouse

PySpark, Delta Lake, and PyIceberg

PySpark and delta-spark, for Delta Lake tables. PyIceberg, with Hive and S3 support, for Iceberg tables.

Data in Python

pandas, Polars, PyArrow, and DuckDB

Data manipulation and analysis libraries, and Matplotlib and Seaborn for charts.

SQL

Trino, ClickHouse, and JupySQL

The Trino and ClickHouse clients, SQLAlchemy, and JupySQL, for SQL in the cells themselves.

Databases and messaging

Drivers and Kafka

Drivers for PostgreSQL, MySQL, Oracle, MongoDB, and ODBC, and confluent-kafka for Kafka.

Quality and storage

Great Expectations and boto3

Great Expectations, for data validation, and boto3, for S3-compatible storage.

In both editions, the path of a cell with PySpark is the one in Figure 1; what changes is where the Spark application runs: on YARN, in TDP Datacenter; on a standalone cluster or in the user's own Pod, in TDP Kubernetes.

Next steps​

Sources​

JupyterLab Documentation

JupyterLab - Overview

JupyterLab - The JupyterLab Interface

JupyterLab - Extensions

Project Jupyter Documentation

Project Jupyter - Architecture: How IPython and Jupyter Notebook work

Project Jupyter - Kernels

Jupyter Server

Jupyter Server - Architecture Diagrams

Jupyter Server - WebSocket kernel wire protocols

Jupyter Client - Messaging in Jupyter

nbformat - The Notebook file format

Project Jupyter - About