<@ULVA73B9P> Can I obtain the return value of a su...
# ask-marvin
j
@Marvin Can I obtain the return value of a sub-flow if I do not call it directly? For example, I run the sub-flow using run_deployment() instead.
m
It seems that the Prefect documentation doesn't explicitly detail how to directly obtain the return value of a sub-flow when using
run_deployment()
. Typically, when you run a deployment, the flow's results are not directly accessible like they would be if you called the flow function directly. However, you can retrieve the results of a flow run by accessing the flow run's state after it completes. This involves interacting with the Prefect API to query the state of the flow run, which contains the results. Here is a general approach you might take: 1. Run the Deployment: Use
run_deployment()
to execute the deployment. 2. Retrieve Flow Run State: Use the Prefect client to query the state of the flow run. This state will include the result of the flow if it completed successfully. For more precise guidance, you might need to reference the Prefect API documentation or explore the Prefect client capabilities to interact with flow runs and their states. If you're interested in the detailed API usage, you could explore the Prefect client module for querying flow run states.
n
tldr, yes via
flow_run.state.result()
if and only if that flow has persisted its results
👍 1
j
Thank you, I'll play around with it
n
👍
j
This is example rocks, its pretty much what my project is doing. Thanks alot!
catjam 2