<@ULVA73B9P> If I have a FlowRun object that has e...
# ask-marvin
n
@Marvin If I have a FlowRun object that has ended, is it possible to retrieve the duration of the flow?
m
thought for 64.8 seconds
Yes — for an ended
FlowRun
, you can get its duration from
flow_run.total_run_time
. Example:
Copy code
python
duration = flow_run.total_run_time
print(duration.total_seconds())
A few useful details: -
total_run_time
is a
datetime.timedelta
- For a completed flow run, this is usually the best field to use - If you want wall-clock elapsed time instead, you can also compute:
Copy code
python
if flow_run.start_time and flow_run.end_time:
    elapsed = flow_run.end_time - flow_run.start_time
Difference: -
total_run_time
= accumulated runtime tracked by Prefect -
end_time - start_time
= simple elapsed time between start and finish If you want, I can also show how to retrieve the
FlowRun
first using the Prefect client.