Shrikkanth
10/18/2022, 5:27 AMdef post_to_slack_on_success(task, old_state, new_state):
if new_state.is_successful():
flow_run = FlowRunView.from_flow_run_id(prefect.context.get("flow_run_id"))
task_run = flow_run.get_task_run(task_run_id=prefect.context.get("task_run_id"))
msg = task_run.get_result()
SlackTask(message=msg).run()
flow.state_handlers.append(slack)
Second flow function try:
def post_to_slack_on_success(task, old_state, new_state):
if new_state.is_successful():
print(new_state)
print(old_state)
print("Result : ", new_state.result, new_state.message)
Screenshot of the alert:Mason Menges
10/18/2022, 5:10 PMShrikkanth
10/19/2022, 4:49 AM