Repository navigation
[CLI] Add --output id|json to sky jobs launch - #10879
Merged
Merged
Conversation
Scripts need the managed job ID to chain further commands. With --output, launch sends all other output to stderr, skips log streaming, and prints only the job IDs: one per line for id, or {"job_ids": [...]} for json.
aylei
marked this pull request as ready for review
September 25, 2026 05:45
--config and --workspace are applied in option callbacks, which run before the command body, so their debug logs reached stdout ahead of the IDs. --output is now eager and starts the redirect in its own callback; the IDs are written to the original stdout.
Michaelvll
reviewed
Sep 25, 2026
Michaelvll
approved these changes
Sep 25, 2026
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.
Scripts that chain work after
sky jobs launchneed the managed job ID, but today they have to parse it out of the human-readable output (Managed Job ID: N).This adds
--output/-o id|jsontosky jobs launch:-o idprints only the job IDs on stdout, one per line;--num-jobsgives one line per job.-o jsonprints{"job_ids": [...]}.sys.stdout.--detach-run.--asyncis rejected with--output, because it returns before the IDs exist.JOB_ID=$(sky jobs launch -y -o id task.yaml)Tested (run the relevant ones):
sky/client/cli/command.pyand the test filepytest tests/unit_tests/test_sky/test_cli_launch_validation.py: 10 passed, including new cases for-o id,-o json,--num-jobs, the--asyncrejection, and the redirect of a stream bound to the original stdout.sky jobs launch -y -o id task.yamlwrote exactly13\nto stdout, with the YAML, spinner and launch lines on stderr;-o jsonprinted{"job_ids": [12]}./smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)