Hello, i was wondering if there was a way to retri...
# prefect-community
f
Hello, i was wondering if there was a way to retrieve current flow run metadata such as id or time elapsed inside the code ?
2
a
Is this a question for Prefect 2.0 or 1.0 @Florian Guily?
f
1.0 🙂
a
the short answer is yes, but for things such as duration, you may need to do more work to get it https://docs.prefect.io/api/latest/utilities/context.html#context
e.g.
Copy code
prefect.context.get("flow_run_id")
prefect.context.get("flow_id")
there is also scheduled_start_time depends on what you want to do, but context is a good place to get more info
there's also FlowRunView https://docs.prefect.io/api/latest/backend/flow_run.html#flowrunview but a bit more advanced and more "heavy" since this actually performs GraphQL queries under the hood
f
oh nice it is inside context. Thanks a lot !
👍 1