Urgent.News

What's breaking now, across thousands of outlets.

Tech

Smarter Python Configs: an OOP Framework

Originally published on wisl.dev . Update: this framework grew into bakefile , a task runner: the same base, service, and instance inheritance, rearchitected and published as a library. The story behind it: Developer Workflows Need an Abstraction . Managing configurations across multiple environments and services is one of those things that should be simple, but rarely is. If you've worked with…

Managing configurations across multiple environments and services can be a complex task. Developers often face redundant work due to the need for separate config setups for each environment and service. This is where an OOP-based configuration framework in Python comes into play. The framework, built on Pydantic, simplifies and centralizes configuration management.

The configuration structure consists of four layers. The base layer contains shared, global settings like environment identifier, logging level, and GCP credentials. Environment-specific mixins, such as ProdConfigsMixin, override these shared values and add environment-specific configurations. The service layer contains service-specific variables and behavior, while the instance layer includes instance-specific configurations.

By defining configurations as Python classes and using object-oriented programming, the framework encourages composition and reuse. A set of CLI tools, such as ac, allows developers to easily manage and deploy configurations. The ac command can output all resolved configs for the current environment, enabling dynamic generation of environment variables in shell sessions or pipelines. This eliminates the need for handcrafting .env files for CI/CD pipelines, as environment-specific values can be dynamically generated.

The framework's key advantage lies in its ability to encode environment-specific behavior within the config object. CI/CD pipelines can simply run deploy and assert_deploy commands in the appropriate environment. Adding new services or environments requires only the creation of a new config class, rather than a complete overhaul of the pipeline. This results in a more efficient and streamlined process, minimizing redundancy and improving overall delivery speed.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Apple M6: Why There Will Never Be an M6 Pro

Six months ago I wrote that the age of monolithic Apple Silicon was over. The M5 Pro and M5 Max had arrived as bonded dual-die parts, Fusion Architecture was real, and the direction looked obvious…

The Model Is Not the Product. Here's What Actually Is.

I spend a lot of time in the AI space -- reading papers, building things, talking to engineers who are actually shipping.

  • An agent is a system with an objective and decision-making capabilities.
  • Most production AI systems are narrow, task-specific pipelines.
  • Successful AI teams prioritize tool design, failure handling, and observability.

More from Monday 14 September →