From 511db52bb7a47270dd883bb490a8844f9b25fe76 Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:21:13 +0530 Subject: [PATCH] Remove unnecessary GET call in pipeline runner (#1850) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes This GET API call is unnecessary and serves no purpose. Let's remove it. Noticed this when I was adding a unit test for the pipeline runner here: https://github.com/databricks/cli/pull/1849 ## Tests Manually. ### Case 1: The pipeline does not exist Before: ``` ➜ my_project git:(master) ✗ databricks bundle run my_project_pipeline -p dogfood Error: User shreyas.goenka@databricks.com does not have View permissions on pipeline 9941901a-e48b-4d04-b6ba-e0072ad126bg. ``` After: ``` ➜ my_project git:(master) ✗ cli bundle run my_project_pipeline -p dogfood Error: User shreyas.goenka@databricks.com does not have Run permissions on pipeline 9941901a-e48b-4d04-b6ba-e0072ad126bg. ``` ### Case 2: Pipeline exists Before: ``` ➜ my_project git:(master) ✗ databricks bundle run my_project_pipeline -p dogfood --restart Update URL: https://e2-dogfood.staging.cloud.databricks.com/#joblist/pipelines/9941901a-e48b-4d04-b6ba-e0072ad126bf/updates/0f988d62-9ec7-49f1-b429-5572ece3a9aa 2024-11-18T15:30:36.054Z update_progress INFO "Update 0f988d is WAITING_FOR_RESOURCES." ``` After: ``` ➜ my_project git:(master) ✗ cli bundle run my_project_pipeline -p dogfood --restart Update URL: https://e2-dogfood.staging.cloud.databricks.com/#joblist/pipelines/9941901a-e48b-4d04-b6ba-e0072ad126bf/updates/87b43350-6186-4a9b-9d0e-38da2ecf33ae 2024-11-18T15:28:27.144Z update_progress INFO "Update 87b433 is WAITING_FOR_RESOURCES." ``` --- bundle/run/pipeline.go | 5 ----- bundle/run/pipeline_test.go | 2 -- 2 files changed, 7 deletions(-) diff --git a/bundle/run/pipeline.go b/bundle/run/pipeline.go index a0e7d1e1e..d84015d76 100644 --- a/bundle/run/pipeline.go +++ b/bundle/run/pipeline.go @@ -90,11 +90,6 @@ func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (output.RunOutp // Include resource key in logger. ctx = log.NewContext(ctx, log.GetLogger(ctx).With("resource", r.Key())) w := r.bundle.WorkspaceClient() - _, err := w.Pipelines.GetByPipelineId(ctx, pipelineID) - if err != nil { - log.Warnf(ctx, "Cannot get pipeline: %s", err) - return nil, err - } req, err := opts.Pipeline.toPayload(r.pipeline, pipelineID) if err != nil { diff --git a/bundle/run/pipeline_test.go b/bundle/run/pipeline_test.go index 66f9d86be..bfa0c5846 100644 --- a/bundle/run/pipeline_test.go +++ b/bundle/run/pipeline_test.go @@ -90,8 +90,6 @@ func TestPipelineRunnerRestart(t *testing.T) { PipelineId: "123", }).Return(mockWait, nil) - pipelineApi.EXPECT().GetByPipelineId(mock.Anything, "123").Return(&pipelines.GetPipelineResponse{}, nil) - // Mock runner starting a new update pipelineApi.EXPECT().StartUpdate(mock.Anything, pipelines.StartUpdate{ PipelineId: "123",