Shubham
07/10/2026, 7:46 AMMarvin
07/10/2026, 7:46 AMMarvin
07/10/2026, 7:48 AMcommand and command_arguments vary per run.
The usual pattern in Prefect 3.x is:
1. Define them as flow parameters
2. Optionally set sensible defaults in the deployment
3. Override them when triggering each run
So for your case, make these runtime parameters:
- integration_params
- command
- command_arguments
Example flow:
python
from prefect import flow
@flow
def my_flow(
integration_params: dict,
command: str,
command_arguments: list[str],
):
print(integration_params)
print(command)
print(command_arguments)
# your logic here
Then create a deployment with defaults if you want:
python
if __name__ == "__main__":
my_flow.deploy(
name="my-deployment",
work_pool_name="my-pool",
parameters={
"integration_params": {},
"command": "python",
"command_arguments": []
}
)
Then override at run time.
From CLI:
bash
prefect deployment run "my-flow/my-deployment" \
-p integration_params='{"source":"s3","target":"db"}' \
-p command='"python"' \
-p command_arguments='["script.py","--date","2025-07-10"]'
A few important notes:
- -p / --param values are interpreted as JSON
- strings often need quotes like '"python"'
- arrays/lists should be JSON arrays like ["a","b"]
If you trigger from Python instead:
python
from prefect.deployments import run_deployment
run_deployment(
name="my-flow/my-deployment",
parameters={
"integration_params": {"source": "s3", "target": "db"},
"command": "python",
"command_arguments": ["script.py", "--date", "2025-07-10"],
},
)
Best practice
- Put stable defaults in the deployment
- Pass changing values at run time
- Don’t hardcode values that change every run
If your flow has “multiple functions”, that’s fine — Prefect only cares about the flow’s parameters. Inside the flow, you can route those parameters to whichever internal function/task needs them.
If you want, I can also show you:
1. how to do this in prefect.yaml, or
2. how to structure this with a single Pydantic model for cleaner validation.
CLI reference: prefect deployment runShubham
07/10/2026, 7:58 AMMarvin
07/10/2026, 7:58 AMMarvin
07/10/2026, 7:58 AMcommand
- command_arguments
- changing integration_params
One important caveat:
If you create a schedule on a deployment, that schedule needs some parameter values to use for each scheduled run.
So if your flow requires:
- integration_params
- command
- command_arguments
then a scheduled run must get them from somewhere:
- deployment defaults, or
- schedule-specific parameters
If you leave deployment params empty and those parameters are required with no defaults in the flow, scheduled runs may fail unless the schedule provides them.
A clean setup is:
python
from prefect import flow
@flow
def my_flow(
integration_params: dict = {},
command: str = "",
command_arguments: list[str] = [],
):
...
Then:
- deployment can stay mostly empty
- schedules can override with their own fixed values
- manual runs can pass custom values
But even better than mutable defaults is:
python
from typing import Optional
from prefect import flow
@flow
def my_flow(
integration_params: Optional[dict] = None,
command: Optional[str] = None,
command_arguments: Optional[list[str]] = None,
):
integration_params = integration_params or {}
command_arguments = command_arguments or []
That avoids Python mutable default issues.
So short answer:
Yes, leave deployment params empty if:
- you plan to provide params for every manual run
- each schedule provides its own params
- or your flow has safe defaults
If you want, I can show you the best Prefect 3.x way to attach different parameters to different schedules on the same deployment.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by