Skip to content

feat: add sp CLI — command-line client for the platform REST API (WIP)#1121

Draft
gaurav02081 wants to merge 5 commits into
CCExtractor:masterfrom
gaurav02081:feat/sp-cli
Draft

feat: add sp CLI — command-line client for the platform REST API (WIP)#1121
gaurav02081 wants to merge 5 commits into
CCExtractor:masterfrom
gaurav02081:feat/sp-cli

Conversation

@gaurav02081

Copy link
Copy Markdown

Summary

Adds sp_cli — an agent- and script-friendly command-line client for the platform's REST API (/api/v1). Emits JSON by default (so it can be driven by scripts and AI agents) with an --output table mode for humans.

Commands

  • sp health, sp queue — system status
  • sp run ls / show / summary / failures / results / result / diff / logs / errors / approve-baseline
  • sp sample ls / show / history, sp regression ls
  • sp auth login / logout, sp investigate

Highlights

  • Failure classifier (run failures, investigate): turns raw signals (exit code, output diff) into a triage verdict with a confidence level and a plain-language reason — so a person or an agent learns why a test failed without reading logs.
  • Validated end-to-end against the REST API endpoints: fixed the diff endpoint contract, aligned status vocabulary, and added approve-baseline (admin-only, with the cross-platform baseline warning).
  • 32 CLI tests; passes the same checks CI runs (pycodestyle / isort / pydocstyle).

Status / dependency

Opening as a draft: the CLI consumes the REST API endpoints introduced in #1117, which is not yet merged. The sp_cli package and its tests are self-contained (tests mock the HTTP client), so this passes CI independently. I'll mark it ready for review once #1117 lands.

Notes

  • run.py gains a DISABLE_GCS=1 environment flag so the app can boot locally without GCS credentials (useful for development and for exercising the CLI).

gaurav-dev02 and others added 5 commits June 14, 2026 15:15
Adds the sp_cli package (client, commands, runner, output, classifier,
triage) plus test_cli suite and pyproject packaging.
Validated against pulk17:Feature/REST-API-Endpoints (PR CCExtractor#1117):
- diff is keyed by media sample_id + regression_id + output_id as PATH
  segments, not query params on /samples/<id>/diff
- the diff route's <sample_id> slot is the media sample id (different from
  the regression_test_id used by the result-detail route); pull it from
  detail['sample_id'] instead of reusing the CLI argument
- per-output status vocab is pass|fail|missing_output, not 'match'
Aligns the CLI with the mentor's review of the REST API (PR CCExtractor#1117):
- new 'sp run approve-baseline' (POST baseline-approval): requires explicit
  --regression/--output (destructive), maps --remove-variants to the API's
  remove_variants, resolves the media sample id from result detail (the
  endpoint's <sample_id> slot is the media sample, not the result id), and
  carries the cross-platform warning + admin-only note in its help
- 'sp run logs' help now states it requires contributor/admin privileges

Read-only behaviour is unchanged; approve-baseline is the CLI's only
mutating command besides auth.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
8 Security Hotspots
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@gaurav02081 gaurav02081 changed the title feat: add sp CLI — command-line client for the platform REST API feat: add sp CLI — command-line client for the platform REST API (WIP) Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants