https://prefect.io logo
b

brian

01/19/2022, 7:03 PM
Hi prefectionists! I’m wanting to use a link to a flow run that I’m running in prefect cloud as metadata of sorts, so I can trace long-running queries back to the flow run easily. Are there env vars populated automatically (e.g. FLOW_RUN_ID, FLOW_ID, etc) that would allow me to construct this link, or more generally, is there any way for a task to automatically get info about it’s own identity?
k

Kevin Kho

01/19/2022, 7:05 PM
Hi @brian, you would get it from context during run time.
Copy code
@task
def make_link():
    flow_id = prefect.context.get("flow_id")
    flow_run_id = prefect.context.get("flow_run_id")
Available things can be found here
👍 1
b

brian

01/19/2022, 7:09 PM
Thanks!
4 Views