Value sharing
Info
Needs arta>=0.10.0.
Between conditions and actions
It is possible to share some informations between condition and action implementations.
It can be usefull when an action needs some data that was computed in a condition (e.g., sanity check use cases).
In the following example, a condition is computing the median of some input values and checking it. Then, the action retrieves this median value and uses it.
Two things have to be done for that:
- Add the
**kwargsparameter in your functions' definition (validation and action functions) if not already there. - Set some new subkeys in the
input_datakey.
Set the value (in a condition for example):
- Add the **kwargs parameter.
- Set your value in the
input_data.
Get the value (in an action for example):
- Add the **kwargs parameter.
- Get the value.
User extra arguments
The following code shows how to set custom user extra arguments (e.g., add_details) within the .apply_rules() method:
Used inside action and/or condition functions:
- Don't forget to add the **kwargs parameter.
- Straight use of the corresponding extra argument.