py flow rules
A simple rules engine implementation for python.
Features
- Allows the developer to write simple rules policies to aggregate the business logic for an application.
Installation
Clone this repository and install the necessary dependencies.
git clone https://github.com/p1971/pyFlowRules.git
cd pyFlowRules
python -m venv .venv
source .venv/bin/activate # On Windows use: .\.venv\Scripts\activate
# For core functionality only (no dependencies required):
pip install -e .
# For development (includes testing tools):
pip install -r requirements-dev.txt
# For running examples:
pip install -r requirements-examples.txt
Make sure you have Python 3.10 or above installed.
Versioning
This project follows Semantic Versioning. Version numbers are in the format MAJOR.MINOR.PATCH:
- MAJOR version for incompatible API changes
- MINOR version for added functionality in a backwards compatible manner
- PATCH version for backwards compatible bug fixes
Current version:
Requirements Files
The project uses separate requirements files for different purposes:
requirements.txt- Core dependencies (currently empty as we only use standard library)requirements-dev.txt- Development dependencies (pytest, coverage, etc.)requirements-examples.txt- Dependencies for running example code
Usage
Here is an example of how to use the project:
from dataclasses import dataclass
from flowrules.rules_engine import policy, rule, Policy
@dataclass
class Request:
id: int
notional: float
client: str
@policy(policy_id="P01", policy_name="InitialRequestValidation")
class InitialRequestPolicy(Policy):
@rule(rule_id="R001", rule_name="Validate notional", failure_message="The notional is too high.")
def validate_notional(self, r: Request):
return r.notional < 100000
@rule(rule_id="R002", rule_name="Validate client", failure_message="The client is unknown.")
def validate_client(self, r: Request):
return r.client in ["client1", "client2"]
policy = InitialRequestPolicy()
result = policy.execute(Request(id=1, notional=90000, client="client1"))
print(result)
You can find more examples in the example/ directory.
For example
python -m example.main
Running Tests
Unit tests are included for this project. Use pytest to run them (recommended):
pip install pytest # Install pytest if not already done
pytest
Contributing
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m 'Add some feature'). - Push your branch (
git push origin feature/your-feature). - Open a pull request.
Make sure your code passes all tests and follows Python best practices.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for py-flow-rules 1.1.0
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 |
|---|---|---|---|---|
| py_flow_rules-1.1.0.tar.gz | 7.5 kB | Without provenance | Details for py_flow_rules-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_flow_rules-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for py_flow_rules-1.1.0-py3-none-any.whl |
Total release size: 14.4 kB
Release files / py_flow_rules-1.1.0.tar.gz
| Download URL | py_flow_rules-1.1.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69b93e02abe1a7d2b5875fe579c9819e208879da2a3cc1fbec10c35a679d8f20
|
|
BLAKE2b-256 checksum How to use checksums |
27c664c46e01c2610848eeadc33d4d939c700d916b990c52f96ef9e13b1176c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / py_flow_rules-1.1.0-py3-none-any.whl
| Download URL | py_flow_rules-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e31cfb8a8a60697ec4f38fd039516b116f1d3d6c4bc28cf705c21df843786ba5
|
|
BLAKE2b-256 checksum How to use checksums |
43d54fde8a7278be759e6010c5f87ccea54682269b1d39dde2eb7c2cc851340e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for py-flow-rules 1.1.0
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.