decisionengine.framework.logicengine package
Subpackages
- decisionengine.framework.logicengine.tests package
- Submodules
- decisionengine.framework.logicengine.tests.test_bool_function_name module
- decisionengine.framework.logicengine.tests.test_cascaded_rules module
- decisionengine.framework.logicengine.tests.test_construction module
- decisionengine.framework.logicengine.tests.test_duplicate_fact_names module
- decisionengine.framework.logicengine.tests.test_facts module
- decisionengine.framework.logicengine.tests.test_fail_on_error module
- decisionengine.framework.logicengine.tests.test_pandas_fact module
- decisionengine.framework.logicengine.tests.test_rule_with_negated_fact module
- decisionengine.framework.logicengine.tests.test_simple_configuration module
- Module contents
Submodules
decisionengine.framework.logicengine.BooleanExpression module
- class decisionengine.framework.logicengine.BooleanExpression.BooleanExpression(expr)[source]
Bases:
object
decisionengine.framework.logicengine.FactLookup module
- class decisionengine.framework.logicengine.FactLookup.FactLookup(fact_names, rules_cfg)[source]
Bases:
object
Establishes a policy for looking up a fact based on the given name.
To with, the first fact with a given name is the one that is used in the evaluation of all subsequent facts.
As an example, consider the following configuration:
{ "facts": { "should_publish": "(True)" }, "rules": { "publish_1": { "expression": "should_publish", "facts": ["should_publish"] }, "publish_2": { "expression": "should_publish", "actions": ["go_to_press"], "facts": ["should_publish"] }, "retract": { "expression": "not should_publish", "facts": ["should_retract"] } } }
In the above, the first fact to be evaluated will always be the top-level facts (i.e. those not encapsulated by the ‘rules’ table). The rules labeled ‘publish_1’ and ‘publish_2’ both rely on the ‘should_publish’ fact in their expressions, and they in turn create their own facts with the same name. FactLookup ensures that ‘publish_1’ and ‘publish_2’ will both use the evaluated fact from the top-level ‘facts’ table.
decisionengine.framework.logicengine.LogicEngine module
- class decisionengine.framework.logicengine.LogicEngine.LogicEngine(cfg)[source]
Bases:
Module
- _create_facts_dataframe(newfacts)[source]
Convert newfacts dict in format below to dataframe with columns [‘rule_name’, ‘fact_name’, fact_value’]
facts dict format:
{ "newfacts": { "publish_glidein_requests": { "allow_hpc_new": true, "allow_foo": true }, "dummy_rule": { "dummy_new_fact": true } } }
- consumes()[source]
Return the names of all the items that must be in the DataBlock for the rules to be evaluated.
- evaluate(db)[source]
Evaluate our facts and rules, in the context of the given data. db can be any mappable, in particular a DataBlock or dictionary.
- Parameters:
db (
DataBlock
) – Products used to evaluate facts.
decisionengine.framework.logicengine.Rule module
decisionengine.framework.logicengine.RuleEngine module
- class decisionengine.framework.logicengine.RuleEngine.RuleEngine(fact_names, rules_cfg)[source]
Bases:
object
Engine responsible for evaluating logic-engine rules.
This class is responsible for (a) forming a sorted set of rules that supports dependencies between them, and (b) evaluating the rules according to a specified fact-lookup policy.