From 8b4fb770b5cb302ee93942e1d62f3dd7ef6f18a8 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Wed, 1 Nov 2023 15:52:02 +0100 Subject: [PATCH] Fix uniqueness constraint with `.auth.db.models.SqlUser.username` --- CHANGES.md | 1 + mlflow_cratedb/patch/mlflow/model.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 092a334..7d0d063 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ ## in progress - Update to MLflow 2.8.0 +- Fix uniqueness constraint with `mlflow.server.auth.db.models.SqlUser.username`. ## 2023-11-01 v2.7.1 - Fix uniqueness constraint with `SqlRegisteredModel.name`. Thanks, @andnig. diff --git a/mlflow_cratedb/patch/mlflow/model.py b/mlflow_cratedb/patch/mlflow/model.py index 71e0664..20bef5a 100644 --- a/mlflow_cratedb/patch/mlflow/model.py +++ b/mlflow_cratedb/patch/mlflow/model.py @@ -9,12 +9,18 @@ def polyfill_uniqueness_constraints(): TODO: Submit patch to `crate-python`, to be enabled by a dialect parameter `crate_polyfill_unique` or such. + + TODO: There are two more unique constraints defined on the MLflow data model. + - SqlExperimentPermission: "experiment_id", "user_id" + - SqlRegisteredModelPermission: "name", "user_id" """ from mlflow.store.model_registry.dbmodels.models import SqlRegisteredModel from mlflow.store.tracking.dbmodels.models import SqlExperiment + from mlflow.server.auth.db.models import SqlUser listen(SqlExperiment, "before_insert", check_uniqueness_factory(SqlExperiment, "name")) listen(SqlRegisteredModel, "before_insert", check_uniqueness_factory(SqlRegisteredModel, "name")) + listen(SqlUser, "before_insert", check_uniqueness_factory(SqlUser, "username")) def polyfill_refresh_after_dml():