Python DSL for setting up business intelligence rules
Project description
business-rule-engine
As a software system grows in complexity and usage, it can become burdensome if every change to the logic/behavior of the system also requires you to write and deploy new code. The goal of this business rules engine is to provide a simple interface allowing anyone to capture new rules and logic defining the behavior of a system, and a way to then process those rules on the backend.
You might, for example, find this is a useful way for analysts to define marketing logic around when certain customers or items are eligible for a discount or to automate emails after users enter a certain state or go through a particular sequence of events.
Usage
1. Define Your set of variables
Variables represent values in your system, usually the value of some particular object. You create rules by setting threshold conditions such that when a variable is computed that triggers the condition some action is taken.
params = {
'products_in_stock': 10
}
2. Define custom functions
def order_more(items_to_order):
print("you ordered {} new items".format(items_to_order))
return items_to_order
3. Write the rules
rules = """
rule "order new items"
when
products_in_stock < 20
then
order_more(50)
end
"""
3. Create the parser and parse the rule
from business_rule_engine import RuleParser
parser = RuleParser()
parser.register_function(order_more)
parser.parsestr(rules)
parser.execute(params)
Supported functions
Business rule engine uses Excel like functions. So it is possible to use most of them in the rules.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for business-rule-engine-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d20f013fef376dc8712930f1c00cd66528adeec091382dee928f1e6a7998a09 |
|
MD5 | aabce7686b35c8b2ebae6f7b700bf7ef |
|
BLAKE2b-256 | cf7ec8fd4abfe334783a9c4cc56aae8c581d53e806a4524df9c0cb1950b0a4cc |
Hashes for business_rule_engine-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7fb326ea9253d9a46dff77a8cf4bf6c3bbf4a1238b2b64ba4b27cae60c82185 |
|
MD5 | 41f9286c54f6e1f6eea54e039f90bce4 |
|
BLAKE2b-256 | 3dd8264eef7198dc0560f47d0ebabb84c52a992d103734ce33bd4994a5c980af |