Jordan Fisher
08/02/2024, 8:30 AMMarvin
08/02/2024, 8:30 AMpython
from prefect import flow
from prefect.runtime import flow_run
@flow
def generate_flow_run_url():
flow_run_id = flow_run.id
account_id = "your_account_id" # Replace with your actual account ID
workspace_id = "your_workspace_id" # Replace with your actual workspace ID
base_url = "<https://app.prefect.cloud>"
url = f"{base_url}/account/{account_id}/workspace/{workspace_id}/flow-runs/flow-run/{flow_run_id}"
return url
if __name__ == "__main__":
print(generate_flow_run_url())
This script constructs the URL using the runtime variables and your specific account and workspace IDs. Adjust the account_id
and workspace_id
accordingly.
For more detailed information, you can refer to the links provided in the search results:
- Prefect Flows Documentation
- Prefect Automations Documentation
If you have any further questions or need additional assistance, please let me know.Jordan Fisher
08/02/2024, 8:43 AMMarvin
08/02/2024, 8:44 AMprefect.runtime.flow_run.get_flow_run_ui_url
indeed does provide the URL for viewing the flow run in the Prefect UI.
Here's a simple example to use it within your flow:
python
from prefect import flow
from prefect.runtime.flow_run import get_flow_run_ui_url
@flow
def display_flow_run_url():
flow_run_url = get_flow_run_ui_url()
print(f"Flow run URL: {flow_run_url}")
if __name__ == "__main__":
display_flow_run_url()
This will fetch and print the URL to the Prefect UI for the current flow run.
For more detailed information, you can refer to the links provided in the search results:
- Runtime Context Guide
- Automations Documentation
If you have any more questions or need further assistance, feel free to ask!