Fix bugs with dependency tracking

This commit is contained in:
Olivier 'reivilibre' 2021-01-13 15:36:18 +00:00
parent 86e893d7ba
commit 619cae3f45
2 changed files with 12 additions and 2 deletions

View File

@ -217,7 +217,7 @@ class DependencyVarProxy:
else:
return repr(self)
def raw_(self) -> Dict[str, Any]:
def raw_(self) -> Union[Dict[str, Any], List[Any], int, str, bool]:
if not self._current_path_prefix:
raw_dict = self._vars.toplevel()
else:
@ -238,6 +238,12 @@ class DependencyVarProxy:
self._tracker.register_variable(dotted_path, raw_value)
return raw_value
def __iter__(self):
return iter(self.raw_())
def __contains__(self, item):
return item in self.raw_()
class DependencyCache:
def __init__(self):

View File

@ -247,7 +247,11 @@ class Kitchen:
sous_vars = recipe.recipe_context.variables
vars_to_hash = {}
for var in prev_book.var_list:
vars_to_hash[var] = sous_vars.get_dotted(var)
try:
vars_to_hash[var] = sous_vars.get_dotted(var)
except KeyError:
# variable missing
return prev_book, False
my_varhash = hash_dict(vars_to_hash)
if prev_book.varhash != my_varhash:
return prev_book, False