jpuris
09/19/2022, 6:38 PMSam Garvis
09/19/2022, 6:51 PMjpuris
09/19/2022, 6:55 PMMason Menges
09/19/2022, 7:00 PMjpuris
09/19/2022, 7:01 PMMason Menges
09/19/2022, 7:02 PMjpuris
09/19/2022, 7:09 PMexpected_start_time
(A) from flow context and compare it with current time - 5 minutes
(B), if A < B, then have flow complete without running any tasks.
There are couple of issues with my idea and it feels fairly hacky 😞
What would be the recommended approach to achieve something like this?Mason Menges
09/20/2022, 3:41 PMjpuris
09/20/2022, 3:53 PMfrom prefect import flow, context
@flow(name="Hello Flow")
def hello_world():
ctx = context.get_run_context()
print('================')
print('----CONTEXT----')
print(ctx)
print('----CONTEXT, start_time ----')
print(ctx.get().start_time)
print('----CONTEXT, expected_start_time ----')
print(ctx.get().expected_start_time)
print('================')
if __name__ == '__main__':
hello_world()
I found this out solely by experimentation.
I suspect I’m querying the flow’s context incorrectly with ctx.get().expected_start_time
as it produces following error (full run in attachment)
...
AttributeError: 'FlowRunContext' object has no attribute 'expected_start_time'
...
If you have any docs on mechanics of Context object for prefect 2, please do point me in the correct direction 🙏Mason Menges
09/20/2022, 4:10 PMfrom prefect import context
test_context = context.FlowRunContext.get()
start_time = test_context.flow_run.expected_start_time
jpuris
09/20/2022, 4:14 PMflow_run=FlowRun(..., estimated_run_time=foo)
.
Thank you, thank you, thank you!Mason Menges
09/20/2022, 4:32 PM