-
Notifications
You must be signed in to change notification settings - Fork 15
Universal Config Loader #254
Description
Is your feature request related to a problem? Please describe.
It would be useful to have a single function to handle how we load all of the different configuration file formats. Right now, we support Fortran namelists (mainly for the translate tests) and YAML files (used in the Pace driver), but we load them in different ways. This could potentially add more consistency to the code. If we have a generic load mechanism, it may also make it easier in the future if we encounter another file format to support.
Describe the solution you'd like
We recently added helper functions to load a Fortran namelist (PR #246 , which is related to Issue #64 ):
load_f90nml
load_f90nml_as_dict
However, it might be useful to have more universal loaders like:
load_config
load_config_as_dict
- The
as_dictis only a suggestion because we currently usedicts+daciteto initialize some of our config classes. - I think the main goal for these functions would be to act as a minimal bridge from file to config classes (
PhysicsConfig,DynamicalCoreConfig), where the configs act as the main place to store these parameters within the submodules. - Another idea was to consider creating a mapping layer from
f90nmltoyamlto help with this.
Describe alternatives you've considered
I'm writing here some ideas that I've heard swirling around from conversations that might be related to this.
- Another idea would be to create some sort of
ConfigFactory. The could be initialized from a config file:
ConfigFactory.from_config('input.nml')
ConfigFactory.from_config('baroclinic.yaml')
With this, we'd need some sort of Registry to keep track the configs coming from the different submodules. Then, instead of passing along a yaml or a dict or a f90nml, we'd pass along this factory to spit out configs as we need them.
Additional context
Originally suggested by @FlorianDeconinck