-
Notifications
You must be signed in to change notification settings - Fork 13
Support consuming YAML files directly #93
Comments
Proposed changes to ConfigSuiteCurrently, it's not trivial to integrate popular configuration document formats Solution 1: Non-integrated utility function/classProof of concept: #94 Here, we have a separate utility class called
The latter is useful for when
While this is simple to implement, this approach has several problems:
Solution 2: Move ConfigSuite to a more abstract systemI propose, instead of using Python's
Each
This can then be combined to create an error message like this:
We can implement the functionality for loading Yaml document in several ways: Way 1: As part of
|
Applause for the extensive comment 👏 Unfortunately I have not yet found time to read it properly... Will get back to it as soon as possible! |
Again, thank you for the extensive comment 🚀 For the rest of this answer I'll make a clear distinction between the consumer and user, because they have different needs. The consumer is utilizing the API of
We should not be afraid to leave some responsibility to the consumer of our API as long as we are up front about it. In particular, for every assumption we make regarding usage, we are giving less control to consumer. I would rather be clear about something being the consumers responsibility, then to get in their way. Duplicate keys is a bit intricate in yamls is a bit intricate in Python. Most people agree with you that it is strange behavior to at all accept these files. And in most cases we do not want our users to give such files as input. There are many reasons why I don't think it is a big problem that we don't handle this and why I would require it to be possible to opt-out of this behavior if implemented.
We might never do this. Because the transformation belongs to the consumer, while the error belongs to the user. If validation fails, whether that is due to a transformation or not is impossible to tell. In particular, a user will not even know what a transformation is. I'm happy to continue this discussion, but I'm not convinced this is feasible to do in a consistent manner. And if we can't do it consistently, we are not implementing it. Intended consumption class MyConfig(ConfigSuite):
def __init__(self, data_source):
super.__init__(self, data_source, layers=_get_default_values())
.... So if someone wants to add In addition I think all errors should implement the same interface, as otherwise you would have to treat an error from a yaml-file different than other data formats. And that quickly gets ugly. We could for instance support a Anyway, my vote goes for 1 or 2.2. I don't want |
Currently, in order to read and validate YAML files, we first have to convert a the YAML file to a python dict. We lose a lot of useful information doing it this way. Instead, we should traverse the graph that PyYAML gives us using the
yaml.SafeLoader
class. This will let us do the following:The text was updated successfully, but these errors were encountered: