-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch From Using Confuse to Pydantic For Config Parsing #254
Comments
Quick thought. Not being a software person, I just used |
Thanks @TimothyWillard, that was indeed the next step after Sara developed the pydantic parser. I really love Pydantic and there are so many downstream advantage we would get switching to it (biggest one is one place with every config option and value, second come validation, ...). I agree about confuse being... confusing. AFAIK (because I wasnot there when this choice was made) It has been used because it has some very good performance when config are very long (you can pickle small subviews in subprocesses, it's easy to read multiple files for the same configs). But now pydantic is just amazing and confuse as very strange behaviour that has caused it share of bugs. This is not a easy change though. |
Also absolutely not helpful at all but somewhere in the code there is an example of how to create an object for tests without reading a file, from a dictionnary or a string. Could not find it. |
Yeah, I agree that it's not an easy change. Definitely will need more test coverage of No worries on finding the example, I'm assuming it's just using |
Possible bug: #313 (comment). |
The config parsing in
gempyor
currently relies on theconfuse
in some ways that are less than ideal. The current issues I see are:config
object is a global object ingempyor.utils
, which can make it challenging to unit test the config parsing/validation independent of other package components. To create unit tests for the config (or just have two instances of config in the same python process) a copy has to be made withcopy.deepcopy
.confuse
relies on a customgempyor.utils.add_method
function to hijack and add methods to theconfuse.ConfigView
class, which modifiesconfuse.ConfigView
for the entire python process (see below).pydantic
defines it's model in regular python classes so extending a model is as easy as adding a method.Also, it appears that
pydantic
is more actively maintained thanconfuse
. There are some other benefits as well such as opening the door to more config file format options (I think @pearsonca is a fan of JSON for example). Looks like some initial work has already been completed by @saraloo in #222. Probably need to expand on parts of the package that touch thegempyor.utils.config
object to ensure stability when working on this. Thoughts @jcblemai and others?The text was updated successfully, but these errors were encountered: