I'm considering using this to handle user-provided configurations for a scientific data processing pipeline. Most of the config parameters have sane defaults, but these defaults themselves are configurable by the system admin who deployed the pipeline software.
I'd really like to be able to have default config parameters that users can leave out of their config files, but I'd like to write out a copy of the full config spec including those parameters that weren't explicitly supplied by the user. This would give us a copy of the config used for an execution of the pipeline that records every config parameter and its value whether the user supplied it or not. This is important for us as we want to keep records of the configs used for reproducibility and we anticipate that different deployments of the software will have different defaults. Ideally, I'd also insert a comment next to the parameters where the default value was used, but that's less important.
I was thinking perhaps this could be implemented by adding a kwarg to Map.to_yaml, e.g. Map.to_yaml(drop_defaults=True) where setting it to False would include the optional keys with their default values in the output.
I have is that I was aiming for serialize(parse(x)) to be an idempotent operation. However, I don't have that yet now and I'm fairly sure this feature is compatible with that goal.
I'm not sure about "drop_defaults" as the name.
If you'd like to contribute the change, please feel free. I've been pretty busy lately!
Thanks for the library!
I'm considering using this to handle user-provided configurations for a scientific data processing pipeline. Most of the config parameters have sane defaults, but these defaults themselves are configurable by the system admin who deployed the pipeline software.
I'd really like to be able to have default config parameters that users can leave out of their config files, but I'd like to write out a copy of the full config spec including those parameters that weren't explicitly supplied by the user. This would give us a copy of the config used for an execution of the pipeline that records every config parameter and its value whether the user supplied it or not. This is important for us as we want to keep records of the configs used for reproducibility and we anticipate that different deployments of the software will have different defaults. Ideally, I'd also insert a comment next to the parameters where the default value was used, but that's less important.
I was thinking perhaps this could be implemented by adding a kwarg to
Map.to_yaml
, e.g.Map.to_yaml(drop_defaults=True)
where setting it toFalse
would include the optional keys with their default values in the output.For example:
would output
Do you think such a feature is warranted? I'm happy to contribute.