Skip to main content

business-rule-engine

CodeFactor Github version PyPI version Supported Python versions PyPI downloads GitHub

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

business-rule-engine-0.0.3.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

business_rule_engine-0.0.3-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file business-rule-engine-0.0.3.tar.gz.

File metadata

  • Download URL: business-rule-engine-0.0.3.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.2 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9

File hashes

Hashes for business-rule-engine-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5a2f14a8d33e3adec60057fb3e6d4177cbcea6b4edc170991960ca9f8b44d9cc
MD5 cb95dc331bd96cc31a8dc33847996423
BLAKE2b-256 9fdc4db606d4f72d73deb42e7e57eb1d86c0418b03cc7666a6e322e5821e633b

See more details on using hashes here.

File details

Details for the file business_rule_engine-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: business_rule_engine-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.2 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9

File hashes

Hashes for business_rule_engine-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 667e49fe73219d2019bafa0bae7da6d39bb70d7d49778ee2a44da5416bd912ee
MD5 4a131772f3b376f1ec9215a5ce023c2d
BLAKE2b-256 61d4e0e41b860ab6206fa662ecce615449ea282df1ef0f82c2e835a575a1030d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page