Hi everyone, I am just getting started with prefect and am struggling with what is probably a very b...
c
Hi everyone, I am just getting started with prefect and am struggling with what is probably a very basic concept. Is it possible to use a @task decorator with tasks from the task library? My primary use case is orchestrating dbt jobs and I would like to add a state handler for my tests to send a notification on task failure.
k
Hey @Chris McLaughlin, no worries! You don’t need a task decorator with those.
Copy code
from prefect.tasks... import SomeTask

some = SomeTask(state_handlers=[mystatehandler])

with Flow(..) as flow:
    some(x=1, y=2)
c
Ah, way easier than I thought! I'm assuming you could define a trigger in the same manner?
k
Yes the tasks in the task library take in the same arguments as
@task()
. If your task has inputs, you can still stick them in there.
Copy code
some = SomeTask(x=1, y=2, state_handlers=[mystatehandler], triggers=...)
with Flow(...) as flow:
    some()
🙌 1