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

Pause quality monitors when "mode: development" is used #1481

Merged
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
10 changes: 10 additions & 0 deletions bundle/config/mutator/process_target_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/dyn"
"github.com/databricks/cli/libs/log"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/databricks/databricks-sdk-go/service/jobs"
"github.com/databricks/databricks-sdk-go/service/ml"
)
Expand Down Expand Up @@ -105,6 +106,15 @@ func transformDevelopmentMode(ctx context.Context, b *bundle.Bundle) diag.Diagno
// (registered models in Unity Catalog don't yet support tags)
}

for i := range r.QualityMonitors {
// Remove all schedules from monitors, since they don't support pausing/unpausing.
// Quality monitors might support the "pause" property in the future, so at the
// CLI level we do respect that property if it is set to "unpaused".
if r.QualityMonitors[i].Schedule != nil && r.QualityMonitors[i].Schedule.PauseStatus != catalog.MonitorCronSchedulePauseStatusUnpaused {
r.QualityMonitors[i].Schedule = nil
}
}

return nil
}

Expand Down
16 changes: 16 additions & 0 deletions bundle/config/mutator/process_target_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ func mockBundle(mode config.Mode) *bundle.Bundle {
},
QualityMonitors: map[string]*resources.QualityMonitor{
"qualityMonitor1": {CreateMonitor: &catalog.CreateMonitor{TableName: "qualityMonitor1"}},
"qualityMonitor2": {
CreateMonitor: &catalog.CreateMonitor{
TableName: "qualityMonitor2",
Schedule: &catalog.MonitorCronSchedule{},
},
},
"qualityMonitor3": {
CreateMonitor: &catalog.CreateMonitor{
TableName: "qualityMonitor3",
Schedule: &catalog.MonitorCronSchedule{
PauseStatus: catalog.MonitorCronSchedulePauseStatusUnpaused,
},
},
},
},
},
},
Expand Down Expand Up @@ -151,6 +165,8 @@ func TestProcessTargetModeDevelopment(t *testing.T) {

// Quality Monitor 1
assert.Equal(t, "qualityMonitor1", b.Config.Resources.QualityMonitors["qualityMonitor1"].TableName)
assert.Nil(t, b.Config.Resources.QualityMonitors["qualityMonitor2"].Schedule)
assert.Equal(t, catalog.MonitorCronSchedulePauseStatusUnpaused, b.Config.Resources.QualityMonitors["qualityMonitor3"].Schedule.PauseStatus)
}

func TestProcessTargetModeDevelopmentTagNormalizationForAws(t *testing.T) {
Expand Down
15 changes: 11 additions & 4 deletions bundle/tests/quality_monitor/databricks.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
bundle:
name: quality_monitors

resources:
quality_monitors:
my_monitor:
table_name: "main.test.thing1"
table_name: "main.test.dev"
assets_dir: "/Shared/provider-test/databricks_monitoring/main.test.thing1"
output_schema_name: "test"
output_schema_name: "main.dev"
inference_log:
granularities: ["1 day"]
timestamp_col: "timestamp"
prediction_col: "prediction"
model_id_col: "model_id"
problem_type: "PROBLEM_TYPE_REGRESSION"
schedule:
quartz_cron_expression: "0 0 12 * * ?" # every day at noon
timezone_id: UTC

targets:
development:
mode: development
default: true
resources:
quality_monitors:
my_monitor:
Expand All @@ -24,14 +31,14 @@ targets:
quality_monitors:
my_monitor:
table_name: "main.test.staging"
output_schema_name: "staging"
output_schema_name: "main.staging"

production:
resources:
quality_monitors:
my_monitor:

Choose a reason for hiding this comment

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

what does this name mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original name wasn't valid according the the API. It requires something of the format catalog.schema. Actually, that seems like something to reflect on https://docs.databricks.com/api/workspace/qualitymonitors/create?

table_name: "main.test.prod"
output_schema_name: "prod"
output_schema_name: "main.prod"
inference_log:
granularities: ["1 hour"]
timestamp_col: "timestamp_prod"
Expand Down
6 changes: 3 additions & 3 deletions bundle/tests/quality_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestMonitorTableNames(t *testing.T) {
p := b.Config.Resources.QualityMonitors["my_monitor"]
assert.Equal(t, "main.test.dev", p.TableName)
assert.Equal(t, "/Shared/provider-test/databricks_monitoring/main.test.thing1", p.AssetsDir)
assert.Equal(t, "test", p.OutputSchemaName)
assert.Equal(t, "main.dev", p.OutputSchemaName)

assertExpectedMonitor(t, p)
}
Expand All @@ -36,7 +36,7 @@ func TestMonitorStaging(t *testing.T) {
p := b.Config.Resources.QualityMonitors["my_monitor"]
assert.Equal(t, "main.test.staging", p.TableName)
assert.Equal(t, "/Shared/provider-test/databricks_monitoring/main.test.thing1", p.AssetsDir)
assert.Equal(t, "staging", p.OutputSchemaName)
assert.Equal(t, "main.staging", p.OutputSchemaName)

assertExpectedMonitor(t, p)
}
Expand All @@ -48,7 +48,7 @@ func TestMonitorProduction(t *testing.T) {
p := b.Config.Resources.QualityMonitors["my_monitor"]
assert.Equal(t, "main.test.prod", p.TableName)
assert.Equal(t, "/Shared/provider-test/databricks_monitoring/main.test.thing1", p.AssetsDir)
assert.Equal(t, "prod", p.OutputSchemaName)
assert.Equal(t, "main.prod", p.OutputSchemaName)

inferenceLog := p.InferenceLog
assert.Equal(t, []string{"1 day", "1 hour"}, inferenceLog.Granularities)
Expand Down