This topic describes how to create, edit, run, publish, import, and export a notebook and share code between notebooks in Alibaba Cloud E-MapReduce (EMR) Serverless Spark.
Prerequisites
A workspace and a notebook session are created. For more information, see Create a workspace and Manage notebook sessions.
Create a notebook
Go to the Data Development page
Log on to the E-MapReduce (EMR) console.
In the navigation pane on the left, choose .
On the Spark page, find the desired workspace and click the name of the workspace.
In the navigation pane on the left of the EMR Serverless Spark page, click Development.
Create a notebook.
On the Development tab, click the
icon. Enter a name, set Type to , and then click OK.
Edit and run the notebook
In the upper-right corner of the configuration tab of the notebook, select a notebook session that you created and started from the Notebook Sessions drop-down list.
You can also click Create Notebook Session from the Notebook Sessions drop-down list to create a notebook session.
NoteA notebook session can be used by multiple notebooks at a time. This way, you do not need to seperately create a notebook session for each notebook.
Enter Python statements in the cell.
Click Execute All Cells or the
icon in front of the cell to run the notebook.
Publish the notebook
Confirm that the job runs as expected. Then, in the upper-right corner of the configuration tab of the job, click Publish.
In the Publish dialog box, configure the Remarks parameter and click OK.
Export the notebook
On the Development tab of the Development page, move the pointer over the notebook name and choose .
Import a notebook
You can upload only a file of the Notebook type.
On the Development tab of the Development page, move the pointer over a specific folder and click the
icon. 
In the dialog box that appears, click the area in the dotted line rectangle to select a local file, or drag the file to the area. Then, click OK.
Call other notebooks in a notebook
In a notebook, you can use the %run magic command to execute code from another notebook. This is useful when you need to share functions or variables between multiple notebooks.
For example, 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, define a simple function
greetand a variablemessage.# notebook_a.ipynb def greet(name): return f"Hello, {name}!" message = "Welcome to our Python session."In notebook_b, use the
%runcommand to call notebook_a.%run /dev/path/to/notebook_aNoteThe file path must start with
/dev. Replacepath/to/with the actual folder path. In this example, notebook_a is in the test folder.Use the content defined in notebook_a in the new cell.
print(greet("EMR Serverless Spark")) print(message)The following information is returned.

> Export