global_policy
prefect.server.orchestration.global_policy
Bookkeeping logic that fires on every state transition.
For clarity, GlobalFlowpolicy
and GlobalTaskPolicy
contain all transition logic
implemented using [BaseUniversalTransform
][prefect.server.orchestration.rules.BaseUniversalTransform].
None of these operations modify state, and regardless of what orchestration Prefect REST API might
enforce on a transition, the global policies contain Prefect’s necessary bookkeeping.
Because these transforms record information about the validated state committed to the
state database, they should be the most deeply nested contexts in orchestration loop.
Functions
COMMON_GLOBAL_TRANSFORMS
Classes
GlobalFlowPolicy
Global transforms that run against flow-run-state transitions in priority order.
These transforms are intended to run immediately before and after a state transition is validated.
Methods:
priority
GlobalTaskPolicy
Global transforms that run against task-run-state transitions in priority order.
These transforms are intended to run immediately before and after a state transition is validated.
Methods:
priority
SetRunStateType
Updates the state type of a run on a state transition.
SetRunStateName
Updates the state name of a run on a state transition.
SetStartTime
Records the time a run enters a running state for the first time.
SetRunStateTimestamp
Records the time a run changes states.
SetEndTime
Records the time a run enters a terminal state.
With normal client usage, a run will not transition out of a terminal state. However, it’s possible to force these transitions manually via the API. While leaving a terminal state, the end time will be unset.
IncrementRunTime
Records the amount of time a run spends in the running state.
IncrementFlowRunCount
Records the number of times a run enters a running state. For use with retries.
RemoveResumingIndicator
Removes the indicator on a flow run that marks it as resuming.
IncrementTaskRunCount
Records the number of times a run enters a running state. For use with retries.
SetExpectedStartTime
Estimates the time a state is expected to start running if not set.
For scheduled states, this estimate is simply the scheduled time. For other states, this is set to the time the proposed state was created by Prefect.
SetNextScheduledStartTime
Records the scheduled time on a run.
When a run enters a scheduled state, run.next_scheduled_start_time
is set to
the state’s scheduled time. When leaving a scheduled state,
run.next_scheduled_start_time
is unset.
UpdateSubflowParentTask
Whenever a subflow changes state, it must update its parent task run’s state.
UpdateSubflowStateDetails
Update a child subflow state’s references to a corresponding tracking task run id in the parent flow run
UpdateStateDetails
Update a state’s references to a corresponding flow- or task- run.