Skip to content

Add model environment logs command and switch deployment logs to GET - #32

Merged
cretz merged 1 commit into
mainfrom
cretz/cli-env-logs
Jul 7, 2026
Merged

Add model environment logs command and switch deployment logs to GET#32
cretz merged 1 commit into
mainfrom
cretz/cli-env-logs

Conversation

@cretz

@cretz cretz commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

🚀 What

  • Adds baseten model environment logs - full parity with model deployment logs (--tail, --start/--end/--since, --min-level, --includes/--excludes, --search-pattern, --replica, --request-id, text/json/jsonl).
  • Switches model deployment logs (and model push --tail) from the deprecated POST logs endpoint to the GET endpoint.

💻 How

  • Extracted shared LogFlags embedded by both flag structs.
  • Single runLogsCommand + transport-neutral tailLogs loop; each command supplies only FetchLogs/FetchStatus closures. TailDeploymentLogs is now a thin adapter.

🔬 Testing

  • New unit tests for env logs; deployment-logs tests converted to GET query-param assertions; push-tail test routes updated to GET.
  • New Logs/Environment e2e sub-test; ran the scoped logs e2e against staging.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 logs with the same windowing/filtering/tail UX as model deployment logs.
  • Refactors log querying/tailing into shared helpers (LogFlags, runLogsCommand, transport-neutral tailLogs).
  • 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.

Comment on lines 371 to 375
// 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 {
Comment thread cmd/command.model.go
// 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 {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this struct (and several places in this PR) was just a refactor to get reuse with deployment logs

Comment thread cmd/command.model.go
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)."`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's more like replica suffix. I called it this because that's what UI and API calls it.

@cretz
cretz merged commit f5883c8 into main Jul 7, 2026
5 checks passed
@cretz
cretz deleted the cretz/cli-env-logs branch July 7, 2026 14:09
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.

3 participants