diff --git a/.nextchanges/air/list-info-pane-experiment.md b/.nextchanges/air/list-info-pane-experiment.md new file mode 100644 index 00000000000..6378f6afcec --- /dev/null +++ b/.nextchanges/air/list-info-pane-experiment.md @@ -0,0 +1 @@ +* Fix the `air list` info pane showing `N/A` for a run's Experiment and Accelerators; it now shows them as `air get` does. ([#7598](https://github.com/databricks/cli/pull/7598)) diff --git a/cmd/air/list_detail.go b/cmd/air/list_detail.go index 96e50728dc0..55451550d77 100644 --- a/cmd/air/list_detail.go +++ b/cmd/air/list_detail.go @@ -32,6 +32,11 @@ func runDetailText(ctx context.Context, w *databricks.WorkspaceClient, runID int url := mlflowLogsURL(w.Config.Host, ids) data.MLflowURL = &url } + // Same as `air get`: the experiment and accelerators come from the run's + // ai_runtime_task; a sweep or GenAI compute run has none. + if findForEachTask(run) == nil && genAIComputeTask(run) == nil { + enrichFromAiRuntimeTask(run, &data) + } var buf bytes.Buffer renderRunText(ctx, &buf, w, run, &data, ids) diff --git a/cmd/air/list_detail_test.go b/cmd/air/list_detail_test.go index 997b8131c48..e64140f4348 100644 --- a/cmd/air/list_detail_test.go +++ b/cmd/air/list_detail_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/assert" @@ -145,3 +146,28 @@ func TestUnnamedOlderRetryLabelFitsTheListColumnAndIsWholeInTheInfoPane(t *testi assert.Equal(t, mlflowColWidth, lipgloss.Width(rows[0].MLflowLabel)) assert.Contains(t, info, mlflowRunID+" (retry 0)") } + +func TestInfoPaneShowsExperimentAndAcceleratorsLikeAirGet(t *testing.T) { + // Given a finished run whose ai_runtime_task names its experiment and compute. + run := indexRun(7, 1000_000) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/api/2.2/jobs/runs/get" { + _ = json.NewEncoder(w).Encode(run) + return + } + _, _ = w.Write([]byte(`{}`)) + })) + t.Cleanup(srv.Close) + ctx := cmdio.MockDiscard(t.Context()) + w := newTestWorkspaceClient(t, srv.URL) + + // When the info pane renders the run. + info, err := runDetailText(ctx, w, 7) + require.NoError(t, err) + + // Then it shows the experiment and accelerators that `air get` shows for the + // same run, instead of their "N/A" fallbacks. + plain := ansi.Strip(info) + assert.Contains(t, plain, "Experiment exp ") + assert.Contains(t, plain, "Accelerators 1x H100 ") +}