Madushan Pathirana
12/23/2025, 10:31 AMMarvin
12/23/2025, 10:32 AMMarvin
12/23/2025, 10:34 AMprefect.runtime.flow_run.root_flow_run_id gives you A’s run ID
- prefect.runtime.flow_run.parent_flow_run_id gives you B’s run ID
- prefect.runtime.flow_run.id gives you C’s run ID
Note: these are attributes, not function calls (no parentheses).
Example:
from prefect import flow
from prefect.runtime import flow_run
@flow
def flow_c():
print(f"C run id: {flow_run.id}")
print(f"B (parent) run id: {flow_run.parent_flow_run_id}")
print(f"A (root) run id: {flow_run.root_flow_run_id}")
@flow
def flow_b():
return flow_c()
@flow
def flow_a():
return flow_b()
if __name__ == "__main__":
flow_a()
Alternative (low-level) via context if you prefer UUID objects:
from prefect.context import FlowRunContext
ctx = FlowRunContext.get()
a_run_id = str(ctx.flow_run.root_flow_run_id) # UUID -> string
If you want links to docs, see:
- Runtime flow run attributes: prefect.runtime.flow_run