Add loops commands - #50
Open
cretz wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new baseten loops command surface (run, usage, checkpoint) backed by the generated baseten-go management client, and refactors the shared logs flow to validate flags before performing entity lookups/network calls. This fits into the CLI by expanding the command tree and reusing existing output/log streaming infrastructure (tables/JSON/JSONL, shared logs tail/paging).
Changes:
- Add
baseten loopscommands: run create/list/describe/deactivate/logs, usage, checkpoint list/files (+ extensive httptest-backed unit tests). - Refactor shared logs handling: introduce
validateLogFlags, generalize tail gating viatailStatus, and update model/environment logs + model push to use it. - Update environment deployment nil-handling and bump
github.com/basetenlabs/baseten-gopseudo-version.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/ssh/connect.go | Fix nil-handling when resolving an environment’s current deployment. |
| internal/cmd/command.model_push.go | Update tail result handling to use the new tailStatus accessor. |
| internal/cmd/command.model_environment.go | Make environment list/describe resilient to CurrentDeployment == nil. |
| internal/cmd/command.model_environment_logs.go | Validate log flags before lookups; adapt tail status fetcher to tailStatus. |
| internal/cmd/command.model_environment_logs_test.go | Add regression test ensuring flag validation happens before model lookup. |
| internal/cmd/command.model_deployment_logs.go | Introduce validateLogFlags, tailStatus, and refactor tail gating + final status reporting. |
| internal/cmd/command.loops.go | Implement Loops command handlers (runs/usage/checkpoints) using management REST endpoints. |
| internal/cmd/command.loops_test.go | Add comprehensive unit tests for all Loops commands and log/usage behaviors. |
| cmd/command.loops.go | Add loops command tree + flag structs + JSON/text output descriptions. |
| cmd/command.go | Register loops at the root command level. |
| go.mod | Bump baseten-go dependency to a newer pseudo-version. |
| go.sum | Update sums for the bumped baseten-go version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
marius-baseten
approved these changes
Aug 7, 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.
🚀 What
Adds the
baseten loopscommand surface, ported fromtruss loops. Nouns follow the backend (run, sampler, checkpoint); truss's deprecated spellings and its per-command output-format flag are dropped, the latter because the CLI has a global--output.loops run create(trussloops push): creates a session, a run, and its paired sampler. Renamed because nothing is uploaded.--base-modelrequired;--name,--replicas,--teamoptional. Returns once provisioned rather than blocking on readiness, which is the SDK's job.loops run list(trussloops view, plus the deprecatedloops runs view): runs newest-first.--orgadds an OWNER column,--allincludes inactive runs,--base-modelfilters,--directionsorts.loops run describe(no truss equivalent): one run, with its paired sampler's URL and model/deployment ids.loops run deactivate(trussloops deactivate): tears down trainer and sampler. Prompts unless--yes;--yesrequired when stdin is not a TTY.loops run logs(trussloops logs): trainer logs by default,--samplerfor the sampler's separate stream. Uses the shared logs flow, so--tail,--since/--start/--end, and--limitall work. Only--min-levelis offered as a filter, since the trainer endpoint has no message or replica filters.loops usage(trussloops usage): GPU summary plus one row per trainer and per standalone sampler.--org,--user,--allto include allocations holding no live GPUs. Also covers the deprecatedloops samplers view.loops checkpoint list(trussloops checkpoints view): top-level rather than nested, matching REST, since checkpoints are queryable across runs.--run-idor--base-model, one required.loops checkpoint files(no truss equivalent, SDK-only): presigned download URLs for a checkpoint's files.loops checkpoint deployyet: it is the only GraphQL-backed command in the surface and takes an evaluated Python file as config, so it likely needs to delegate to truss. Deferred until thetrainport, which hits the same question withtrain deploy_checkpoints.💻 How
--org/--usermap to the RESTscope=orgparam; owner filtering for--useris client-side.loops usagejoins trainer deployments with standalone samplers client-side, matching paired samplers by id before the owner filter so a filtered-out trainer's sampler is not counted as standalone. The summary totals every row, including ones the table hides.loops checkpoint fileswalks every page and streams records viaNewJSONArrayWriter, since the URLs are short-lived. Dropping the response envelope also dropstotal_countfrom its JSON.validateLogFlagsholds the standalone checks and every logs command calls it before resolving the entity it fetches logs for, so a flag mistake no longer costs an API call or hides behind a lookup error.runLogsCommandkeeps only the checks needing the window resolved against now. This also fixesmodel environment logs --model-name, which had the same ordering.🔬 Testing
internal/cmd/command.loops_test.gocovering all eight commands: team-scoped creation, scope/filter/direction handling, the trainer-versus-sampler logs split, tail termination on trainer status, the usage pairing/summary/hidden-row logic, and the checkpoint-files page walk in table, JSON, and JSONL form.internal/cmdpackage passes.