Skip to content

Commit 7f4c8ec

Browse files
denikIsaac
andcommitted
Rename registered models in place and follow parent renames
A registered model's name is now an updatable ID field: a rename sends new_name and keeps the model's versions, instead of deleting and recreating it. A model inside a renamed catalog or schema is re-keyed without a request, like volumes; recreating it failed with RESOURCE_ALREADY_EXISTS. Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 27ceb82 commit 7f4c8ec

17 files changed

Lines changed: 655 additions & 51 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Rename a registered model in place when its `name` changes, keeping its versions, instead of deleting and recreating it. Registered models inside a renamed catalog or schema now follow it to the new name; recreating them failed because they already exist there.

‎acceptance/bundle/migrate/auto/registered-model-rename/output.txt‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
=== Replay the prior terraform deployment (captured from a real terraform run)
33
>>> replay_tfstate.py terraform-requests.json terraform.tfstate
44

5-
=== Rename the model (an immutable id field) and deploy on direct
5+
=== Rename the model (an updatable id field) and deploy on direct
66
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle deploy
7-
Warn: migration to direct: registered_models.my_model: name differs between config ("themodel-[UNIQUE_NAME]-renamed") and terraform state ("themodel-[UNIQUE_NAME]"); this resource will be recreated.
7+
Warn: migration to direct: registered_models.my_model: name differs between config ("themodel-[UNIQUE_NAME]-renamed") and terraform state ("themodel-[UNIQUE_NAME]"); this resource will be renamed.
88
Notice: migrating your bundle to direct deployment engine (https://github.com/databricks/cli/issues/6765).
99
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
1010
Migrated 2 resources to direct deployment engine.
11-
Recreated registered_models.my_model
11+
Updated registered_models.my_model
1212
Files: 2 uploaded, 0 deleted
13-
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
13+
Resources: 0 created, 1 changed, 0 deleted, 1 unchanged
1414

1515
>>> print_migration_telemetry
16-
direct_migrate_recreate_planned true
1716
direct_migrated_via_env true
1817

1918
=== Redeploy on direct: the model now matches config, so the plan is a clean no-op

‎acceptance/bundle/migrate/auto/registered-model-rename/script‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ title "Replay the prior terraform deployment (captured from a real terraform run
1010
trace replay_tfstate.py terraform-requests.json terraform.tfstate
1111
rm -f "$OUT_REQUESTS"
1212

13-
title "Rename the model (an immutable id field) and deploy on direct"
14-
# name is a provided id field on registered models, so a rename recreates. reconcileIDFields
15-
# seeds the deployed name into the converted state, so the migration's plan sees a real
16-
# recreate. Unlike schemas/volumes, registered models are not in the destructive-approval
17-
# group (a model recreate loses no data), so the deploy is approved without --auto-approve:
18-
# the migration commits and the recreate applies on direct.
13+
title "Rename the model (an updatable id field) and deploy on direct"
14+
# name is an updatable id field: the model is renamed in place (UpdateWithID), keeping its
15+
# versions. reconcileIDFields seeds the deployed name into the converted state, so the
16+
# migration's plan sees a rename rather than snapshotting the new name as already applied.
1917
update_file.py databricks.yml "themodel-$UNIQUE_NAME" "themodel-$UNIQUE_NAME-renamed"
2018
trace DATABRICKS_BUNDLE_ENGINE=direct $CLI bundle deploy
2119
trace print_migration_telemetry

‎acceptance/bundle/migrate/auto/volume-type-change/script‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export DATABRICKS_BUNDLE_ENGINE=
22

33
# Testserver-only: changing volume_type to EXTERNAL needs a storage_location backed by a
44
# registered external location on a real workspace, so this is not Cloud-enabled. The
5-
# recreate class it covers is verified on cloud by schema-catalog-change / registered-model-rename.
5+
# recreate class it covers is verified on cloud by schema-catalog-change / registered-model-catalog-change.
66

77
# volume_type is both a provided id field and a recreate_on_changes field. reconcileIDFields
88
# records the deployed value, so the migration's plan sees a real change and recreates. Volumes

‎acceptance/bundle/resources/registered_models/basic/output.txt‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
5858
"schema_name": "default"
5959
}
6060

61-
=== update the name, this should recreate
61+
=== update the name, this renames the model in place
6262
>>> [CLI] bundle plan
63-
recreate registered_models.my_registered_model
63+
update registered_models.my_registered_model
6464

65-
Plan: 1 to add, 0 to change, 1 to delete, 0 unchanged
65+
Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged
6666

6767
>>> [CLI] bundle deploy
6868
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/deploy-registered-models-basic-[UNIQUE_NAME]/default/files...
69-
Recreated registered_models.my_registered_model
69+
Updated registered_models.my_registered_model
7070
Files: 1 uploaded, 0 deleted
71-
Resources: 1 created, 0 changed, 1 deleted, 0 unchanged
71+
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
7272

7373
>>> [CLI] registered-models get main.default.my-registered-model-updated-[UNIQUE_NAME]
7474
{

‎acceptance/bundle/resources/registered_models/basic/script‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ deploy_registered_model
3636
export NAME="my-registered-model-updated-$UNIQUE_NAME"
3737
envsubst < databricks.yml.tmpl > databricks.yml
3838

39-
title "update the name, this should recreate"
39+
title "update the name, this renames the model in place"
4040
deploy_registered_model
4141

4242
title "update the catalog name, this should recreate"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bundle:
2+
name: test-bundle-$UNIQUE_NAME
3+
4+
resources:
5+
catalogs:
6+
catalog1:
7+
name: test_catalog_$UNIQUE_NAME
8+
schemas:
9+
schema1:
10+
catalog_name: ${resources.catalogs.catalog1.name}
11+
name: myschema
12+
registered_models:
13+
model1:
14+
catalog_name: ${resources.catalogs.catalog1.name}
15+
schema_name: ${resources.schemas.schema1.name}
16+
name: mymodel
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cloud = true
2+
EnvMatrix.DMS = ["", "true"]

0 commit comments

Comments
 (0)