View a markdown version of this page

Amazon EMR Notebooks - Amazon EMR Migration Guide

Amazon EMR Notebooks

Note

For new migrations, Amazon SageMaker Unified Studio (SMUS) is the recommended notebook and integrated development environment. The EMR Studio Workspaces content in this chapter remains relevant for organizations with existing EMR Studio deployments or with requirements that SMUS does not yet support. For more information, see the Phase 5 advisory in Securing your Resources on Amazon EMR.

Amazon EMR Notebooks provide a capability for SQL developers and data engineers to run ad-hoc queries using managed Jupyter notebooks within the Amazon EMR console. Unlike a traditional notebook, the contents (equations, queries, models, code, and narrative text) run in a client, with commands executed using a kernel on the Amazon EMR cluster. Notebook contents are saved to Amazon S3 separately from cluster data for durability and reuse.

This lets you detach a notebook from a running cluster and attach it to a different cluster that meets the requirements. Several Amazon EMR notebooks can attach to the same cluster, and multiple users can attach notebooks simultaneously and share notebook files in Amazon S3. This multi-tenant capability is based on the memory constraints of the primary node instance type.

You can configure AWS IAM roles so that one user's notebook cannot be accessed by another user in the same account. Amazon EMR Notebooks also provide Git and Bitbucket integration, supporting GitHub, CodeCommit, Bitbucket, or any Git provider through a URL.

Headless (programmatic) execution

Amazon EMR Notebooks support headless (programmatic) execution through the Amazon EMR API, without interacting with the console. You include a cell with a parameters tag so that a script can pass new input values. Parameterized notebooks can be reused with different input values without creating copies, and Amazon EMR creates and saves the output notebook on Amazon S3 for each run.

Amazon EMR Notebooks support clusters using Amazon EMR releases 5.18.0 and higher. We recommend the latest Amazon EMR version, or at least 5.30.0, 5.32.0 or later, or 6.2.0 or later. With these releases, Jupyter kernels run on the attached cluster rather than on a Jupyter instance, which improves performance and the customization of kernels and libraries.

Advanced AI-powered features

Amazon EMR includes AI-powered features that automate code upgrades and simplify troubleshooting, alongside new security and session management capabilities.

AI-powered features

  • Spark Upgrade Agent automates PySpark and Scala code upgrades using natural language prompts. It handles API changes, resolves dependency conflicts, and validates compatibility, and it supports Spark 2.4 through 3.5 and 4.x.

  • Spark Troubleshooting Agent analyzes failed Spark jobs, pinpoints bottlenecks, and suggests targeted code fixes for Amazon EMR, AWS Glue, and Amazon SageMaker workloads from job logs and execution context.

Security and session management

  • IAM Identity Center background sessions — EMR Studio supports running long Spark workloads after logoff through trusted identity propagation with IAM Identity Center.

  • Fine-grained access control — Amazon EMR enforces table-level permissions for Apache Hudi, Apache Iceberg, and Delta Lake tables through AWS Lake Formation. This is available from Amazon EMR 6.15.0 and later, with full IAM Identity Center integration from Amazon EMR 7.2.0 and later.

EMR Studio integration

EMR Studio provides a unified, web-based integrated development environment for Jupyter notebooks running on Amazon EMR clusters.

Unified console access

EMR Studio provides a single console experience for creating, managing, and running notebooks. You access workspaces, attached clusters, and job history centrally.

Enhanced cluster management

You can attach and detach clusters seamlessly from the workspace, switch clusters without losing notebook state, and monitor cluster health and resource utilization.

SQL Explorer

You can browse and query data using SQL-based exploration tools within EMR Studio. You can discover tables, preview data, and run ad-hoc queries against the AWS Glue Data Catalog and a self-hosted Hive Metastore version 3.1. SQL Explorer requires a Presto or Trino cluster.

Service Catalog integration

Administrators define pre-approved cluster templates, and users provision Amazon EMR clusters from them within EMR Studio without direct AWS console access.

Real-time collaboration

Multiple users can co-edit a notebook simultaneously.

Important

Workspace collaboration is not supported when Trusted Identity Propagation (TIP) is enabled, or with Amazon EMR Serverless interactive applications. If your migration uses TIP, which we recommend for fine-grained access control, real-time collaboration is not available in EMR Studio.

Pipeline integration

You can schedule and run notebooks as part of larger workflows, and trigger parameterized notebooks through the Amazon EMR API.

Simplified debugging

EMR Studio provides built-in access to the Spark UI, the YARN Timeline Service, and job logs, so you can navigate from a notebook to diagnostic views.

Cluster requirements

Before attaching a cluster to an Amazon EMR notebook, ensure that the cluster meets all of the following requirements.

Supported Amazon EMR releases

Amazon EMR Notebooks support Amazon EMR 5.18.0 and higher. We recommend Amazon EMR 6.2.0 or later, or 7.0.0 or later.

Required applications

Hadoop, Spark, and Livy must be installed. Jupyter Enterprise Gateway is required for Amazon EMR 5.32.0 and later and 6.2.0 and later.

Unsupported instance types

AMD EPYC processor-based instances (m5a.* and r5a.*) are not supported.

Graviton support

AWS Graviton instances are supported with Jupyter Enterprise Gateway on Amazon EMR 6.9.0 and later and 5.31.1 and later. We recommend Graviton instances for better price-performance. For more information, see Compute optimization in Operational Excellence.

Network and security configuration

  • VisibleToAllUsers must be true.

  • Clusters with multiple primary nodes (HA clusters) are not supported for Amazon EMR Notebooks or EMR Studio Workspaces.

  • Clusters must be launched in EC2-VPC. Public and private subnets are supported; EC2-Classic is not supported.

  • Kerberos authentication is not supported.

  • Amazon EMR Block Public Access must be enabled.

  • With AWS Lake Formation integration, supported clusters can install notebook-scoped libraries only.

Comparison of JupyterHub on Amazon EMR and Amazon EMR Notebooks

The following table compares JupyterHub on Amazon EMR with Amazon EMR managed notebooks, which are surfaced as EMR Studio Workspaces.

JupyterHub on Amazon EMR compared with Amazon EMR Notebooks
Attribute JupyterHub on Amazon EMR Amazon EMR managed notebooks (EMR Studio Workspaces)
Custom packages For the Python kernel, custom packages are installed manually within the Docker container that JupyterHub runs on. For the PySpark kernel, from Amazon EMR 5.26.0 and later, custom packages install through notebook-scoped libraries on the Spark context. On Amazon EMR earlier than 5.26.0, install them on all nodes through a bootstrap action or at the AMI level. For the Python kernel, upload the tar installation file manually, then perform a conda offline installation. For the PySpark kernel, from Amazon EMR 5.26.0 and later, use notebook-scoped libraries. On Amazon EMR earlier than 5.26.0, install them on all nodes through a bootstrap action or the AMI.
Git integration JupyterLab and Git integration is not supported natively. You can install a JupyterLab plugin with a Git extension through Docker commands. Git and Bitbucket integration is supported natively and can be used to check out code through JupyterLab.
Notebook storage Notebooks are stored locally in the cluster. They must be saved manually and uploaded to Amazon S3, or JupyterHub must be configured to save to Amazon S3 at cluster launch. Notebooks are saved in the Amazon S3 base location specified during notebook creation.
Flexibility The JupyterHub instance is locked to a single Amazon EMR cluster. If the cluster terminates, notebooks are deleted unless they are backed up in Amazon S3. The notebook is not locked to one cluster. Because notebooks are stored in Amazon S3, on cluster termination the notebook can be re-attached to a different running cluster without data loss.
Multi-tenancy All users share the same JupyterHub instance. PAM, LDAP, or SAML authentication must be set up to segregate notebooks per user. Many notebooks can attach to a single cluster based on the primary node instance type. A notebook can be created per user and access restricted using IAM policies. Multiple users can attach simultaneously and share files in Amazon S3.
Authentication LDAP, Kerberos, and SAML can be custom configured, but only one mechanism at a time. Supports IAM users, SAML authentication through AWS Lake Formation, and IAM Identity Center for long-running workloads. Kerberized Amazon EMR clusters without AWS Lake Formation are not supported.
Programmatic execution Not supported natively. Supported through the Amazon EMR API (headless execution). Parameterized notebooks are reused with different inputs, and output is saved to Amazon S3 per run.
AI-powered tools Not available. Spark Upgrade Agent and Spark Troubleshooting Agent for automated code upgrades and job debugging.
Access control Basic user-level access control. Fine-grained table-level permissions for Apache Hudi, Apache Iceberg, and Delta Lake through AWS Lake Formation. Available from Amazon EMR 6.15.0 and later, with full IAM Identity Center integration from Amazon EMR 7.2.0 and later.
SQL Explorer Not available. Browse and query data using SQL-based exploration tools within EMR Studio.
Service Catalog integration Not available. Provision Amazon EMR clusters using AWS Service Catalog for governed, pre-approved cluster creation.

Migrating Jupyter notebooks to Amazon EMR Notebooks

To migrate your Jupyter notebooks, export and copy the notebook files to an Amazon S3 location used by your Amazon EMR notebook. If required, convert Python or PySpark files to notebook format and upload them to Amazon S3.

Method 1: Manual export for a small number of notebooks

Download each notebook by choosing File, Download As, Notebook (.ipynb). Then copy the notebook to Amazon S3 through the console or the Amazon S3 CLI.

aws s3 cp SharedNotebook.ipynb s3://MyBucket/MyNotebooksFolder/e-12A3BCDEFGHIJKLMNO45PQRST/MyNotebook.ipynb

Method 2: Bulk export for multiple notebooks

Copy notebooks directly from the Jupyter installation to Amazon S3. Use SSH to connect to the node that holds the Jupyter installation, go to where the notebooks are saved (for example, /mnt/var/lib/jupyter/home/jovyan/), and run the following command:

aws s3 cp /mnt/var/lib/jupyter/home/jovyan/ s3://MyBucket/MyNotebooksFolder/e-12A3BCDEFGHIJKLMNO45PQRST/ --recursive

Converting Python or PySpark files to notebook format

If your programs are in .py format, convert them to .ipynb before using them in an Amazon EMR notebook. Use the open-source Python package jupytext.

jupytext --to notebook myscript.py
Note

We recommend jupytext for converting .py files to .ipynb. Install it with the following command:

pip install jupytext

Key updates from the previous version

  • EMR Studio Workspaces — Amazon EMR Notebooks are surfaced as Workspaces in the Amazon EMR console with a Create Workspace button. Users need additional IAM role permissions to access or create Workspaces.

  • Architecture clarification — Notebook contents run in a client with commands executed using a kernel on the Amazon EMR cluster, rather than running directly on a Jupyter instance.

  • Programmatic execution — Headless execution through the Amazon EMR API with parameterized notebooks. Output notebooks are saved to Amazon S3 per run.

  • Version requirements — Clusters using Amazon EMR releases 5.18.0 and higher; we recommend 5.30.0, 5.32.0 or later, or 6.2.0 or later.

  • New AI-powered features (2025) — Spark Upgrade Agent for automated PySpark and Scala upgrades from Spark 2.4 to 4.x, and Spark Troubleshooting Agent for automated job failure analysis and code fix suggestions.

  • IAM Identity Center background sessions — Running long Spark workloads after logoff using trusted identity propagation.

  • Fine-grained access control — Table-level permissions for Apache Hudi, Apache Iceberg, and Delta Lake through AWS Lake Formation, from Amazon EMR 6.15.0 and later.

  • EMR Studio integration — Unified console access, enhanced cluster management, SQL Explorer, Service Catalog integration, real-time collaboration, pipeline integration, and simplified debugging.