-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rules called on already retracted facts #41
Comments
Hi @nilp0inter, I am using pyknow library to build some logic based on logic and facts. I have faced the same behavior as you explain in this issue. In fact, I had the same error as it seems in one point (not exactly when) the activations in the agenda have a factid that has being retracted (so it does not exists any more). I have created on a fork the behavior that I would need, but I suppose the problem should be solved by ensuring the activation facts has the proper factid that stays in the facts list of the engine, no? Thanks! |
This is maybe a regression after the last optimizations made this year. A couple of regression tests and a git bisect could help here. |
+1 any updates on this? |
for my case this decorator solves my problem: def safe_access_fact(attr, fact_type):
def func_receiver(func):
def inner(*args, **kwargs):
database = args[0]
for fact in database.facts.items():
if isinstance(fact[1], fact_type):
return func(*args,
**kwargs,
**{attr: fact[1]})
return func(*args, **kwargs)
return inner
return func_receiver And the use: @Rule(
EXISTS(SystemPreCheck()),
Common(current_state=QuestionsBlock.SYSTEM_PRE_CHECK),
~SystemPreCheck(have_error_within_time_limit=W()))
@safe_access_fact('system', SystemPreCheck)
def have_error_within_time_limit(self, system):
read = auto_read([True, False])
print(f'Existe defeito atribuído dentro do prazo?: {"y" if read else "n"}')
self.modify(system, have_error_within_time_limit=read) if I use the |
Already fixed in Experta |
Rules are being called on already retracted facts.
This code raises the following exception:
A similar exception is raised if the method
modify
is used instead ofretract
+declare
.The text was updated successfully, but these errors were encountered: