Demid
07/23/2025, 12:32 PMMarvin
07/23/2025, 12:33 PMMarvin
07/23/2025, 12:33 PMpython
from prefect import flow
@flow(tags=["production", "ml-pipeline"])
def my_flow():
# flow code here
pass
# When deploying
flow.from_source(
source="<https://github.com/your-repo>",
entrypoint="path/to/file.py:my_flow",
).deploy(
name="my-deployment",
work_pool_name="my-work-pool",
tags=["production", "ml-pipeline"]
)
2. Work Pool Configuration
When creating a work pool, you can set up matching criteria that will determine which flows run in that pool. You can create a work pool using the CLI:
bash
prefect work-pool create "my-production-pool" --type kubernetes
3. Job Template Configuration
For more advanced routing, you can modify the work pool's job template to include specific matching criteria based on tags and other attributes.
Important Notes:
- Tags specified at the flow level (@flow decorator) will be combined with tags specified during deployment
- Work pool matching is based on exact matches of tags and other criteria
- You can inspect a work pool's configuration using prefect work-pool inspect "pool-name"
- Multiple work pools can match the same criteria, but a flow will only run in one pool at a time
Best Practices:
- Use consistent naming conventions for your tags
- Document your tagging strategy to maintain clarity across teams
- Use specific, meaningful tags that reflect the purpose or requirements of the flow
- Consider using hierarchical tags (e.g., "env:production", "resource:gpu")
If you need more specific information about setting up matching criteria for work pools or have a particular use case in mind, please let me know and I can provide more detailed guidance.