Tag: Python

TIL: Simplified(?) Python Development Environment with pyenv & pipenv

Creating & maintaining a stable local Python development environment has often felt like more trouble than it ought to be, especially when you haven’t created one in a while but need to. The main goals/challenges of creating one are: Installing the desired version of Python with the least amount of trouble. Installing any necessary Python […]

Managing Alembic Migrations with a single alembic.ini & env.py

The current project that I am working on has multiple databases, but we wanted to streamline the migrations for while keeping them tracked separately with alembic. Previously we had a migration configuration for each database & it just felt unwieldy & unpythonic having multiple alembic.ini & env.py files that all pretty much contained the same […]

Using the Starship Prompt in pipenv Virtual Environment on Mac OSX

While attending PyCon 2021 online, I learned about Starship prompt & was impressed. It isn’t all that impressive when you are just navigating the file system, but as soon as you enter a project directory…that is when it springs to life. There is some magic that looks at the files & suddenly will tell you […]

Upgrading Python in an Existing pipenv Virtual Environment

While I have a love-hate relationship with pipenv–make no mistake, it’s definitely more love than hate–the things that I hate seem to be more due to a lack of (quality) documentation than a lack of anything else. A simple example is upgrading the version of python running in an existing virtual environment. My “google-fu” was […]

Cleaning Up Your Very First (Bad) Alembic Migration

As with many things, the first time you try something, it often doesn’t go well. And recently we’ve adopted using alembic for database migrations with a python-based project. Conceptually, alembic is a lot like git–each migration is a commit-like object that you can apply (upgrade) or remove (downgrade). And an autogenerated hash is assigned to […]

Another Way to Dynamically Create New Tasks: Factory Methods

New project, new challenge. This time I wanted to create very similar tasks (in this case to drop indexes), however, I didn’t want to be locked in with doing those similar tasks at the same time (read: in parallel with help from an iterable). So while I will not even pretend to be the originator […]

Why Setting an SLA for Your DAGs Might Be a Very Good Idea

While I feel like I’d already taken plenty of steps to be notified if there’s a problem when a DAG fails, I recently discovered that I hadn’t done anything to catch those scenarios where a DAG takes longer–or in my case, a lot longer–to complete (or fail) than normal. Thus, the need to learn how […]

Complex Formatting of Results in List or Dictionary Comprehensions (or Generators)

I love the power that comes with list (or dictionary) comprehensions or generators in Python. I also despise the code pattern of iterating over object and appending the results to another list. Let’s keep an example simple with a list comprehension performing a single calculation on each value in the original list: In either bits […]