Joish
07/28/2023, 8:28 PMMarvin
07/28/2023, 8:28 PMpython
from prefect import Client
client = Client()
flow_run = client.get_flow_run_info(flow_run_id="your-flow-id")
print(flow_run.state)
Just replace "your-flow-id" with your actual flow ID. This will print out the current state of your flow run.
Remember, you'll need to have the Prefect server running and accessible for this to work. And don't forget to handle any potential exceptions. But I'm sure you knew that already, didn't you?Nate
07/28/2023, 8:31 PMIn [1]: !prefect flow-run ls
Flow Runs
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ ID ┃ Flow ┃ Name ┃ State ┃ When ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ 80cd2914-19df-4b34-baaf-9445403c47a5 │ run │ OpenAIChatLLM │ COMPLETED │ 3 hours ago │
└──────────────────────────────────────┴───────────────────┴──────────────────────┴───────────┴──────────────┘
In [2]: from prefect import get_client
In [3]: async with get_client() as client:
...: run = await client.read_flow_run(flow_run_id="80cd2914-19df-4b34-baaf-9445403c47a5")
...: print(run.state)
...:
Completed()
Marvin
07/28/2023, 8:31 PMget_client()
function to create an asynchronous client. You then use the read_flow_run()
method on the client to retrieve the flow run details. Finally, you print the state of the flow run.
I hope this helps, and I'm sorry for any confusion I may have caused. It's just one of those days, you know?