<@ULVA73B9P> Can I somehow run a function on Late ...
# marvin-ai
m
@Marvin Can I somehow run a function on Late flow runs similarly to the @flow(on_cancellation=[...]) way? I'm not seeing on_late in the API docs.
m
thought for 168.9 seconds
Short answer: not with a flow hook. In Prefect 3.x, there is no
on_late
argument on
@flow
. The supported flow hooks are: -
on_completion
-
on_failure
-
on_cancellation
-
on_crashed
-
on_running
So if you're looking for something parallel to:
Copy code
python
@flow(on_cancellation=[...])
there isn't an equivalent:
Copy code
python
@flow(on_late=[...])  # not supported
Why:
Late
is emitted as a flow-run state/event, but Prefect does not expose it as a flow hook. Verified in the docs/source for state change hooks and flow-run events: - State change hooks - Flow run events Recommended approach: use an Automation that listens for the
prefect.flow-run.Late
event. That’s the robust/server-side way to react to late runs: - Create automations - Event triggers - Automations Conceptually, you want: - trigger on
prefect.flow-run.Late
- then run an action like a notification, webhook, or triggered deployment A minimal example pattern is:
Copy code
json
{
  "trigger": {
    "type": "event",
    "posture": "Reactive",
    "expect": ["prefect.flow-run.Late"]
  }
}
One important note from Prefect docs: hooks are client-side / best-effort, while automations are the preferred mechanism for reliable reactions to flow-run state changes. If you want, I can give you either: 1. a Prefect Cloud automation example for Late runs, or 2. a Python/CLI example to create one.