EvalEvaluator is called only if in root context. Added action and action_context to ExecutionContext
This commit is contained in:
+14
-23
@@ -18,7 +18,6 @@ from printer.SheerkaPrinter import SheerkaPrinter
|
||||
from sdp.sheerkaDataProvider import SheerkaDataProvider, Event
|
||||
|
||||
BASE_NODE_PARSER_CLASS = "parsers.BaseNodeParser.BaseNodeParser"
|
||||
CONCEPTS_FILE = "_concepts.txt"
|
||||
EXIT_COMMANDS = ("quit", "exit", "bye")
|
||||
|
||||
|
||||
@@ -156,7 +155,13 @@ class Sheerka(Concept):
|
||||
|
||||
event = Event("Initializing Sheerka.", user_id=self.name)
|
||||
self.sdp.save_event(event)
|
||||
with ExecutionContext(self.key, event, self, "Initializing Sheerka.", self.init_log) as exec_context:
|
||||
with ExecutionContext(self.key,
|
||||
event,
|
||||
self,
|
||||
BuiltinConcepts.INIT_SHEERKA,
|
||||
None,
|
||||
desc="Initializing Sheerka.",
|
||||
logger=self.init_log) as exec_context:
|
||||
if self.sdp.first_time:
|
||||
self.first_time_initialisation(exec_context)
|
||||
|
||||
@@ -355,7 +360,13 @@ class Sheerka(Concept):
|
||||
evt_digest = self.sdp.save_event(event)
|
||||
self.log.debug(f"{evt_digest=}")
|
||||
|
||||
with ExecutionContext(self.key, event, self, f"Evaluating '{text}'", self.log) as execution_context:
|
||||
with ExecutionContext(self.key,
|
||||
event,
|
||||
self,
|
||||
BuiltinConcepts.PROCESS_INPUT,
|
||||
text,
|
||||
desc=f"Evaluating '{text}'",
|
||||
logger=self.log) as execution_context:
|
||||
user_input = self.ret(self.name, True, self.new(BuiltinConcepts.USER_INPUT, body=text, user_name=user_name))
|
||||
reduce_requested = self.ret(self.name, True, self.new(BuiltinConcepts.REDUCE_REQUESTED))
|
||||
|
||||
@@ -757,26 +768,6 @@ class Sheerka(Concept):
|
||||
|
||||
return sorted(res, key=lambda i: int(i.id))
|
||||
|
||||
def restore(self):
|
||||
"""
|
||||
Restore the state with all previous valid concept definitions
|
||||
:return:
|
||||
"""
|
||||
try:
|
||||
self.during_restore = True
|
||||
with open(CONCEPTS_FILE, "r") as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if line == "" or line.startswith("#"):
|
||||
continue
|
||||
self.log.info(line)
|
||||
res = self.evaluate_user_input(line)
|
||||
if len(res) > 1 or not res[0].status:
|
||||
self.log.error("Error detected !")
|
||||
self.during_restore = False
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
def get_last_execution(self):
|
||||
return self._last_execution
|
||||
|
||||
|
||||
Reference in New Issue
Block a user