pythonrulesrule-engineclips

Python Rule Engine


I have a set of rules that I need to apply on a couple of python objects and I am wondering how could I do this. The main goal would be to run my object through the set of rules and obtain which rule matched if any.

Example Objects:

class Student:
    def __init__(self):
        self.country:str
        self.name:str
        self.surname:str
        self.grade:int

class StudentsExamReport:
    def __init__(self):
        self.exam_id:str
        self.students: List[Student]

Example rule:

A rule I would like to apply would be something like "If more than 3 students have a grade lower than 4 then match".

I found CLIPS but I'm not sure if it can be used to match python objects or if it may be too overkill or AI oriented for me.


Solution

  • I ended up creating my own engine as I didn't find one that suited my needs.

    You can find it here: https://github.com/santalvarez/python-rule-engine