Skip to main content

ops prefect

Prefect flow and deployment management. Prefect is the primary flow orchestrator for all data pipelines in the Wasteology portfolio. These commands are now the single CLI surface for the complete flow lifecycle — an agent (or engineer) can probe an API, smoke-test locally, ship a new image, deploy, run with row-count gating, and diagnose stalls entirely through ops prefect without touching the Prefect UI or bare az / prefect CLIs.

Primary Orchestrator

Prefect runs the daily import flows, transformations, and scheduled jobs for every owned project. When something fails, ops prefect runs --state FAILED is usually the fastest path to the root cause.

Subcommands

SubcommandDescription
deploymentsList Prefect deployments
runsList recent flow runs
triggerTrigger a deployment run (simple, no gating)
inspectInspect a specific flow run
cancelCancel a running flow
blocksList Prefect Cloud blocks
runTrigger a deployment with optional watch + row-count gate
deployRegister or update a deployment from a YAML or script
shipBuild image → deploy → gated run in one command
run-localRun a flow file locally for pre-ship smoke testing
probeAuthenticated API probe using a Prefect credentials block
doctorDiagnose "scheduled but never starts" failures

ops prefect runs

List recent flow runs, optionally filtered by state, flow prefix, or count. This is the most-used subcommand — keep it close.

Show the 20 most recent flow runs
Terminal
$ops prefect runs

Flags

FlagTypeDescriptionDefault
--limit-lINTEGERMaximum number of runs to display20
--state-sTEXTFilter by state (COMPLETED, FAILED, RUNNING, CRASHED, CANCELLED)
--filter-fTEXTFilter to flows whose name contains this prefix
--jsonflagOutput as JSON for scripts and AI agents

Examples

Only failed runs — the daily triage workhorse
Terminal
$ops prefect runs --state FAILED
Show the 50 most recent runs of any flow whose name starts with 'wdp'
Terminal
$ops prefect runs --filter wdp --limit 50
JSON output for downstream tooling or AI context
Terminal
$ops prefect runs --json
Daily Triage

--state FAILED is the single most useful flag here. Run it first thing in the morning to see what broke overnight.


ops prefect deployments

List all Prefect deployments — the named, schedulable instances of flows.

Enumerate every deployment registered with Prefect Cloud
Terminal
$ops prefect deployments

ops prefect trigger

Trigger a deployment to start a new flow run immediately, outside of its normal schedule. This is the simple, ungated variant — use ops prefect run if you need watch mode or row-count verification.

Kick off a deployment on demand
Terminal
$ops prefect trigger <deployment-id>
Production Impact

Triggered runs use the deployment's configured environment. Double-check you're not pointing at production before triggering ad-hoc runs.


ops prefect inspect

Inspect a single flow run in detail — parameters, state transitions, logs pointer, timing.

Deep-dive on one flow run
Terminal
$ops prefect inspect <run-id>

ops prefect cancel

Cancel a flow run that's currently in flight. Useful when you spot a bad input or need to stop a runaway job.

Stop a running flow
Terminal
$ops prefect cancel <run-id>

ops prefect blocks

List Prefect Cloud blocks — credentials, secrets, and configuration objects registered with the workspace. Replaces running bare prefect block ls outside of ops.

List all blocks registered in Prefect Cloud
Terminal
$ops prefect blocks

Flags

FlagTypeDescriptionDefault
--filter-fTEXTShow only blocks whose name or type contains this string
--jsonflagOutput as JSON

Examples

Find all blocks related to CieTrade (e.g. credentials, API config)
Terminal
$ops prefect blocks --filter cietrade

ops prefect run

Trigger a named deployment and optionally wait for it to finish. With --watch, the command exits non-zero unless the run reaches Completed. Add --verify-count to also gate on a minimum row count in a target table — useful for ensuring an ETL actually landed data before declaring success.

This is the production-safe successor to trigger: it enforces outcomes, not just submission.

Trigger the cietrade-etl/prod deployment and return immediately
Terminal
$ops prefect run "cietrade-etl/prod"
Trigger and wait up to 10 minutes; exit non-zero if the run does not reach Completed
Terminal
$ops prefect run "wdp-daily/prod" --watch --timeout 600
Run, watch, and fail if the table ends up with fewer than 300 000 rows
Terminal
$ops prefect run "cietrade-etl/prod" --watch --verify-count cietrade.service_record_expenses --min-rows 300000

Flags

FlagTypeDescriptionDefault
--paramsJSONJSON string of parameters to pass to the deployment
--watchflagPoll until the run reaches a terminal state; exit non-zero on anything other than Completed
--timeoutINTEGERSeconds to wait when --watch is set before timing out300
--verify-countTEXTschema.table to row-count after the run; requires --watch
--min-rowsINTEGERMinimum acceptable row count for --verify-count1
--connTEXTSling connection name to use for --verify-countWASTE_PG_DEV
--jsonflagOutput as JSON

ops prefect deploy

Register or update a Prefect deployment from a YAML spec file or a Python deploy script, without leaving wg-orchestration. The command runs inside the owning repo (prefect-azure-infra by default) via the cross-project path plumbing already configured in the registry.

Register or update the deployment described by the YAML file
Terminal
$ops prefect deploy flows/cietrade/cietrade_etl.yaml
Run a Python deploy script in the prefect-azure-infra repo and emit JSON
Terminal
$ops prefect deploy flows/wdp/deploy.py --repo prefect-azure-infra --json

Flags

FlagTypeDescriptionDefault
--repoTEXTProject registry alias for the repo that owns the deployment fileprefect-azure-infra
--jsonflagOutput as JSON

ops prefect ship

Build and push the shared Prefect container image, deploy, then trigger a gated run — all in one command. Designed for CieTrade flow releases where every step must succeed before the next one starts.

Full ship: rebuild shared image → deploy → run → verify row count
Terminal
$ops prefect ship "CieTrade April release" --deploy flows/cietrade/cietrade_etl.yaml --run "cietrade-etl/prod" --watch --verify-count cietrade.service_record_expenses --min-rows 300000 --confirm

Flags

FlagTypeDescriptionDefault
--deployTEXTDeployment YAML or script to apply after the image push
--runTEXT"flow/deployment" to trigger after deploy
--watchflagWait for the triggered run to reach a terminal state
--verify-countTEXTschema.table to row-count after the run
--min-rowsINTEGERMinimum acceptable row count for --verify-count1
--connTEXTSling connection name to use for --verify-countWASTE_PG_DEV
--confirmflagREQUIRED. Acknowledges blast-radius before rebuilding the shared image
--jsonflagOutput as JSON
Shared Image — Blast Radius

--confirm is required because rebuilding the shared CieTrade image redeploys all CieTrade flows simultaneously. Any broken dependency in the new image takes down every CieTrade flow at once. Always smoke-test with ops prefect run-local before calling ship.


ops prefect run-local

Run a flow file directly (uv run python <flow_file>) inside the owning repo, without pushing an image or touching Prefect Cloud. Use this for pre-ship smoke testing: verify the flow logic is sound before committing to a full ship.

Execute the flow locally inside prefect-azure-infra
Terminal
$ops prefect run-local flows/cietrade/cietrade_etl.py
Run locally with a 2-minute timeout
Terminal
$ops prefect run-local flows/wdp/wdp_daily.py --repo prefect-azure-infra --timeout 120

Flags

FlagTypeDescriptionDefault
--repoTEXTProject registry alias for the repo that owns the flow fileprefect-azure-infra
--timeoutINTEGERSeconds before the local run is killed300
--jsonflagOutput as JSON
Pre-Ship Checklist

Run ops prefect run-local → confirm it succeeds → then call ops prefect ship --confirm. This two-step pattern catches most regressions before the shared image is rebuilt.


ops prefect probe

Send an authenticated HTTP request to a JSON API using credentials stored in a Prefect credentials block, and validate the response. Exits non-zero if the response returns fewer records than --min-records. Use this as a lockout gate before deploying or running a flow that depends on the upstream API.

Probe the CieTrade accounts endpoint using the stored credentials block
Terminal
$ops prefect probe https://api.cietrade.net/v1/accounts --block cietrade-credentials/cietrade-api
Probe and fail if fewer than 100 records are returned — prevents running an ETL against a locked-out API
Terminal
$ops prefect probe https://api.cietrade.net/v1/service-records --block cietrade-credentials/cietrade-api --user-field user_id --user-param UserID --secret-field auth_key --min-records 100

Flags

FlagTypeDescriptionDefault
--blockTEXTPrefect credentials block in "block-type/block-name" format
--user-fieldTEXTField name in the block that holds the username/user IDuser_id
--user-paramTEXTQuery-parameter name to send the user value asUserID
--secret-fieldTEXTField name in the block that holds the secret/API keyauth_key
--paramTEXT (repeatable)Additional KEY=VALUE query parameters
--min-recordsINTEGERMinimum number of records the response must contain; exits non-zero below this threshold1
--jsonflagOutput as JSON

ops prefect doctor

Run the "Scheduled but never starts" checklist for a deployment. Checks the entrypoint path, service-principal permissions, ACI quota, and image tag — the four most common causes of a deployment that queues forever. Exits non-zero on any hard failure. Gracefully skips az-dependent checks when the Azure CLI is not available.

Full diagnostic for one deployment
Terminal
$ops prefect doctor --deployment "cietrade-etl/prod"
Run all optional checks: work pool health, ACR accessibility, and image tag resolution
Terminal
$ops prefect doctor --deployment "cietrade-etl/prod" --pool --acr --image
Machine-readable diagnostic output for AI agents or CI gates
Terminal
$ops prefect doctor --json

Flags

FlagTypeDescriptionDefault
--deploymentTEXT"flow/deployment" to diagnose; omit to run workspace-level checks only
--poolflagAlso check work pool health and agent heartbeat
--acrflagAlso verify that the ACR is reachable and the service principal can pull images
--imageflagAlso resolve and validate the image tag referenced by the deployment
--jsonflagOutput as JSON
When to Run Doctor

If a deployment shows Scheduled in the Prefect UI but no run ever appears as Running, run ops prefect doctor --deployment "<flow>/<dep>" --pool --acr --image before digging into logs. It surfaces the four most common root causes in under a minute.