This message was deleted.
# ask-marvin
s
This message was deleted.
m
thought for 149.9 seconds
In Prefect 3.x, if you're launching a deployment from the CLI, a dict-like parameter generally does need to be provided as JSON. So the short answer is: You can't avoid JSON syntax in the CLI for a raw dict parameter. But you can make the parameter experience much better by using a Pydantic model instead of an untyped
dict
. Recommended approach Instead of this:
Copy code
python
from typing import Any
from prefect import flow

@flow
def my_flow(config: dict[str, Any]):
    print(config)
use this:
Copy code
python
from pydantic import BaseModel
from prefect import flow

class Config(BaseModel):
    database_url: str
    timeout: int = 30
    debug: bool = False

@flow
def my_flow(config: Config):
    print(config.database_url)
    print(config.timeout)
Why this helps: - Prefect generates a structured parameter schema - the UI can present it more clearly - Prefect validates the input before the run starts - your code gets typed access instead of manual dict handling Important caveat If you run the deployment via CLI, you'll still pass the value as JSON:
Copy code
bash
prefect deployment run my-flow/my-deployment \
  --param config='{"database_url":"postgres://...","timeout":60,"debug":true}'
If you want to avoid JSON strings entirely, use the Python API instead of the CLI:
Copy code
python
from prefect.deployments import run_deployment

run_deployment(
    name="my-flow/my-deployment",
    parameters={
        "config": {
            "database_url": "postgres://...",
            "timeout": 60,
            "debug": True,
        }
    },
)
Bottom line - CLI: dict/object parameters are passed as JSON - Python API: you can pass a normal Python dict - Best practice for structured inputs: use a
pydantic.BaseModel
instead of
dict[str, Any]
If you want, I can also show you: 1. how this looks in the Prefect UI form, or 2. how to define this in a deployment so users get nicer parameter inputs.