forked from docs/doc-exports
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>
94 lines
9.3 KiB
HTML
94 lines
9.3 KiB
HTML
<a name="modelarts_04_0220"></a><a name="modelarts_04_0220"></a>
|
|
|
|
<h1 class="topictitle1">Downloading a File from OBS</h1>
|
|
<div id="body8662426"><div class="note" id="modelarts_04_0220__en-us_topic_0220956297_note1030220262196"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="modelarts_04_0220__en-us_topic_0220956297_p11302192619194">If the size of a file in a folder exceeds 5 GB, the file cannot be downloaded in this mode.</p>
|
|
</div></div>
|
|
<div class="section" id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_section20261580353"><h4 class="sectiontitle">Sample Code</h4><p id="modelarts_04_0220__en-us_topic_0220956297_p16518162411313">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_0220__en-us_topic_0220956297_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_file</span><span class="p">(</span><span class="n">src_obs_file</span><span class="o">=</span><span class="s2">"obs://bucket-name/dir1/file1.txt"</span><span class="p">,</span> <span class="n">dst_local_dir</span><span class="o">=</span><span class="s2">"/home/ma-user/"</span><span class="p">)</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<p id="modelarts_04_0220__en-us_topic_0220956297_p93231521161819">After the sample code is executed, source file <span class="filepath" id="modelarts_04_0220__en-us_topic_0220956297_filepath9109153515244"><b>file1.txt</b></span> is downloaded from OBS to <span class="filepath" id="modelarts_04_0220__en-us_topic_0220956297_filepath79739217253"><b>/home/ma-user/file1.txt</b></span>.</p>
|
|
<div class="section" id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_section78291820269"><h4 class="sectiontitle">Parameter Description</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="modelarts_04_0220__en-us_topic_0220956297_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_0220__en-us_topic_0220956297_en-us_topic_0173848863_row254817912212"><th align="left" class="cellrowborder" valign="top" width="20.75%" id="mcps1.3.4.2.2.5.1.1"><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p12549899214">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="11.99%" id="mcps1.3.4.2.2.5.1.2"><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p3552101193813">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="13.320000000000002%" id="mcps1.3.4.2.2.5.1.3"><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p1755169172118">Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="53.94%" id="mcps1.3.4.2.2.5.1.4"><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p55521998211">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_row8893215413"><td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.2.2.5.1.1 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p6891421842">session</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.99%" headers="mcps1.3.4.2.2.5.1.2 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p68972047">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.320000000000002%" headers="mcps1.3.4.2.2.5.1.3 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p158912219419">Object</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.3.4.2.2.5.1.4 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p1689152543">Session object</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_row1530181931"><td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.2.2.5.1.1 "><p id="modelarts_04_0220__en-us_topic_0220956297_p1315881682013">src_obs_file</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.99%" headers="mcps1.3.4.2.2.5.1.2 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p6675978319">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.320000000000002%" headers="mcps1.3.4.2.2.5.1.3 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p46751171339">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.3.4.2.2.5.1.4 "><p id="modelarts_04_0220__en-us_topic_0220956297_p19233184612200">Path to the source file to be downloaded from OBS. The path must start with <span class="filepath" id="modelarts_04_0220__en-us_topic_0220956297_filepath416152032116"><b>obs://</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_row167932713277"><td class="cellrowborder" valign="top" width="20.75%" headers="mcps1.3.4.2.2.5.1.1 "><p id="modelarts_04_0220__en-us_topic_0220956297_p36098872111">dst_local_dir</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.99%" headers="mcps1.3.4.2.2.5.1.2 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p77948710279">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="13.320000000000002%" headers="mcps1.3.4.2.2.5.1.3 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p3794167192716">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="53.94%" headers="mcps1.3.4.2.2.5.1.4 "><p id="modelarts_04_0220__en-us_topic_0220956297_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_0220__en-us_topic_0220956297_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_0220__en-us_topic_0220956297_en-us_topic_0173848863_row40618446173927"><th align="left" class="cellrowborder" valign="top" width="25.490000000000002%" id="mcps1.3.5.2.4.1.1"><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p1631242217407">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="23.72%" id="mcps1.3.5.2.4.1.2"><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p5427574117407">Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="50.79%" id="mcps1.3.5.2.4.1.3"><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p12364118914">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_row11062410173927"><td class="cellrowborder" valign="top" width="25.490000000000002%" headers="mcps1.3.5.2.4.1.1 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p688954611624">error_code</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23.72%" headers="mcps1.3.5.2.4.1.2 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p3804851211624">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50.79%" headers="mcps1.3.5.2.4.1.3 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p156551524172412">Error code when the API call fails.</p>
|
|
<p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p6203060911624">This parameter is not included when the API call succeeds.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_row52351653173927"><td class="cellrowborder" valign="top" width="25.490000000000002%" headers="mcps1.3.5.2.4.1.1 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p4368550411624">error_msg</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="23.72%" headers="mcps1.3.5.2.4.1.2 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p6574380911624">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="50.79%" headers="mcps1.3.5.2.4.1.3 "><p id="modelarts_04_0220__en-us_topic_0220956297_en-us_topic_0173848863_p1277593619">Error message when the API call fails.</p>
|
|
<p id="modelarts_04_0220__en-us_topic_0220956297_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>
|
|
|