Add --output json to flow ls, work-pool ls, task-run ls, concurrency-limit ls#20904
Open
h1whelan wants to merge 1 commit intoPrefectHQ:mainfrom
Open
Add --output json to flow ls, work-pool ls, task-run ls, concurrency-limit ls#20904h1whelan wants to merge 1 commit intoPrefectHQ:mainfrom
h1whelan wants to merge 1 commit intoPrefectHQ:mainfrom
Conversation
…concurrency-limit ls Related to PrefectHQ#19483 Add --output/-o json support to four CLI list commands that were missing it, following the established pattern from flow-run ls and deployment ls: - flow ls - work-pool ls - task-run ls - concurrency-limit ls Each command now accepts --output json / -o json to emit machine-readable JSON (via orjson) instead of the Rich table. Empty results return [] in JSON mode. Invalid format values produce a clear error. Also adds proper empty-list handling (exit_with_success) where it was previously missing. Includes tests for JSON output, empty JSON output, and invalid format rejection for all four commands.
38 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to #19483
Adds
--output json/-o jsonsupport to four CLI list commands that were missing it:flow lswork-pool lstask-run lsconcurrency-limit lsEach follows the established pattern from
flow-run lsanddeployment ls:--output/-ooption (accepts"json")output == "json", serialize response objects withorjson.dumps(..., option=orjson.OPT_INDENT_2)and print[]in JSON mode instead of a text messageAlso adds proper empty-list handling (
exit_with_success) forflow lsandtask-run lswhere it was previously missing.Changes
src/prefect/cli/flow.py--output jsontoflow lssrc/prefect/cli/work_pool.py--output jsontowork-pool lssrc/prefect/cli/task_run.py--output jsontotask-run lssrc/prefect/cli/concurrency_limit.py--output jsontoconcurrency-limit lstests/cli/test_flow.pyflow lsJSON outputtests/cli/test_task_run.pytask-run lsJSON outputtests/cli/test_work_pool.pywork-pool lsJSON outputtests/cli/test_concurrency_limit.pyconcurrency-limit lsJSON outputTest plan
[](not a text message) in JSON mode-o xml) returns error with exit code 1task-run ls --state Running -o json)--outputis not specified