Here we describe the Rubrix listeners capabilities

class rubrix.listeners.Metrics(*args, **kwargs)#

Metrics results for a single listener execution.

The metrics object exposes the metrics configured for the listener as property values. For example, if you define a listener including the metric β€œF1”, the results will be accessible as metrics.F1

class rubrix.listeners.RBDatasetListener(dataset, action, metrics=None, query=None, query_params=None, condition=None, query_records=True, interval_in_seconds=30)#

The Rubrix dataset listener class

Return type


property formatted_query: Optional[str]#

Formatted query using defined query params, if any


True if listener is running

start(*action_args, **action_kwargs)#

Start listen to changes in the dataset. Additionally, args and kwargs can be passed to action by using the action_* arguments

If the listener is already started, a ValueError will be raised


Stops listener if it’s still running.

If listener is already stopped, a ValueError will be raised

class rubrix.listeners.RBListenerContext(listener, search=None, metrics=None, query_params=None)#

The Rubrix listener execution context. This class keeps the context components related to a listener

Return type


property dataset: str#

Computed property that returns the configured listener dataset name

property query: Optional[str]#

Computed property that returns the configured listener query string

class rubrix.listeners.Search(total, query_params=None)#

Search results for a single listener execution

  • total (int) – The total number of records affected by the listener query

  • query_params (Optional[Dict[str, Any]]) – The query parameters applied to the executed search

Return type


rubrix.listeners.listener(dataset, query=None, metrics=None, condition=None, with_records=True, execution_interval_in_seconds=30, **query_params)#

Configures the decorated function as a Rubrix listener.

  • dataset (str) – The dataset name.

  • query (Optional[str]) – The query string.

  • metrics (Optional[List[str]]) – Required metrics for listener condition.

  • condition (Optional[Callable[[rubrix.listeners.models.Search, Optional[rubrix.listeners.models.RBListenerContext]], bool]]) – Defines condition over search and metrics that launch action when is satisfied.

  • with_records (bool) – Include records as part or action arguments. If False, only the listener context RBListenerContext will be passed. Default: True.

  • execution_interval_in_seconds (int) – Define the execution interval in seconds when listener iteration will be executed.

  • **query_params – Dynamic parameters used in the query. These parameters will be available via the listener context and can be updated for subsequent queries.