<@ULVA73B9P> I would like to know how to add tags ...
# ask-marvin
p
@Marvin I would like to know how to add tags when i deploy a pipeline into prefect
m
thought for 302.2 seconds
Great question! Assuming you’re on Prefect 3.x, you can add tags to your deployment at creation time. Here are the common ways: Python API - If you deploy from code with `flow.deploy(...)`:
Copy code
from prefect import flow

@flow
def my_flow():
    ...

my_flow.deploy(
    name="my-deployment",
    work_pool_name="my-pool",
    tags=["production", "etl", "team-data"]
)
- If you deploy from source:
Copy code
from prefect import flow

my_flow = flow.from_source(
    source="<https://github.com/org/repo>",
    entrypoint="flows.py:my_flow",
)

my_flow.deploy(
    name="my-deployment",
    work_pool_name="my-pool",
    tags=["production", "etl", "team-data"]
)
CLI - With the
prefect deploy
command, pass
--tag
(repeatable):
Copy code
prefect deploy ./flows.py:my_flow -n my-deployment \
  --tag production \
  --tag etl \
  --tag team-data
Notes - Tags are for organization and filtering; they do not route work. Use work pools/queues for routing. - Deployment tags are merged into each flow run’s tags. - You can also add run-level tags dynamically with the context manager:
Copy code
from prefect import flow, tags

@flow
def my_flow():
    with tags("urgent"):
        ...
Want me to tailor this to your setup? Are you deploying via Python or the CLI, and what tags do you want to use? If you’re on Prefect 2.x, I can share the equivalent approach there too.