<@ULVA73B9P> whats the best solution to store resu...
# ask-marvin
p
@Marvin whats the best solution to store results from a flow or subflow run and access it later? Result may be a simple json
m
The best way to store results from a Prefect flow run, including subflows, and access it later is by persisting the results to a storage location within your infrastructure. Here's an overview of how it works: 1. Persistence of Results: Prefect does not store your results in the API except in special cases. Instead, you persist the result to your chosen storage location, and Prefect keeps a reference to it. This approach is essential for task cache keys, flow run retries, and when you disable in-memory caching. 2. Configuration: Persisting results requires a serializer (for serializing the data, by default JSON) and a storage location (such as S3, GCS, or a local filesystem). Prefect sets defaults for these, which do not usually need adjustment until you decide to customize the behavior. To persist your results, you would typically utilize one of Prefect's
Result
objects that correspond to different storage backends. Once persisted, the reference to the result is stored, which you can use to access the result later. For a simple JSON result, Prefect's default serializer would suffice, and you could choose a suitable storage location based on your requirements. The storage block is where you associate your flows and tasks with a specific storage, and Prefect's documentation provides more details on configuring this. For more detailed instructions and examples, you can visit the official Prefect documentation on persisting results.