Skip to content

Commit

Permalink
solar - no engine. Exploring... tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
valhuber committed Dec 7, 2020
1 parent 1aadfe5 commit 8dccb53
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion banking/basic_web_app/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@
if use_rules:
rule_bank_setup.setup(db.session, db.engine)
activate_basic_rules()
rule_bank_setup.validate(db.session, db.engine) # checks for cycles, etc
rule_bank_setup.compute_formula_execution_order(db.session, db.engine) # checks for cycles, etc

from . import views
8 changes: 4 additions & 4 deletions logic_bank/logic_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlalchemy.orm import session

from logic_bank.rule_bank import rule_bank_withdraw # reduce circular imports
from logic_bank.rule_bank.rule_bank_setup import setup, validate
from logic_bank.rule_bank.rule_bank_setup import setup, compute_formula_execution_order
from logic_bank.rule_type.constraint import Constraint
from logic_bank.rule_type.copy import Copy
from logic_bank.rule_type.count import Count
Expand All @@ -31,10 +31,10 @@ def activate(session: session, activator: callable):
:param activator: function that declares rules (e.g., Rule.sum...)
:return:
"""
engine = session.bind.engine
setup(session, engine)
# solar engine = session.bind.engine
setup(session) # solar , engine)
activator()
validate(session, engine)
compute_formula_execution_order() # solar session, engine)


class Rule:
Expand Down
10 changes: 5 additions & 5 deletions logic_bank/rule_bank/rule_bank_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sqlalchemy.orm import session


def setup(a_session: session, an_engine: Engine):
def setup(a_session: session): # solar , an_engine: Engine):
"""
Initialize the RuleBank
Expand All @@ -35,7 +35,7 @@ def set_referring_children(rule, dependency: list):
pass


def validate_formula_dependencies(class_name: str):
def compute_formula_execution_order_for_class(class_name: str):
"""
compute formula._exec_order per formula._dependencies
"""
Expand Down Expand Up @@ -75,16 +75,16 @@ def validate_formula_dependencies(class_name: str):
raise Exception("Mapped Class[" + class_name + "] blocked by circular dependencies:" + cycles)


def validate(a_session: session, engine: Engine):
def compute_formula_execution_order() -> bool: # solar, a_session: sessionengine: Engine):
"""
Determine formula execution order based on "row.xx" references,
Determine formula execution order based on "row.xx" references (dependencies),
(or raise exception if cycles detected).
"""
list_rules = "\n\nValidate Rule Bank"
rules_bank = RuleBank()

for each_key in rules_bank.orm_objects:
validate_formula_dependencies(class_name=each_key)
compute_formula_execution_order_for_class(class_name=each_key)
list_rules += rules_bank.__str__()
print(list_rules)
return True
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ python-dateutil==2.8.1
six==1.15.0
SQLAlchemy==1.3.20
SQLAlchemy-Utils==0.36.8
Flask-AppBuilder==3.1.0
Flask-AppBuilder==3.1.1
LogicBankUtils==0.5.0

0 comments on commit 8dccb53

Please sign in to comment.