diff --git a/bundle/config/mutator/translate_paths.go b/bundle/config/mutator/translate_paths.go index ab2534ac..940ac212 100644 --- a/bundle/config/mutator/translate_paths.go +++ b/bundle/config/mutator/translate_paths.go @@ -154,6 +154,11 @@ func (m *translatePaths) Apply(_ context.Context, b *bundle.Bundle) error { return fmt.Errorf("unable to determine directory for job %s: %w", key, err) } + // Do not translate job task paths if using git source + if job.GitSource != nil { + continue + } + for i := 0; i < len(job.Tasks); i++ { err := m.translateJobTask(dir, b, &job.Tasks[i]) if err != nil { diff --git a/bundle/config/mutator/translate_paths_test.go b/bundle/config/mutator/translate_paths_test.go index ef7bed6c..df99bc19 100644 --- a/bundle/config/mutator/translate_paths_test.go +++ b/bundle/config/mutator/translate_paths_test.go @@ -31,6 +31,73 @@ func touchEmptyFile(t *testing.T, path string) { f.Close() } +func TestTranslatePathsSkippedWithGitSource(t *testing.T) { + dir := t.TempDir() + bundle := &bundle.Bundle{ + Config: config.Root{ + Path: dir, + Workspace: config.Workspace{ + FilesPath: "/bundle", + }, + Resources: config.Resources{ + Jobs: map[string]*resources.Job{ + "job": { + + Paths: resources.Paths{ + ConfigFilePath: filepath.Join(dir, "resource.yml"), + }, + JobSettings: &jobs.JobSettings{ + GitSource: &jobs.GitSource{ + GitBranch: "somebranch", + GitCommit: "somecommit", + GitProvider: "github", + GitTag: "sometag", + GitUrl: "https://github.com/someuser/somerepo", + }, + Tasks: []jobs.JobTaskSettings{ + { + NotebookTask: &jobs.NotebookTask{ + NotebookPath: "my_job_notebook.py", + }, + }, + { + PythonWheelTask: &jobs.PythonWheelTask{ + PackageName: "foo", + }, + }, + { + SparkPythonTask: &jobs.SparkPythonTask{ + PythonFile: "my_python_file.py", + }, + }, + }, + }, + }, + }, + }, + }, + } + + err := mutator.TranslatePaths().Apply(context.Background(), bundle) + require.NoError(t, err) + + assert.Equal( + t, + "my_job_notebook.py", + bundle.Config.Resources.Jobs["job"].Tasks[0].NotebookTask.NotebookPath, + ) + assert.Equal( + t, + "foo", + bundle.Config.Resources.Jobs["job"].Tasks[1].PythonWheelTask.PackageName, + ) + assert.Equal( + t, + "my_python_file.py", + bundle.Config.Resources.Jobs["job"].Tasks[2].SparkPythonTask.PythonFile, + ) +} + func TestTranslatePaths(t *testing.T) { dir := t.TempDir() touchNotebookFile(t, filepath.Join(dir, "my_job_notebook.py"))