Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Common Functions of JupyterLab

Updated on 2024-10-29 GMT+08:00

Introduction

To access JupyterLab from a running notebook instance, perform the following operations:

  1. Log in to the ModelArts management console. In the navigation pane on the left, choose Development Workspace > Notebook.
  2. Click Open in the Operation column of a running notebook instance to access JupyterLab.
  3. The Launcher page is automatically displayed. Perform required operations. For details, see JupyterLab Documentation.
    Figure 1 JupyterLab homepage
    NOTE:

    The notebook and console kernels and versions displayed on the Launcher page vary depending on the AI engine based on which a notebook instance is created. Figure 1 shows an example only. Obtain the notebook and console kernels and versions on the management console.

    • Notebook: Select a kernel for running notebook, for example, TensorFlow or Python.
    • Console: Call the terminal for command control.
    • Other: Edit other files.

Creating a Terminal in JupyterLab

You can run Python commands on the terminal to operate the terminal. The following describes how to open the terminal of JupyterLab.

  1. Create a notebook instance. When the instance is running, click Open in the Operation column. The JupyterLab page is displayed.
  2. Choose File > New > Terminal. The Terminal page is displayed.
    Figure 2 Terminal
  3. You can use pip to install external libraries in the TensorFlow-1.8 environment on the Terminal page. For example, to install Shapely:

    Enter the following commands in the code input box to obtain the kernel of the current environment and activate the Python environment on which the installation depends:

    cat /home/ma-user/README

    source /home/ma-user/anaconda3/bin/activate TensorFlow-1.8

    NOTE:

    To install TensorFlow in another Python environment, replace TensorFlow-1.8 in the command with the target engine.

    Figure 3 Activating the environment

    Run the following command in the code input box to install Shapely:

    pip install Shapely

Creating an IPYNB File in JupyterLab

On the JupyterLab homepage, click a proper AI engine in the Notebook area to create an IPYNB file.

The AI engines supported by each notebook instance vary depending on the runtime environment. The following figure is only an example. Select an AI engine based on site requirements.

Figure 4 Selecting an AI engine and creating IPYNB file

The created IPYNB file is displayed in the navigation pane on the left.

Figure 5 Created IPYNB file

Creating a Notebook File and Accessing the Console

A console is a Python terminal, which is similar to the native IDE of Python, displaying the output after a statement is entered.

On the JupyterLab homepage, click a proper AI engine in the Console area to create a notebook file.

The AI engines supported by each notebook instance vary depending on the runtime environment. The following figure is only an example. Select an AI engine based on site requirements.

Figure 6 Selecting an AI engine and creating a console

After the file is created, the console page is displayed.

Figure 7 Creating a notebook file (console)

Editing a File in JupyterLab

JupyterLab allows you to open multiple notebook instances or files (such as HTML, TXT, and Markdown files) in one window and displays them on different tab pages.

In JupyterLab, you can customize the display of multiple files. In the file display area on the right, you can drag a file to adjust its position. Multiple files can be concurrently displayed.

Figure 8 Customized display of multiple files

When writing code in a notebook instance, you can create multiple views of a file to synchronously edit the file and view execution results in real time.

To open multiple views, open an IPYNB file and choose File > New View for Notebook.

Figure 9 Multiple views of a file

Before coding in the code area of an IPYNB file in JupyterLab, add an exclamation mark (!) before the code.

For example, install an external library Shapely.

!pip install Shapely

For example, obtain PythonPath.

!echo $PYTHONPATH
Figure 10 Running code

Renewing or Automatically Stopping a Notebook Instance

If you enable auto stop when you created or started a notebook instance, the remaining duration for stopping the instance is displayed in the upper right corner of JupyterLab. You can click the time for renewal.

Figure 11 Remaining duration
Figure 12 Renewing an instance

Common JupyterLab Buttons and Plug-ins

Figure 13 Common JupyterLab buttons and plug-ins
Table 1 JupyterLab buttons

Button

Description

Quickly open notebook instances and terminals. Open the Launcher page, on which you can quickly create notebook instances, consoles, or other files.

Create a folder.

Upload files.

Refresh the file directory.

Git plug-in, which can be used to access the GitHub code library associated with the notebook instance.

Table 2 JupyterLab plug-ins

Plug-in

Description

List files. Click this button to show all files in the notebook instance.

Display the terminals and kernels that are running in the current instance.

Git plug-in, which can be used to quickly access the GitHub code library.

Property inspector.

Show the document organization.

Figure 14 Buttons in the navigation bar
Table 3 Buttons in the navigation bar

Button

Description

File

Actions related to files and directories, such as creating, closing, or saving notebooks.

Edit

Actions related to editing documents and other activities in the IPYNB file, such as undoing, redoing, or cutting cells.

View

Actions that alter the appearance of JupyterLab, such as showing the bar or expanding code.

Run

Actions for running code in different activities such as notebooks and code consoles.

Kernel

Actions for managing kernels, such as interrupting, restarting, or shutting down a kernel.

Git

Actions on the Git plug-in, which can be used to quickly access the GitHub code library.

Tabs

A list of the open documents and activities in the dock panel.

Settings

Common settings and an advanced settings editor.

Help

A list of JupyterLab and kernel help links.

Figure 15 Buttons in the menu bar of an IPYNB file

Table 4 Buttons in the menu bar of an IPYNB file

Button

Description

Save a file.

Add a new cell.

Cut the selected cell.

Copy the selected cell.

Paste the selected cell.

Execute the selected cell.

Terminate a kernel.

Restart a kernel.

Restart a kernel and run all code of the current notebook again.

There are four options in the drop-down list:

Code (Python code), Markdown (Markdown code, typically used for comments), Raw (a conversion tool), and - (not modified)

View historical code versions.

Git plug-in. The gray button indicates that the plug-in is unavailable in the current region.

Instance flavor.

Kernel for you to select.

Code running status. indicates the code is being executed.

Using Code-based Plug-ins

The code parametrization plug-in simplifies notebook cases. You can quickly adjust parameters and train models based on notebook cases without complex code. This plug-in can be used to customize notebook cases for competitions and learning.

  • The Add Form and Edit Form buttons are available only to the shortcut menu of code cells, as shown below.
    Figure 16 Viewing a code cell
  • After opening new code, add a form before editing it.
    Figure 17 Shortcut menu of code cells
  • If you click Add Form, a code cell will be split into the code and form edit area. Click Edit on the right of the form to change the default title.
    Figure 18 Two edit areas
  • If you click Edit Form, four sub-options will be displayed: Add new form field, Hide code, Hide form, and Show All.
    Table 5 Edit Form sub-options

    Edit-Form Sub-option

    Description

    Add new form field

    • The form field types include dropdown, input, and slider, as shown in Figure 19. Each time a field is added, the corresponding variable is added to the code and form areas. If a value in the form area is changed, the corresponding variable in the code area is also changed.
    NOTE:

    When creating a dropdown form, click ADD Item and add at least two items, as shown in Figure 20.

    • If the form field type is set to dropdown, the supported variable types are raw and string.
    • If the form field type is set to input, the supported variable types are boolean, date, integer, number, raw, and string.
    • If the form field type is set to slider, the minimum value, maximum value, and step can be set.

    Hide code

    Hide the code.

    Hide form

    Hide the forms.

    Show all

    Display both code and forms.

    Figure 19 Form field types
    Figure 20 Creating a dropdown form
    Figure 21 Deleting a form

Monitoring Resources

To obtain resource usage, select Resource Monitor in the right pane. The CPU usage and memory usage can be viewed.

Figure 22 Resource usage

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback