os.walk has a major gotcha

Python's os.walk is a very useful idiom for recursively iterating over a directory. However it has one big gotcha that bit us recently: by default, it silently no-ops if the directory doesn't exist: >>> import os >>> list(os.walk('/nonexistent/dir')) [] However os.…

Introducing Toolchain!

Throughout our careers in software engineering, we’ve each worked on a variety of projects, using various programming languages and frameworks, at several different companies. Yet there was always one experience in common: Builds. Just. SUCKED. In fact, the common bond that unites every developer seems to be that builds…

TIL: Pythons 2 and 3 can coexist under pyenv

pyenv is a wonderful tool for managing multiple Python versions on your system. It uses shims to select a specific interpreter either globally, per-directory or per-shell. I recently learned that you can actually select both a Python 2 and a Python 3 interpreter in a single context. For example: pyenv…

Python 3 text file encoding is still system-dependent

Python 3 assumes a default encoding of UTF-8 in a variety of useful scenarios. For example, s: str = buf.decode() will decode the byte buffer as UTF-8. And similarly for buf = s.encode().  Python 3 also defaults to encoding filenames as UTF-8, and Python 3 source code itself is encoded…

Django migrations directories cannot be namespace packages

Django's migrate command locates migration files for an app by loading a subpackage of the app, named migrations, and then searching that subpackage for modules. Unfortunately, there's a check in the code that does not allow migrations to be a namespace package. In other words, it must contain an __init_…

Terraform boolean gotcha

Terraform coerces the literal booleans false and true (e.g., when used as variable values) to 0 and 1 respectively. As a result, this ternary expression: count = "${var.myboolean == true ? 1 : 0}"unexpectedly always evaluates to 0. You want to use count = "${var.myboolean ? 1 : 0}"Or even just count…

ALB Ingress controller gotcha

If you're running a Kubernetes cluster on AWS (via EKS, kops, or otherwise), you're probably using the AWS ALB Ingress controller to create Application Load Balancers (ALBs) that map to Kubernetes Ingress resources. If so, be aware of the following gotcha: When adding ALB-specific annotations on the Ingress config, be…

Welcome to the Toolchain Engineering Blog

You've probably seen corporate engineering blogs before. You know the deal - a post every few weeks, or months, boasting about a new feature, or an open-source project with a "cool" name*, or a conference talk, all inevitably ending with "we're hiring!" Well, this blog is a little different. We…