Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bundle/artifacts/whl/autodetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func (m *detectPkg) Name() string {
}

func (m *detectPkg) Apply(ctx context.Context, b *bundle.Bundle) error {
wheelTasks := libraries.FindAllWheelTasks(b)
wheelTasks := libraries.FindAllWheelTasksWithLocalLibraries(b)
if len(wheelTasks) == 0 {
log.Infof(ctx, "No wheel tasks in databricks.yml config, skipping auto detect")
log.Infof(ctx, "No local wheel tasks in databricks.yml config, skipping auto detect")
return nil
}
cmdio.LogString(ctx, "artifacts.whl.AutoDetect: Detecting Python wheel project...")
Expand Down
2 changes: 1 addition & 1 deletion bundle/artifacts/whl/from_libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (*fromLibraries) Apply(ctx context.Context, b *bundle.Bundle) error {
return nil
}

tasks := libraries.FindAllWheelTasks(b)
tasks := libraries.FindAllWheelTasksWithLocalLibraries(b)
for _, task := range tasks {
for _, lib := range task.Libraries {
matches, err := filepath.Glob(filepath.Join(b.Config.Path, lib.Whl))
Expand Down
14 changes: 12 additions & 2 deletions bundle/libraries/libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,28 @@ func findAllTasks(b *bundle.Bundle) []*jobs.Task {
return result
}

func FindAllWheelTasks(b *bundle.Bundle) []*jobs.Task {
func FindAllWheelTasksWithLocalLibraries(b *bundle.Bundle) []*jobs.Task {
tasks := findAllTasks(b)
wheelTasks := make([]*jobs.Task, 0)
for _, task := range tasks {
if task.PythonWheelTask != nil {
if task.PythonWheelTask != nil && IsTaskWithLocalLibraries(task) {
wheelTasks = append(wheelTasks, task)
}
}

return wheelTasks
}

func IsTaskWithLocalLibraries(task *jobs.Task) bool {
for _, l := range task.Libraries {
if isLocalLibrary(&l) {
return true
}
}

return false
}

func isMissingRequiredLibraries(task *jobs.Task) bool {
if task.Libraries != nil {
return false
Expand Down
5 changes: 3 additions & 2 deletions bundle/python/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/mutator"
"github.com/databricks/cli/bundle/libraries"
"github.com/databricks/databricks-sdk-go/service/jobs"
)

Expand Down Expand Up @@ -72,8 +73,8 @@ func (t *pythonTrampoline) GetTasks(b *bundle.Bundle) []mutator.TaskWithJobKey {
for i := range tasks {
task := &tasks[i]

// Keep only Python wheel tasks
if task.PythonWheelTask == nil {
// Keep only Python wheel tasks with local libraries referenced
if task.PythonWheelTask == nil || !libraries.IsTaskWithLocalLibraries(task) {
continue
}

Expand Down
11 changes: 11 additions & 0 deletions bundle/python/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/config/paths"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -82,11 +83,21 @@ func TestTransformFiltersWheelTasksOnly(t *testing.T) {
{
TaskKey: "key1",
PythonWheelTask: &jobs.PythonWheelTask{},
Libraries: []compute.Library{
{Whl: "./dist/test.whl"},
},
},
{
TaskKey: "key2",
NotebookTask: &jobs.NotebookTask{},
},
{
TaskKey: "key3",
PythonWheelTask: &jobs.PythonWheelTask{},
Libraries: []compute.Library{
{Whl: "dbfs:/FileStore/dist/test.whl"},
},
},
},
},
},
Expand Down