<@ULVA73B9P> what are ways to call a flow that wou...
# ask-marvin
r
@Marvin what are ways to call a flow that would be run by a process worker polling a process workpool remotely
m
thought for 446.1 seconds
Great question. Assuming Prefect 3.x, here are the main ways to trigger a deployment so a Process worker polling a Process work pool picks it up. In all cases, make sure: - Your deployment targets the Process work pool you’re running - A worker is running and polling that pool (and queue, if used) Start a Process worker:
Copy code
prefect 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.
Copy code
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:
Copy 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):
Copy code
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:
Copy code
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.
If you tell me which interface you prefer (CLI, Python, REST, UI, or Automations), I can tailor a minimal example against your deployment and pool names.