Skip to content

feat: add --output json support to task-run ls command#20755

Open
cluster2600 wants to merge 3 commits intoPrefectHQ:mainfrom
cluster2600:feat/task-run-ls-json-output
Open

feat: add --output json support to task-run ls command#20755
cluster2600 wants to merge 3 commits intoPrefectHQ:mainfrom
cluster2600:feat/task-run-ls-json-output

Conversation

@cluster2600
Copy link

Summary

Adds machine-readable JSON output to the prefect task-run ls command, following the existing pattern established in task-run inspect, flow-run ls, and deployment ls.

Changes

  • Added --output/-o option to task-run ls accepting "json" format
  • When --output json is set, task runs are serialized via orjson with pretty-printing and printed to stdout
  • Empty result returns a JSON empty array [] instead of the human-readable "No task runs found." message
  • Existing Rich table rendering is preserved when the flag is not provided
  • Added tests for: JSON output with task runs present, empty list case, and invalid format error

Usage

# Machine-readable JSON output
prefect task-run ls --output json
prefect task-run ls -o json

# Pipe-friendly usage
prefect task-run ls -o json | jq '.[].name'

Related

Related to #19483 (checks off task-run ls from the list)

Checklist

  • Code follows the existing pattern (task_run.py inspect, flow_run.py, deployment.py)
  • Tests added for both output modes
  • No breaking changes to existing table output

Adds machine-readable JSON output to the  command,
following the same pattern established in  and
.

- Add / option accepting  format
- When  is set, serialize flows with orjson and print
- Preserve existing Rich table rendering when flag is not provided
- Add tests for JSON output, empty list, short flag (-o), and invalid
  format error

Closes PrefectHQ#20752
Adds machine-readable JSON output to the `prefect work-pool ls` command,
following the same pattern established in `flow-run ls`, `deployment ls`,
and `work-pool inspect`.

- Add `--output`/`-o` option accepting `"json"` format
- When `--output json` is set, serialize work pools with orjson and print
- Preserve existing Rich table rendering when flag is not provided
- Add tests for JSON output, empty list, short flag (-o), and invalid
  format error

Related to PrefectHQ#19483
Adds machine-readable JSON output to the `prefect task-run ls` command,
following the same pattern established in `flow-run ls`, `deployment ls`,
and `task-run inspect`.

- Add `--output`/`-o` option accepting `"json"` format
- When `--output json` is set, serialize task runs with orjson and print
- Empty result returns JSON empty array `[]` instead of "No task runs found"
- Preserve existing Rich table rendering when flag is not provided
- Add tests for JSON output, empty list, and invalid format error

Related to PrefectHQ#19483
@github-actions github-actions bot added cli Related to the Prefect CLI enhancement An improvement of an existing feature pyladies-amsterdam PyLadies Amsterdam MLOps Open Source Sprint (Feb 27, 2026) labels Feb 19, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 19, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing cluster2600:feat/task-run-ls-json-output (7c32a6b) with main (6712b8e)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to the Prefect CLI enhancement An improvement of an existing feature pyladies-amsterdam PyLadies Amsterdam MLOps Open Source Sprint (Feb 27, 2026)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments