Notebook Lab lets you preview and edit notebook files stored in Object Storage Service (OSS) without starting compute resources. To run code, connect a notebook to a DSW instance. Multiple notebooks can share one instance for better resource utilization.
Notebook Lab vs. DSW
|
Feature comparison |
Notebook Lab |
DSW instance |
|
Core concept |
A lightweight notebook editor where multiple notebooks can share a single instance. |
A complete AI development environment. |
|
File storage |
Stored in OSS, decoupled from compute. |
Bound to the working directory of the instance. |
|
Billing model |
No charge for editing. |
Billing starts when the instance is launched. |
|
Toolset |
Focused on notebook authoring. |
Includes Notebook, WebIDE, and Terminal. |
Quick start
Step 1: Access Notebook Lab
-
Log in to the PAI console and select the Region in the upper-left corner.
-
In the navigation pane on the left, click Workspaces, then click the name of your target workspace.
-
In the navigation pane on the left, choose Model Training > Data Science Workshop (DSW), then click the Notebook tab.
Step 2: Select a code directory
Click Select Code Directory. Select an OSS bucket and create a directory such as notebook_test to store your notebook files. The notebook list displays all *.ipynb files in this directory.
Step 3: Create a notebook and write code
-
Click Create Instance to open the development environment and create a notebook file.
-
Edit your code. Click +Python to add a Python code cell.
Example:
Note-
Install dependencies first: Include dependency installation commands in each notebook so your code runs correctly when switching between instances.
-
Save your code: Notebook Lab does not auto-save. Save your changes manually.
-
Step 4: Connect an instance and run code
-
Click Associate DSW instance, then select a Running instance.
-
Click the
icon to run the code.# Since notebook files are decoupled from DSW instances, we recommend including dependency installation logic in your notebook file. # This ensures your code runs correctly when you switch between different DSW instances. !pip install pandas # 1. Import the pandas library and alias it as pd. import pandas as pdIf the kernel fails to load from the Select Kernel menu, refresh your browser.
Output:
Pandas Version: 2.3.3 Fruit Sales (kg) Price (CNY/kg) 0 Apple 120 8.5 1 Banana 200 3.2 2 Orange 150 5.0 3 Strawberry 80 15.0 4 Blueberry 50 25.0
Stop DSW instances promptly: Pay-As-You-Go instances are billed from the moment they enter the Running state, regardless of whether you run code. Stop or delete idle instances to avoid unnecessary charges.
Use Copilot for coding assistance
Copilot provides coding assistance. Trigger it using either method:
-
Method 1: Click the Generate button in the Notebook Lab toolbar.
-
Method 2: Select a cell and press:
-
Windows:
Ctrl+I -
macOS:
Command+I
-
Run MaxCompute SQL
-
Install dependencies. Add a Python cell and run:
!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 -
Bind a MaxCompute resource.
-
In the top toolbar, click +SQL to create a SQL cell, or switch a Python cell to SQL by clicking MaxCompute SQL in the lower-right corner of the cell.
-
Bind computing resources. Click Select computing resources, then click Bind computing resources. You are redirected to DataWorks to bind computing resources.
-
-
Write and run the SQL cell. This example uses a public dataset.
SET odps.namespace.schema=true; SELECT * FROM bigdata_public_dataset.default.employee_raw_scores limit 10;Result:
SET odps.namespace.schema=true; SELECT * FROM bigdata_public_dataset.default.employee_raw_scores limit 10; There's a new dataworks-magic version available (0.1.11.2), you're running 0.1.5. To upgrade: pip install https://dataworks-notebook-cn-shanghai.oss-cn-shanghai.aliyuncs.com/public-datasets/pypi/dataworks-magic/datawor... MaxCompute LogView Address: http://logview.odps.aliyun.com/logview/?h=http://service.cn-hangzhou.maxcompute.aliyun-inc.com/a... index employee_id period_name score_item_code item_score 0 0 19039043 2023-09 ItemP16 10 1 1 19039043 2023-09 ItemG7 6 2 2 19039043 2023-09 ItemC3 1 3 3 19039043 2023-09 ItemT20 2
Billing
Editing in Notebook Lab is free. Connecting a notebook to a running DSW instance incurs charges as described in Data Science Workshop (DSW) Billing.
MaxCompute SQL queries incur separate charges as described in the MaxCompute billing overview.