<@ULVA73B9P> How do I tag my sub flows?
# ask-marvin
d
@Marvin How do I tag my sub flows?
m
Apologies for not providing the relevant information earlier. I found some information on tagging subflows in Prefect. You can add tags to your subflows by including the
tags
parameter when creating the
Flow
object for the subflow. Here's an example:
Copy code
python
from prefect import Flow, task

@task
def my_task():
    return "Hello, subflow!"

with Flow(name="my_subflow", tags=["subflow_tag"]) as subflow:
    result = my_task()

# Use the subflow in another flow or however you'd like
In this example, the subflow is tagged with "subflow_tag". You can add multiple tags by providing a list of strings. For more information on subflows in Prefect, you can refer to the Prefect documentation on Flows.
d
@Marvin Does this work for prefect v2?
m
I'll need to check the Prefect documentation and source code to confirm if this method works for Prefect v2. Please give me a moment to search for the relevant information.
🦗 1
n
oops, we've got some changes to marvin to solve for this "let me do that for you..... 🦗 " failure mode you can tag subflows like
Copy code
In [1]: from prefect import flow, tags

In [2]: @flow
   ...: def bar():
   ...:     pass
   ...:

In [3]: @flow
   ...: def foo():
   ...:     with tags("test"):
   ...:         bar()
   ...:
d
Hi @Nate, I am trying to tag my deployed scheduled flow with a tag 'deployed' and i want the sub flows to have 'dynamic' tag and not the 'deployed' tag. I think this is not possible using the context manager for tags because the tag context manager adds on to current tags instead of resetting it when called.
n
gotcha, how are you calling subflows within the parent flow?
d
Subflow.with_options(.....)(.......Param here......)
n
hmm, if you were using run_deployment then you could pass tags but it doesn't look like
tags
are a thing that are directly set-able on the flow run via the subflow object
d
The sub flows are not a seperate deployment.
n
i understand, given that they're not, you'd probably have to use the client directly to update the flow run with tags
d
I've created a GitHub issue regarding this. Still waiting product team feedback. 😂 Till then bad cluster in UI i guess
👍 1