Add sp run wait to block until runs finish - #3
Open
cfsmp3 wants to merge 1 commit into
Open
Conversation
Every consumer of this CLI that cares about a run's outcome -- CI scripts, agents, a developer watching a PR -- currently has to write its own poll loop, and each one picks its own interval and its own idea of which statuses are terminal. `sp run wait 9476 9477` polls until every run leaves queued/running, then prints the final records. Progress goes to stderr so the payload on stdout stays pipeable, and the exit code carries the result: 0 when every run succeeded, 1 when any failed or was canceled, 2 on timeout. That lets a script gate on the outcome without parsing anything. An unrecognised status counts as terminal rather than as "keep polling", so a new server-side state cannot leave the command spinning forever.
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.
Why
Anything that cares about a run's outcome — a CI script, an agent, a developer watching a PR — currently has to write its own poll loop against
sp run ls. Each one picks its own interval and its own idea of which statuses are terminal, and they all get it slightly differently.What
Polls until every named run leaves
queued/running, then prints the final records.0every run succeeded,1any run failed or was canceled,2timeout. A script can gate on the outcome without parsing anything.Notes
Statuses live in
constants.py(RUN_PENDING_STATUSES,RUN_UNSUCCESSFUL_STATUSES) rather than inline, sincewaitand the existing listing code need to agree on what "done" means.Defaults are 30s interval / 3600s timeout.
Testing
6 new tests covering: all-success, mixed failure, timeout, unknown-status-is-terminal,
--quiet, and multi-run polling. Full suite 216 pass; isort/pycodestyle/pydocstyle/mypy clean.Also exercised against the live deployment on two real queued runs — it correctly held through ~85 minutes of queue latency and exited 2 with the still-pending IDs named.