Bernhard
03/13/2025, 3:45 PMMarvin
03/13/2025, 3:46 PMprefect.context.get_run_context()
, which provides access to runtime information, including the flow run ID. Here's the relevant documentation link.
Regarding retries, when a flow is retried, a new flow run ID is created. However, for tasks, a new task run is not created when a task is retried; instead, a new state is added to the state history of the original task run. More on this can be found in the task retry documentation.
As for retrieving the old run ID, it appears there's no direct mechanism to fetch previous flow run IDs from within the Prefect context itself. However, if you have implemented caching policies or custom logging, you might have stored these IDs externally. You can refer to the cache policies code for more details on how cache keys are computed, which might give you insights into custom storage solutions.
If you have further specific requirements or setups, feel free to share them, and I can assist you more precisely.Nate
03/13/2025, 3:46 PMNate
03/13/2025, 3:46 PM#[1]
from prefect import flow, runtime
#[2]
@flow(retries=2)
def f():
print(runtime.flow_run.id)
raise ValueError
Nate
03/13/2025, 3:47 PMBernhard
03/13/2025, 4:01 PM