-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
cliRelated to the Prefect CLIRelated to the Prefect CLIenhancementAn improvement of an existing featureAn improvement of an existing feature
Description
Parent Issue
Part of #19903 (CLI improvements for automation and agent usage)
Problem
Currently prefect flow-run delete only accepts a single flow run ID:
# Works
prefect flow-run delete 8d38609e-0a80-4045-bfb1-8f3c07e5cf55
# Doesn't work - have to run 4 separate commands
prefect flow-run delete id1 id2 id3 id4When cleaning up orphaned or stuck flow runs, this requires running the command multiple times in a loop, which is slow and tedious.
Proposed Solution
1. Accept multiple IDs as positional arguments
prefect flow-run delete <id1> <id2> <id3> <id4>2. Accept IDs from stdin
# Pipe from another command
prefect flow-run ls --state PENDING -o json | jq -r '.[].id' | prefect flow-run delete --stdin
# Or from a file
cat orphaned-runs.txt | prefect flow-run delete --stdin3. Query-based delete (stretch goal)
# Delete all pending runs older than 7 days
prefect flow-run delete --state PENDING --older-than 7d
# Delete orphaned runs (no deployment)
prefect flow-run delete --deployment-id null
# Dry run to preview
prefect flow-run delete --state FAILED --dry-runUse Case
While debugging a Prefect workspace, I found 4 orphaned flow runs from 2 days ago stuck in PENDING state with deployment: null (their deployments had been deleted). Cleaning these up required:
prefect flow-run delete 8d38609e-0a80-4045-bfb1-8f3c07e5cf55
prefect flow-run delete 3b7ce29f-64cf-4d1b-ad16-cff9cac1ce61
prefect flow-run delete ecfbecf9-4841-4320-980f-3405bc11b398
prefect flow-run delete 1b230e8e-69e9-4db0-b169-838a00d74db6With batch support, this becomes:
prefect flow-run delete 8d38609e-0a80-4045-bfb1-8f3c07e5cf55 3b7ce29f-64cf-4d1b-ad16-cff9cac1ce61 ecfbecf9-4841-4320-980f-3405bc11b398 1b230e8e-69e9-4db0-b169-838a00d74db6Additional Notes
- Should also apply to
prefect flow-run cancel - Consider similar patterns for other resources (deployments, blocks, etc.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
cliRelated to the Prefect CLIRelated to the Prefect CLIenhancementAn improvement of an existing featureAn improvement of an existing feature