<@ULVA73B9P> when using `prefect deploy` how do I ...
# ask-marvin
r
@Marvin when using
prefect deploy
how do I set specific parameters for the deployment?
m
thought for 155.5 seconds
Great question! In Prefect 3.x, you set default flow parameters at deploy time with the
prefect deploy
CLI using either
--param
(repeatable key=value) or
--params
(single JSON object). These are mutually exclusive. - Use
--param key=value
for individual parameters (repeatable). Values are parsed as JSON if possible; otherwise treated as strings. - Use
--params '{"k":"v"}'
to provide all parameters at once as a JSON object. Examples:
Copy code
# Set individual params (repeatable)
prefect deploy ./flows.py:my_flow \
  --name my-deployment \
  --param customer_id=12345 \
  --param enabled=true \
  --param tags='["gold","priority"]'

# Set all params at once (JSON)
prefect deploy ./flows.py:my_flow \
  --name my-deployment \
  --params='{"customer_id":12345,"enabled":true,"tags":["gold","priority"]}'
Notes: - Don’t mix
--param
and
--params
in the same command (you’ll get an error). - These values become the deployment’s default parameters. You can override them at run time:
Copy code
prefect deployment run my-flow/my-deployment --param customer_id=999
If you prefer YAML, you can put defaults under
parameters:
for a deployment in `prefect.yaml`:
Copy code
deployments:
  - name: my-deployment
    entrypoint: flows.py:my_flow
    parameters:
      customer_id: 12345
      enabled: true
CLI flags will merge with and override values defined in
prefect.yaml
. Programmatic equivalent (Python):
Copy code
from prefect import flow

@flow
def my_flow(customer_id: int, enabled: bool = True): ...

flow.from_source(
    source="<https://github.com/org/repo.git>",
    entrypoint="flows.py:my_flow"
).deploy(
    name="my-deployment",
    work_pool_name="my-pool",
    parameters={"customer_id": 12345, "enabled": True}
)
Docs: - Create deployments - prefect.yaml - Trigger deployment runs