Comments (5)
So this also implies that, when a package developed with this template is shipped through, let's say, pip, only things below the src/ directory would be contained in that bundle
that is correct
Thus, no pre-set or template config.yml is provided to a user for reference or "easily changing config"
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 again for the clarification!!
Thanks for the question! Maybe we should extend the Readme to clarify the usage of the hocon config.
from at-python-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 src/
directory would be contained in that bundle. Thus, no pre-set or template config.yml
is provided to a user for reference or "easily changing config", which is of course the intended behaviour but for non-developer users might then pose a challenge to get proper logging feedback from the package.
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!!
from at-python-template.
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:
/src/{{cookiecutter.module_name}}/res/default.conf
: config that ships with the module which contains default values for everything that should have a default value/config/debug.conf
: another config that is not shipped with the module that overrides default values - you can have several of those, depending on your use case
A setup like this is only possible, because pyhocon, the hocon parsing library, allows for inheritance between different config files (see util.py
for the implementation). As far as I know, a similar option does not exist when dealing with yaml files.
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 config.yml
into the module is not a good idea, as long as we can't have a separate config file that can override it.
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.
from at-python-template.
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.
A good addition to the provided default config at both locations could be to showcase the supported variable substitution, because it's quite useful in my opinion. It's actually why I'm only using hocon configs now. It's a great way to set up config files for different environments/stages, like dev.conf, prod.conf, but only set e.g. a variable env=dev
, env=prod
, and the rest of the configuration parameters will get filled automagically substituting the definitions in the default.conf.
from at-python-template.
@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?
from at-python-template.
Related Issues (20)
- update cookiecutter README.md instructions for code to work
- Cookiecutter setup yes/no choose order HOT 2
- When wrong syntax in project slug, necessary to start the script from the beginning HOT 2
- Links in Contributing section of Readme are outdated
- Stopping generation because post_gen_project hook script didn't exit successfully Hook script failed (exit status: 1)
- Harmonize python version in pre-commit.config and environment.yml
- Handle deprecation warnings
- Update Readme
- Add isort to pre-commit hooks HOT 1
- Refactor Dockerfile for pip
- Refactor Dockerfile for poetry
- Refactor Dockerfile for conda HOT 1
- Fix whitespace issues everywhere
- Simplify setup.py HOT 1
- Create template for documentation HOT 1
- Dependency Dashboard
- Replace str.format with f-strings HOT 1
- Fix the build status badge
- Add .DS_Store into .gitignore HOT 1
- Replace PyYAML config with OmegaConf
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from at-python-template.