-
Notifications
You must be signed in to change notification settings - Fork 19
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
Reason behind two separate locations for config files? #38
Comments
The part about the yaml config is correct, but the hocon config setup is more complex. There are two places where hocon config is stored:
A setup like this is only possible, because pyhocon, the hocon parsing library, allows for inheritance between different config files (see The purpose of a config file is to provide settings to an application that can easily be changed without editing the source code and recompiling the application. Therefore the config must be a file that is stored outside of your module. The default hocon config is an exception to that rule, because you only provide the defaults in there and still have the option to specify a separate config file that overrides these defaults. Therefore I believe moving the We could implement a setup which uses a bundled yaml config that can be replaced by some external config, but I don't like that it would completely replace the bundled config. Also, so far noone requested that feature and we should try to avoid adding too much complexity to this template. |
Okay, flawless reasoning! :D So this also implies that, when a package developed with this template is shipped through, let's say, pip, only things below the But I completely agree that this is nothing to act on proactively, as creating our own yaml-inheritance would needlessly increase the complexity of this template which (as you said) should be avoided because then people might be less inclined to use the template in the first place! Thanks again for the clarification!! |
that is correct
well, installing a Python package means that you should not change the source of that package, so there would be no use in shipping a config like that. If you want the user to make use of some kind of config, you should teach them in your documentation on how to do that.
Thanks for the question! Maybe we should extend the Readme to clarify the usage of the hocon config. |
That's a good idea, but a link to the hocon project should suffice. The docstring in the load_config method explains it well enough. |
@rauerhans I like your suggestion, the distinction between dev and prod would probably be a better way to showcase the usefulness of this feature than the simple debug.conf file we have right now. Would you like to implement it? |
Depending on the choice of config file type (yaml / hocon / none), different locations for the respecitve config files are used.
The hocon choice uses
while the yaml choice uses
The hocon choice has the benefit that this path lies within the sourcepath of the module, meaning that functions like
{{ cookiecutter.module_name }}.util.get_resource_string
can fetch config files regardless of module location / installation / etc.I suggest moving the
config.yml
also to theres/
directory and while we're at it, also specifying the default path to theconfig.yml
inutil.load_config
, as it is the case when choosing the hocon option.The text was updated successfully, but these errors were encountered: