datasource_XXX.py
file under system/plugin
, where XXX
is the name of the datasource.DataSource_XXX
from DataSource
in datasource.py
.__init__()
get_channels()
get_timeseries()
get_object()
get_blob()
(usually empty)get_dataframe()
(optional)Datasource
class provides methods that can be used by plugin:
resample()
The minimal / empty class will be:
from datasource import DataSource
class Datasource_XXX(Datasource):
def __init__(self, project_config, config):
super.__init__(project_config, config)
def get_channels(self):
return []
def get_timeseries(self, channels, length, to, resampling=None, reducer='last'):
return {}
def get_object(self, channels, length, to):
return {}
def get_blob(self, channel, params, output):
return None
__init___
get_channels()
[ {"name": NAME, "type": TYPE, ...}, ... ]
type
is one of: timeseries
, histogram
, table
, and tree
get_timeseries()
def get_timeseries(self, channels, length, to, resampling=None, reducer='last'):
result = {}
...
return result
DataModel.md
documentresampling
is not None, apply resampling.
resampling <= 0
, just align data points among channels with inferring the intervals from data.reducer
can be:
first
: value of the first non-NaN data pointlast
: value of the last non-NaN data pointmean
: mean of non-NaN data point valuesmedian
: median of non-NaN data point valuessum
: sum of non-NaN data point valuescount
: number of non-NaN data point valuesstd
: standard deviation of non-NaN data point valuesmin
: minimum data point valuemax
: maximum data point valueself.resample()
.get_object()
DataModel.md
documentget_blob()
get_dataframe()
def get_dataframe(self, channels, length, to, resampling=None, reducer='last', timezone='local'):
result = []
...
return result
get_timeseries()
The JSON format is
where RAW[k]
is:
resample()
This will be used in user’s get_timeseries()
, if the data source does not efficiently support resampling, typically like: