Pooyan
03/13/2025, 11:25 PMMarvin
03/13/2025, 11:25 PMPrefectClient
from the prefect.client.orchestration
module. This client allows you to interact with the Prefect API to retrieve details about flow runs, including their status.
Here's a basic approach to achieve this:
1. Import the necessary module:
python
from prefect.client.orchestration import get_client
2. Use the client to fetch the flow run status:
python
import asyncio
async def get_flow_run_status(flow_run_id):
async with get_client() as client:
flow_run = await client.read_flow_run(flow_run_id)
return flow_run.state.name
# Example usage
flow_run_id = "your-flow-run-uuid"
status = asyncio.run(get_flow_run_status(flow_run_id))
print(f"Flow run status: {status}")
This code snippet sets up an asynchronous function to get the flow run status using its UUID. Make sure to replace "your-flow-run-uuid"
with the actual UUID of your flow run.
For more information, you can explore the Prefect 2.x documentation or the Prefect Client module documentation.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by