Ron Levi
08/04/2024, 7:15 AMNate
08/04/2024, 11:14 PMNate
08/04/2024, 11:15 PMMarvin
08/04/2024, 11:15 PMread_task_runs
method from the Prefect
client to fetch details about task runs. Below is an example that demonstrates how to use this method:
from prefect.client import OrionClient
async def get_task_runs():
async with OrionClient() as client:
task_runs = await client.read_task_runs()
for task_run in task_runs:
print(task_run)
# Make sure to run this in an async environment.
import asyncio
asyncio.run(get_task_runs())
This script sets up an async function get_task_runs
that establishes a connection to the Prefect Orion API client and fetches task runs using the read_task_runs
method. The details of each task run are then printed to the console.
For more detailed examples of Prefect tasks, check out this sample code:
Prefect Code ExampleNate
08/04/2024, 11:17 PM