diff --git a/bundle/config/mutator/translate_paths.go b/bundle/config/mutator/translate_paths.go index c00964602..d34a3f005 100644 --- a/bundle/config/mutator/translate_paths.go +++ b/bundle/config/mutator/translate_paths.go @@ -115,6 +115,13 @@ func (m *translatePaths) translatePipelineLibrary(b *bundle.Bundle, library *pip } } + if library.File != nil { + err = m.rewritePath(b, &library.File.Path, m.translateFilePath) + if err != nil { + return err + } + } + return nil } diff --git a/bundle/config/mutator/translate_paths_test.go b/bundle/config/mutator/translate_paths_test.go index f6a87bc9c..0767200bd 100644 --- a/bundle/config/mutator/translate_paths_test.go +++ b/bundle/config/mutator/translate_paths_test.go @@ -99,6 +99,11 @@ func TestTranslatePaths(t *testing.T) { { Jar: "foo", }, + { + File: &pipelines.FileLibrary{ + Path: "./my_python_file.py", + }, + }, }, }, }, @@ -148,6 +153,11 @@ func TestTranslatePaths(t *testing.T) { "/bundle/my_pipeline_notebook", bundle.Config.Resources.Pipelines["pipeline"].Libraries[2].Notebook.Path, ) + assert.Equal( + t, + "/bundle/my_python_file.py", + bundle.Config.Resources.Pipelines["pipeline"].Libraries[4].File.Path, + ) } func TestJobNotebookDoesNotExistError(t *testing.T) { diff --git a/bundle/deploy/terraform/convert_test.go b/bundle/deploy/terraform/convert_test.go index 2d833ffd6..8d2e4e8ef 100644 --- a/bundle/deploy/terraform/convert_test.go +++ b/bundle/deploy/terraform/convert_test.go @@ -9,6 +9,7 @@ import ( "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/databricks/databricks-sdk-go/service/libraries" "github.com/databricks/databricks-sdk-go/service/mlflow" + "github.com/databricks/databricks-sdk-go/service/pipelines" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -108,6 +109,39 @@ func TestConvertJobTaskLibraries(t *testing.T) { assert.Equal(t, "mlflow", out.Resource.Job["my_job"].Task[0].Library[0].Pypi.Package) } +func TestConvertPipeline(t *testing.T) { + var src = resources.Pipeline{ + PipelineSpec: &pipelines.PipelineSpec{ + Name: "my pipeline", + Libraries: []pipelines.PipelineLibrary{ + { + Notebook: &pipelines.NotebookLibrary{ + Path: "notebook path", + }, + }, + { + File: &pipelines.FileLibrary{ + Path: "file path", + }, + }, + }, + }, + } + + var config = config.Root{ + Resources: config.Resources{ + Pipelines: map[string]*resources.Pipeline{ + "my_pipeline": &src, + }, + }, + } + + out := BundleToTerraform(&config) + assert.Equal(t, "my pipeline", out.Resource.Pipeline["my_pipeline"].Name) + assert.Len(t, out.Resource.Pipeline["my_pipeline"].Library, 2) + assert.Nil(t, out.Data) +} + func TestConvertPipelinePermissions(t *testing.T) { var src = resources.Pipeline{ Permissions: []resources.Permission{