Stop worrying about configs with Gin

Shayla Donaldson
1 min readJan 22, 2021

We’ve all been there, you’re modelling away and one by one the hyper-parameters start adding up. At first, you ignore the problem and tell yourself that you’ll go back later to sort it out but inevitably don’t. There are loads of bad ways to tackle the problem of project configuration they include but are by no means limited to:

The really silly ways to configure your project:

  1. Creating a list of variables at the top of your script that you change until you find ones that work
  2. Maybe you just define defaults for your functions and classes that you change on the fly

The less silly ways to configure your project:

  1. Use a TOML or YAML file and pass a dictionary of config variables around with you
  2. Use a config script that sets environment variables that get read by your packages

The last two aren’t bad options but they come with the overhead of having to carry around a dictionary of parameters that you can pass as **kwargs to a function or class. What if we could abstract that all away and get Python to do all the heavy lifting for us? Well, there’s where Gin comes in. Gin is a lightweight Python library developed by Google to specifically try and tackle this problem. In this article, we’re going to take a look at the basics of how to use the library and then try and work out if it’s actually something you would use.

--

--