psimakis
10/01/2020, 11:28 AMfrom prefect.tasks.shell import ShellTask
from prefect import Flow
a = ShellTask()
commands = [
'ls',
'ls -l',
'invalidcommand'
]
with Flow('test') as flow:
b = a.map(commands)
# send a single slack nofiication
# that summarize the states of mapped tasks
send_slack_notification()
The purpose of this slack notification is to summarize the states of mapped tasks by displaying the percentage of successfully mapped tasks. In the case above, this percentage will be 66.6% (the last command will fail).
I tried to approach the problem using triggers and state handlers but I couldn't find a clean way to achieve the goal.
Have you been in this situation before? Any hint?
Thanks in advance!nicholas
b
, and then pass that result to your send_slack_notification
task.
from prefect.tasks.shell import ShellTask
from prefect import Flow
#... other stuff
with Flow('test') as flow:
b = a.map(commands)
# send a single slack notification
# that summarize the states of mapped tasks
send_slack_notification(b)