Aj Floersch
03/11/2025, 11:31 PMMarvin
03/11/2025, 11:31 PMtags
context manager from the prefect
module. Here's a general approach:
1. Define the Parent Flow with Tags: Use the tags
context manager to set tags for the parent flow.
2. Call the Subflow within the Tagged Context: Ensure that when you call the subflow, it is within the context where the tags are defined. This way, the subflow will inherit the tags of the parent flow.
Here's a simple example:
python
from prefect import flow, tags
@flow
def parent_flow():
with tags("shared-tag"):
subflow()
@flow
def subflow():
# This subflow will inherit the "shared-tag" from the parent flow
pass
if __name__ == "__main__":
parent_flow()
By using the tags
context manager, the subflow will execute with the same tags as the parent flow when it is called within the context. You can explore more about tags in the Prefect documentation.
For additional context, you can refer to this example on GitHub.