Help Center> ModelArts> DevEnviron> Local IDE> Local IDE (VS Code)> Connecting to a Notebook Instance Through VS Code Toolkit
Updated on 2023-11-21 GMT+08:00

Connecting to a Notebook Instance Through VS Code Toolkit

This section describes how to use the ModelArts VS Code Toolkit plug-in to remotely connect to a notebook instance.

Prerequisites

You have downloaded and installed VS Code. For details, see Installing VS Code.

Step 1 Install the VS Code Plug-in

  1. Search for ModelArts-HuaweiCloud in the EXTENSIONS text box and click Install.
    Figure 1 Installing the VS Code plug-in
  2. Wait for about 1 to 2 minutes.
    Figure 2 Installation process
  3. After the installation is complete, check the message displayed in the lower right corner. If the ModelArts icon and remote SSH icon are displayed in the navigation pane on the left, the VS Code plug-in is installed.
    Figure 3 Installation completion message
    Figure 4 Installation completed
Network issues may cause an installation failure. If this occurs, proceed with follow-up operations. After 1 in Step 4 Access the Notebook Instance is performed, the system will automatically display a dialog box shown in the following figure. In this case, click Install and Reload.
Figure 5 Reconnecting remote SSH

Step 2 Log In to the VS Code Plug-in

  1. In the local VS Code development environment, click and User Settings, and configure the login information.
    Figure 6 Logging in to the plug-in
    Enter the login information and click Log in.
    • Name: Custom username, which is displayed only on the VS Code page and is not associated with any Huawei Cloud account.
    • AK and SK: Access key pair. To create a key pair, choose My Credentials > API Credentials > Access Keys, and click Create Access Key.
    • Region: must be the same as that of the notebook instance to be remotely connected. Otherwise, the connection will fail.
  2. After the login, check the notebook instance list.
    Figure 7 Login succeeded

Step 3 Create a Notebook Instance

  • Create a notebook instance with remote SSH enabled, and download the key file to either of the following directories based on your OS:

    Windows: C:\Users\{{user}}

    macOS or Linux: Users/{{user}}

  • A key pair is automatically downloaded after you create it. Securely store your key pair. If an existing key pair is lost, create a new one.

Create a notebook instance with remote SSH enabled. For details, see Creating a Notebook Instance.

Step 4 Access the Notebook Instance

  1. In the local VS Code development environment, right-click the instance name and choose Connect to Instance from the shortcut menu to start and connect to the notebook instance.

    The notebook instance can either be running or stopped. If it is stopped, the VS Code plug-in starts the instance and then connects to it.

    Figure 8 Connecting to a notebook instance
    Alternatively, click the instance name. On the instance details page, click Connect. Then, the system automatically starts and connects to the notebook instance.
    Figure 9 Viewing details about a notebook instance
  2. When you connect to a notebook instance for the first time, the system prompts you in the lower right corner to configure the key file. In this case, select the local .pem key file and click OK.
    Figure 10 Configuring the key file
  3. Wait for about 1 to 2 minutes until the notebook instance is accessed. After information similar to the following is displayed in the lower left corner of the VS Code environment, the connection is succeeded.
    Figure 11 Connection succeeded

Related Operations

For details about uninstalling the VS Code plug-in, see Figure 12.

Figure 12 Uninstalling the VS Code plug-in