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

Connecting to a Notebook Instance Through PyCharm Toolkit

Updated on 2024-08-14 GMT+08:00

ModelArts provides the PyCharm plug-in PyCharm Toolkit for you to remotely access a notebook instance through SSH, upload code, submit a training job, and obtain training logs for local display.

Prerequisites

PyCharm professional 2019.2 or later has been installed locally. Remote SSH applies only to the PyCharm professional edition. Download PyCharm and install it.

NOTE:

Download PyCharm Professional 2023.2 or an earlier version. The PyCharm Toolkit is not adapt to PyCharm Professional whose version is later than 2023.2.

Step 1 Create a Notebook Instance

Create a notebook instance with remote SSH enabled and whitelist configured. Ensure that the instance is running. For details, see Creating a Notebook Instance.

Step 2 Download and Install PyCharm Toolkit

In PyCharm, choose File > Settings > Plugins, search for ModelArts in Marketplace, and click Install. For details, see Downloading and Installing PyCharm Toolkit.

Step 3 Log In to the Plug-in

To use the AK/SK pair for login authentication, perform the following steps:

  1. Open PyCharm with Toolkit installed. Choose ModelArts > Edit Credential from the menu bar.
    Figure 1 Edit Credential
  2. In the displayed dialog box, select the region where ModelArts is located, enter the AK and SK, and click OK. For details about how to obtain the AK and SK, see How Do I Obtain an Access Key?.
    • Region: Select a region from the drop-down list. It must be the same as the region of the ModelArts console.
    • Project: After the region is selected, the project is automatically filled.
    • Access Key ID: Enter the AK.
    • Secret Access Key: Enter the SK.
    Figure 2 Entering the region and access keys
  3. View the verification result.

    In the Event Log area, if information similar to the following is displayed, the access key has been successfully added:

    16:01Validate Credential Success: The HUAWEI CLOUDcredential is valid.

Step 4 Automatically Configure PyCharm Toolkit

  1. In the local PyCharm development environment, choose ModelArts > Notebook > Remote Config..., and configure PyCharm Toolkit.
    Figure 3 Remotely connecting to PyCharm Toolkit
  2. Choose the target instance from the drop-down list, where all notebook instances with remote SSH enabled under the account are displayed.
    Figure 4 Notebook list
    • KeyPair: Select the locally stored key pair of the notebook instance for authentication. The key pair created during the notebook instance creation is saved in your browser's default downloads folder.
    • PathMappings: Synchronization directory for the local IDE project and notebook, which defaults to /home/ma-user/work/Project name and is adjustable.
  3. Click Apply. After the configuration is complete, restart the IDE for the configuration to take effect.

    After the restart, it takes about 20 minutes to update the Python interpreter for the first time.

Step 5 Access a Notebook Instance Through PyCharm Toolkit

Click the notebook instance name and connect it to the local IDE as prompted. The connection is kept for 4 hours by default.

Figure 5 Starting the connection

To interrupt the connection, click the notebook name and disconnect it from the local IDE as prompted.

Figure 6 Interrupting the connection

Step 6 Upload Local Files to the Notebook Instance

Code in a local file can be copied to the local IDE, which will automatically synchronize the code to the in-cloud development environment.

Initial synchronization

In the Project directory of the local IDE, right-click Deployment and choose Upload to Notebook name from the shortcut menu to upload the local project file to the specified notebook instance.

Figure 7 Synchronizing local data to a notebook instance

Follow-up synchronization

After modifying the code, press Ctrl+S to save it. The local IDE will automatically synchronize the modification to the specified notebook instance.

After PyCharm Toolkit is installed, Automatic Upload is automatically enabled in the local IDE for automatically uploading the files in the local directory to the target notebook instance. If Automatic Upload is not enabled, enable it by referring to the following figure.

Figure 8 Enabling Automatic Upload

Step 7 Remotely Debug the Code

Click Interpreter in the lower right corner of the local IDE and select a notebook Python interpreter.

Figure 9 Selecting a Python interpreter

Run the code in the notebook instance. The logs are displayed locally.

Figure 10 Runtime logs

Click Run/Debug Configurations in the upper right corner of the local IDE to set runtime parameters.

Figure 11 Setting runtime parameters (1)

Select the Python interpreter that remotely connects to the target notebook instance.

Figure 12 Setting runtime parameters (2)

To debug code, set breakpoints and run the program in debug mode.

Figure 13 Running the program in debug mode

In debug mode, the code execution is suspended in the specified line, and you can obtain variable values.

Figure 14 Viewing variable values in debug mode

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