simple-rule-engine
A lightweight yet powerful rule engine that allows declarative specification of business rules and saves tons of repeated development work.
- This library has been utilized in authoring & evaluation of a number of complex credit decisioning, upgrade/downgrade, and lender evaulation criteria rules at FundsCorner
- This library can also be considered as a Policy Framework for validating IaC (Infrastructure as Code).
At a glance
simple-rule-engine is a Python library that enables declarative specification of decision or scoring rules.
Example Decision matrix
| Bureau Score | Marital Status | Decision |
|---|---|---|
| between 650 and 800 | in [Married, Unspecified] | GO |
Rule specification
from simpleruleengine.conditional.when_all import WhenAll
from simpleruleengine.expression.expression import Expression
from simpleruleengine.operator.between import Between
from simpleruleengine.operator.string_in import In
from simpleruleengine.rulerow.rule_row_decision import RuleRowDecision
from simpleruleengine.ruleset.rule_set_decision import RuleSetDecision
from simpleruleengine.token.numeric_token import NumericToken
from simpleruleengine.token.string_token import StringToken
if __name__ == "__main__":
cibil_score_between_650_800 = Expression(
NumericToken("cibil_score"),
Between(floor=650, ceiling=800)
)
marital_status_in_married_unspecified = Expression(
StringToken("marital_status"),
In("Married", "Unspecified")
)
rule_row_decision_go = RuleRowDecision(
WhenAll(
cibil_score_between_650_800,
marital_status_in_married_unspecified
),
"GO"
)
rule_set_decision = RuleSetDecision(rule_row_decision_go)
fact = dict(
cibil_score=700,
marital_status="Married"
)
assert rule_set_decision.evaluate(fact) == "GO"
Key Features
- Ability to declaratively author both Scoring and Decision Rules.
- The library offers composable functional syntax that can be extended with various format adapters. See here for an example of such an extension.
- Ability to version control rule declarations thus enabling auditing of rule changes over a period of time.
- Ability to author chained rules. Evaluation of one rule can refer to the result of another rule, thus enabling modular, hierarchical rules.
Installation
pip install simpleruleengine==2.0.2
Source Code
simple-rule-engine GitHub Repository
Simple Rule Engine - Motivation and Under-the-Hood
Metadata
Release files for simpleruleengine 2.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simpleruleengine-2.0.3.tar.gz | 11.9 kB | Without provenance | Details for simpleruleengine-2.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simpleruleengine-2.0.3-py3-none-any.whl | Python 3 | none | any | Details for simpleruleengine-2.0.3-py3-none-any.whl |
Total release size: 39.2 kB
Release files / simpleruleengine-2.0.3.tar.gz
| Download URL | simpleruleengine-2.0.3.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91210176e7ea5d67ad7eb6fce1b7ac0b105e6e3e6c372371475e7c44b01daea8
|
|
BLAKE2b-256 checksum How to use checksums |
393744d33a6b5f2886ecfb625b06807af0b07ed1290b7a716d9992d1922a62ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.5
|
Release files / simpleruleengine-2.0.3-py3-none-any.whl
| Download URL | simpleruleengine-2.0.3-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d934ef44b8752489f0aee7c16da6a6e281b211dbe5fdc1cedda0989c68d05488
|
|
BLAKE2b-256 checksum How to use checksums |
b8d4e0ce44a3bbefb6cb04ccbf4144a20425f9064b2d9f1c239ffbdacb9a4cbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.5
|
Security for simpleruleengine 2.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.