Debugging Kubernetes

23 Jul 2024

Helpful tips for debugging applications running in k8s

build/k8s.png

Handling multiple errors in Rust iterator adapters

17 Dec 2023

Approaches for handling multiple errors within iterator adapters

build/rust.png

Better FastAPI Background Jobs

29 Aug 2022

A more featureful background task runner for Async apps like FastAPI or Discord bots

build/fastapi_logo.png

Useful Linux Examples

21 Dec 2021

A plethora of helpful tips for working in Linux

build/bash_logo.png
Continue to all blog posts

Managing Local Environment Variable

Recently I was helping out a colleague set up a local Apache Airflow environment and needed a way of managing various environment variables. We required these to be constrained to the project and not applicable globally to avoid messing up other things he was doing. I remembered using dotenv in the past for this sort of thing, but was looking for something that didn’t require installing nodejs because he didn’t already have it installed.

direnv

Enter direnv, something I can quickly install via the linux package manager.

Nice features:

  • Explicitly opt in each directory ( direnv allow . ), useful when checking out other people’s code
  • Support for .env files like dotenv ( echo dotenv[_if_exists] >> .envrc )
  • Other helpers like PATH_add <path> for easily adding to the PATH variable

Learnings along the way

PYTHONPATH

The environment variable PYTHONPATH can be used to set where local modules can be loaded from. Particularly important with Airflow if you want to use code from outside your dags folder.

bash defaults

Reading the documentation also reminded me of the default syntax in bash which I had forgotten about

$ echo ${FOO-does_not_exist}
does_not_exist

$ export FOO=BAR

$ echo ${FOO-does_not_exist}
BAR