Adam
07/06/2025, 6:30 PMMarvin
07/06/2025, 6:30 PMMarvin
07/06/2025, 6:31 PMyaml
deployments:
- name: daily-etl
entrypoint: flows/etl.py:main_flow
schedule:
cron: "0 0 * * *"
tags: ["etl", "production"]
- name: hourly-metrics
entrypoint: flows/metrics.py:metrics_flow
schedule:
interval: 3600
tags: ["metrics", "production"]
- name: weekly-cleanup
entrypoint: flows/maintenance.py:cleanup_flow
schedule:
cron: "0 0 * * 0"
tags: ["maintenance"]
However, there might be cases where multiple files make sense:
- When deployments are managed by different teams
- If you have a very large number of deployments with different lifecycle management needs
- When deployments have significantly different security or access requirements
The documentation provides more details about deployment configuration options at: https://docs-3.prefect.io/v3/how-to-guides/deployments/prefect-yaml
Sigh - I suppose I should mention that while this might seem like a trivial organizational decision, getting it right early can save you from the existential dread of deployment management chaos later on.Adam
07/06/2025, 6:33 PMMarvin
07/06/2025, 6:33 PMMarvin
07/06/2025, 6:36 PMyaml
deployments:
# Data Ingestion Flows
- name: customer-data-ingest
entrypoint: flows/ingestion/customer.py:ingest_flow
tags: ["ingestion", "customers"]
- name: product-data-ingest
entrypoint: flows/ingestion/product.py:ingest_flow
tags: ["ingestion", "products"]
# Transform Flows
- name: customer-transform
entrypoint: flows/transform/customer.py:transform_flow
tags: ["transform", "customers"]
# Reporting Flows
- name: daily-sales-report
entrypoint: flows/reporting/sales.py:report_flow
tags: ["reporting", "sales"]
2. Use Clear Section Comments
yaml
deployments:
# ======================
# CRITICAL PRIORITY FLOWS
# ======================
- name: core-customer-sync
description: "Mission-critical customer synchronization"
tags: ["critical", "sync"]
# ======================
# SCHEDULED BATCH FLOWS
# ======================
- name: nightly-batch
description: "Nightly data processing"
tags: ["batch", "nightly"]
3. Consistent Formatting Pattern
yaml
deployments:
- name: flow-name # Always first
description: "Clear description" # Always second
entrypoint: path/to/flow.py # Always third
schedule: # Consistent order for
cron: "0 0 * * *" # optional elements
tags: [] # Always last
4. Use Meaningful Prefixes
yaml
deployments:
- name: etl-customer-daily
entrypoint: flows/etl/customer.py:daily_flow
- name: etl-customer-hourly
entrypoint: flows/etl/customer.py:hourly_flow
- name: ml-training-weekly
entrypoint: flows/ml/train.py:training_flow
Key Organizational Principles:
1. Consistency: Whatever pattern you choose, maintain it throughout the file
2. Searchability: Use consistent naming patterns to make grep/search effective
3. Grouping: Keep related deployments together
4. Documentation: Use comments to explain groups or complex configurations
5. Spacing: Use whitespace to improve readability between sections
Additional Tips:
- Use meaningful, consistent tags for easier filtering and management
- Keep descriptions clear and informative
- Consider adding a header comment block with maintenance information
- Use environment variables for values that change between environments
Example Header:
yaml
# =============================================
# Prefect Deployment Configuration
# =============================================
# Last Updated: 2023-11-14
# Team: Data Engineering
# Contact: <mailto:data-team@company.com|data-team@company.com>
#
# Deployment Groups:
# - Data Ingestion
# - Transformations
# - Reporting
# =============================================
deployments:
# Deployment definitions follow...
Oh, the irony of bringing order to chaos through yet another YAML file. At least this one won't try to indent itself to death like most do.
Remember, the goal isn't just organization for its own sake - it's about making the file maintainable and understandable by both humans and machines. Choose a pattern that makes sense for your team's workflow and stick to it consistently.