pynenc.trigger.arguments.result_filter¶
Result filters for trigger-based task executions.
This module defines filters for task results that leverage the existing argument filtering infrastructure. These filters determine if task results match certain criteria by adapting them to the argument filter format.
Module Contents¶
Classes¶
Protocol defining the interface for result filters. |
|
This will disable result filtering. |
|
Filters task results based on exact matching with an expected value. |
|
Filters task results using a custom callable function. |
Functions¶
Factory function to create the appropriate result filter based on the input type. |
API¶
- class pynenc.trigger.arguments.result_filter.ResultFilterProtocol[source]¶
Bases:
typing.ProtocolProtocol defining the interface for result filters.
This protocol specifies the required methods that any result filter must implement, regardless of class hierarchy.
- filter_id() str¶
Generate a unique ID for this argument filter.
The ID is based on the ID of the callable filter.
- to_json(app: pynenc.app.Pynenc) str[source]¶
Serialize this argument filter to a JSON string.
- Parameters:
app – Pynenc application instance for serializing complex arguments
- Returns:
JSON string representation of this argument filter
- class pynenc.trigger.arguments.result_filter.NoResultFilter[source]¶
Bases:
pynenc.trigger.arguments.argument_filters.ArgumentFilterThis will disable result filtering.
- classmethod _from_json(data: dict[str, Any], app: pynenc.app.Pynenc) pynenc.trigger.arguments.result_filter.NoResultFilter[source]¶
- class pynenc.trigger.arguments.result_filter.StaticResultFilter(expected_result: Any)[source]¶
Bases:
pynenc.trigger.arguments.argument_filters.StaticArgumentFilterFilters task results based on exact matching with an expected value.
This filter adapts the StaticArgumentFilter to work with result values.
Initialization
Initialize with an expected result value.
- Parameters:
expected_result – Result value that task results must match
- classmethod _from_json(data: dict[str, Any], app: pynenc.app.Pynenc) pynenc.trigger.arguments.result_filter.StaticResultFilter[source]¶
Create a StaticResultFilter from parsed JSON data.
- Parameters:
data – Dictionary with filter data
app – Pynenc application instance for deserializing complex arguments
- Returns:
A new StaticResultFilter instance
- class pynenc.trigger.arguments.result_filter.CallableResultFilter(callable_filter: Callable[[Any], bool] | pynenc.trigger.arguments.arguments_common.SerializableCallable)[source]¶
Bases:
pynenc.trigger.arguments.argument_filters.CallableArgumentFilterFilters task results using a custom callable function.
This filter adapts the CallableArgumentFilter to work with result values.
Initialization
Initialize with a callable filter for results.
- Parameters:
callable_filter – Function that takes a result and returns a boolean
- pynenc.trigger.arguments.result_filter.create_result_filter(filter_spec: Any | Callable[[Any], bool]) pynenc.trigger.arguments.result_filter.ResultFilterProtocol[source]¶
Factory function to create the appropriate result filter based on the input type.
- Parameters:
filter_spec – Either an expected result value or a callable function
- Returns:
An instance of ArgumentFilter