feat(loops): add truss loops runs metrics command#2495
Open
rcano-baseten wants to merge 2 commits into
Open
Conversation
Adds a metrics command scoped to a Loops run that reports request volume and concurrent requests for both the trainer deployment and its paired sampler within a configurable time window. - Defaults to a single snapshot for the window `run.created_at → now`. - `--tail` enables live updates (cli-table refreshes in place; json mode emits NDJSON, one document per refresh tick). - `--since` (duration like '30m'/'2h'/'1d') or `--start`/`--end` (ISO-8601) override the default window. - `-o cli-table|json` matches the existing `loops view` convention; `--output-file PATH` redirects JSON to a file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rcano-baseten
commented
Jun 10, 2026
Comment on lines
+224
to
+228
| _DEFAULT_METRICS_REFRESH_SECONDS = 30 | ||
| _SPARKLINE_BLOCKS = "▁▂▃▄▅▆▇█" | ||
| _SPARKLINE_WIDTH = 24 | ||
| _DURATION_RE = re.compile(r"^\s*(\d+)\s*([smhd])\s*$", re.IGNORECASE) | ||
| _DURATION_UNIT_SECONDS = {"s": 1, "m": 60, "h": 3600, "d": 86400} |
Contributor
Author
There was a problem hiding this comment.
can we create another file that's focused on showing the metrics display?
Contributor
Author
There was a problem hiding this comment.
Done in 6336694 — moved the cli-table layout, NDJSON emission, and tail loop into truss/cli/loops_run_metrics_viewer.py (mirroring loops_checkpoint_viewer.py). The command body in loops_commands.py is now wiring + dispatch.
Extracts the cli-table layout, NDJSON emission, and live-tail loop into loops_run_metrics_viewer.py, mirroring the existing loops_checkpoint_viewer pattern. The command body in loops_commands.py now reads as wiring + dispatch (parse args → resolve trainer deployment → build fetch closure → delegate to render_metrics_snapshot / tail_metrics_table / emit_json_snapshots). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
truss loops runs metrics --run-id <id>showing request volume + concurrent requests for the run's trainer deployment and its paired sampler, over a configurable windowrun.created_at → now.--tailkeeps refreshing until interrupted (live cli-table or NDJSON in json mode)--since 30m|2h|1dor--start/--end(ISO-8601, mutually exclusive with--since)-o cli-table|json(matches existingloops viewconvention) and--output-file PATHfor jsonTest plan
--output-file,--since/--startmutex,--output-filerequires json, invalid duration, no matching active deployment, inactive deployments ignored during resolution, run without sampler, and--sinceoverrides the default windowuv run pytest truss/tests/cli/test_loops_cli.py→ 56 passeduv run ruff check+uv run ruff formatcleanbaseten-localonce a Loops run is up — not yet run🤖 Generated with Claude Code