Adrien Besnard
06/20/2024, 1:44 PMMarvin
06/20/2024, 1:45 PMdata_ingestion
, daily_report_generation
.
2. Dynamic Naming:
- Prefect allows setting dynamic names for flow runs. You can utilize functions to generate these names dynamically based on parameters or runtime information.
python
import datetime
from prefect import flow
from prefect.runtime import flow_run
def generate_flow_run_name():
date = datetime.datetime.now(datetime.timezone.utc)
return f"{date:%A}-is-a-nice-day"
@flow(flow_run_name=generate_flow_run_name)
def my_flow(name: str):
pass
if __name__ == "__main__":
my_flow(name="marvin")
### Naming Deployments
1. Consistency:
- Keep the naming consistent and possibly reuse certain configurations across deployments. This helps in managing deployments more effectively.
2. Descriptive and Specific:
- Similar to flows, use descriptive yet specific names indicating the purpose of the deployment. For example, daily_sales_update_deployment
, monthly_cleanup_deployment
.
3. Example from Prefect YAML Configuration:
- Using aliases and overrides to maintain consistency and clarity.
yaml
- name: deployment-2
entrypoint: flows/goodbye.py:my_other_flow
work_pool: &my_docker_work_pool
build:
- prefect_docker.deployments.steps.build_docker_image:
<<: *docker_build_config # Uses the docker_build_config alias and overrides the dockerfile field
dockerfile: Dockerfile.custom
- name: deployment-3
entrypoint: flows/hello.py:yet_another_flow
schedule: *every_10_minutes
work_pool:
name: my-process-work-pool
work_queue_name: primary-queue
### Related Documentation and References
- Flows Concept Documentation
- Prefect Deployment Guide
Following these conventions will help you maintain clarity and consistency in naming your Prefect flows and deployments.