Demid
07/23/2025, 10:58 AMMarvin
07/23/2025, 10:58 AMMarvin
07/23/2025, 10:59 AMpython
@flow(tags=['test'])
is not correct for Prefect 3.x. In Prefect 3.x, tags are not specified directly in the flow decorator. Instead, you should use the tags context manager. Here's the correct way to add tags to a flow:
python
from prefect import flow
from prefect.context import tags
with tags("test"):
@flow
def my_flow():
# your flow code here
pass
Or if you need multiple tags:
python
with tags("test", "development"):
@flow
def my_flow():
# your flow code here
pass
The flow decorator itself has various other options you can use (as shown in the signature above), such as:
- `name`: Custom name for the flow
- `description`: Description of what the flow does
- `version`: Version of the flow
- `retries`: Number of times to retry the flow
- And many others
But for tags specifically, you need to use the context manager approach. This gives you more flexibility as you can apply tags dynamically at runtime.
Would you like me to explain more about how to use tags effectively in Prefect 3.x or show you other flow decorator options that might be useful?