Add warnings when reading config.yaml files with duplicate keys (as PyYAML library silently over-writes the value with the subsequent value)
When adding restarts to config.yaml when creating a new git branch, allow duplicate keys but still warn that they will get deleted when the config.yaml file gets modified (note the subsequent key will get deleted). Ruamel yaml library is used for modifying the config files as it can preserve multi-line strings and comments.
Added a test for testing the warnings above
Closes #441
By default warnings are formatted with a line of the source code, e.g. the line warnings.warn( in
/home/189/jb4202/payu_fork/payu/fsops.py:83: UserWarning: Duplicate key found in config.yaml: key 'model' with value 'mom6' (original value: '')
warnings.warn(
In fb45911983e399befc52e03feb9394a74c796f93, I have just patched the warnings used globally it doesn't include the line of source code. This is to avoid logs with like warnings.warn( with unclosed brackets.
coverage: 52.758% (+0.5%) from 52.281%
when pulling cddbef651ae7d474fcfe378ce426b47e9eca742b on ACCESS-NRI:441-inconsistency-between-yaml-libs-bugfix
into 83001a2b45ef786e178894f77dd9fbc0878e73c1 on payu-org:master.
As suggested in this issue #441,
Closes #441
By default warnings are formatted with a line of the source code, e.g. the line
warnings.warn(
inIn fb45911983e399befc52e03feb9394a74c796f93, I have just patched the warnings used globally it doesn't include the line of source code. This is to avoid logs with like
warnings.warn(
with unclosed brackets.