Plugin Development¶
Build custom plugins for Niamoto without patching the core runtime.
Plugin Types¶
Type |
Register with |
Where Niamoto uses it |
What it does |
|---|---|---|---|
Loader |
|
|
Fetch rows before a transform runs |
Transformer |
|
|
Compute derived data |
Widget |
|
|
Render HTML for exported pages |
Exporter |
|
|
Generate files or sites |
Deployer |
|
|
Publish generated exports |
Start Here¶
architecture.md explains registry, loading, and config surfaces.
creating-transformers.md shows how to write a transformer and validate its config.
building-widgets.md covers widget params, rendering, and
export.yml.custom-exporters.md covers exporter params, target configs, and output generation.
database-aggregator-guide.md documents the SQL-based transformer that ships with Niamoto.
Minimal Transformer¶
from typing import Any, Dict, Literal
import pandas as pd
from pydantic import Field
from niamoto.core.plugins.base import PluginType, TransformerPlugin, register
from niamoto.core.plugins.models import BasePluginParams, PluginConfig
class MeanDbhParams(BasePluginParams):
field: str = Field(default="dbh")
class MeanDbhConfig(PluginConfig):
plugin: Literal["mean_dbh"] = "mean_dbh"
params: MeanDbhParams
@register("mean_dbh", PluginType.TRANSFORMER)
class MeanDbhTransformer(TransformerPlugin):
config_model = MeanDbhConfig
param_schema = MeanDbhParams
def transform(self, data: pd.DataFrame, config: Dict[str, Any]) -> Dict[str, float]:
validated = self.config_model(**config)
params = validated.params
return {"mean_dbh": float(data[params.field].dropna().mean())}
Workflow¶
Pick the plugin type.
Define a params model with
BasePluginParams.Define a config model that wraps
pluginandparams.Register the class with
@register("name", PluginType.X).Wire it into
transform.yml,export.yml, ordeploy.yml.Add tests under the matching tree in
tests/core/plugins/.
Test Locations¶
Transformers:
tests/core/plugins/transformers/Widgets:
tests/core/plugins/widgets/Exporters:
tests/core/plugins/exporters/Loaders:
tests/core/plugins/loaders/Deployers:
tests/core/plugins/deployers/