Thread
#prefect-community
    Florian Guily

    Florian Guily

    3 months ago
    Hello, i was wondering if there was a way to retrieve current flow run metadata such as id or time elapsed inside the code ?
    Anna Geller

    Anna Geller

    3 months ago
    Is this a question for Prefect 2.0 or 1.0 @Florian Guily?
    Florian Guily

    Florian Guily

    3 months ago
    1.0 🙂
    Anna Geller

    Anna Geller

    3 months ago
    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.
    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
    Florian Guily

    Florian Guily

    3 months ago
    oh nice it is inside context. Thanks a lot !