https://prefect.io logo
Title
s

Sam Cook

02/01/2023, 9:16 PM
Hello! Is there a convenient way to get a Flow's
expected_start_time
from within a task? If I retrieve the context using
get_run_context
and the
expected_start_time
field from within a task, I get a TaskRunContext and the expected start time for the specific task which is different from the flow's
expected_start_time
by a fair margin, depending on how long it took to actually start the current task.
I'm on Prefect version 2.7.1 if that's relevant
c

Christopher Boyd

02/02/2023, 2:33 PM
You should be able to get the flow context
Maybe I’m wrong here, and now I can’t find it but you can return / save expected_start_time from the flow context as a global var that the task can access
global start_time = get_run_context().start_time
s

Sam Cook

02/02/2023, 2:56 PM
I'm using a custom flow that lives in a different file from the task, so I can't use globals to transfer state