doc-exports/docs/fg/umn/functiongraph_01_2102.html
Chen, Junjie dac566cf2f FG UMN 20230725 version
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: Chen, Junjie <chenjunjie@huawei.com>
Co-committed-by: Chen, Junjie <chenjunjie@huawei.com>
2024-04-03 10:30:56 +00:00

156 lines
19 KiB
HTML

<a name="functiongraph_01_2102"></a><a name="functiongraph_01_2102"></a>
<h1 class="topictitle1">Dependent Libraries</h1>
<div id="body32001227"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p7451785119"><strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b11244648101911">Supported Dependent Libraries</strong></p>
<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1177517243919">FunctionGraph supports both standard and third-party libraries.</p>
<ul id="functiongraph_01_2102__en-us_topic_0000001532946444_ul43795614143652"><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li3549028143652">Standard libraries<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p17781284144455"><a name="functiongraph_01_2102__en-us_topic_0000001532946444_li3549028143652"></a><a name="en-us_topic_0000001532946444_li3549028143652"></a>When using standard libraries, you can import them to your inline code or package and upload them to FunctionGraph.</p>
</li><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li37689144451">Supported non-standard libraries<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p35942680143727"><a name="functiongraph_01_2102__en-us_topic_0000001532946444_li37689144451"></a><a name="en-us_topic_0000001532946444_li37689144451"></a>FunctionGraph provides built-in third-party components listed in <a href="#functiongraph_01_2102__en-us_topic_0000001532946444_table143351951242">Table 1</a> and <a href="#functiongraph_01_2102__en-us_topic_0000001532946444_table39721459145614">Table 2</a>. You can import these libraries to your inline code in the same way as you import standard libraries.</p>
<div class="tablenoborder"><a name="functiongraph_01_2102__en-us_topic_0000001532946444_table143351951242"></a><a name="en-us_topic_0000001532946444_table143351951242"></a><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_01_2102__en-us_topic_0000001532946444_table143351951242" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Third-party components integrated with the Node.js runtime</caption><thead align="left"><tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row15336557411"><th align="left" class="cellrowborder" valign="top" width="28.532853285328528%" id="mcps1.3.3.2.2.2.4.1.1"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1033655643">Name</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="38.133813381338136%" id="mcps1.3.3.2.2.2.4.1.2"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p233635143">Usage</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.3.2.2.2.4.1.3"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1733612515413">Version</p>
</th>
</tr>
</thead>
<tbody><tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row113361153412"><td class="cellrowborder" valign="top" width="28.532853285328528%" headers="mcps1.3.3.2.2.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1336195243">q</p>
</td>
<td class="cellrowborder" valign="top" width="38.133813381338136%" headers="mcps1.3.3.2.2.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p12336151410">Asynchronous method encapsulation</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.2.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p18336851148">1.5.1</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row33369511419"><td class="cellrowborder" valign="top" width="28.532853285328528%" headers="mcps1.3.3.2.2.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p123366511415">co</p>
</td>
<td class="cellrowborder" valign="top" width="38.133813381338136%" headers="mcps1.3.3.2.2.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p17336751942">Asynchronous process control</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.2.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p173361651142">4.6.0</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row103361751945"><td class="cellrowborder" valign="top" width="28.532853285328528%" headers="mcps1.3.3.2.2.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p833614510419">lodash</p>
</td>
<td class="cellrowborder" valign="top" width="38.133813381338136%" headers="mcps1.3.3.2.2.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1633611514410">Common tool and method library</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.2.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p14336457412">4.17.10</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row10336550412"><td class="cellrowborder" valign="top" width="28.532853285328528%" headers="mcps1.3.3.2.2.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p93361251844">esdk-obs-nodejs</p>
</td>
<td class="cellrowborder" valign="top" width="38.133813381338136%" headers="mcps1.3.3.2.2.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p143361453415">OBS sdk</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.2.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p203383519412">2.1.5</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row99017489112"><td class="cellrowborder" valign="top" width="28.532853285328528%" headers="mcps1.3.3.2.2.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p441934817265">express</p>
</td>
<td class="cellrowborder" valign="top" width="38.133813381338136%" headers="mcps1.3.3.2.2.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1141984892615">Simplified web-based application development framework</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.2.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1341974802613">4.16.4</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row6439151514"><td class="cellrowborder" valign="top" width="28.532853285328528%" headers="mcps1.3.3.2.2.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p5572124552610">fgs-express</p>
</td>
<td class="cellrowborder" valign="top" width="38.133813381338136%" headers="mcps1.3.3.2.2.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p17572104515268">Provides a Node.js application framework for FunctionGraph and APIG to run serverless applications and REST APIs. This component provides an example of using the Express framework to build serverless web applications or services and RESTful APIs.</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.2.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p357334510265">1.0.1</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row74216551117"><td class="cellrowborder" valign="top" width="28.532853285328528%" headers="mcps1.3.3.2.2.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p194242051192617">request</p>
</td>
<td class="cellrowborder" valign="top" width="38.133813381338136%" headers="mcps1.3.3.2.2.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p0424195115262">Simplifies HTTP invocation and supports HTTPS and redirection.</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.2.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1942410516269">2.88.0</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablenoborder"><a name="functiongraph_01_2102__en-us_topic_0000001532946444_table39721459145614"></a><a name="en-us_topic_0000001532946444_table39721459145614"></a><table cellpadding="4" cellspacing="0" summary="" id="functiongraph_01_2102__en-us_topic_0000001532946444_table39721459145614" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Non-standard libraries supported by the Python runtime</caption><thead align="left"><tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row38504252145614"><th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.3.2.3.2.4.1.1"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p18095115145614">Module</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.3.2.3.2.4.1.2"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p56418216145614">Usage</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.3.3.2.3.2.4.1.3"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p6472802145614">Version</p>
</th>
</tr>
</thead>
<tbody><tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row27527076145614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p61556839145835">dateutil</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p20048058145835">Date and time processing</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p13280010145835">2.6.0</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row31269908145614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p20787913145835">requests</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p6099393145835">HTTP library</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p21238847145835">2.7.0</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row49919776145614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p2253865145835">httplib2</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p48345381145835">httpclient</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p23661785145835">0.10.3</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row62147669142314"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p37098266142327">numpy</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p12907260142336">Mathematical computing</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p1917910376333">For pip 2.7, numpy==1.16.6.</p>
<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p9179737133314">For pip 3.10, numpy==1.24.2.</p>
<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p2179337163314">For pip 3.9, numpy==1.18.5.</p>
<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p6179163718335">For pip 3.6, numpy==1.18.5.</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row14959080145614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p56491286145835">redis</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p12391471145835">Redis client</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p31607657145835">2.10.5</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row51131826145614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p35946515145835">obsclient</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p25986613145835">OBS client</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p41658471145835">-</p>
</td>
</tr>
<tr id="functiongraph_01_2102__en-us_topic_0000001532946444_row67511052536"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.1 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p20456111512267">smnsdk</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.2 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p14527042152416">SMN access</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.3.3.2.3.2.4.1.3 "><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p5530154219246">1.0.1</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
<ul id="functiongraph_01_2102__en-us_topic_0000001532946444_ul2307043014379"><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li3961345914379">Other third-party libraries (FunctionGraph has no built-in non-standard third-party libraries except those listed in the preceding table.)<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p13086888114225"><a name="functiongraph_01_2102__en-us_topic_0000001532946444_li3961345914379"></a><a name="en-us_topic_0000001532946444_li3961345914379"></a>Package the dependency third-party libraries and upload them to an OBS bucket or on the function details page. These libraries will then be used in your function code.</p>
</li></ul>
<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p393213242212"><strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b723511171243">Importing Dependent Libraries</strong></p>
<div class="p" id="functiongraph_01_2102__en-us_topic_0000001532946444_p206691338191819">Importing a dependency for Python:<pre class="screen" id="functiongraph_01_2102__en-us_topic_0000001532946444_screen205015413221">from com.obs.client.obs_client import ObsClient</pre>
</div>
<div class="p" id="functiongraph_01_2102__en-us_topic_0000001532946444_p13618243227">Importing a dependency for Node.js:<pre class="screen" id="functiongraph_01_2102__en-us_topic_0000001532946444_screen8408344142214">const ObsClient = require('esdk-obs-nodejs');</pre>
</div>
<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p155532035181117">For standard libraries and supported non-standard libraries, you can directly use them in your function.</p>
<p id="functiongraph_01_2102__en-us_topic_0000001532946444_p5035394015262">For non-standard third-party libraries that are not provided by FunctionGraph, you can use them by performing the following steps:</p>
<ol id="functiongraph_01_2102__en-us_topic_0000001532946444_ol61614926152816"><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li23043309152816">Package the dependent libraries into a ZIP file, upload the ZIP file to an OBS bucket, and obtain the OBS link URL.</li><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li188213716122">Log in to the FunctionGraph console, and choose <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b9963412112914">Functions</strong> &gt; <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b189648126293">Dependencies</strong> in the navigation pane.</li><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li3154182116499">Click <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b9317515122911">Create Dependency</strong>.</li><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li224619133510"><a name="functiongraph_01_2102__en-us_topic_0000001532946444_li224619133510"></a><a name="en-us_topic_0000001532946444_li224619133510"></a>Set the dependency name and runtime, specify the OBS link URL, and click <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b19348417112916">OK</strong>.<div class="fignone" id="functiongraph_01_2102__en-us_topic_0000001532946444_fig5180350115015"><span class="figcap"><b>Figure 1 </b>Setting the dependency</span><br><span><img id="functiongraph_01_2102__en-us_topic_0000001532946444_image1818085095019" src="en-us_image_0000001757397373.png"></span></div>
</li><li id="functiongraph_01_2102__en-us_topic_0000001532946444_li22911748194019">On the function details page, click the <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b9540162415306">Code</strong> tab, click <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b75418240305">Add</strong> in the <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b4541122453018">Dependencies</strong> area, select the dependency created in <a href="#functiongraph_01_2102__en-us_topic_0000001532946444_li224619133510">4</a>, and click <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b8541172415303">OK</strong>.<div class="fignone" id="functiongraph_01_2102__en-us_topic_0000001532946444_fig201992211570"><span class="figcap"><b>Figure 2 </b>Selecting a dependency</span><br><span><img id="functiongraph_01_2102__en-us_topic_0000001532946444_image161962215716" src="en-us_image_0000001709398390.png"></span></div>
<div class="p" id="functiongraph_01_2102__en-us_topic_0000001532946444_p20291164812409"><div class="warning" id="functiongraph_01_2102__en-us_topic_0000001532946444_note915121316348"><span class="warningtitle"><img src="public_sys-resources/warning_3.0-en-us.png"> </span><div class="warningbody"><p id="functiongraph_01_2102__en-us_topic_0000001532946444_p7151513113420">Each dependency package cannot contain a file with the same name as a code file. Otherwise, the two files may be incorrectly merged or overwritten. For example, if dependency package <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b7448161816324">depends.zip</strong> contains a file named <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b544817188325">index.py</strong>, the handler of a function cannot be set to <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b344821810328">index.handler</strong>. Otherwise, a code file also named <strong id="functiongraph_01_2102__en-us_topic_0000001532946444_b164493185324">index.py</strong> will be generated.</p>
</div></div>
</div>
</li></ol>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_01_0391.html">Dependency Management</a></div>
</div>
</div>