EvalEvaluator is called only if in root context. Added action and action_context to ExecutionContext

This commit is contained in:
2020-06-12 17:47:29 +02:00
parent c43a3ef946
commit 912455c343
27 changed files with 292 additions and 117 deletions
@@ -104,7 +104,9 @@ class SheerkaEvaluateConcept(BaseService):
context.log(f"Recognized concept '{concept_found}'", self.NAME)
concept.compiled[part_key] = concept_found
else:
with context.push(desc=f"Initializing *compiled* for {part_key}") as sub_context:
with context.push(BuiltinConcepts.INIT_COMPILED,
{"part": part_key, "source": source},
desc=f"Initializing *compiled* for {part_key}") as sub_context:
sub_context.add_inputs(source=source)
to_parse = self.sheerka.ret(context.who, True,
self.sheerka.new(BuiltinConcepts.USER_INPUT, body=source))
@@ -128,7 +130,9 @@ class SheerkaEvaluateConcept(BaseService):
context.log(f"Recognized concept '{concept_found}'", self.NAME)
concept.compiled[var_name] = concept_found
else:
with context.push(desc=f"Initializing *compiled* for property {var_name}") as sub_context:
with context.push(BuiltinConcepts.INIT_COMPILED,
{"property": var_name, "source": default_value},
desc=f"Initializing *compiled* for property {var_name}") as sub_context:
sub_context.add_inputs(source=default_value)
to_parse = self.sheerka.ret(context.who, True,
self.sheerka.new(BuiltinConcepts.USER_INPUT, body=default_value))
@@ -148,7 +152,10 @@ class SheerkaEvaluateConcept(BaseService):
# manage infinite loop
if self.infinite_recursion_detected(context, current_concept):
with context.push(desc="Infinite recursion detected", obj=current_concept) as sub_context:
with context.push(BuiltinConcepts.MANAGE_INFINITE_RECURSION,
current_concept,
desc="Infinite recursion detected",
obj=current_concept) as sub_context:
# I create a sub context in order to log what happened
ret_val = self.manage_infinite_recursion(context)
sub_context.add_values(return_values=ret_val)
@@ -156,7 +163,10 @@ class SheerkaEvaluateConcept(BaseService):
desc = f"Evaluating {current_prop} (concept={current_concept})"
context.log(desc, self.NAME)
with context.push(desc=desc, obj=current_concept) as sub_context:
with context.push(BuiltinConcepts.EVALUATING_CONCEPT,
current_prop,
desc=desc,
obj=current_concept) as sub_context:
if force_evaluation:
sub_context.local_hints.add(BuiltinConcepts.EVAL_BODY_REQUESTED)