https://prefect.io logo
Title
d

Deceivious

04/24/2023, 7:58 AM
@Marvin How do I tag my sub flows?
m

Marvin

04/24/2023, 7:59 AM
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:
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

Deceivious

04/24/2023, 8:00 AM
@Marvin Does this work for prefect v2?
m

Marvin

04/24/2023, 8:00 AM
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

Nate

04/25/2023, 4:54 PM
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
In [1]: from prefect import flow, tags

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

In [3]: @flow
   ...: def foo():
   ...:     with tags("test"):
   ...:         bar()
   ...:
d

Deceivious

04/25/2023, 4:58 PM
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

Nate

04/25/2023, 4:59 PM
gotcha, how are you calling subflows within the parent flow?
d

Deceivious

04/25/2023, 4:59 PM
Subflow.with_options(.....)(.......Param here......)
n

Nate

04/25/2023, 5:13 PM
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

Deceivious

04/25/2023, 5:21 PM
The sub flows are not a seperate deployment.
n

Nate

04/25/2023, 5:22 PM
i understand, given that they're not, you'd probably have to use the client directly to update the flow run with tags
d

Deceivious

04/25/2023, 5:22 PM
I've created a GitHub issue regarding this. Still waiting product team feedback. 😂 Till then bad cluster in UI i guess
👍 1