diff --git a/experimental/air/cmd/logstream_support.go b/experimental/air/cmd/logstream_support.go index ac250547e1..baf80575ea 100644 --- a/experimental/air/cmd/logstream_support.go +++ b/experimental/air/cmd/logstream_support.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "io" + "strings" "time" ) @@ -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 diff --git a/experimental/air/cmd/logstream_test.go b/experimental/air/cmd/logstream_test.go index 78604fe3f1..63ccfd27ca 100644 --- a/experimental/air/cmd/logstream_test.go +++ b/experimental/air/cmd/logstream_test.go @@ -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")