All the information about the configuration options for an app can be found somewhere in the code, either where the configuration is loaded, where it is validated or where it is actually used. But users must also get this information (without knowing the source code) in order to write their own configuration files: What parameters are there? What are their data types? How do they change the behaviour of the app? What are the restrictions on the values that each parameter can have? This documentation is commonly provided separately as a PDF or a wiki page. Finally there are also “template” configuration files, where all the parameters are already listed but the values are missing (or are filled using defaults). These templates are convenient because users can simply copy them and quickly set up the app.
In total, we have now three separate places where some or all of the details about the configuration are included, and they need to be kept synchronized! If you change the name of a parameter in the code and forget to update the documentation on the wiki page, you get angry users. Change the default value of a parameter and forget to update the template file? Angry users. You get the idea.
This happens all of the time. So much so, that experienced programmers often prefer checking the details looking directly in the source code, because they know the documentation cannot be trusted.
PyConfig solves this problem by automatically generating a fully detailed documentation of the configuration options, as well as a template file, directly from the source code. The users can generate either one whenever they want, and the result is by definition up-to-date.
And as a developer, you don’t have to worry about synchronizing all these sources of information and can focus on what really matters, which is the source code.
There are several different formats commonly used for app configuration (for example .INI, .YAML, .JSON or .ENV) and sometimes it is convenient to use “environment variables” instead of files for this purpose (but do not worry if you don’t know what those are). Usually, developers have to make a choice about what format they want to support. Different formats require different code to read the files and transform their contents into python variables, so it is a lot of work to support more than one option. In fact, developers do not want to deal with this issue at all because configuration files and formats and environment variables have nothing to do with the actual problem they’re trying to solve with their software. It is boring, repetitive and distracts us from the real challenges such as in our case of the Virtual Power Plant managing the energy production of thousands of power plants and securing the smooth operation of the power system!
Our library separates the application logic from configuration loading mechanisms and allows developers to write their code independently from any configuration formats. App users, on the other hand, have the flexibility to choose whatever format they like, or environment variables, or both.
And even more: Format support evolves together with the library. In its early days, PyConfig supports only .INI and .YAML for files, plus environment variables. In future versions we intend to add more formats (for example JSON). App developers simply have to switch to the newest library version (but don’t have to change anything in their source code) in order to offer their users this additional flexibility.
At Next Kraftwerke we’ve enjoyed the benefits of the rich python open source community for a long time and it was about time we give something back. PyConfig is our first open project and hopefully soon only one of many. We invite you to check out our code on github, try it out, submit bug reports, feature requests, pull requests or even just get in touch. And to the python community: Thanks for everything. Thanks for letting us in. We’re just glad to play our part.
All about our Products and Services
With the rise of renewables all over the world, we are facing a gigantic transformation of the global energy system. The Virtual Power Plant answers the demands of the decentralized energy world and opens up new business prospects for its participants and, of course, RES aggregators. We help you utilize them in the best possible way.