pynenc.trigger.conditions.result¶
Result-based trigger conditions for task execution.
This module defines conditions based on the result of a task, enabling triggers when a task produces specific result values.
Module Contents¶
Classes¶
Context for result-based conditions. |
|
Condition based on the result of a task. |
API¶
- class pynenc.trigger.conditions.result.ResultContext[source]¶
Bases:
pynenc.trigger.conditions.status.StatusContextContext for result-based conditions.
This context holds the data required to evaluate conditions based on the result of a task. It extends StatusContext to add result information.
- __post_init__() None[source]¶
Validate the context after initialization. Ensures that the status is final
- _to_json(app: pynenc.app.Pynenc) dict[str, Any][source]¶
Create a serializable representation of this result context.
- Parameters:
app – Pynenc application instance
- Returns:
Dictionary with serialized context data
- classmethod _from_json(data: dict[str, Any], app: pynenc.app.Pynenc) pynenc.trigger.conditions.result.ResultContext[source]¶
Create a ResultContext from parsed JSON data.
- Parameters:
data – Dictionary with context data
app – Pynenc application instance
- Returns:
A new ResultContext instance
- class pynenc.trigger.conditions.result.ResultCondition(task_id: str, arguments_filter: pynenc.trigger.arguments.ArgumentFilter, result_filter: pynenc.trigger.arguments.result_filter.ResultFilterProtocol)[source]¶
Bases:
pynenc.trigger.conditions.base.TriggerCondition[pynenc.trigger.conditions.result.ResultContext]Condition based on the result of a task.
Triggers a task when another task produces a specific result. This can filter based on both:
The task call arguments (to match specific task invocations)
The result value (to trigger based on specific result values)
This implementation composes with StatusCondition to reuse its functionality while maintaining proper typing.
Initialization
Create a result condition.
- Parameters:
task_id – ID of the task to monitor
arguments_filter – Filter for task call arguments
result_filter – Filter to apply to the result
- context_type: ClassVar[type[pynenc.trigger.conditions.result.ResultContext]]¶
None
- property arguments_filter: pynenc.trigger.arguments.ArgumentFilter¶
Get the arguments filter for this condition.
- Returns:
The arguments filter
- property statuses: list[pynenc.invocation.status.InvocationStatus]¶
Get the statuses that this condition triggers on.
For result conditions, this is always [InvocationStatus.SUCCESS]
- Returns:
List of statuses
- property condition_id: str¶
Generate a unique ID for this result condition.
- Returns:
A string ID based on the task ID, arguments, and result filter
- _to_json(app: pynenc.app.Pynenc) dict[str, Any][source]¶
Create a serializable representation of this condition.
- Parameters:
app – Pynenc application instance for serializing complex arguments
- Returns:
Dictionary with serialized condition data
- classmethod _from_json(data: dict[str, Any], app: pynenc.app.Pynenc) pynenc.trigger.conditions.result.ResultCondition[source]¶
Create a ResultCondition from parsed JSON data.
- Parameters:
data – Dictionary with condition data
app – Pynenc application instance for deserializing complex arguments
- Returns:
A new ResultCondition instance
- Raises:
ValueError – If the data is invalid for this condition type
- _is_satisfied_by(context: pynenc.trigger.conditions.result.ResultContext) bool[source]¶
Check if a task result satisfies this condition.
- Parameters:
context – Result context with result data
- Returns:
True if the task status condition is satisfied and result passes the filter