decision_lab
is a Python library that provides a simple and intuitive interface for creating and managing DECISIONS that can be accessed via APIs. With decision_lab
, you can make code behavior changes without changing the code itself, saving time and money on development and maintenance.
pip install decisionlab
from decisionlab import DecisionLab
decision_lab = DecisionLab(token='your_read_only_token')
# Get the list of decisions
In [3]: dl = DecisionLab(token='dfda3ffe-0cd7-48e4-9034-c926c580bee6')
In [4]: dl.list_decisions()
Out[4]: ['decision_name', 'decision_name2']
dl.get_decision('decision_name')
>> 'decision_value'
from decisionlab import DecisionLab
dl = DecisionLab(token='your_read_and_write_token', is_read_write=True)
Rewriting of decisions from the library is also possible with this token
dl.update_decision_value('decision_name', 'decision_value')
Decision Duty is a feature that allows for simple but powerful alerts to be sent via email when a decision is change via the api. If a decision name starts with “DUTY&rduo; and it is changed with the api (i.e using this library) then an email will be sent to the team members. This is useful for critical systems so that if a decision is changed, the team is notified.
try:
critical_function_that_should_never_fail()
except Exception as e:
error = str(e)
dl.update_decision_value('DUTY_decision_name', f'ERROR: {error}')')
🚨EMERGENCY
The duty decision DUTY_emergency_demo has been updated to:
Exception on attempt 3: Traceback (most recent call last):
File "/critical_system.py",
line 13, in wrapper_retry return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "", line 4,
in demo_function raise ValueError("Demo error") ValueError: Demo error