Hey, I have a flow with manual task. I added a state handler, in order to post a Slack Message in a channel, to let know that a task is waiting for approval. Is there a way to print some kind of link to the task is running?
k
Kevin Kho
02/08/2022, 9:45 PM
Did the state handler not fire? Can I see it?
s
Santiago Gonzalez
02/08/2022, 9:47 PM
Yeah, the state handler is being triggered. But I wanted to print in slack a link to the current execution, if there is a way.
k
Kevin Kho
02/08/2022, 9:48 PM
Ah I know what you are saying. You are using the
slack_notification
right?
Kevin Kho
02/08/2022, 9:51 PM
You can make a state handler like this and used the paused state and fire a message using the SlackTask instead. It’s configurable.
Copy code
from prefect.engine.state import Paused
def post_to_slack_on_failure(task, old_state, new_state):
if isinstance(new_state, Paused):
SlackTask(message=msg).run()
return new_state
Kevin Kho
02/08/2022, 9:51 PM
And then you can pull the task run id and stuff from the context
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.