Adeel Shakir
09/19/2024, 11:21 AMMarvin
09/19/2024, 11:21 AMAdeel Shakir
09/19/2024, 11:25 AMMarvin
09/19/2024, 11:26 AMpython
from prefect import flow
@flow
def example_flow():
print("Running Example Flow")
if __name__ == "__main__":
flow_run = example_flow.with_options(tags={"manual"})
flow_run()
Alternatively, you can add custom metadata while creating the flow run from the CLI or API.
2. Exclude Tag in Automations:
Set up an automation that triggers an alert unless the flow run includes the "manual" tag.
For more details, refer to the Prefect 2.x Automations Guide.
#### Prefect 3.x
1. Add Tag on Manual Trigger:
Similar to Prefect 2.x, but you might need specific 3.x adaptations:
python
from prefect import flow
@flow
def example_flow():
print("Running Example Flow")
if __name__ == "__main__":
from prefect.client import get_client
from prefect.orion.schemas.filters import FlowRunFilter
client = get_client()
example_flow.run(tags={"manual"})
2. Configure Automation:
Use the automations API or UI to create a trigger condition that excludes flow runs tagged as "manual".
Here’s a detailed guide on Prefect 3.x Automations and Triggers and Custom Triggers.
Following these steps ensures that your automations will only send alerts for scheduled runs and ignore any manual triggers, keeping your notifications relevant and precise. Let me know if you have more questions or need further assistance!