Skip to content
Draft
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
1 change: 1 addition & 0 deletions .nextchanges/bundles/registered-model-rename.md
Original file line number Diff line number Diff line change
@@ -0,0 +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. ([#7379](https://github.com/databricks/cli/pull/7379))
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
=== Replay the prior terraform deployment (captured from a real terraform run)
>>> replay_tfstate.py terraform-requests.json terraform.tfstate

=== Rename the model (an immutable id field) and deploy on direct
=== Rename the model (an updatable id field) and deploy on direct
>>> DATABRICKS_BUNDLE_ENGINE=direct [CLI] bundle deploy
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.
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.
Notice: migrating your bundle to direct deployment engine (https://github.com/databricks/cli/issues/6765).
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files...
Migrated 2 resources to direct deployment engine.
Recreated registered_models.my_model
Updated registered_models.my_model
Files: 2 uploaded, 0 deleted
Resources: 1 created, 0 changed, 1 deleted, 1 unchanged
Resources: 0 created, 1 changed, 0 deleted, 1 unchanged

>>> print_migration_telemetry
direct_migrate_recreate_planned true
direct_migrated_via_env true

=== Redeploy on direct: the model now matches config, so the plan is a clean no-op
Expand Down
10 changes: 4 additions & 6 deletions acceptance/bundle/migrate/auto/registered-model-rename/script
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ title "Replay the prior terraform deployment (captured from a real terraform run
trace replay_tfstate.py terraform-requests.json terraform.tfstate
rm -f "$OUT_REQUESTS"

title "Rename the model (an immutable id field) and deploy on direct"
# name is a provided id field on registered models, so a rename recreates. reconcileIDFields
# seeds the deployed name into the converted state, so the migration's plan sees a real
# recreate. Unlike schemas/volumes, registered models are not in the destructive-approval
# group (a model recreate loses no data), so the deploy is approved without --auto-approve:
# the migration commits and the recreate applies on direct.
title "Rename the model (an updatable id field) and deploy on direct"
# name is an updatable id field: the model is renamed in place (UpdateWithID), keeping its
# versions. reconcileIDFields seeds the deployed name into the converted state, so the
# migration's plan sees a rename rather than snapshotting the new name as already applied.
update_file.py databricks.yml "themodel-$UNIQUE_NAME" "themodel-$UNIQUE_NAME-renamed"
trace DATABRICKS_BUNDLE_ENGINE=direct $CLI bundle deploy
trace print_migration_telemetry
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/migrate/auto/volume-type-change/script
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export DATABRICKS_BUNDLE_ENGINE=

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

# volume_type is both a provided id field and a recreate_on_changes field. reconcileIDFields
# records the deployed value, so the migration's plan sees a real change and recreates. Volumes
Expand Down
10 changes: 5 additions & 5 deletions acceptance/bundle/resources/registered_models/basic/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ Resources: 0 created, 1 changed, 0 deleted, 0 unchanged
"schema_name": "default"
}

=== update the name, this should recreate
=== update the name, this renames the model in place
>>> [CLI] bundle plan
recreate registered_models.my_registered_model
update registered_models.my_registered_model

Plan: 1 to add, 0 to change, 1 to delete, 0 unchanged
Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged

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

>>> [CLI] registered-models get main.default.my-registered-model-updated-[UNIQUE_NAME]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ deploy_registered_model
export NAME="my-registered-model-updated-$UNIQUE_NAME"
envsubst < databricks.yml.tmpl > databricks.yml

title "update the name, this should recreate"
title "update the name, this renames the model in place"
deploy_registered_model

title "update the catalog name, this should recreate"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bundle:
name: test-bundle-$UNIQUE_NAME

resources:
catalogs:
catalog1:
name: test_catalog_$UNIQUE_NAME
schemas:
schema1:
catalog_name: ${resources.catalogs.catalog1.name}
name: myschema
registered_models:
model1:
catalog_name: ${resources.catalogs.catalog1.name}
schema_name: ${resources.schemas.schema1.name}
name: mymodel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
EnvMatrix.DMS = ["", "true"]
Loading
Loading