Why it's beneficial to separate flow storage from code dependencies required by your flow?

Prefect 2.0 no longer requires DAG preregistration. You can point to your flow file in your deployment spec, and Prefect will download it at runtime rather than using flow code baked (almost “hardcoded”?) into the image. This allows you for much greater flexibility:

  • your flow may change without having to recreate a deployment - e.g., you commit changes to flow code to your Git repository or upload a modified file to S3, and you don’t need to perform any costly operations of building all code dependencies along with your flow
  • based on our experience with Prefect users, the code dependencies usually change much less frequently than the flow code - separating concerns here allows you to have your Docker image or Kubernetes job with a fairly static definition while flow code remains fully dynamic without the need for costly redeployments
  • it significantly reduces latency in deploying new flow versions
  • it often reduces user’s costs due to fewer image versions needing to be stored (images with all dependencies can range from 100MB up to several GB, while flow code is a lightweight single python file)
1 Like