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.
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.
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.
In the Glossary: Cell · Jupyter Server
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Architecture
The interface in the browser, the Jupyter Server, and the kernels: three pieces that talk to each other only through the server.
What the figure shows:
- 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.
- 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.
- The .ipynb files are the notebooks saved in JSON, which the Contents Manager reads and writes.
- 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.
- 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.
- 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.
- 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.
- 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.
The work area
Documents and activities side by side, in the same window, in tabs and splitters.
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.
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
| Edition | Version | Documentation |
|---|---|---|
| TDP Datacenter | 4.4.5 | TDP Datacenter components |
| TDP Kubernetes · JupyterHub | 5.3.0 · chart tdp-jupyter 3.0.3 | Configuration in TDP Kubernetes |
In TDP Datacenter
In TDP Datacenter, JupyterLab is the Jupyterlab Notebook service of the stack, installed and managed by Ambari.
JUPYTERLAB (master, one or more). The JUPYTERLAB requires SPARK3_CLIENT (Spark) and YARN_CLIENT (YARN). Component category.
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.
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.
Notebooks with examples of integration and use of various components, which can be enabled in load_examples.enabled.
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.
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.
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.
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.
The notebook image is large, and the chart pre-pulls it on the nodes that run notebooks. See JupyterHub.
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.
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
TDP Kubernetes
JupyterLab Integrations
Local Spark or external cluster, and Iceberg tables in the notebooks.
TDP Kubernetes
JupyterLab Security
Authentication, LDAP, Active Directory, and the NetworkPolicy of the user servers.
TDP Datacenter
TDP Datacenter Architecture
Where JupyterLab sits in the Ambari-managed cluster, alongside HDFS, YARN, and Spark.
Sources
JupyterLab - The JupyterLab Interface
Project Jupyter - Architecture: How IPython and Jupyter Notebook work
Jupyter Server - Architecture Diagrams
Jupyter Server - WebSocket kernel wire protocols
Jupyter Client - Messaging in Jupyter