Ravish Mallya
09/27/2025, 7:34 AMMarvin
09/27/2025, 7:34 AMMarvin
09/27/2025, 7:42 AMprefect worker start -p "my-process-pool"
Docs: Workers and work pools
Ways to call the flow (create a run for the deployment):
1) CLI (quick ad‑hoc run)
- Create a run immediately (or schedule via flags); worker will pick it up when it polls.
prefect deployment run "flow-name/deployment-name" \
--param foo=bar \
--job-variable env='{"EXTRA_FLAG": "1"}' \
--tag adhoc \
--watch
Help: run prefect deployment run --help
How-to: Run deployments (CLI/Python/UI)
2) Python SDK – high-level helper
- Synchronously create and optionally wait on a run from code:
from prefect.deployments.flow_runs import run_deployment
run = run_deployment(
name="flow-name/deployment-name",
parameters={"foo": "bar"},
tags=["adhoc"],
job_variables={"env": {"EXTRA_FLAG": "1"}},
flow_run_name="triggered-from-code",
)
print(run.id)
Reference: Run deployments (CLI/Python/UI)
3) Python SDK – direct client call
- Use the client to create a run from a deployment ID (async):
import asyncio
from prefect.client.orchestration import get_client
async def main():
async with get_client() as client:
run = await client.create_flow_run_from_deployment(
deployment_id="00000000-0000-0000-0000-000000000000",
parameters={"foo": "bar"},
tags=["adhoc"],
name="triggered-via-client",
job_variables={"env": {"EXTRA_FLAG": "1"}},
)
print(run.id)
asyncio.run(main())
4) REST API (curl, other systems)
- Call the API to create a run from a deployment ID:
curl -X POST "$PREFECT_API_URL/api/deployments/<deployment_id>/create_flow_run" \
-H "Authorization: Bearer $PREFECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"parameters": {"foo": "bar"},
"tags": ["adhoc"],
"name": "triggered-via-curl",
"job_variables": {"env": {"EXTRA_FLAG": "1"}}
}'
API docs: Create Flow Run from Deployment (REST)
5) Prefect UI (manual run)
- In the UI, open your Deployment and click Run/Quick run; set parameters, tags, etc. The worker will pick up the run.
How-to: Run deployments (CLI/Python/UI)
6) Schedules on the deployment
- Add a cron/interval/RRule schedule to the deployment. The Prefect scheduler creates runs automatically; the worker executes them.
Docs:
- Schedules concepts
- Create deployment schedules
7) Automations (event-driven)
- Create an Automation with a “Run deployment” or “Create flow run” action, triggered by events (e.g., webhook, state changes, time-based, etc.).
Docs:
- Creating automations
- Webhook trigger (Cloud): Create a webhook
Notes to ensure the Process worker runs your flow:
- The deployment’s work_pool_name must match your Process pool.
- If you use work queues, set the deployment’s work_queue_name and start the worker with the same queue(s).
- The worker must be running at the time the run is ready to execute.Marvin
09/27/2025, 7:42 AM