Skip to main content

Configuration files using Pydantic and YAML

· 13 min read
Tony Hallam
Application Consultant @ EPCC

Often when working on custom Python tooling or commandline applications it might be helpful to have some sort of configuration file rather than passing a long list of flags and arguments in the shell. There are a lot of different configuration file formats people use like ini, toml, json and yaml. Generally I prefer YAML because of its easy to read structure and the simplicity with which it maps to Python objects, particularly dictionaries. YAML also supports comments which can be a big plus when you want to explain what parameters are or why you have a particularly value for your deployment.

This post describes one implementation for managing YAML configurations using Pydantic with some improvements for usability and documentation.

TQDM for an async Queue

· 8 min read
Tony Hallam
Application Consultant @ EPCC

After working through the Real Python tutorial for async functions I was curious about whether I could monitor the status of the async Queue used in one of the examples.

The example works by creating a number of producer coroutines and consumer coroutines that systematically add and remove 'jobs' from the shared queue. You can play with the number of producers and consumers to adjust the speed at which these jobs are produced and consumed which affects the size and status of the queue. You can get a feeling for it intrinsically by watching the standard output but I wondered if you could use TQDM.