https://prefect.io logo
Title
l

Leela Surya Teja Mangamuri

04/27/2023, 12:32 AM
Hi @Prefect I am getting this error ImportError("cannot import name 'runtime' from 'prefect' (/usr/local/lib/python3.8/site-packages/prefect/__init__.py)")
1
s

Serina

04/27/2023, 12:43 AM
Hi @Leela Surya Teja Mangamuri! We introduced
prefect.runtime
access in 2.8.6 📃 Feel free to check out our release notes for details on all of our features and enhancements 🙂 https://github.com/PrefectHQ/prefect/blob/main/RELEASE-NOTES.md#prefectruntime-for-context-access
l

Leela Surya Teja Mangamuri

04/27/2023, 12:45 AM
what shall I use in 2.8.2?
prefect context is not working in 2.8.2
s

Serina

04/27/2023, 12:47 AM
Hi @Leela Surya Teja Mangamuri can you be more specific when you say it is not working?
l

Leela Surya Teja Mangamuri

04/27/2023, 12:48 AM
I need to get shceduled time using context
This feature is not available in 2.8.2
s

Serina

04/27/2023, 1:02 AM
Diving a bit into the code, we can see that
prefect.runtime.flow_run.scheduled_start_time
is written like so: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runtime/flow_run.py#L113 So we should be able to access it like:
from prefect.context import FlowRunContext

flow_run_ctx = FlowRunContext.get()
scheduled_start_time = flow_run_ctx.flow_run.expected_start_time
l

Leela Surya Teja Mangamuri

04/27/2023, 2:53 AM
Thanks'