Listeners#
Here we describe the Argilla listeners capabilities:
- class argilla.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 argilla.listeners.RGDatasetListener(dataset: str, action: Union[Callable[[List[Union[TextClassificationRecord, TokenClassificationRecord, Text2TextRecord, TextGenerationRecord]], RGListenerContext], bool], Callable[[RGListenerContext], bool]], metrics: Optional[List[str]] = None, query: Optional[str] = None, query_params: Optional[Dict[str, Any]] = None, condition: Optional[Callable[[Search, Optional[RGListenerContext]], bool]] = None, query_records: bool = True, interval_in_seconds: int = 30)#
The argilla dataset listener class
- Parameters:
dataset โ The dataset over which listener is created
action โ The action to execute when the condition is satisfied
metrics โ A list of metrics ids that will be required in condition
query โ The query string to apply
query_params โ Defined parameters used dynamically in the provided query
condition โ The condition to satisfy to execute the action
query_records โ If
False
, the records wonโt be passed as argument to the action. Default:True
interval_in_seconds โ How often the listener is executed. Default to 30 seconds
- property formatted_query: Optional[str]#
Formatted query using defined query params, if any
- is_running()#
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
- stop()#
Stops listener if itโs still running.
If listener is already stopped, a
ValueError
will be raised
- class argilla.listeners.RGListenerContext(listener: RGDatasetListener, search: Optional[Search] = None, metrics: Optional[Metrics] = None, query_params: Optional[Dict[str, Any]] = None)#
The argilla listener execution context. This class keeps the context components related to a listener
- Parameters:
listener โ The argilla listener instance
search โ Search results for current execution
metrics โ Metrics results for current execution
query_params โ Dynamic parameters used in the listener query
- 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 argilla.listeners.Search(total: int, query_params: Optional[Dict[str, Any]] = None)#
Search results for a single listener execution
- Parameters:
total โ The total number of records affected by the listener query
query_params โ The query parameters applied to the executed search
- argilla.listeners.listener(dataset: str, query: Optional[str] = None, metrics: Optional[List[str]] = None, condition: Optional[Callable[[Search, Optional[RGListenerContext]], bool]] = None, with_records: bool = True, execution_interval_in_seconds: int = 30, **query_params)#
Configures the decorated function as an argilla listener.
- Parameters:
dataset โ The dataset name.
query โ The query string.
metrics โ Required metrics for listener condition.
condition โ Defines condition over search and metrics that launch action when is satisfied.
with_records โ Include records as part of action arguments. If
False
, only the listener contextRGListenerContext
will be passed. Default:True
.execution_interval_in_seconds โ 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.