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 -q yourqueue -t yourtag

I do that, this way:

        "desk": Desk.index,
        "date_ids": date_ids,
    tags=["exchange1", "latencies", "index", "backfill"],

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

I’m having a similar issue - I have a flow that has several subflows. I add tags to the deployment on the parent flow, but when the subflows run they don’t have the tags applied. Is there a way to have subflows inherit the tags of their parent flow?

why would you want to do that? tags are helpful for deployments, they don’t play any role on flows - you can’t even attach tags to flows, only to deployments

tags are helpful for deployments, they don’t play any role on flows

I don’t really see it this way because tags are shown in the “Flow Runs” list (and on a flow runs page), so they are related to flows in some way (or specifically a flow run). We use tags on flow runs to indicate how they were created (e.g. “auto-scheduled”, “cloud-function”), but the subflows (which were created the same way) don’t get any tags.

I understand why filtering this way could be useful, so worth opening a feature request as a GitHub issue and we can see whether we can add it. do you want to open a GitHub issue?