PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
17.55k stars 1.65k forks source link

"Inspect" CLI commands should support JSON output #13188

Open abrookins opened 6 months ago

abrookins commented 6 months ago

First check

Prefect Version

2.x

Describe the current behavior

Running a command like prefect work-pool inspect <name> always outputs object representations in Python objects.

Describe the proposed behavior

Running a command like prefect work-pool inspect <name> should support a flag to output the result in JSON.

Example Use

prefect work-pool inspect <name> --output=json prefect work-pool inspect <name> -o json

Additional context

There are times when it can be useful to save JSON representations to use as subsequent input to commands that expect JSON, such as prefect work-pool update <name> --base-job-template <file.json>.

serinamarie commented 6 months ago

Makes sense to me. I can implement a POC with the work I'm currently building in the global concurrency limit CLI.

serinamarie commented 6 months ago

Unassigned myself for now as this a variety of PRs may help close this issue.

serinamarie commented 6 months ago

The POC has been created in the above PR, so anyone can contribute easily to this!

olanna12 commented 5 months ago

Hi @abrookins! I would like to be assigned this issue.

trymzet commented 2 days ago

IMO all CLI commands that output anything should support JSON output to allow scripting.

Currently, the issue is not only that output has to be parsed (so eg. a change in formatting of the output could break scripts), but that it can also be trimmed by Rich. So for semi-reliability, all scripts using Prefect CLI's output must currently set the COLUMNS env var to a high value (eg. 200) to ensure output is not trimmed in some environments (eg. GitHub Actions' default shell width is 80). Or just use the REST API instead.