This topic describes how to develop with notebooks in EMR Serverless Spark. You will learn how to create, edit, run, publish, import, and export notebooks, and share code between them.
Prerequisites
You have created a workspace and a notebook session. For more information, see Create a workspace and Manage notebook sessions.
Create a notebook
-
Go to the development page.
-
Log on to the E-MapReduce (EMR) console.
-
In the left-side navigation pane, choose EMR Serverless > Spark.
-
On the Spark page, click the name of your target workspace.
-
On the EMR Serverless Spark page, click Data Development in the left-side navigation pane.
-
-
Create a notebook.
-
On the Development tab, click the
icon. -
Enter a name, select for Type, and click OK.
-
Edit and run a notebook
-
In the upper-right corner, select a running notebook session.
You can also select Create Notebook Session from the drop-down list to create a new one.
NoteMultiple notebooks can share the same notebook session instance, allowing you to access and use the same session resources from multiple notebooks simultaneously.
-
Enter Python statements in a cell of the new notebook.
-
Click Run All Cells or the
icon beside a cell to run the notebook.
Publish a notebook
-
After the run completes, click Publish in the upper-right corner.
-
In the Publish dialog box, enter the required details and click OK to save the notebook as a new version.
Export a notebook
On the Development tab in Data Development, hover over a Notebook and select .
Import a notebook
Currently, only notebook files can be imported.
-
On the Development tab in Data Development, hover over a folder, and then click the
icon.
-
In the dialog box, click the upload area to select a local file, or drag a file into the area, and then click OK.
Call another notebook
You can use the %run magic command to run code from another notebook. This is useful when you need to share functions or variables across multiple notebooks.
For example, assume you have two notebook files: notebook_a.ipynb and notebook_b.ipynb. The notebook_a.ipynb file defines functions and variables that you want to use in notebook_b.ipynb.
-
In
notebook_a.ipynb, define a simple function namedgreetand a variable namedmessage.# notebook_a.ipynb def greet(name): return f"Hello, {name}!" message = "Welcome to our Python session." -
In
notebook_b.ipynb, use the%runcommand to callnotebook_a.ipynb.%run /dev/path/to/notebook_aNoteThe file path must start with
/dev. Replacepath/to/with the actual folder path. In this example,notebook_ais in the test folder. -
In a new cell, use the function and variable defined in
notebook_a.ipynb.print(greet("EMR Serverless Spark")) print(message)The output is similar to the following:

> Export