mirror of https://github.com/databricks/cli.git
Only transform wheel libraries when using trampoline (#1248)
## Changes Only transform wheel libraries when using trampoline ## Tests Added regression test
This commit is contained in:
parent
982f1b5398
commit
29ab96f327
|
@ -81,6 +81,7 @@ func TestTransformWithExperimentalSettingSetToTrue(t *testing.T) {
|
||||||
},
|
},
|
||||||
Libraries: []compute.Library{
|
Libraries: []compute.Library{
|
||||||
{Whl: "/Workspace/Users/test@test.com/bundle/dist/test.whl"},
|
{Whl: "/Workspace/Users/test@test.com/bundle/dist/test.whl"},
|
||||||
|
{Jar: "/Workspace/Users/test@test.com/bundle/dist/test.jar"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -110,5 +111,6 @@ func TestTransformWithExperimentalSettingSetToTrue(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, path.Join(filepath.ToSlash(internalDirRel), "notebook_job1_key1"), task.NotebookTask.NotebookPath)
|
require.Equal(t, path.Join(filepath.ToSlash(internalDirRel), "notebook_job1_key1"), task.NotebookTask.NotebookPath)
|
||||||
|
|
||||||
require.Empty(t, task.Libraries)
|
require.Len(t, task.Libraries, 1)
|
||||||
|
require.Equal(t, "/Workspace/Users/test@test.com/bundle/dist/test.jar", task.Libraries[0].Jar)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config/mutator"
|
"github.com/databricks/cli/bundle/config/mutator"
|
||||||
"github.com/databricks/cli/bundle/libraries"
|
"github.com/databricks/cli/bundle/libraries"
|
||||||
|
"github.com/databricks/databricks-sdk-go/service/compute"
|
||||||
"github.com/databricks/databricks-sdk-go/service/jobs"
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -79,7 +80,14 @@ type pythonTrampoline struct{}
|
||||||
|
|
||||||
func (t *pythonTrampoline) CleanUp(task *jobs.Task) error {
|
func (t *pythonTrampoline) CleanUp(task *jobs.Task) error {
|
||||||
task.PythonWheelTask = nil
|
task.PythonWheelTask = nil
|
||||||
task.Libraries = nil
|
|
||||||
|
nonWheelLibraries := make([]compute.Library, 0)
|
||||||
|
for _, l := range task.Libraries {
|
||||||
|
if l.Whl == "" {
|
||||||
|
nonWheelLibraries = append(nonWheelLibraries, l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
task.Libraries = nonWheelLibraries
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -115,12 +123,19 @@ func needsTrampoline(task *jobs.Task) bool {
|
||||||
|
|
||||||
func (t *pythonTrampoline) GetTemplateData(task *jobs.Task) (map[string]any, error) {
|
func (t *pythonTrampoline) GetTemplateData(task *jobs.Task) (map[string]any, error) {
|
||||||
params, err := t.generateParameters(task.PythonWheelTask)
|
params, err := t.generateParameters(task.PythonWheelTask)
|
||||||
|
whlLibraries := make([]compute.Library, 0)
|
||||||
|
for _, l := range task.Libraries {
|
||||||
|
if l.Whl != "" {
|
||||||
|
whlLibraries = append(whlLibraries, l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
data := map[string]any{
|
data := map[string]any{
|
||||||
"Libraries": task.Libraries,
|
"Libraries": whlLibraries,
|
||||||
"Params": params,
|
"Params": params,
|
||||||
"Task": task.PythonWheelTask,
|
"Task": task.PythonWheelTask,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue