Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt at making substitutions work inside dicts and lists. #269

Merged
merged 6 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion scabha/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def evaluate_dict(self, params: Dict[str, Any],
defaults: Dict[str, Any] = {},
sublocation = [],
raise_substitution_errors: bool = True,
recursive: bool = False,
recursive: bool = True,
verbose: bool = False):
params_out = params
for name, value in list(params.items()):
Expand Down Expand Up @@ -625,6 +625,31 @@ def evaluate_dict(self, params: Dict[str, Any],
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,
corresponding_ns,
defaults,
sublocation=sublocation + [name],
raise_substitution_errors=raise_substitution_errors,
recursive=True,
verbose=verbose
)
elif isinstance(value, (list, ListConfig)) and recursive:
params_out[name] = type(value)(
[
*self.evaluate_dict(
{f"[{i}]": v for i, v in enumerate(value)},
corresponding_ns,
defaults,
sublocation=sublocation + [name],
raise_substitution_errors=raise_substitution_errors,
recursive=True,
verbose=verbose
).values()
]
)

return params_out


Expand Down
1 change: 1 addition & 0 deletions stimela/stimelogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def update_file_logger(log: logging.Logger, logopts: DictConfig, nesting: int =
setup_file_logger(log, path, level=logopts.level, symlink=logopts.symlink)
else:
disable_file_logger(log)
log.propagate = True


def get_logfile_dir(log: logging.Logger):
Expand Down
Loading