-
Notifications
You must be signed in to change notification settings - Fork 72
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
Default to forward slash-separated paths for path translation #2145
Changes from all commits
c814fd8
751b480
e5df30f
4dcdf74
53fb805
046ad48
3a29719
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
"os" | ||
"path/filepath" | ||
"runtime" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/databricks/cli/bundle" | ||
|
@@ -226,7 +225,7 @@ func TestTranslatePaths(t *testing.T) { | |
) | ||
assert.Equal( | ||
t, | ||
filepath.Join("dist", "task.whl"), | ||
"dist/task.whl", | ||
b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl, | ||
) | ||
assert.Equal( | ||
|
@@ -251,7 +250,7 @@ func TestTranslatePaths(t *testing.T) { | |
) | ||
assert.Equal( | ||
t, | ||
filepath.Join("dist", "task.jar"), | ||
"dist/task.jar", | ||
b.Config.Resources.Jobs["job"].Tasks[5].Libraries[0].Jar, | ||
) | ||
assert.Equal( | ||
|
@@ -362,7 +361,7 @@ func TestTranslatePathsInSubdirectories(t *testing.T) { | |
) | ||
assert.Equal( | ||
t, | ||
filepath.Join("job", "dist", "task.jar"), | ||
"job/dist/task.jar", | ||
b.Config.Resources.Jobs["job"].Tasks[1].Libraries[0].Jar, | ||
) | ||
assert.Equal( | ||
|
@@ -774,8 +773,8 @@ func TestTranslatePathJobEnvironments(t *testing.T) { | |
diags := bundle.Apply(context.Background(), b, mutator.TranslatePaths()) | ||
require.NoError(t, diags.Error()) | ||
|
||
assert.Equal(t, strings.Join([]string{".", "job", "dist", "env1.whl"}, string(os.PathSeparator)), b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[0]) | ||
assert.Equal(t, strings.Join([]string{".", "dist", "env2.whl"}, string(os.PathSeparator)), b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[1]) | ||
assert.Equal(t, "./job/dist/env1.whl", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question - might not be in scope for this PR - sometimes the paths have ./ in front ("./job/dist/env1.whl"), sometimes they don't ("job/dist/task.jar"). Should we standardize on that? Why not drop "./" from everywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I recall correctly, this has its roots in the need to differentiate between a path reference and a PyPI package. Agree that we should revisit and see if it can be normalized. @andrewnester Do you recall the specifics? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally I think that was the reason but now I think we can safely drop it |
||
assert.Equal(t, "./dist/env2.whl", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[1]) | ||
assert.Equal(t, "simplejson", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[2]) | ||
assert.Equal(t, "/Workspace/Users/foo@bar.com/test.whl", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[3]) | ||
assert.Equal(t, "--extra-index-url https://name:token@gitlab.com/api/v4/projects/9876/packages/pypi/simple foobar", b.Config.Resources.Jobs["job"].JobSettings.Environments[0].Spec.Dependencies[4]) | ||
|
@@ -839,7 +838,7 @@ func TestTranslatePathWithComplexVariables(t *testing.T) { | |
|
||
assert.Equal( | ||
t, | ||
filepath.Join("variables", "local", "whl.whl"), | ||
"variables/local/whl.whl", | ||
b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl, | ||
) | ||
} | ||
|
@@ -952,34 +951,34 @@ func TestTranslatePathsWithSourceLinkedDeployment(t *testing.T) { | |
// updated to source path | ||
assert.Equal( | ||
t, | ||
filepath.Join(dir, "my_job_notebook"), | ||
dir+"/my_job_notebook", | ||
b.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath, | ||
) | ||
assert.Equal( | ||
t, | ||
filepath.Join(dir, "requirements.txt"), | ||
dir+"/requirements.txt", | ||
b.Config.Resources.Jobs["job"].Tasks[2].Libraries[0].Requirements, | ||
) | ||
assert.Equal( | ||
t, | ||
filepath.Join(dir, "my_python_file.py"), | ||
dir+"/my_python_file.py", | ||
b.Config.Resources.Jobs["job"].Tasks[3].SparkPythonTask.PythonFile, | ||
) | ||
assert.Equal( | ||
t, | ||
filepath.Join(dir, "my_pipeline_notebook"), | ||
dir+"/my_pipeline_notebook", | ||
b.Config.Resources.Pipelines["pipeline"].Libraries[0].Notebook.Path, | ||
) | ||
assert.Equal( | ||
t, | ||
filepath.Join(dir, "my_python_file.py"), | ||
dir+"/my_python_file.py", | ||
b.Config.Resources.Pipelines["pipeline"].Libraries[2].File.Path, | ||
) | ||
|
||
// left as is | ||
assert.Equal( | ||
t, | ||
filepath.Join("dist", "task.whl"), | ||
"dist/task.whl", | ||
b.Config.Resources.Jobs["job"].Tasks[0].Libraries[0].Whl, | ||
) | ||
assert.Equal( | ||
|
@@ -989,7 +988,7 @@ func TestTranslatePathsWithSourceLinkedDeployment(t *testing.T) { | |
) | ||
assert.Equal( | ||
t, | ||
filepath.Join("dist", "task.jar"), | ||
"dist/task.jar", | ||
b.Config.Resources.Jobs["job"].Tasks[4].Libraries[0].Jar, | ||
) | ||
assert.Equal( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to perform similar clean up across the whole codebase, or at least in bundle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few other places where we do the same (e.g. sync includes), but definitely not everywhere.
The
filepath
package must be used for relative path computations because on Windows it makes sure it doesn't escape the drive or UNC path. I recall that also for globbing the input paths need to use the platform-native separator or they don't work.