mirror of https://github.com/databricks/cli.git
Filter down to Python wheel tasks only for trampoline (#712)
## Changes Fixes issue introduced in #635. ## Tests Added new unit test to confirm correct behavior. Manually deployed sample bundle.
This commit is contained in:
parent
12368e3382
commit
ca2f1dc06c
|
@ -69,6 +69,12 @@ func (t *pythonTrampoline) GetTasks(b *bundle.Bundle) []mutator.TaskWithJobKey {
|
|||
tasks := r.Jobs[k].JobSettings.Tasks
|
||||
for i := range tasks {
|
||||
task := &tasks[i]
|
||||
|
||||
// Keep only Python wheel tasks
|
||||
if task.PythonWheelTask == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result, mutator.TaskWithJobKey{
|
||||
JobKey: k,
|
||||
Task: task,
|
||||
|
|
|
@ -4,6 +4,9 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/databricks/cli/bundle"
|
||||
"github.com/databricks/cli/bundle/config"
|
||||
"github.com/databricks/cli/bundle/config/resources"
|
||||
"github.com/databricks/databricks-sdk-go/service/jobs"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -12,9 +15,9 @@ type testCase struct {
|
|||
Actual []string
|
||||
Expected string
|
||||
}
|
||||
type NamedParams map[string]string
|
||||
|
||||
type testCaseNamed struct {
|
||||
Actual NamedParams
|
||||
Actual map[string]string
|
||||
Expected string
|
||||
}
|
||||
|
||||
|
@ -27,12 +30,12 @@ var paramsTestCases []testCase = []testCase{
|
|||
}
|
||||
|
||||
var paramsTestCasesNamed []testCaseNamed = []testCaseNamed{
|
||||
{NamedParams{}, `"python"`},
|
||||
{NamedParams{"a": "1"}, `"python", "a=1"`},
|
||||
{NamedParams{"a": "'1'"}, `"python", "a='1'"`},
|
||||
{NamedParams{"a": `"1"`}, `"python", "a=\"1\""`},
|
||||
{NamedParams{"a": "1", "b": "2"}, `"python", "a=1", "b=2"`},
|
||||
{NamedParams{"data": `{"a": 1}`}, `"python", "data={\"a\": 1}"`},
|
||||
{map[string]string{}, `"python"`},
|
||||
{map[string]string{"a": "1"}, `"python", "a=1"`},
|
||||
{map[string]string{"a": "'1'"}, `"python", "a='1'"`},
|
||||
{map[string]string{"a": `"1"`}, `"python", "a=\"1\""`},
|
||||
{map[string]string{"a": "1", "b": "2"}, `"python", "a=1", "b=2"`},
|
||||
{map[string]string{"data": `{"a": 1}`}, `"python", "data={\"a\": 1}"`},
|
||||
}
|
||||
|
||||
func TestGenerateParameters(t *testing.T) {
|
||||
|
@ -64,3 +67,35 @@ func TestGenerateBoth(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
require.ErrorContains(t, err, "not allowed to pass both paramaters and named_parameters")
|
||||
}
|
||||
|
||||
func TestTransformFiltersWheelTasksOnly(t *testing.T) {
|
||||
trampoline := pythonTrampoline{}
|
||||
bundle := &bundle.Bundle{
|
||||
Config: config.Root{
|
||||
Resources: config.Resources{
|
||||
Jobs: map[string]*resources.Job{
|
||||
"job1": {
|
||||
JobSettings: &jobs.JobSettings{
|
||||
Tasks: []jobs.Task{
|
||||
{
|
||||
TaskKey: "key1",
|
||||
PythonWheelTask: &jobs.PythonWheelTask{},
|
||||
},
|
||||
{
|
||||
TaskKey: "key2",
|
||||
NotebookTask: &jobs.NotebookTask{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
tasks := trampoline.GetTasks(bundle)
|
||||
require.Len(t, tasks, 1)
|
||||
require.Equal(t, "job1", tasks[0].JobKey)
|
||||
require.Equal(t, "key1", tasks[0].Task.TaskKey)
|
||||
require.NotNil(t, tasks[0].Task.PythonWheelTask)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue