Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed processing jobs libraries with remote path #638

Merged
merged 1 commit into from
Aug 7, 2023
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
18 changes: 17 additions & 1 deletion bundle/libraries/libraries.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"path/filepath"
"strings"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
Expand Down Expand Up @@ -111,5 +112,20 @@ func libPath(library *compute.Library) string {
}

func isLocalLibrary(library *compute.Library) bool {
return libPath(library) != ""
path := libPath(library)
if path == "" {
return false
}

return !isDbfsPath(path) && !isWorkspacePath(path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another indicator of non-local is that it'll be an absolute path. We use this in the notebook path translation logic. We should combine the two into a single code path that determines if a path is local or not.

}

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/")
}
2 changes: 2 additions & 0 deletions bundle/tests/bundle/python_wheel/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ resources:
python_wheel_task:
package_name: "my_test_code"
entry_point: "run"
libraries:
- whl: ./my_test_code/dist/*.whl
15 changes: 15 additions & 0 deletions bundle/tests/bundle/python_wheel_dbfs_lib/bundle.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions bundle/tests/bundle/python_wheel_no_artifact/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ resources:
python_wheel_task:
package_name: "my_test_code"
entry_point: "run"
libraries:
- whl: ./dist/*.whl
22 changes: 22 additions & 0 deletions bundle/tests/bundle/wheel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/libraries"
"github.com/databricks/cli/bundle/phases"
"github.com/stretchr/testify/require"
)
Expand All @@ -21,6 +22,10 @@ func TestBundlePythonWheelBuild(t *testing.T) {
matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl")
require.NoError(t, err)
require.Equal(t, 1, len(matches))

match := libraries.MatchWithArtifacts()
err = match.Apply(context.Background(), b)
require.NoError(t, err)
}

func TestBundlePythonWheelBuildAutoDetect(t *testing.T) {
Expand All @@ -34,4 +39,21 @@ func TestBundlePythonWheelBuildAutoDetect(t *testing.T) {
matches, err := filepath.Glob("python_wheel/my_test_code/dist/my_test_code-*.whl")
require.NoError(t, err)
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)
}