Migrate quality_monitor_test.go to acceptance test (#2192)

This commit is contained in:
Denis Bilenko 2025-01-20 17:33:03 +01:00 committed by GitHub
parent 84a73052d2
commit ee4a4b4c24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 76 additions and 59 deletions

View File

@ -0,0 +1,73 @@
>>> $CLI bundle validate -o json -t development
{
"mode": "development",
"quality_monitors": {
"my_monitor": {
"assets_dir": "/Shared/provider-test/databricks_monitoring/main.test.thing1",
"inference_log": {
"granularities": [
"1 day"
],
"model_id_col": "model_id",
"prediction_col": "prediction",
"problem_type": "PROBLEM_TYPE_REGRESSION",
"timestamp_col": "timestamp"
},
"output_schema_name": "main.dev",
"schedule": null,
"table_name": "main.test.dev"
}
}
}
>>> $CLI bundle validate -o json -t staging
{
"mode": null,
"quality_monitors": {
"my_monitor": {
"assets_dir": "/Shared/provider-test/databricks_monitoring/main.test.thing1",
"inference_log": {
"granularities": [
"1 day"
],
"model_id_col": "model_id",
"prediction_col": "prediction",
"problem_type": "PROBLEM_TYPE_REGRESSION",
"timestamp_col": "timestamp"
},
"output_schema_name": "main.staging",
"schedule": {
"quartz_cron_expression": "0 0 12 * * ?",
"timezone_id": "UTC"
},
"table_name": "main.test.staging"
}
}
}
>>> $CLI bundle validate -o json -t production
{
"mode": null,
"quality_monitors": {
"my_monitor": {
"assets_dir": "/Shared/provider-test/databricks_monitoring/main.test.thing1",
"inference_log": {
"granularities": [
"1 day",
"1 hour"
],
"model_id_col": "model_id_prod",
"prediction_col": "prediction_prod",
"problem_type": "PROBLEM_TYPE_REGRESSION",
"timestamp_col": "timestamp_prod"
},
"output_schema_name": "main.prod",
"schedule": {
"quartz_cron_expression": "0 0 12 * * ?",
"timezone_id": "UTC"
},
"table_name": "main.test.prod"
}
}
}

View File

@ -0,0 +1,3 @@
trace $CLI bundle validate -o json -t development | jq '{ mode: .bundle.mode, quality_monitors: .resources.quality_monitors }'
trace $CLI bundle validate -o json -t staging | jq '{ mode: .bundle.mode, quality_monitors: .resources.quality_monitors }'
trace $CLI bundle validate -o json -t production | jq '{ mode: .bundle.mode, quality_monitors: .resources.quality_monitors }'

View File

@ -1,59 +0,0 @@
package config_tests
import (
"testing"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/bundle/config/resources"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/stretchr/testify/assert"
)
func assertExpectedMonitor(t *testing.T, p *resources.QualityMonitor) {
assert.Equal(t, "timestamp", p.InferenceLog.TimestampCol)
assert.Equal(t, "prediction", p.InferenceLog.PredictionCol)
assert.Equal(t, "model_id", p.InferenceLog.ModelIdCol)
assert.Equal(t, catalog.MonitorInferenceLogProblemType("PROBLEM_TYPE_REGRESSION"), p.InferenceLog.ProblemType)
}
func TestMonitorTableNames(t *testing.T) {
b := loadTarget(t, "./quality_monitor", "development")
assert.Len(t, b.Config.Resources.QualityMonitors, 1)
assert.Equal(t, config.Development, b.Config.Bundle.Mode)
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, "main.dev", p.OutputSchemaName)
assertExpectedMonitor(t, p)
}
func TestMonitorStaging(t *testing.T) {
b := loadTarget(t, "./quality_monitor", "staging")
assert.Len(t, b.Config.Resources.QualityMonitors, 1)
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, "main.staging", p.OutputSchemaName)
assertExpectedMonitor(t, p)
}
func TestMonitorProduction(t *testing.T) {
b := loadTarget(t, "./quality_monitor", "production")
assert.Len(t, b.Config.Resources.QualityMonitors, 1)
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, "main.prod", p.OutputSchemaName)
inferenceLog := p.InferenceLog
assert.Equal(t, []string{"1 day", "1 hour"}, inferenceLog.Granularities)
assert.Equal(t, "timestamp_prod", p.InferenceLog.TimestampCol)
assert.Equal(t, "prediction_prod", p.InferenceLog.PredictionCol)
assert.Equal(t, "model_id_prod", p.InferenceLog.ModelIdCol)
assert.Equal(t, catalog.MonitorInferenceLogProblemType("PROBLEM_TYPE_REGRESSION"), p.InferenceLog.ProblemType)
}