Help Center> ModelArts> DevEnviron> Managing Notebook Instances> Dynamically Mounting an OBS Parallel File System

Dynamically Mounting an OBS Parallel File System

Overview

Dynamic OBS mounting uses a mounting tool to convert the object storage protocol into the POSIX file protocol. OBS storage is simulated as a local file system and dynamically mounted to a running notebook container. After the mounting, you can perform application operations on the OBS objects in the notebook container.

Application Scenarios

Scenario 1: After you mount the OBS storage in which the target dataset is stored to your notebook instance, you can preview and perform operations in the dataset like operating a local file system.

Scenario 2: When training data in a notebook instance, you can use the dataset mounted to a notebook container.

Restrictions

OBS provides object buckets and parallel file systems for storage.

The ModelArts notebook of the new version supports only the mounting of an OBS parallel file system to /data/ of a notebook container.

Procedure

Method 1: Through the ModelArts management console

  1. Log in to the ModelArts management console. In the left navigation pane, choose DevEnviron > Notebook.
  2. Select a running notebook instance and click its name. On the notebook instance details page, click the Storage tab. From there, click Mount Storage and configure mounting parameters.
    1. Set a local mounting directory. Enter a folder name in /data/, for example, demo. The system will automatically create the folder in /data/ of the notebook container to mount the OBS file system.
    2. Select the folder for storing the OBS parallel file system and click OK.
      Figure 1 Dynamically mounting an OBS parallel file system
  3. View the mounting result on the notebook instance details page.
    Figure 2 Successful mounting

Method 2: Through APIs

The API for dynamic OBS mounting has been released in CN North-Beijing4 and CN East-Shanghai1 regions. Perform the mounting in the notebook of the new version. Create an IPYNB file and run the script. For details, see Accessing JupyterLab and Creating an IPYNB File in JupyterLab.

The following shows example script code for dynamic OBS mounting. For details about API parameters, see OBS Storage Mounting.

import os
from json import JSONEncoder
from modelarts.config.auth import auth_by_apig
from modelarts.session import Session

session = Session()
request_url = "/v1/{}/notebooks/{}/storage".format(os.environ['PROJECT_ID'], os.environ["INSTANCE_ID"])


# View the dynamic mounting list.
auth_by_apig(session, 'GET', request_url)


# In dynamic mounting, change the OBS path obs://obs-bucket-train/dir/ as needed and set mount_path to customizable /data/xxx/ (/data/demo/ in this example).
body = {
    "category": "OBS",
    "uri": "obs://obs-bucket-train/dir/",
    "mount_path": "/data/demo/"
}
auth_by_apig(session, 'POST', request_url, body=JSONEncoder().encode(body))

# Dynamic unmounting
auth_by_apig(session, 'DELETE', request_url + "/ea217c4f-3282-4af2-98ea-d3c668d2fba9")