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
- Log in to the ModelArts management console. In the left navigation pane, choose DevEnviron > Notebook.
- 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.
- 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.
- Select the folder for storing the OBS parallel file system and click OK.
Figure 1 Dynamically mounting an OBS parallel file system
- 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")
Last Article: Changing a Notebook Instance Image
Next Article: Dynamically Expanding EVS Disk Capacity
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.