Ruslan
01/15/2021, 1:47 PMAmanda Wee
01/15/2021, 2:38 PMnicholas
01/15/2021, 3:40 PMfrom prefect import Task, Flow
from prefect.tasks.notifications import SlackTask
class GetValue(Task):
def run(self):
return "Test SlackTask!"
flow = Flow("slack-test")
value = GetValue()
slack_task = SlackTask()
slack_task.set_upstream(value, key="message", flow=flow)
or with the functional API like this (both with a data dependency and without shown):
from prefect import task, Flow
from prefect.tasks.notifications import SlackTask
@task
def get_value():
return "Test SlackTask!"
slack_task = SlackTask()
with Flow("slack-test") as flow:
value = get_value()
slack_task(message=value) # data dependencies will automatically create upstream/downstream relationships
slack_task(upstream_tasks=[value]) # if there isn't a data dependency, but you still need to run tasks in a specific order, you can use the `upstream_tasks` kwarg, which takes a list of task references
You can read more about dependencies here 🙂Ruslan
01/15/2021, 3:45 PMnicholas
01/15/2021, 3:50 PMwith Flow("some flow") as flow:
task_1 = t1()
task_2 = t2()
t3(upstream_tasks=[task_1, task_2])
t4(upstream_tasks=[task_1, task_2])
Ruslan
01/15/2021, 3:54 PMnicholas
01/15/2021, 3:57 PMall_finished
trigger for that.Ruslan
01/15/2021, 3:59 PMAmanda Wee
01/15/2021, 4:00 PMRuslan
01/15/2021, 4:02 PMAmanda Wee
01/15/2021, 4:06 PM@prefect.task(trigger=prefect.triggers.all_finished)
decorator too, and probably just return
in the function.Ruslan
01/15/2021, 4:07 PM