Downloading a File from JupyterLab to a Local Path
Files created in JupyterLab can be downloaded to a local path. For details about how to upload files to JupyterLab, see Uploading Files to JupyterLab.
- If a file is no larger than 100 MB, directly download it from JupyterLab. For details, see Downloading a File No Larger Than 100 MB to a Local Path.
- If a file is larger than 100 MB, transfer it from JupyterLab to OBS and then download it from OBS to a local path. For details, see Downloading a File Larger Than 100 MB to a Local Path.
Downloading a File No Larger Than 100 MB to a Local Path
In the JupyterLab file list, right-click the file to be downloaded and select Download from the shortcut menu.
The file will be downloaded to your browser's downloads folder.

Downloading a File Larger Than 100 MB to a Local Path
Upload a file larger than 100 MB from a notebook instance to OBS and then download the file from OBS to a local path. The procedure is as follows:
- Open the Python runtime environment.
As shown in the following figure, click python-3.7.10 in the Notebook area on the Launcher page. The following figure shows an example environment.
Figure 2 Opening the Python runtime environment - Call the ModelArts SDK to upload the target file from the notebook instance to OBS.
- Call the ModelArts SDK for uploading a file to OBS.
Sample code: Upload file1.txt in the notebook instance to OBS bucket obs://bucket-name/dir1/. All the bucket name, folder name, and file name are customizable.
from modelarts.session import Session session = Session() session.obs.upload_file(src_local_file='/home/ma-user/work/file1.txt', dst_obs_dir='obs://bucket-name/dir1/')
- Call the ModelArts SDK for uploading a folder to OBS.
Sample code: Upload /work/ in the notebook instance to obs://bucket-name/dir1/work/ of bucket-name. The bucket name and folder name are customizable.
from modelarts.session import Session session = Session() session.obs.upload_dir(src_local_dir='/home/ma-user/work/', dst_obs_dir='obs://bucket-name/dir1/')
- Call the ModelArts SDK for uploading a file to OBS.
- Use OBS or ModelArts SDK to download the file from OBS to the local path.
- Method 1: Use OBS to download the file.
Download obs_file.txt from OBS to the local path. If you have a large amount of data, use OBS Browser+ to download data or folders. For details about how to download OBS files, see Downloading a File.
- Method 2: Downloading the files using the ModelArts SDKs
Download files from OBS to a local path. For details, see Downloading a File from OBS. The sample code is as follows:
from modelarts.session import Session # Hard-coded or plaintext AK/SK is risky. For security, encrypt your AK/SK and store them in the configuration file or environment variables. # In this example, the AK/SK is stored in environment variables for identity authentication. Before running this example, set environment variables HUAWEICLOUD_SDK_AK and HUAWEICLOUD_SDK_SK. __AK = os.environ["HUAWEICLOUD_SDK_AK"] __SK = os.environ["HUAWEICLOUD_SDK_SK"] # Decrypt the information if it is encrypted. session = Session(access_key=__AK,secret_key=__SK, project_id='***', region_name='***') session.download_data(bucket_path="/bucket_name/obs_file.txt",path="/home/user/obs_file.txt")
- Method 1: Use OBS to download the file.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot