mirror of https://github.com/databricks/cli.git
Fixed processing jobs libraries with remote path (#638)
## Changes Some library paths such as for Spark jobs, can reference a lib on remote path, for example DBFS. This PR fixes how CLI handles such libraries and do not report them as missing locally. ## Tests Added unit tests + ran `databricks bundle deploy` manually
This commit is contained in:
parent
ce9c9148c9
commit
f7a76ff5d8
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
|
@ -111,5 +112,20 @@ func libPath(library *compute.Library) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isLocalLibrary(library *compute.Library) bool {
|
func isLocalLibrary(library *compute.Library) bool {
|
||||||
return libPath(library) != ""
|
path := libPath(library)
|
||||||
|
if path == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return !isDbfsPath(path) && !isWorkspacePath(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isDbfsPath(path string) bool {
|
||||||
|
return strings.HasPrefix(path, "dbfs:/")
|
||||||
|
}
|
||||||
|
|
||||||
|
func isWorkspacePath(path string) bool {
|
||||||
|
return strings.HasPrefix(path, "/Workspace/") ||
|
||||||
|
strings.HasPrefix(path, "/Users/") ||
|
||||||
|
strings.HasPrefix(path, "/Shared/")
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,3 +17,5 @@ resources:
|
||||||
python_wheel_task:
|
python_wheel_task:
|
||||||
package_name: "my_test_code"
|
package_name: "my_test_code"
|
||||||
entry_point: "run"
|
entry_point: "run"
|
||||||
|
libraries:
|
||||||
|
- whl: ./my_test_code/dist/*.whl
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
bundle:
|
||||||
|
name: python-wheel
|
||||||
|
|
||||||
|
resources:
|
||||||
|
jobs:
|
||||||
|
test_job:
|
||||||
|
name: "[${bundle.environment}] My Wheel Job"
|
||||||
|
tasks:
|
||||||
|
- task_key: TestTask
|
||||||
|
existing_cluster_id: "0717-132531-5opeqon1"
|
||||||
|
python_wheel_task:
|
||||||
|
package_name: "my_test_code"
|
||||||
|
entry_point: "run"
|
||||||
|
libraries:
|
||||||
|
- whl: dbfs://path/to/dist/mywheel.whl
|
|
@ -11,3 +11,5 @@ resources:
|
||||||
python_wheel_task:
|
python_wheel_task:
|
||||||
package_name: "my_test_code"
|
package_name: "my_test_code"
|
||||||
entry_point: "run"
|
entry_point: "run"
|
||||||
|
libraries:
|
||||||
|
- whl: ./dist/*.whl
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/libraries"
|
||||||
"github.com/databricks/cli/bundle/phases"
|
"github.com/databricks/cli/bundle/phases"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -21,6 +22,10 @@ func TestBundlePythonWheelBuild(t *testing.T) {
|
||||||
matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl")
|
matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, len(matches))
|
require.Equal(t, 1, len(matches))
|
||||||
|
|
||||||
|
match := libraries.MatchWithArtifacts()
|
||||||
|
err = match.Apply(context.Background(), b)
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBundlePythonWheelBuildAutoDetect(t *testing.T) {
|
func TestBundlePythonWheelBuildAutoDetect(t *testing.T) {
|
||||||
|
@ -34,4 +39,21 @@ func TestBundlePythonWheelBuildAutoDetect(t *testing.T) {
|
||||||
matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl")
|
matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, 1, len(matches))
|
require.Equal(t, 1, len(matches))
|
||||||
|
|
||||||
|
match := libraries.MatchWithArtifacts()
|
||||||
|
err = match.Apply(context.Background(), b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBundlePythonWheelWithDBFSLib(t *testing.T) {
|
||||||
|
b, err := bundle.Load("./python_wheel_dbfs_lib")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
m := phases.Build()
|
||||||
|
err = m.Apply(context.Background(), b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
match := libraries.MatchWithArtifacts()
|
||||||
|
err = match.Apply(context.Background(), b)
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue