From ea864a1ab3d502cb675e2c1f9b0b9e5a29e46f8f Mon Sep 17 00:00:00 2001 From: "Chi Song (from Dev Box)" Date: Wed, 2 Oct 2024 20:08:17 -0700 Subject: [PATCH] runbook refactoring: move set to optional --- lisa/parameter_parser/runbook.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lisa/parameter_parser/runbook.py b/lisa/parameter_parser/runbook.py index 5940d3264..4dcf355dd 100644 --- a/lisa/parameter_parser/runbook.py +++ b/lisa/parameter_parser/runbook.py @@ -63,7 +63,7 @@ class RunbookBuilder: # merge all parameters builder._log.info(f"loading runbook: {builder._path}") data = builder._load_data( - builder._path.absolute(), set(), higher_level_variables=builder._cmd_args + path=builder._path.absolute(), higher_level_variables=builder._cmd_args ) builder._raw_data = data @@ -121,7 +121,7 @@ class RunbookBuilder: result._variables.update(variables) # reload data to support dynamic path in combinators or transformers. result._raw_data = result._load_data( - self._path, set(), higher_level_variables=result._variables + path=self._path, higher_level_variables=result._variables ) result._remove_extensions() result._remove_variables() @@ -323,8 +323,8 @@ class RunbookBuilder: def _load_data( self, path: Path, - used_path: Set[str], higher_level_variables: Union[List[str], Dict[str, VariableEntry]], + used_path: Optional[Set[str]] = None, ) -> Any: """ Load runbook, but not to validate. It will be validated after @@ -337,6 +337,9 @@ class RunbookBuilder: if not data_from_current: raise LisaException(f"file '{path}' cannot be empty.") + if not used_path: + used_path = set() + variables = load_variables( data_from_current, higher_level_variables=higher_level_variables ) @@ -380,9 +383,9 @@ class RunbookBuilder: new_used_path = used_path.copy() new_used_path.add(raw_path) include_data = self._load_data( - include_path, - used_path=new_used_path, + path=include_path, higher_level_variables=variables, + used_path=new_used_path, ) data_from_include = self._merge_data( include_path.parent, include_data, data_from_include