<@ULVA73B9P> Is there a specific good practice or ...
# ask-marvin
l
@Marvin Is there a specific good practice or recommended style/rules for the naming of flows in deployments?
m
thought for 113.1 seconds
Yes — there are a few practical conventions in Prefect 3.x, but not a heavy formal style guide beyond validation rules. Short version: - Use kebab-case for flow names and deployment names - Make names descriptive and stable - Treat
flow-name/deployment-name
as the important human-facing identifier - Avoid encoding too much changing metadata into the flow name itself What Prefect enforces Flow/deployment names cannot contain: -
/
-
%
-
&
-
>
-
<
So names like
daily-etl
are fine, but
daily/etl
is not. Recommended style Prefect docs and examples consistently use hyphen-separated lowercase names, e.g.: - Flows:
daily-etl
,
customer-sync
,
billing-reconciliation
- Deployments:
prod
,
staging
,
nightly
,
backfill
,
us-east
Also, if you do not explicitly name a flow, Prefect will turn a Python function like
my_flow_function
into
my-flow-function
, which is a good signal that kebab-case is the intended convention. Example:
Copy code
python
from prefect import flow

@flow(name="daily-etl")
def run_daily_etl():
    pass
Then deployments might be:
Copy code
python
run_daily_etl.from_source(...).deploy(
    name="prod",
    work_pool_name="my-pool",
)
That gives you a clear identifier:
Copy code
text
daily-etl/prod
Good practice for naming A useful pattern is: - Flow name = what the workflow does - Deployment name = how/where/when it runs Examples: - Flow:
customer-sync
- Deployments:
prod
,
staging
,
hourly
,
manual-backfill
- Flow:
warehouse-load
- Deployments:
daily-prod
,
ad-hoc
,
dev
This is usually better than putting environment/schedule into the flow name itself unless they are truly different workflows. Recommended rules of thumb 1. Keep flow names stable - Prefer
customer-sync
- Avoid renaming frequently, since names are how people recognize runs in the UI/CLI 2. Put execution context in deployment names - Environment:
prod
,
staging
,
dev
- Trigger/schedule:
daily
,
hourly
,
manual
- Purpose:
backfill
,
smoke-test
3. Be concise but specific - Better:
stripe-invoice-sync
- Worse:
sync
- Worse:
data-pipeline-thing
4. Use one consistent format everywhere - Prefer all lowercase + hyphens - Avoid mixing
snake_case
,
camelCase
, and spaces 5. Don’t overstuff names -
customer-sync-prod-daily-us-east-batch-v2
is usually too much - If you need more metadata, use tags, parameters, descriptions, or work pools Suggested naming patterns Some patterns that work well: - By business function - Flow:
invoice-generation
- Deployments:
prod
,
staging
- By source -> destination - Flow:
salesforce-to-snowflake
- Deployments:
hourly
,
backfill
- By operation - Flow:
db-maintenance
- Deployments:
nightly
,
manual
When to create separate flows vs separate deployments Use separate deployments when the core logic is the same but execution context differs. Use separate flows when the workflows are meaningfully different. For example: - Same code, different schedule/env → one flow, multiple deployments - Different business process or task graph → separate flows Example I’d recommend
Copy code
python
from prefect import flow

@flow(name="customer-sync")
def customer_sync():
    pass
Deployments: -
customer-sync/prod
-
customer-sync/staging
-
customer-sync/backfill
That tends to stay readable in both UI and CLI. Relevant docs/examples - Prefect flows concept docs: Flows - Prefect deployments docs: Deployments - Python deployment patterns with `from_source(...).deploy(...)`: Deploy via Python If you want, I can also suggest a team-wide naming convention template for flows + deployments for dev/staging/prod environments.
l
@Marvin So
/
are valid in a deployment
name
as long as it separates the name of the flow from the actual deployment identifier (e.g. the parameter)?
m
thought for 6.9 seconds
Yes — exactly.
/
is not valid inside the flow name or the deployment name itself, but Prefect uses
/
as the separator in the fully qualified deployment identifier:
Copy code
text
<flow-name>/<deployment-name>
So this is valid:
Copy code
text
customer-sync/prod
Where: - flow name =
customer-sync
- deployment name =
prod
But this would not be valid as a deployment name by itself:
Copy code
text
prod/us-east
because
/
cannot appear inside the
name
field. So if you want that extra structure, prefer something like:
Copy code
text
customer-sync/prod-us-east
or:
Copy code
text
customer-sync/prod_us_east
though kebab-case like
prod-us-east
is the more common Prefect style. In practice: - Valid deployment reference:
my-flow/my-deployment
- Invalid flow name:
my/flow
- Invalid deployment name:
my/deployment
If helpful, I can also show where this matters in: -
prefect deploy
- Python
.deploy(name=...)
- running deployments from the CLI/API