Confire: A new Python library

Announcing the release of a new open source library: Confire is a simple but powerful configuration scheme that builds on the configuration parsers of Scapy, elasticsearch, Django and others. The basic scheme is to have a configuration search path that looks for YAML files in standard locations. The search path is hierarchical (meaning that system configurations are overloaded by user configurations, etc). These YAML files are then added to a default, class-based configuration management scheme that allows for easy development.

Full documentation can be found here: http://confire.readthedocs.org/

Confire on PyPI

In a fit of procrastination, I put my first project on PyPI (the Python Package Index): Confire, a simple app configuration scheme using YAML and class based defaults. It was an incredible learning experience into the amount of work that goes into Python developers being simply able to pip install something! I wanted to go the whole nine yards, and set up documentation on Read The Docs and an open source platform on Github and even though it took a while, it was well worth the effort!

There are many configuration packages available on PyPI – it seems that everyone has a different way of doing it. However, this is my prefered way, and I found that after I copy and pasted this code into more than 3 projects that it was time to add it as a dependency via PyPI. The configuration builds on what I’ve learned/done in configuring Scapy, elasticsearch, and Django – and builds on these principles:

  1. Configuration should not be Python (sorry Django). It’s too easy to screw stuff up, and anyway, you don’t want to deal with importing a settings file from /etc!
  2. Configuration should be on a per-system basis. This means that there should be an /etc/app.yaml configuration file as well as a $HOME/.app.yaml configuration file that overwrites the system defaults for a particular user. For development purposes there should also be a $(pwd)/app.yaml file so that you don’t have to sprinkle things throughout the system if not needed.
  3. Developers should be able to have reasonable defaults already written in code if no YAML file has been provided. These defaults should be added in an API like way that is class based and modularized.
  4. Accessing settings from the code should be easy.

So there you have it, with these things in mind I wrote confire and I hope you enjoy it!

The awesome details:

The link on PyPI is here: https://pypi.python.org/pypi/confire
The docs on Read the Docs: http://confire.readthedocs.org/
The docs on Pyhosted: http://pythonhosted.org/confire/

The regular details:

The repository is here: https://github.com/bbengfort/confire
And the bug tracker, of course: https://github.com/bbengfort/confire/issues
The agile board: https://waffle.io/bbengfort/confire

Needless to say, this means you can do the following:

pip install confire

Hopefully this means you will be able to quickly deploy sensible configuration defaults in your code!

The following two tabs change content below.

Benjamin Bengfort

Chief Data Scientist at Cobrain
Benjamin is a data scientist with a passion for massive machine learning involving gigantic natural language corpora, and has been leveraging that passion to develop a keen understanding of recommendation algorithms at Cobrain in Bethesda, MD where he serves as the Chief Data Scientist. With a professional background in military and intelligence, and an academic background in economics and computer science, he brings a unique set of skills and insights to his work. Ben believes that data is a currency that can pave the way to discovering insights and solve complex problems. He is also currently pursuing a PhD in Computer Science at the University of Maryland.

Latest posts by Benjamin Bengfort (see all)

This entry was posted in Announcements, Python and tagged , , , , , . Bookmark the permalink.
  • Gregory J. Baker

    Interesting but I could not see in the documentation which version of Python is being used by the library. Reading through the code I noticed the use of the print statement rather than the print function, so I am assuming Python 2.X. Is that right?

    Might be a good idea to make it very clear to the casual reader.

    • http://www.bengfort.com/ Benjamin Bengfort

      Interesting you should ask this, just recently, a contributor from St. Petersburg cleaned up the code a bit to ensure it was fully compatible with Python 3, in particular the relative imports, but from what I could tell, the changes were minimal to ensure Python 3 compatibility. We now test this library on both Python 2.7 and Python 3.3 and will work ensure it is compatible on both 2.6+ and Python 3 in the future.

      I do develop in Python 2.7 – so if you saw a print statement, it was probably inside an ifmain block, right? But currently the code (and especially the 0.1.1 release) is Python version agnostic.

      • Gregory J. Baker

        Good to hear Python 3 supported. Will have to try it out. You are correct, the print statement I saw was indeed in an ifmain block.