<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=338168267432629&amp;ev=PageView&amp;noscript=1">
Programming

Rules Engine With Python and Django

We all have our reasons for wanting a great rules engine in Python/Django. For us, those reasons are a) we enjoy programming in Python/Django and b) programming in a rules engine is much better for managing people and things. For example, when a client signs up with us (we are a Python …


We all have our reasons for wanting a great rules engine in Python/Django. For us, those reasons are a) we enjoy programming in Python/Django and b) programming in a rules engine is much better for managing people and things. For example, when a client signs up with us (we are a Python shop), notify the PM to get their ticketing portal setup. With a rules engine, that type of thing can be just one script! If-signal-then do something complex, and maybe set off another signal. Basically, can I program human and software and machine workflows with rules, on the same platform, in Python?

Fred_dibnah_funeral

Existing Software

I have looked into all the angles when considering the best way to streamline our company using code rather than BPM(not fun) tools with heavy WYSIWYG programming UI’s.  And why not? Programmers can solve these issues easily! Here are a few packages in the arena:

Pyke is interesting since it creates “Expert Systems” and has an inference engine. That’s not exactly what we needed in a business environment.  In fact, with all the tools listed above we ran into similar problems:

  • The libraries are generally unused/not production ready
  • No help with interfacing to the outside world
  • Very little help with troubleshooting/authoring/administrating rule execution

For example, let’s say you have a rule that should have executed last night because some alert came into the system. You need a record of that alert and  record of why your rule didn’t trigger. You need some type of process ID to track this instance, and the ability to create a new PID easily for testing. How about a debuging environment? How about a test mode so we don’t spam everyone/everything? How about deleting the PID’s? How about a unified type system for key value pairs between different systems? How about….

Actually, I wanted more than a rules engine

It turns out I wanted much more than a rule engine in Python. In one way, you could say that a tool that simply executes your rules, well that could be done in one script really.  What I wanted was a full platform! I wanted a swarm of tools to help me write a rule one time, and have any other machine or person or module abide.

I got together with my very smart business partners and programmers and spec-ed out this platform. This way we would know exactly what we are looking for, and if it’s not available, exactly what we would need to build.

Along this journey I discovered rule-engine apathy. Seriously. Very smart people sometimes just gloss over the opportunity. I happen to gloss over their opinion because I understand that I am not looking for a rule engine, but a rule/workflow/event-based/Python platform.   It’s hard for them to understand a platform that hasn’t really existed yet.

Rules are great, but you need more than a small library!

So where did that lead us? First of all we found some neat tools that have similarities to what we want, but happen to fall short in key areas. They fall short because they might have created their own language, or they are too much a silo, or they are under powered and so on.  IFTTT is probably the closest in terms of connectivity, and Decisions or Drools is probably the closes in terms of rich logical rule ability and platform. But they simply can’t meet our needs. That means…we had to make our own!

To that end we created NebriOS and discovered that writing simple rules is a very interesting way to make process flows. Some call it automation.  Since we hadn’t built a serious platform before I seriously underestimated the time it would take to get Nebri running, even in a minimal state. Try to make a OS with throw away code! Not gonna happen. You have to be careful and planned the entire way through.

But the power! It’s amazing what you can do with just a few scripts. Write one rule and it NEVER breaks. It’s a much more human/organic way to think and develop. I would be suprised if you weren’t able to improve your situation with a bit of rule-love.

Similar posts

Get notified about the latest in Tech

Be the first to know about new tech from the experts at Bixly!