All Products
Search
Document Center

E-MapReduce:Develop a notebook

Last Updated:Mar 26, 2026

Notebooks in EMR Serverless Spark provide an interactive environment for writing and running Apache Spark code. This topic explains how to create, edit, run, publish, import, and export a notebook, and how to share code between notebooks using the %run magic command.

Prerequisites

Before you begin, make sure you have:

Create a notebook

  1. Log on to the E-MapReduce (EMR) console.

  2. In the navigation pane on the left, choose EMR Serverless > Spark.

  3. On the Spark page, find your workspace and click its name.

  4. In the navigation pane on the left, click Development.

  5. On the Development tab, click the image icon.

  6. Enter a name, set Type to Interactive Development > Notebook, and click OK.

Edit and run a notebook

  1. In the upper-right corner of the configuration tab of the notebook, select a notebook session from the Notebook Sessions drop-down list. A single notebook session can serve multiple notebooks simultaneously, so you do not need a dedicated session per notebook. To create a session on the spot, click Create Notebook Session from the drop-down list.

  2. Enter Python statements in a cell.

  3. Run the notebook using one of the following options:

    • To run all cells, click Execute All Cells.

    • To run a single cell, click the image icon in front of that cell.

Publish a notebook

  1. Confirm the job runs as expected.

  2. In the upper-right corner of the configuration tab of the notebook, click Publish.

  3. In the Publish dialog box, configure the Remarks parameter and click OK.

Export a notebook

On the Development tab, hover over the notebook name and choose image > Export.

Import a notebook

Only files of the Notebook type can be imported.
  1. On the Development tab, hover over the target folder and click the image icon.

    image

  2. In the dialog box, click the dotted-border area to select a local file, or drag the file into the area.

  3. Click OK.

Share code between notebooks

Use the %run magic command to execute code from another notebook. This is useful for sharing functions and variables across multiple notebooks.

All %run paths must start with /dev, followed by the folder path to the target notebook.

Example: Share a function defined in notebook_a with notebook_b.

  1. In notebook_a, define a function and a variable.

    # notebook_a.ipynb
    def greet(name):
        return f"Hello, {name}!"
    
    message = "Welcome to our Python session."
  2. In notebook_b, run notebook_a using the %run command. Replace path/to/ with the actual folder path.

    %run /dev/path/to/notebook_a
  3. In a new cell in notebook_b, use the function and variable from notebook_a.

    print(greet("EMR Serverless Spark"))
    print(message)

    The output is similar to:

    image