Forwarders#

Objects to be optionally provided to gordo_client.client.Client which forwards the resulting predictions.

class gordo_client.forwarders.ForwardPredictionsIntoInflux(destination_influx_uri: str | None = None, destination_influx_api_key: str | None = None, destination_influx_recreate: bool = False, n_retries=5)#

Bases: PredictionForwarder

To be used as a ‘forwarder’ for the prediction client

After instantiation, it is a coroutine which accepts prediction dataframes which it will pass onto Influx

Create an instance which, when called, is a coroutine capable of being sent dataframes generated from the ‘/anomaly/prediction’ machine

Parameters:
  • destination_influx_uri – Connection string for destination influx - format: <username>:<password>@<host>:<port>/<optional-path>/<db_name>

  • destination_influx_api_key – API key if needed for destination db

  • destination_influx_recreate – Drop the database before filling it with data?

forward_predictions(predictions: DataFrame, machine: Machine, metadata: dict = {})#

Takes a multi-layed column dataframe and write points to Influx where each top level name is treated as the measurement name.

How the data is written via InfluxDB DataFrameClient in this method determines the schema of the database.

Parameters:

predictions – Multi layed column dataframe, where top level names will be treated as the ‘measurement’ name in influx and 2nd level will be the fields under those measurements.

send_sensor_data(sensors: DataFrame)#

Write sensor-data to Influx

class gordo_client.forwarders.PredictionForwarder#

Bases: object

Definition of a callable which the gordo_client.client.Client will call after each successful prediction response.

def my_forwarder(
    predictions: pd.DataFrame = None,
    machine: Machine = None,
    metadata: dict = dict(),
    resampled_sensor_data: pd.DataFrame = None
):
    ...