Is there a way to return persisted results via the...
# prefect-cloud
r
Is there a way to return persisted results via the PREFECT API? I mean the actual results, not meta data šŸ™‚
āœ… 1
s
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
OK, thanks for the quick answer :)
n
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
Copy code
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
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?