All Products
Search
Document Center

Platform For AI:Notebook Lab

Last Updated:Nov 06, 2025

With Notebook Lab, you can preview and edit any Notebook file on Object Storage Service (OSS) without launching a compute resource. To run your code, connect the Notebook to a DSW instance. Multiple Notebooks can share a single instance, improving resource utilization.

Comparison with DSW

Feature comparison

Notebook Lab

DSW instance

Core

Lightweight Notebook editor

A complete AI development environment

File

Stored in Object Storage Service (OSS), decoupled from compute resources

Bound to the compute instance in the same working directory

Billing

No charge for editing

Billing starts when the instance is launched

Tools

Focused on Notebook development

Includes JupyterLab, WebIDE, and Terminal

Access a notebook

  1. Log on to the PAI console.

  2. In the upper-left corner, select the required region.

  3. In the navigation pane on the left, choose Workspaces, and then click the name of your target workspace.

  4. In the navigation pane on the left, choose Model Training > Data Science Workshop (DSW), then click the Notebook tab.

Configure code directory

Click Select Code Directory.

image

After you configure a custom code directory, Notebook Lab scans the directory and lists all Notebook files (*.ipynb) from the specified OSS path. You can then select an existing Notebook or create a new one in the configured directory.

Create and develop a notebook

  1. Click Create Notebook. This creates a new Notebook file in the configured code directory.

    image

  2. On the development page, you can work in a Jupyter-style interactive environment.

    Because Notebook files are decoupled from DSW instances, include the logic for downloading and installing environment dependencies directly in your Notebook file. This ensures that your code runs correctly even when you switch between different DSW instances.

Develop a notebook

Prerequisites

(Optional) To use SQL, install the SQL plugin.

!pip install https://dataworks-notebook-cn-shanghai.oss-cn-shanghai.aliyuncs.com/public-datasets/pypi/dataworks-magic/dataworks_magic-0.1.5-py3-none-any.whl jupysql tenacity sqlparse maxframe alibabacloud_emr_serverless_spark20230808 alibabacloud_ververica20220718 psycopg2-binary

Procedure

  1. Add a cell.

    Create a new cell from the Notebook Lab toolbar or by clicking the buttons that appear above or below an existing cell.

    Note

    To reorder cells, hover over the blue line to the left of a cell, and then drag the cell to a new position.

    image

  2. (Optional) Change the cell type.

    Click the cell type button in the lower-right corner of a cell to change its type. The following cell types are supported:

    Markdown, Python, MaxCompute SQL, Flink SQL Batch, and Flink SQL Streaming.

    Note

    When you change the cell type, the content is preserved. You must manually adapt the code to the new cell type.

    image

  3. Write code in a cell.

    You can edit SQL, Python, or Markdown code in the corresponding cells. Use Copilot for programming assistance. To trigger Copilot, use one of the following methods:

    • Method 1: Trigger Copilot from the Notebook Lab toolbar or by using the buttons that appear above or below a cell.

      image

    • Method 2: Select a cell and use the following keyboard shortcuts:

      • Windows: Ctrl+I

      • macOS: Command+I

Debug and run Notebook

  1. Select a DSW instance.

    After you finish editing your Notebook, click the DSW instance name in the upper-right corner to select an instance to debug or run your code. By default, the list is filtered to show DSW instances in the current workspace. Choose an instance with the appropriate specifications and image.

    When a Notebook is connected to a DSW instance, its working path is the same as the DSW instance's working directory (default: /mnt/workspace). This lets you interact with local files in the DSW instance by using relative paths. You can also create, delete, preview, or edit files within the DSW instance.

    Important

    Billing starts as soon as an instance enters the running state.

  2. (Optional) Select a compute resource, such as MaxCompute or Flink.

    When developing in an SQL cell, click Select a computing resource, and then click Associate Computing Resource to go to DataWorks to associate a computing resource. When you run the cell, the specified compute resource executes the SQL code.

    image

  3. After you write the code in your cells, run them to test your Notebook.

    • Run all cells: Click the image button in the toolbar to run all cells in the Notebook.

    • Run a single cell: Click the image button to the left of a cell to run only that cell.

  4. View the result.

    Click Ask Copilot to view the code analysis results in the right-side pane.

    image