The Prefect documentation provides an overview of how subflows and parent flows are related but doesn't explicitly detail how to retrieve the flow run ID of the parent flow from within a subflow.
In the context of Prefect flows, a subflow run is created when a flow function is called within another flow. The so-called "parent" flow holds this "child" flow (or subflow). The documentation mentions that "the relationship between a child and parent flow is tracked by creating a special task run in the parent flow," which "will mirror the state of the child flow run."
Although the specific method to access the parent flow run ID is not provided, typically, the information about the parent flow would be present in the context or metadata accessible by the subflow. It's possible that Prefect might not directly expose this in an API, as is often the case with many workflow systems, which often expect subflows to be logically isolated.
Based on the available information, I would suggest looking into the Prefect context within your subflow to see if the parent flow run ID is stored there. Otherwise, you may need to pass this information explicitly to the subflow if it is required for your use case.
For more details, you can refer to the documentation on
composing flows.
If you require further assistance, you may want to search through GitHub issues or ask the community for patterns others have used to pass such metadata between parent and subflows.