From 8c8fb35861a7fb3abe3d6930c20e893f6e6f0213 Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Tue, 19 Nov 2024 10:46:40 +0100 Subject: [PATCH] fix: Add explicit warning when using python wheel wrappers with source-linked deployment --- bundle/trampoline/python_dbr_warning.go | 4 ++++ bundle/trampoline/python_dbr_warning_test.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/bundle/trampoline/python_dbr_warning.go b/bundle/trampoline/python_dbr_warning.go index f62e9eab..cf3e9aeb 100644 --- a/bundle/trampoline/python_dbr_warning.go +++ b/bundle/trampoline/python_dbr_warning.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/libraries" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/log" @@ -22,6 +23,9 @@ func WrapperWarning() bundle.Mutator { func (m *wrapperWarning) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { if isPythonWheelWrapperOn(b) { + if config.IsExplicitlyEnabled(b.Config.Presets.SourceLinkedDeployment) { + return diag.Warningf("Python wheel notebook wrapper is not available when using source-linked deployment mode. You can disable this mode by setting 'presets.source_linked_deployment: false'") + } return nil } diff --git a/bundle/trampoline/python_dbr_warning_test.go b/bundle/trampoline/python_dbr_warning_test.go index d293c947..aef1b37b 100644 --- a/bundle/trampoline/python_dbr_warning_test.go +++ b/bundle/trampoline/python_dbr_warning_test.go @@ -335,6 +335,24 @@ func TestNoWarningWhenPythonWheelWrapperIsOn(t *testing.T) { require.NoError(t, diags.Error()) } +func TestPythonWheelWithSourceLinkedDeployment(t *testing.T) { + enabled := true + b := &bundle.Bundle{ + Config: config.Root{ + Experimental: &config.Experimental{ + PythonWheelWrapper: true, + }, + Presets: config.Presets{ + SourceLinkedDeployment: &enabled, + }, + }, + } + + diags := bundle.Apply(context.Background(), b, WrapperWarning()) + require.NoError(t, diags.Error()) + require.Contains(t, diags[0].Summary, "Python wheel notebook wrapper is not available when using source-linked deployment mode") +} + func TestSparkVersionLowerThanExpected(t *testing.T) { testCases := map[string]bool{ "13.1.x-scala2.12": false,