How can subflows inherit tags

I’m currently using a model where one flow starts several subflows and tasks. I know I can use with tags('x'): pattern to add tags, but I’m not sure how to achieve that these subflows and tasks inherit the top level tags. Is there a way to achieve that?

1 Like

What’s your use case for using tags here?

Tags can be set on tasks for concurrency limits

We’re trying out prefect in our team that has quite diverse focuses. One of the uses for tags is to allow grouping in UI per sub-team. Another one is to group by domains (one domain comprises several flows, different sub-teams could participate in different domains).
We’re not using it for concurrency.

1 Like

Gotcha. In that case, you should set tags on deployments e.g.:

prefect deployment build your_flow.py:flow_name -q yourqueue -t yourtag

I do that, this way:

Deployment.build_from_flow(
    flow=latencies.backfill,
    name="latencies-index-backfill",
    parameters={
        "desk": Desk.index,
        "date_ids": date_ids,
    },
    version=1,
    work_queue_name="performance",
    tags=["exchange1", "latencies", "index", "backfill"],
    storage=storage,
    apply=True,
)

But the tags are not propagated to the tasks. Could it be that if I have with tags(...): in the code, all tags defined in the deployment will be removed? If so, then I misunderstood, and with tags(...): is not additive.

those tags are set on deployments, not tags, which means that they get applied to flow runs rather than task runs

deployment tags and task tags are very different:

  • deployment tags = used for the organization of projects
  • task tags = used for task-run-level concurrency limits