Marius Haberstock
07/08/2025, 1:26 PMMarvin
07/08/2025, 1:26 PMMarvin
07/08/2025, 1:28 PMpython
from prefect import run_deployment
# Synchronous execution
flow_run = run_deployment(
name="your-deployment-name/deployment-name", # or deployment_id
parameters={"key": "value"}, # optional flow parameters
)
# Asynchronous execution
import asyncio
from prefect.client.orchestration import get_client
async def run_my_deployment():
async with await get_client() as client:
flow_run = await run_deployment(
name="your-deployment-name/deployment-name",
client=client,
parameters={"key": "value"}
)
return flow_run
# Run the async function
flow_run = asyncio.run(run_my_deployment())
Key parameters for `run_deployment`:
- `name`: Required. Either the deployment name in the format "flow-name/deployment-name" or a deployment ID
- `parameters`: Optional dictionary of parameters to pass to the flow
- `tags`: Optional list of tags to add to the flow run
- `work_queue_name`: Optional name of the work queue to submit the run to
- `flow_run_name`: Optional custom name for the flow run
- `scheduled_time`: Optional datetime to schedule the run for the future
The function returns a FlowRun
object representing the created flow run.
For more details, you can check out:
- Deployment via Python documentation
- REST API documentation for creating flow runsMarius Haberstock
07/08/2025, 1:33 PMMarvin
07/08/2025, 1:33 PMMarvin
07/08/2025, 1:34 PMpython
from prefect.client.orchestration import get_client
# Synchronous approach
from prefect.client import get_client
client = get_client()
flow_run = client.create_flow_run_from_deployment(
deployment_id="deployment-id", # or deployment name
parameters={"key": "value"} # optional
)
# Asynchronous approach
import asyncio
async def create_flow_run():
async with await get_client() as client:
flow_run = await client.create_flow_run_from_deployment(
deployment_id="deployment-id", # or deployment name
parameters={"key": "value"} # optional
)
return flow_run
# Run the async function
flow_run = asyncio.run(create_flow_run())
You can find the deployment ID or name from the Prefect UI or by querying deployments using the client. The deployment name should be in the format "flow-name/deployment-name".
For more details about working with deployments and flow runs, check out:
- Deployment via Python documentation
I apologize for the confusion in my earlier response. Thank you for the correction.Nate
07/08/2025, 2:12 PMNate
07/08/2025, 2:13 PMfrom prefect.deployments import run_deployment
Marius Haberstock
07/08/2025, 8:23 PMMarius Haberstock
07/08/2025, 8:25 PMNate
07/08/2025, 9:00 PMNate
07/08/2025, 9:00 PMNate
07/08/2025, 9:02 PMNate
07/08/2025, 9:02 PMNate
07/09/2025, 4:01 PMMarius Haberstock
07/10/2025, 10:29 AM