Integrations API Reference
MLflow Integration
assert_mlflow_model
Assert MLflow model properties and metrics.
from ml_assert.integrations.mlflow import assert_mlflow_model
# Assert MLflow model
assert_mlflow_model(
model_uri="runs:/run_id/model",
metrics={
"accuracy": 0.8,
"precision": 0.8,
"recall": 0.8
}
)
Parameters
model_uri: MLflow model URImetrics: Dictionary of metric names and minimum valuesparams: Dictionary of parameter names and expected values (optional)
Prometheus Integration
assert_prometheus_metrics
Assert Prometheus metrics for model monitoring.
from ml_assert.integrations.prometheus import assert_prometheus_metrics
# Assert Prometheus metrics
assert_prometheus_metrics(
metrics={
"model_accuracy": 0.8,
"prediction_latency": 100
},
labels={"model": "my_model"}
)
Parameters
metrics: Dictionary of metric names and thresholdslabels: Dictionary of label names and valuestimeout: Maximum time to wait for metrics (default: 30 seconds)
Slack Integration
assert_slack_notification
Assert Slack notification delivery.
from ml_assert.integrations.slack import assert_slack_notification
# Assert Slack notification
assert_slack_notification(
channel="#ml-monitoring",
message="Model drift detected",
timeout=30
)
Parameters
channel: Slack channel namemessage: Expected message contenttimeout: Maximum time to wait for notification (default: 30 seconds)
DVC Integration
assert_dvc_artifact
Assert DVC artifact properties.
from ml_assert.integrations.dvc import assert_dvc_artifact
# Assert DVC artifact
assert_dvc_artifact(
path="models/model.pkl",
exists=True,
size_mb=10
)
Parameters
path: Path to DVC artifactexists: Whether artifact should existsize_mb: Expected size in megabytes (optional)md5: Expected MD5 hash (optional)