doc-exports/docs/modelarts/sdk-ref/modelarts_04_0221.html
Lai, Weijian 1ad28cc33e modelarts sdk-ref first version
Reviewed-by: Jiang, Beibei <beibei.jiang@t-systems.com>
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Lai, Weijian <laiweijian4@huawei.com>
Co-committed-by: Lai, Weijian <laiweijian4@huawei.com>
2023-03-01 15:24:28 +00:00

96 lines
9.8 KiB
HTML

<a name="modelarts_04_0221"></a><a name="modelarts_04_0221"></a>
<h1 class="topictitle1">Downloading a Folder from OBS</h1>
<div id="body8662426"><div class="note" id="modelarts_04_0221__en-us_topic_0220956298_note1030220262196"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="modelarts_04_0221__en-us_topic_0220956298_p11302192619194">If the size of a file in a folder exceeds 5 GB, the file cannot be downloaded in this mode. However, other files whose size is less than 5 GB in the folder can be downloaded.</p>
</div></div>
<div class="section" id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_section20261580353"><h4 class="sectiontitle">Sample Code</h4><p id="modelarts_04_0221__en-us_topic_0220956298_p1199511308410">In the ModelArts notebook instance, you do not need to enter authentication parameters for session authentication. For details about session authentication of other development environments, see <a href="modelarts_04_0153.html">Session Authentication</a>.</p>
<div class="codecoloring" codetype="Python" id="modelarts_04_0221__en-us_topic_0220956298_screen12281171531112"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span></pre></div></td><td class="code"><div><pre><span></span><span class="kn">from</span> <span class="nn">modelarts.session</span> <span class="kn">import</span> <span class="n">Session</span>
<span class="n">session</span> <span class="o">=</span> <span class="n">Session</span><span class="p">()</span>
<span class="n">session</span><span class="o">.</span><span class="n">obs</span><span class="o">.</span><span class="n">download_dir</span><span class="p">(</span><span class="n">src_obs_dir</span><span class="o">=</span><span class="s2">&quot;obs://bucket-name/dir1/&quot;</span><span class="p">,</span> <span class="n">dst_local_dir</span><span class="o">=</span><span class="s2">&quot;/home/ma-user/work/&quot;</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</div>
<p id="modelarts_04_0221__en-us_topic_0220956298_p93231521161819">After the sample code is executed, source folder <span class="filepath" id="modelarts_04_0221__en-us_topic_0220956298_filepath20866651152511"><b>dir1</b></span> is downloaded from OBS to <span class="filepath" id="modelarts_04_0221__en-us_topic_0220956298_filepath127921757122511"><b>/home/ma-user/work/dir1/</b></span>.</p>
<div class="caution" id="modelarts_04_0221__note11146152501412"><span class="cautiontitle"><img src="public_sys-resources/caution_3.0-en-us.png"> </span><div class="cautionbody"><p id="modelarts_04_0221__p51468253144">You must have the write permission on the local path.</p>
</div></div>
<div class="section" id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_section78291820269"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_table155461191218" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Request parameters</caption><thead align="left"><tr id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_row254817912212"><th align="left" class="cellrowborder" valign="top" width="20.75%" id="mcps1.3.5.2.2.5.1.1"><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p12549899214">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="11.99%" id="mcps1.3.5.2.2.5.1.2"><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p3552101193813">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="13.320000000000002%" id="mcps1.3.5.2.2.5.1.3"><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p1755169172118">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="53.94%" id="mcps1.3.5.2.2.5.1.4"><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p55521998211">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_row8893215413"><td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.5.2.2.5.1.1 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p6891421842">session</p>
</td>
<td class="cellrowborder" valign="top" width="11.99%" headers="mcps1.3.5.2.2.5.1.2 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p68972047">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="13.320000000000002%" headers="mcps1.3.5.2.2.5.1.3 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p158912219419">Object</p>
</td>
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.3.5.2.2.5.1.4 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p1689152543">Session object</p>
</td>
</tr>
<tr id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_row1530181931"><td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.5.2.2.5.1.1 "><p id="modelarts_04_0221__en-us_topic_0220956298_p1315881682013">src_obs_dir</p>
</td>
<td class="cellrowborder" valign="top" width="11.99%" headers="mcps1.3.5.2.2.5.1.2 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p6675978319">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="13.320000000000002%" headers="mcps1.3.5.2.2.5.1.3 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p46751171339">String</p>
</td>
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.3.5.2.2.5.1.4 "><p id="modelarts_04_0221__en-us_topic_0220956298_p19233184612200">Path to the source folder to be downloaded from OBS. The path must start with <span class="filepath" id="modelarts_04_0221__en-us_topic_0220956298_filepath416152032116"><b>obs://</b></span> and end with a slash (/). If the downloaded folder contains empty folders, no empty folders are created in the corresponding local path.</p>
</td>
</tr>
<tr id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_row167932713277"><td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.5.2.2.5.1.1 "><p id="modelarts_04_0221__en-us_topic_0220956298_p36098872111">dst_local_dir</p>
</td>
<td class="cellrowborder" valign="top" width="11.99%" headers="mcps1.3.5.2.2.5.1.2 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p77948710279">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="13.320000000000002%" headers="mcps1.3.5.2.2.5.1.3 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p3794167192716">String</p>
</td>
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.3.5.2.2.5.1.4 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p1479417112711">Path to the target local folder. The path must end with a slash (/).</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_table55928961173927" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Failed response parameters</caption><thead align="left"><tr id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_row40618446173927"><th align="left" class="cellrowborder" valign="top" width="25.490000000000002%" id="mcps1.3.6.2.4.1.1"><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p1631242217407">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="23.72%" id="mcps1.3.6.2.4.1.2"><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p5427574117407">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50.79%" id="mcps1.3.6.2.4.1.3"><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p12364118914">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_row11062410173927"><td class="cellrowborder" valign="top" width="25.490000000000002%" headers="mcps1.3.6.2.4.1.1 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p688954611624">error_code</p>
</td>
<td class="cellrowborder" valign="top" width="23.72%" headers="mcps1.3.6.2.4.1.2 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p3804851211624">String</p>
</td>
<td class="cellrowborder" valign="top" width="50.79%" headers="mcps1.3.6.2.4.1.3 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p156551524172412">Error code when the API call fails.</p>
<p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p6203060911624">This parameter is not included when the API call succeeds.</p>
</td>
</tr>
<tr id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_row52351653173927"><td class="cellrowborder" valign="top" width="25.490000000000002%" headers="mcps1.3.6.2.4.1.1 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p4368550411624">error_msg</p>
</td>
<td class="cellrowborder" valign="top" width="23.72%" headers="mcps1.3.6.2.4.1.2 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p6574380911624">String</p>
</td>
<td class="cellrowborder" valign="top" width="50.79%" headers="mcps1.3.6.2.4.1.3 "><p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p1277593619">Error message when the API call fails.</p>
<p id="modelarts_04_0221__en-us_topic_0220956298_en-us_topic_0173848863_p2364831411624">This parameter is not included when the API call succeeds.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="modelarts_04_0006.html">OBS Management (Recommended)</a></div>
</div>
</div>