CABLE-LSM / benchcab

Tool for evaluation of CABLE land surface model
https://benchcab.readthedocs.io/en/latest/
Apache License 2.0
2 stars 4 forks source link

Improvements for `read_optional_key` implementation #284

Open SeanBryan51 opened 6 months ago

SeanBryan51 commented 6 months ago

The read_optional_key function was added in PR https://github.com/CABLE-LSM/benchcab/pull/238:

https://github.com/CABLE-LSM/benchcab/blob/5c526e45ad094c6b024eb41586f34b3e628a5610/src/benchcab/config.py#L74-L121

Instead of hard coding default values for each field within the function, we can use the schema itself to set default values for missing fields in the document. The cerberus python package provides normalization rules which support this functionality. This approach would also lets us change default values for specific fields in the future without breaking the test suite.