Quentin Churet
01/10/2025, 8:31 AMMarvin
01/10/2025, 8:31 AMRunContext
class provides a base context for flow or task runs, which includes data like start time and the client instance used for API communication. However, the documentation doesn't explicitly mention a built-in way to automatically pass the parent context to subflows.
If you want to share data between a parent flow and its subflows, you can manually pass the necessary data as parameters to the subflows. This approach ensures that subflows receive the required context or data from the parent flow.
Here's a simple example of how you might do this:
python
from prefect import flow
@flow
def parent_flow():
context_data = {"key": "value"}
subflow(context_data)
@flow
def subflow(context_data):
print(f"Received context: {context_data}")
parent_flow()
In this example, context_data
is manually passed from parent_flow
to subflow
.
For more details on Prefect's context management, you can check the Prefect context.py source code.Quentin Churet
01/10/2025, 9:01 AMQuentin Churet
01/10/2025, 9:02 AMMarvin
01/10/2025, 9:02 AMRunContext
class. However, it does show key metadata and details about the flow run, such as its start time, status, and any parameters that were passed to it.
If you want to see specific context data in the UI, you can log it or include it in the flow's results or state messages. This way, the information becomes part of the flow's execution record, which can be viewed in the Prefect UI.
For more details on Prefect's context management, you can refer to the Prefect context.py source code.