You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.7 KiB
HTML
80 lines
2.7 KiB
HTML
<style>
|
|
.double-page {
|
|
display:grid;
|
|
grid-template-columns: 49% 1% 49%;
|
|
gap:8px;
|
|
}
|
|
</style>
|
|
<script>
|
|
$(document).ready(()=>{
|
|
_layout = {on:{load:{'visit-us':['www/html/visit-us.html']}}}
|
|
bootup.init('',_layout)
|
|
})
|
|
</script>
|
|
<div>
|
|
<div class="large-text">Plugins</div>
|
|
Plugins are native python functions, that are integrated into <b>{{layout.header.title}}</b> and called as pre/post processing.
|
|
|
|
<div class="source-code">
|
|
$ transport plugins --help
|
|
</div>
|
|
<div class="double-page">
|
|
<div>
|
|
<b>0. Write a plugin function with a decorator</b>
|
|
<p>
|
|
Plugins are native python functions, that take in a single parameter. The following example should be save in a file <b>my-plugin.py</b>
|
|
</p>
|
|
<div class="source-code">
|
|
<b>import</b> transport
|
|
<br><b>import</b> numpy <b>as</b> np
|
|
|
|
<br>_index = 0
|
|
<br><b>@</b>transport.Plugin(name='autoincrement')
|
|
<br><b>def</b> _incr (_data):
|
|
<div style="margin-left:16px">
|
|
global _index
|
|
<br>_data['_id'] = _index + np.arange(_data.shape[0])
|
|
<br>_index = _data.shape[0]
|
|
<br><b>return</b> _data
|
|
</div>
|
|
</div>
|
|
|
|
<div style="border-top:4px dotted #CAD5E0; margin:8px;"></div>
|
|
<b>1. Register & test the plugin</b>
|
|
<p>
|
|
The plugin utility will make a copy of the file and allow it to be reused against any supported database techology.
|
|
More information is available when running
|
|
|
|
</p>
|
|
<div class="source-code">
|
|
$ transport plugins add myplugin my-plugin.py
|
|
</div>
|
|
<p>
|
|
Once registered it is important to see if the function can be tested
|
|
</p>
|
|
<div class="source-code">$ plugin-ix registry list --folder ~/.data-transport</div>
|
|
</div>
|
|
<div style="border-left:4px dotted #cad4e0"></div>
|
|
<div>
|
|
<b>Using our first plugin</b>
|
|
<p>
|
|
Plugins are used as pipelines i.e you can add more than one and they will execute accordingly in the order in which they are expressed.
|
|
</p>
|
|
|
|
<div class="source-code">
|
|
<b>import</b> transport
|
|
<br>
|
|
<br>dbreader = transport.get.reader(label="address-db",plugins=["_incr@myplugin"])
|
|
<br>_df = dbreader.read()
|
|
</div>
|
|
<br>
|
|
The code above shows how a simple plugin function can be applied to a data
|
|
|
|
<br><i class="fa-solid fa-minus"></i> address-db, is the database label that points to the url with data
|
|
<br><i class="fa-solid fa-minus"></i> myplugin, points to a copy of "incr" in "my-plugin.py"
|
|
<p>
|
|
<div id="visit-us"></div>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div> |