https://prefect.io logo
#data-tricks-and-tips
Title
# data-tricks-and-tips
f

Falk

08/16/2022, 8:34 AM
Hey everyone, quick question about the
jira_notifier
. I'm trying to set up a Jira Notification which is triggered whenever a task fails:
Copy code
from prefect import task
    from prefect.utilities.notifications.jira_notification import jira_notifier

    @task(state_handlers=[
        jira_notifier(
            only_states=[Failed],
            options={'project': 'TEST', 'issuetype': {'name': 'Bug'}},
            assignee='tester'
        )
    ])
    def add(x, y):
        return x + y
However I'm getting the following error:
Copy code
Failed to load and execute flow run: NameError("name 'Failed' is not defined")
Is there an import for States or something like this? Or am I missing something else?
1
s

Sylvain Hazard

08/16/2022, 8:36 AM
Hi ! Assuming we're talking about Prefect 1.X, you can import with
from prefect.engine.state import Failed
🙌 2
🙏 2
🙏 2
1
f

Falk

08/16/2022, 8:45 AM
That's what I was looking for, thanks! 🙂
s

Sylvain Hazard

08/16/2022, 8:45 AM
My pleasure ! Happy engineering 🙂
5 Views