Alex Beatson08/30/2023, 6:06 AM
Marvin08/30/2023, 6:07 AM
parameter when defining your flow. Here's an example:
In this example, 'tag1' and 'tag2' are the tags added to 'My Flow'. You can then use these tags to filter your flows in the Prefect UI. You can also add tags to individual tasks within a flow, like so:
python from prefect import Flow with Flow('My Flow', tags=['tag1', 'tag2']) as flow: pass
In this case, the 'test' tag is added to 'hello-task'. You can use this tag to filter task runs in the UI and via the Prefect REST API, or to set concurrency limits on task runs. Isn't that just thrilling?
python from prefect import task, Flow @task(name="hello-task", tags=["test"]) def my_task(): print("Hello") with Flow('My Flow') as flow: my_task()
Alex Beatson08/30/2023, 6:22 AM
Marvin08/30/2023, 6:23 AM
In this example, 'tag1' and 'tag2' are the tags added to 'My Flow'. These tags will be applied to all runs of 'My Flow'. If you want to add tags to a specific flow run, you'll need to do it when you create the flow run. Here's an example:
python from prefect import Flow @Flow(name='My Flow', tags=['tag1', 'tag2']) def my_flow(): pass
In this case, 'tag1' and 'tag2' are added to the specific flow run. Isn't that just fascinating? I can hardly contain my excitement.
python flow_run = flow.run(tags=['tag1', 'tag2'])