<@ULVA73B9P> using a self-hosted setup, how to run...
# ask-marvin
s
@Marvin using a self-hosted setup, how to run a flow locally (i.e. not deployed) with flow parameters on the command line.
m
thought for 308.1 seconds
Short answer: In Prefect 3.x there is no
prefect run
command. To run a flow locally (not deployed) with parameters from the command line, call your flow from a Python entrypoint that parses CLI args and passes them to the flow. Here’s a simple, reliable pattern:
Copy code
# my_flow.py
from prefect import flow

@flow
def my_flow(name: str, count: int = 1):
    print(f"Hello {name}, running {count} times")

if __name__ == "__main__":
    import argparse, json

    parser = argparse.ArgumentParser()
    # Option 1: individual flags
    parser.add_argument("--name")
    parser.add_argument("--count", type=int)
    # Option 2: a JSON dict for complex params
    parser.add_argument("--params", help="JSON dict of flow parameters", default=None)

    args = parser.parse_args()
    params = {}

    if args.params:
        params.update(json.loads(args.params))
    if args.name is not None:
        params["name"] = args.name
    if args.count is not None:
        params["count"] = args.count

    my_flow(**params)
Examples: - Individual flags:
Copy code
python my_flow.py --name "Alice" --count 5
- JSON params (handy for nested structures):
Copy code
python my_flow.py --params '{"name": "Alice", "count": 5}'
Notes for self-hosted: - This executes in your local Python process. If your environment points to your self-hosted API (e.g.,
export PREFECT_API_URL=http://<your-server>:4200/api
or via a Prefect profile), the run and logs will appear in your UI even though it’s not a deployment. - There is no direct CLI to run a flow with params without a deployment in 3.x.
prefect flow serve
creates a runner-style deployment (not an immediate run). If you do want to use a deployment, you can trigger it with parameters via:
Copy code
prefect deployment run "<FLOW_NAME>/<DEPLOYMENT_NAME>" --param name="Alice" --param count=5
If you want, share your entrypoint/param shapes and I can sketch the exact CLI wrapper for your flow.