Ravish Mallya
08/14/2025, 7:28 AMMarvin
08/14/2025, 7:28 AMMarvin
08/14/2025, 7:35 AMchildren or group:alpha). The UI can filter by tags, and you can query by tag from a parent flow before calling them.
- Naming convention: Use a prefix or namespace in deployment names, e.g. etl/child-foo, etl/child-bar. Handy for humans and for pattern-based selection when deploying from prefect.yaml, but API lookups by tag are cleaner.
How to tag deployments
- Code-based deploy:
from prefect import flow
@flow
def child_a(): ...
@flow
def child_b(): ...
child_a.deploy(name="etl/child-a", work_pool_name="...", tags=["children", "group:etl"])
child_b.deploy(name="etl/child-b", work_pool_name="...", tags=["children", "group:etl"])
- YAML-based deploy (excerpt):
deployments:
- name: etl/child-a
entrypoint: child_a.py:child_a
tags: ["children", "group:etl"]
- name: etl/child-b
entrypoint: child_b.py:child_b
tags: ["children", "group:etl"]
Triggering N children from a parent
- Query deployments by tag, then call each with run_deployment. Example (async parent for simplicity):
from prefect import flow
from prefect.deployments import run_deployment
from prefect.client.orchestration import get_client
from prefect.client.schemas.filters import DeploymentFilter, DeploymentFilterTags
@flow
async def parent():
async with get_client() as client:
deployments = await client.read_deployments(
deployment_filter=DeploymentFilter(
tags=DeploymentFilterTags(any_=["children"])
)
)
for d in deployments:
# full name is "<flow_name>/<deployment_name>"
await run_deployment(
name=f"{d.flow_name}/{d.name}",
parameters={"foo": "bar"},
as_subflow=True, # keeps lineage to the parent
tags=["launched-by-parent"] # tags on the created flow runs
)
Notes and niceties:
- CLI: prefect deployment ls can filter by --flow-name but not by tag. For tags, use the UI or the Python client.
- prefect deploy --name accepts patterns to select which deployments from prefect.yaml to deploy (e.g., --name "etl/*").
- If you really prefer names over tags, you can fetch deployments and filter d.name.startswith("child-") in Python, but tags are what they were invented for.
Docs, in case you like proof:
- Deployments concepts: Docs – Deployments
- prefect.yaml guide: Docs – prefect.yaml
If you tell me whether you care more about UI grouping or programmatic selection, I can tailor the example further. Either way, your parent can easily wrangle its unruly children—lucky it.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