We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Answer is definitely "yes" ✅
By using a standard condition.
Using standard conditions is the most versatile way of using Arta.
rules.yaml:
rules.yaml
--- rules: default_rule_set: example_rule: OK: condition: A_BY_B_GT_THRESHOLD action: do_something action_parameters: value: OK KO: condition: not A_BY_B_GT_THRESHOLD action: do_something action_parameters: value: KO conditions: A_BY_B_GT_THRESHOLD: description: "A*B > threshold?" validation_function: is_mul_greater_than condition_parameters: a: input.value_a b: input.value_b threshold: 0.87 conditions_source_modules: - conditions actions_source_modules: - actions
conditions.py:
conditions.py
def is_mul_greater_than(a: float, b: float, threshold: float) -> bool: return a * b > threshold
actions.py:
actions.py
def do_something(value: str, **kwargs) -> str: return value
main.py:
main.py
from typing import Any from arta import RulesEngine eng = RulesEngine(config_path=".") data: dict[str, float] = { "value_a": 1.3, "value_b": 0.7, } result: dict[str, Any] = eng.apply_rules(input_data=data) print(result)
It should print: {'example_rule': 'OK'}
{'example_rule': 'OK'}
1.3*0.7=0.91, greater than 0.87.
Warning: For now you can't use a simple condition for math but we will work on that. See next comment.
Enhancement: The following enhancement proposal could be useful with math in conditions: #7
The text was updated successfully, but these errors were encountered:
Since final release 0.7.0, math expressions are implemented for simple conditions (only basic operators like: +, -, * and /).
+
-
*
/
Example:
--- rules: default_rule_set: math: OPS: simple_condition: input.x+input.y>input.threshold and input.x*input.y<123.4 action: do_nothing action_parameters: null
Sorry, something went wrong.
No branches or pull requests
Answer is definitely "yes" ✅
How?
By using a standard condition.
Example
rules.yaml
:conditions.py
:actions.py
:main.py
:It should print:
{'example_rule': 'OK'}
The text was updated successfully, but these errors were encountered: