<@ULVA73B9P> how can I pass params to a flow `depl...
# ask-community
m
@Marvin how can I pass params to a flow
deploy()
function in the Python SDK?
m
thought for 154.0 seconds
Yes—pass them via the
parameters
keyword on
Flow.deploy(...)
in Prefect 3.x. Example:
Copy code
from prefect import flow

@flow
def my_flow(x: int = 1, y: str = "a"):
    print(x, y)

# Create a deployment with default parameters
my_flow.deploy(
    name="prod",
    work_pool_name="my-pool",
    parameters={"x": 5, "y": "b"},
)
From a source (e.g., GitHub):
Copy code
from prefect import flow

@flow
def my_flow(x: int = 1):
    print(x)

my_flow.from_source(
    "<https://github.com/owner/repo>",
    entrypoint="flows/my_flow.py:my_flow",
).deploy(
    name="prod",
    work_pool_name="my-pool",
    parameters={"x": 42},
)
Notes: - Parameter names must match your flow’s function signature. - Values should be JSON-serializable. - Prefect validates types by default; if needed, set
enforce_parameter_schema=False
. - You can still override parameters at run time (e.g., via UI or
prefect deployment run
with
--param
flags). Docs: - Deploy via Python