mirror of https://github.com/databricks/cli.git
Do not try auto detect Python package if no Python wheel tasks defined (#674)
## Changes Fixes #673 It also includes a change for `libraries` from #635 to get the list of wheel tasks
This commit is contained in:
parent
35e8ed30c6
commit
4694832534
|
@ -10,7 +10,9 @@ import (
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
|
"github.com/databricks/cli/bundle/libraries"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
"github.com/databricks/cli/libs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type detectPkg struct {
|
type detectPkg struct {
|
||||||
|
@ -25,6 +27,11 @@ func (m *detectPkg) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *detectPkg) Apply(ctx context.Context, b *bundle.Bundle) error {
|
func (m *detectPkg) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
|
wheelTasks := libraries.FindAllWheelTasks(b)
|
||||||
|
if len(wheelTasks) == 0 {
|
||||||
|
log.Infof(ctx, "No wheel tasks in databricks.yml config, skipping auto detect")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
cmdio.LogString(ctx, "artifacts.whl.AutoDetect: Detecting Python wheel project...")
|
cmdio.LogString(ctx, "artifacts.whl.AutoDetect: Detecting Python wheel project...")
|
||||||
|
|
||||||
// checking if there is setup.py in the bundle root
|
// checking if there is setup.py in the bundle root
|
||||||
|
|
|
@ -25,26 +25,48 @@ func (a *match) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *match) Apply(ctx context.Context, b *bundle.Bundle) error {
|
func (a *match) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
r := b.Config.Resources
|
tasks := findAllTasks(b)
|
||||||
for k := range b.Config.Resources.Jobs {
|
for _, task := range tasks {
|
||||||
tasks := r.Jobs[k].JobSettings.Tasks
|
if isMissingRequiredLibraries(task) {
|
||||||
for i := range tasks {
|
return fmt.Errorf("task '%s' is missing required libraries. Please include your package code in task libraries block", task.TaskKey)
|
||||||
task := &tasks[i]
|
}
|
||||||
if isMissingRequiredLibraries(task) {
|
for j := range task.Libraries {
|
||||||
return fmt.Errorf("task '%s' is missing required libraries. Please include your package code in task libraries block", task.TaskKey)
|
lib := &task.Libraries[j]
|
||||||
}
|
err := findArtifactsAndMarkForUpload(ctx, lib, b)
|
||||||
for j := range task.Libraries {
|
if err != nil {
|
||||||
lib := &task.Libraries[j]
|
return err
|
||||||
err := findArtifactsAndMarkForUpload(ctx, lib, b)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func findAllTasks(b *bundle.Bundle) []*jobs.Task {
|
||||||
|
r := b.Config.Resources
|
||||||
|
result := make([]*jobs.Task, 0)
|
||||||
|
for k := range b.Config.Resources.Jobs {
|
||||||
|
tasks := r.Jobs[k].JobSettings.Tasks
|
||||||
|
for i := range tasks {
|
||||||
|
task := &tasks[i]
|
||||||
|
result = append(result, task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func FindAllWheelTasks(b *bundle.Bundle) []*jobs.Task {
|
||||||
|
tasks := findAllTasks(b)
|
||||||
|
wheelTasks := make([]*jobs.Task, 0)
|
||||||
|
for _, task := range tasks {
|
||||||
|
if task.PythonWheelTask != nil {
|
||||||
|
wheelTasks = append(wheelTasks, task)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wheelTasks
|
||||||
|
}
|
||||||
|
|
||||||
func isMissingRequiredLibraries(task *jobs.Task) bool {
|
func isMissingRequiredLibraries(task *jobs.Task) bool {
|
||||||
if task.Libraries != nil {
|
if task.Libraries != nil {
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue