From 9c5ed08362d3f7459d61368aef9de676d5c5d956 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Sun, 9 Jun 2024 13:42:12 +0200 Subject: [PATCH 1/2] fixes #309. Fixes #310 --- stimela/kitchen/recipe.py | 2 +- stimela/kitchen/step.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/stimela/kitchen/recipe.py b/stimela/kitchen/recipe.py index 9deaf1f..8f7ec6c 100644 --- a/stimela/kitchen/recipe.py +++ b/stimela/kitchen/recipe.py @@ -179,7 +179,7 @@ def do_assign(assignments): Substitution errors are ignored at this stage, a final round of re-evaluation with ignore=False is done at the end. """ # flatten assignments - flattened = flatten_dict(assignments) + flattened = assignments # flatten_dict(assignments) # drop entries protected from assignment flattened = {name: value for name, value in flattened.items() if name not in self._protected_from_assign} # merge into recipe namespace diff --git a/stimela/kitchen/step.py b/stimela/kitchen/step.py index b0ecd84..7aea970 100644 --- a/stimela/kitchen/step.py +++ b/stimela/kitchen/step.py @@ -410,6 +410,8 @@ def run(self, backend: Optional[Dict] = None, subst: Optional[Dict[str, Any]] = skip = self._skip if self._skip is None and subst is not None: skip = evaluate_and_substitute_object(self.skip, subst, location=[self.fqname, "skip"]) + if skip is UNSET: # skip: =IFSET(recipe.foo) will return UNSET + skip = False self.log.debug(f"dynamic skip attribute evaluation returns {skip}") # formulas with unset variables return UNSET instance if isinstance(skip, UNSET): From 458e0cdee2d634c9d71459b80730d92b32146c3a Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Sun, 9 Jun 2024 14:27:58 +0200 Subject: [PATCH 2/2] fixes #312 --- scabha/evaluator.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scabha/evaluator.py b/scabha/evaluator.py index ee19cc8..3cefc07 100644 --- a/scabha/evaluator.py +++ b/scabha/evaluator.py @@ -621,12 +621,12 @@ def evaluate_dict(self, params: Dict[str, Any], del corresponding_ns[name] elif new_value is not value and new_value != value: if params_out is params: - params_out = params.copy() + params_out = OrderedDict(**params) params_out[name] = new_value if corresponding_ns: corresponding_ns[name] = new_value elif isinstance(value, (dict, DictConfig)) and recursive: - params_out[name] = self.evaluate_dict( + value = self.evaluate_dict( value, corresponding_ns, defaults, @@ -635,9 +635,9 @@ def evaluate_dict(self, params: Dict[str, Any], recursive=True, verbose=verbose ) + params_out[name] = value elif isinstance(value, (list, ListConfig)) and recursive: - params_out[name] = type(value)( - [ + seq = [ *self.evaluate_dict( {f"[{i}]": v for i, v in enumerate(value)}, corresponding_ns, @@ -648,7 +648,7 @@ def evaluate_dict(self, params: Dict[str, Any], verbose=verbose ).values() ] - ) + params_out[name] = type(value)(seq) return params_out