https://prefect.io logo
Title
r

Robin

03/31/2023, 2:28 PM
Is there a way to return persisted results via the PREFECT API? I mean the actual results, not meta data šŸ™‚
āœ… 1
s

Sahil Rangwala

03/31/2023, 7:16 PM
You are able to view the results via the api if you stream the results to logs and then query the logs via the Rest Api
r

Robin

03/31/2023, 7:17 PM
OK, thanks for the quick answer :)
n

Nate

04/02/2023, 9:24 PM
hi @Robin - results can be accessed without sending them to the logs. If the persisted result exists, you can retrieve the result attached to the state of a flow run like
In [14]: !prefect flow-run ls | ag  b99be877
ā”‚ b99be877-74c0-4522-ba75-74d102a479a9 ā”‚ Execute LLM Call ā”‚ Calling langchain.llms.openai ā”‚ COMPLETED ā”‚ 6 days aā€¦ ā”‚

In [15]: from uuid import UUID

In [16]: from prefect import get_client

In [17]: async with get_client() as client:
    ...:     flow_run = await client.read_flow_run(flow_run_id=UUID("b99be877-74c0-4522-ba75-74d102a479a9"))
    ...:     print(flow_run.state.result())
    ...:
None
r

Robin

04/03/2023, 9:37 AM
Oh, that is much better šŸ‘Œ
šŸ‘ 1
What is the most elegant way to stream task progress? e.g. I guess "printing progress to the logs and then querying the logs via REST API" is one option, but maybe there is as well a better option for that?