mirror of https://github.com/databricks/cli.git
Support experiment names that use full paths
This commit is contained in:
parent
6b221c02e5
commit
cbd306825b
|
@ -3,6 +3,7 @@ package mutator
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/bundle/config"
|
"github.com/databricks/cli/bundle/config"
|
||||||
|
@ -60,7 +61,14 @@ func processDevelopmentMode(b *bundle.Bundle) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range r.Experiments {
|
for i := range r.Experiments {
|
||||||
r.Experiments[i].Name = "[dev] " + r.Experiments[i].Name
|
path := r.Experiments[i].Name
|
||||||
|
dir := filepath.Dir(path)
|
||||||
|
base := filepath.Base(path)
|
||||||
|
if dir == "." {
|
||||||
|
r.Experiments[i].Name = "[dev] " + base
|
||||||
|
} else {
|
||||||
|
r.Experiments[i].Name = dir + "/[dev] " + base
|
||||||
|
}
|
||||||
r.Experiments[i].Tags = append(r.Experiments[i].Tags, ml.ExperimentTag{Key: "dev", Value: ""})
|
r.Experiments[i].Tags = append(r.Experiments[i].Tags, ml.ExperimentTag{Key: "dev", Value: ""})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ func TestProcessEnvironmentModeApplyDebug(t *testing.T) {
|
||||||
"pipeline1": {PipelineSpec: &pipelines.PipelineSpec{Name: "pipeline1"}},
|
"pipeline1": {PipelineSpec: &pipelines.PipelineSpec{Name: "pipeline1"}},
|
||||||
},
|
},
|
||||||
Experiments: map[string]*resources.MlflowExperiment{
|
Experiments: map[string]*resources.MlflowExperiment{
|
||||||
"experiment1": {Experiment: &ml.Experiment{Name: "experiment1"}},
|
"experiment1": {Experiment: &ml.Experiment{Name: "/Users/lennart.kats@databricks.com/experiment1"}},
|
||||||
|
"experiment2": {Experiment: &ml.Experiment{Name: "experiment2"}},
|
||||||
},
|
},
|
||||||
Models: map[string]*resources.MlflowModel{
|
Models: map[string]*resources.MlflowModel{
|
||||||
"model1": {Model: &ml.Model{Name: "model1"}},
|
"model1": {Model: &ml.Model{Name: "model1"}},
|
||||||
|
@ -43,7 +44,8 @@ func TestProcessEnvironmentModeApplyDebug(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "[dev] job1", bundle.Config.Resources.Jobs["job1"].Name)
|
assert.Equal(t, "[dev] job1", bundle.Config.Resources.Jobs["job1"].Name)
|
||||||
assert.Equal(t, "[dev] pipeline1", bundle.Config.Resources.Pipelines["pipeline1"].Name)
|
assert.Equal(t, "[dev] pipeline1", bundle.Config.Resources.Pipelines["pipeline1"].Name)
|
||||||
assert.Equal(t, "[dev] experiment1", bundle.Config.Resources.Experiments["experiment1"].Name)
|
assert.Equal(t, "/Users/lennart.kats@databricks.com/[dev] experiment1", bundle.Config.Resources.Experiments["experiment1"].Name)
|
||||||
|
assert.Equal(t, "[dev] experiment2", bundle.Config.Resources.Experiments["experiment2"].Name)
|
||||||
assert.Equal(t, "[dev] model1", bundle.Config.Resources.Models["model1"].Name)
|
assert.Equal(t, "[dev] model1", bundle.Config.Resources.Models["model1"].Name)
|
||||||
assert.Equal(t, "dev", bundle.Config.Resources.Experiments["experiment1"].Experiment.Tags[0].Key)
|
assert.Equal(t, "dev", bundle.Config.Resources.Experiments["experiment1"].Experiment.Tags[0].Key)
|
||||||
assert.True(t, bundle.Config.Resources.Pipelines["pipeline1"].PipelineSpec.Development)
|
assert.True(t, bundle.Config.Resources.Pipelines["pipeline1"].PipelineSpec.Development)
|
||||||
|
|
Loading…
Reference in New Issue