https://prefect.io logo
Title
m

Mrityunjoy Das

02/28/2023, 2:29 AM
Is there any way to get flow run url from the flow ?
r

Rob Freedy

02/28/2023, 3:03 AM
I do not believe there is a flow run URL in the context, but you could infer the URL for a flow run as it is in the format:
<https://app.prefect.cloud/account/><account_id>/workspace/<workspace_id>/flow-runs/flow-run/<flow_run_id>
You can use the
get_run_context()
to get the flow run id and
get_settings_context()
to get the workspace and account ids associated with the flow run. Here are the docs for the Prefect context that you can use in your Prefect code
j

jack

03/22/2023, 10:30 PM
Can you point me to the correct attribute names within the
SettingsContext
that will provide
workspace_id
and
account_id
? I am not seeing them.
Okay here it is:
from prefect.context import get_settings_context()
get_settings_context().settings.PREFECT_API_URL
The `PREFECT_API_URL`contains within it the account_id and the workspace_id