I think the answer to your question is yes - the hooks are ignored when a task already has a cached result.
Looking in
engine.py
, the
on_completion
and
on_failure
hooks for tasks get called during the task run here.
But if there's a cached result for a task, the Prefect API rejects the proposal to transition the task from PENDING -> RUNNING and instead returns the terminal state with the cached result attached.
When that happens, the
state.is_running()
check here is false, and block of code with the hook call gets skipped.
s
scott
04/21/2023, 11:28 PM
Thanks very much 🙏 I wish there was a
on_exit
that would run no matter what the end state - but I’ve hacked something together to get around this (to trigger whether a task state is failed/completed/cached)
r
Ryan Peden
04/21/2023, 11:38 PM
That might be worth opening a GitHub issue for; it sounds like a reasonable feature request.
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.