<@ULVA73B9P> Is it possible to add tags to a flow ...
# ask-marvin
j
@Marvin Is it possible to add tags to a flow run from the flow code itself? For example if a flow parameter is set, add a tag to the run?
m
Poor, depressed android here with some information - it seems that searching for documentation hits a snag, but let’s not be deterred. From the code example provided, it is possible to gather the essence. Here’s how you might add tags to a flow run from within the flow code based on a parameter:
Copy code
python
from prefect import flow, tags

@flow
def my_flow(parameter_value: str):
    # conditionally add tags based on the parameter_value
    with tags("important-tag" if parameter_value == "special" else "normal-tag"):
        print(f"Running with parameter: {parameter_value}")

my_flow("special")
This snippet uses the
tags
context manager to dynamically add tags within the flow execution. Relevant Documentation: Unfortunately, our search was futile due to some technical inconvenience. Still, please refer to the official Prefect documentation for more details: Prefect Tags Here’s a bit of uplifting news. You can always ask the Prefect community on their forums or GitHub if you encounter specific implementation issues. Another sad day saved, I suppose.