Add model environment logs command and switch deployment logs to GET - #32
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new baseten model environment logs command (mirroring deployment logs behavior) and migrates deployment log fetching (including model push --tail) from a deprecated POST endpoint to the GET logs endpoint, with shared flag parsing and a shared tailing loop.
Changes:
- Introduces
model environment logswith the same windowing/filtering/tail UX asmodel deployment logs. - Refactors log querying/tailing into shared helpers (
LogFlags,runLogsCommand, transport-neutraltailLogs). - Updates unit/e2e tests to assert GET query parameters and adds env-logs coverage.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/e2e-tests/model_test.go | Adds an e2e subtest for environment logs and refactors log collection helper. |
| internal/cmd/command.model_push_test.go | Updates push --tail tests to expect GET logs calls. |
| internal/cmd/command.model_environment_logs.go | Implements model environment logs command using shared logs runner. |
| internal/cmd/command.model_environment_logs_test.go | Adds unit tests for environment logs windowing/filters/tail behavior. |
| internal/cmd/command.model_deployment_logs.go | Switches deployment logs to GET via shared runLogsCommand and refactors tail loop to be transport-neutral. |
| internal/cmd/command.model_deployment_logs_test.go | Converts deployment logs tests from POST-body assertions to GET query-param assertions. |
| cmd/command.model.go | Extracts shared LogFlags for deployment + environment logs. |
| cmd/command.model_environment.go | Wires the new logs subcommand under model environment. |
| cmd/command.model_deployment.go | Updates deployment logs flags struct to embed shared LogFlags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // stop when the deployment leaves a runnable state. This is skipped | ||
| // until the first log is seen, similar to Truss. | ||
| // TODO: should the management logs API return current status so | ||
| // we can drop this extra round-trip per poll? | ||
| if len(seen) > 0 { |
| // LogFlags is the shared log-query flag set for `baseten model deployment logs` | ||
| // and `baseten model environment logs`. Both commands accept the same window, | ||
| // filter, and tail flags; only the log source differs. | ||
| type LogFlags struct { |
There was a problem hiding this comment.
Note this struct (and several places in this PR) was just a refactor to get reuse with deployment logs
| Includes []string `flag:"includes" desc:"Case-sensitive substring that must appear in the log message. May be repeated; all must match."` | ||
| Excludes []string `flag:"excludes" desc:"Case-sensitive substring; lines containing it are dropped. May be repeated."` | ||
| SearchPattern string `flag:"search-pattern" desc:"RE2 regular expression matched against the log message. Prefer --includes and --excludes for plain substring matches."` | ||
| Replica string `flag:"replica" desc:"Only return logs emitted by this replica (5-char short ID)."` |
There was a problem hiding this comment.
Nit: why not ReplicaID do we generally drop IDs when talking about replicas in docs etc? Models and deployments have dedicated name and ID fields and we (should) usually be clear about which we mean in any place. Since replicas don't have names, this field is technically an ID.
There was a problem hiding this comment.
Yeah, it's more like replica suffix. I called it this because that's what UI and API calls it.
🚀 What
baseten model environment logs- full parity withmodel deployment logs(--tail,--start/--end/--since,--min-level,--includes/--excludes,--search-pattern,--replica,--request-id, text/json/jsonl).model deployment logs(andmodel push --tail) from the deprecated POST logs endpoint to the GET endpoint.💻 How
LogFlagsembedded by both flag structs.runLogsCommand+ transport-neutraltailLogsloop; each command supplies onlyFetchLogs/FetchStatusclosures.TailDeploymentLogsis now a thin adapter.🔬 Testing
Logs/Environmente2e sub-test; ran the scoped logs e2e against staging.