Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions experimental/air/cmd/logstream_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"strings"
"time"
)

Expand Down Expand Up @@ -143,10 +144,24 @@ func printTerminalEvent(out io.Writer, runID, status, dashboardURL string) {
fmt.Fprintln(out, string(b))
}

// emitLogLine writes one log line: raw in text mode, or a JSONL LOG event under
// --json. In --json mode a line matching a fatal-failure pattern also emits an
// ALERT event first, giving an agent an immediate actionable signal.
const (
missingRequirementsNoticePrefix = "No co-located requirements.yaml at "
missingRequirementsNoticeSuffix = "; skipping requirements.yaml install."
)

// suppressLogLine reports whether a backend log line should be omitted.
func suppressLogLine(body string) bool {
// This backend-derived notice is non-actionable noise because requirements.yaml
// is not supported by Databricks Air and is rejected earlier.
return strings.HasPrefix(body, missingRequirementsNoticePrefix) &&
strings.HasSuffix(body, missingRequirementsNoticeSuffix)
}

// emitLogLine writes one relevant log line.
func emitLogLine(out io.Writer, req logRequest, body string) {
if suppressLogLine(body) {
return
}
if !req.jsonOutput {
fmt.Fprintln(out, body)
return
Expand Down
15 changes: 15 additions & 0 deletions experimental/air/cmd/logstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,21 @@ func TestEmitLogLineText(t *testing.T) {
assert.Equal(t, "hello\n", buf.String())
}

func TestEmitLogLineSuppressesMissingRequirementsNotice(t *testing.T) {
body := "No co-located requirements.yaml at /Workspace/Users/user/.air/cli_launch/run/requirements.yaml; skipping requirements.yaml install."

for _, req := range []logRequest{{node: 0}, {node: 0, jsonOutput: true}} {
var buf bytes.Buffer
emitLogLine(&buf, req, body)
assert.Empty(t, buf.String())
}
}

func TestSuppressLogLineKeepsRequirementsErrors(t *testing.T) {
assert.False(t, suppressLogLine("ERROR: requirements.yaml not found"))
assert.False(t, suppressLogLine("ERROR: Failed to process requirements.yaml"))
}

func TestEmitLogLineJSONFatalEmitsAlert(t *testing.T) {
var buf bytes.Buffer
emitLogLine(&buf, logRequest{node: 1, jsonOutput: true}, "CUDA out of memory")
Expand Down
Loading