Alon Samocha
02/04/2025, 10:27 AMMarvin
02/04/2025, 10:27 AMpython
from prefect import flow
@flow
def parent_flow():
parent_attribute = "some_value"
sub_flow(parent_attribute)
@flow
def sub_flow(parent_attribute):
print(f"Received from parent: {parent_attribute}")
if __name__ == "__main__":
parent_flow()
In this example, parent_attribute
is passed from the parent_flow
to the sub_flow
, allowing the subflow to utilize the data from its parent. For more details, you might want to explore the Prefect documentation or the Prefect GitHub repository.Alon Samocha
02/04/2025, 10:28 AMMarvin
02/04/2025, 10:28 AMparent_task_run_id
attribute when creating a subflow run. This ID is associated with the task run that initiated the subflow. Here's a relevant excerpt from the Prefect source code:
python
flow_run = client.create_flow_run(
flow=self.flow,
parameters=self.flow.serialize_parameters(parameters),
state=Pending(),
parent_task_run_id=getattr(parent_task_run, "id", None),
tags=TagsContext.get().current_tags,
)
This snippet shows how the parent_task_run_id
is set when creating a subflow run. However, to access this ID within the subflow, you would typically need to pass it explicitly as a parameter or use a context that retains this information.
For more details, you might want to explore the Prefect documentation or the Prefect GitHub repository.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by