Is there a callback for when a flow starts? I see ...
# prefect-community
j
Is there a callback for when a flow starts? I see there are callbacks for on_completion and on_failure
c
Hey jack - there isn't right now; could you describe what you would use such a callback for vs. introducing a few additional lines at the beginning of your flow function?
j
We are using the
on_completion
and
on_failure
callback to point to a function
send_slack_message
We wanted the same functionality for
on_start
, but since it doesn't exist yet, I've added these lines at the top of the flow to manually call
send_slack_message
using the same signature as when the callback happens.
Copy code
context = get_run_context()
    send_slack_message(context.flow, context.flow_run, context.flow_run.state)
It would be tidier for this use case if the
on_start
callback worked. It seems odd to call a callback manually. With prefect v1 we used the same callback for any state change. Then we got slack messages for retries as well.
👍 2