<@ULVA73B9P> How can I force a prefix on a run nam...
# marvin-ai
j
@Marvin How can I force a prefix on a run name for particular schedules under a single deployment
m
thought for 207.5 seconds
In Prefect 3.x, not directly at the schedule object level. A single deployment can't say “schedule A should prepend
foo-
and schedule B should prepend `bar-`” with a dedicated per-schedule run-name setting. But you can get this behavior by using: * a
flow_run_name
template on the flow * schedule-specific
parameters
on each schedule Example:
Copy code
python
from prefect import flow
from prefect.schedules import Cron

@flow(flow_run_name="{run_prefix}-{date}")
def my_flow(run_prefix: str = "default", date: str = "today"):
    print("hello")

my_flow.serve(
    name="my-deployment",
    schedules=[
        Cron(
            "0 8 * * *",
            slug="morning",
            parameters={"run_prefix": "morning", "date": "daily"}
        ),
        Cron(
            "0 20 * * *",
            slug="evening",
            parameters={"run_prefix": "evening", "date": "daily"}
        ),
    ],
)
That gives you run names like: *
morning-daily
*
evening-daily
A few important notes: * Schedules can override parameters per schedule. * Schedules cannot set a separate run-name field directly. * Schedules also do not support per-schedule job variables. * If you need truly different behavior beyond parameter overrides, the cleaner option is often separate deployments. If you want, I can also show the equivalent
prefect.yaml
version. Relevant docs: * Deployments * Flows * Serve flows locally