flexmeasures icon indicating copy to clipboard operation
flexmeasures copied to clipboard

Reporting backend infrastructure

Open nhoening opened this issue 1 year ago • 0 comments

We want to be able to automatically produce data derived from existing data, for reporting. An example are KPIs, but often it's data which is used to better explain to users what happened in the past. These reports should be triggerable by a CLI command, so we can periodically create and persist reporting data.

Work on this issue will add the CLI command and four generic report functions will be added, which can build many straightforward formulas.

Furthermore, we can lay the foundation for a function store for FlexMeausures and plugins to use.

Outcomes:

  • A new CLI command to run an existing report function: `flexmeasures add report --name [--input-sensors <Union[List[int], Dict[str, int]]] --output-sensor [--preferred-unit ] [--last-hour ] [--yesterday ] [last-week ] [last-month ] Note: Many arguments are optional, because (a) only one time range identifier is needed and (b) custom reports will often decide sensor and units themselves.
  • A function store for reporting functions, which we'll keep in app.config["func_store"]["reports"]. Functions are loaded with the util logic we've just developed for #9. Also provide a utility function register_function_in_store(app: Flask, name: str, func: Callable, store: str).
  • Four simple implementations, inspired by earlier work we did in our E-mission plugin. These are registered when FlexMeasures starts up. One is add_andor_multiply (from E-mission), the others add_andor_divide, subtract_andor_multiply and subtract_andor_divide.
  • Documentation for plugins how they can add their own reporting functions (by writing a function adhering to the signature we impose and adding it to __functions__.py) under REPORTS, a list (we could also enable to use SCHEDULERS, actually, a dict).

Potentially we can keep the function store out of this, but it might be necessary in #9 anyways.

nhoening avatar Sep 29 '22 15:09 nhoening