https://prefect.io logo
Title
t

Tadej Svetina

01/28/2023, 12:02 PM
Hi, I have some thought about versioning and deployment in Prefect and would love to hear some opinions on it: Basically, the usual deployment/versioning I use is like this: to release a new version of it I create a release on Github, this then builds the image of the service and uploads it to repository, using git tag as the version. Then, I update my terraform files for whatever environment I want (dev/staging/prod), and the old service will be replaced by the new one. easy. With prefect, it's a bit more complicated. There are "versions" for flows/deployments. but they are merely attributes/markers. I can not create a Deployment and say "use this flow, with version X.Y", because the version of the flow is pinned down by the Flow object I need to pass in. So the only solution I see here is to bundle the code of the flows into the Agent image (which I need to create anyway due to dependencies), and version this. Then I just update the agent container version in terraform, and I can make sure that the correct version of dpleoyment will be executed. But there is still a problem of how to update deployments easily on prefect server - this unfortunately does not solve it. One more option is to split flow code and deployment code into two different repositories. Then, flow repository can be nicely versioned, and in deployment repo I can create a separate folder for each environment - each environment can then pin down the version of the flows repo it wants to use. It works, but will get messy when I have more flows and would want to version them independently (now I would need a separate repo for each flow, or use some complicated tag scheme). TL;DR: bundling versions/deployment as is done currently in Prefect makes deployment of deployments/flows to multiple environments really clunky.
c

Chris Whatley

01/28/2023, 12:49 PM
My deployments and python deployment scripts are included in my agent image. Haven’t finished it yet, but my plan is to add deployment steps at my codepipeline setup to redeploy the flows or to run the deploys prior to starting the queue listener in the agent service. So the pipeline would be like build image -> deploy flows for “test” queue -> restart test agent with new image -> manual approval -> deploy flows for “prod” queue -> restart prod agent with new image.
t

Tadej Svetina

01/28/2023, 12:52 PM
Got it, so including everything in the agent image seems like a way to go. Btw, do you have separate Deployment per environment, or just separate queue?
c

Chris Whatley

01/28/2023, 1:08 PM
Just a separate test queue that is run on the most recently built image and the deployments for that test queue use “test” blocks to separate from production resources.
And by test blocks I just mean, e.g., having dbt cli configs named
test_dbt_cli
and
prod_dbt_cli