class maze.core.log_stats.event_decorators.define_step_stats(reduce_function: Optional[Callable], input_name: Optional[str] = None, output_name: Optional[str] = None, group_by: Optional[str] = None, cumulative: bool = False)

Event method decorator, defines a new step statistics calculation for this event.


all events in a single step (and side-loaded step statistics, see ‘reduce_function’ set to None)


step statistics

  • reduce_function – A function that takes a list of values and returns the calculated statistics. In the special case that we do not want to calculate the statistics from events, but have the statistics result already available for the current step, the reduce_function can be set to None. Then the event can be invoked at most once per step to side-load the result. This is very useful to log state information, e.g. the inventory size.

  • input_name

    The name of the event attribute (=keyword attribute), whose values are to be passed to the reduce function. Can be omitted, for which there are two reasons

    • no naming necessary, there is only a single event attribute

    • we want all event attributes to be passed to the reduce_function as dictionaries (or our reduce function does not care, e.g. counting the number of events with len)

  • output_name – The name of the statistics, how it should be passed to the logger resp. the following aggregation stage. Will be the same as input_name if None is provided.

  • group_by – If there are multiple groups defined for an event, per default the statistics is collected at the ‘cell’ level. This option allows to project the statistics onto a single group (e.g. for inventory statistics we might define location and product as groups, but prefer to monitor statistics grouped only per product, regardless of location and vice versa)

  • cumulative – Enable cumulative statistics


The decorator function