feat(bundle): make the bare model name a variable (base_model_name)#16
Merged
Conversation
model_name is now a single bundle variable holding the bare, unqualified name (default fraud_detection), passed everywhere. Notebooks that own the name (training, batch_inference) build the three-level Unity Catalog name locally as uc_model_name = catalog_name.ml_schema.model_name and use it for every UC/MLflow operation. The deployment-job notebooks (evaluation, approval, deployment) receive the full name that Databricks injects into the model_name parameter and read it straight into uc_model_name. No base_model_name, and the bare name is no longer hardcoded in the notebooks. The deployment job's model_name default composes the full name from the parts. Regenerate src.
The deployment-job notebooks previously asserted on the injected model_name/model_version and could not be run by hand. Evaluation and deployment now rebuild those interactively: ml_schema falls back to the per-user dev_<short>_fraud, uc_model_name is composed from catalog + ml_schema + fraud_detection, and model_version defaults to the latest registered version. Added a comment to all three (evaluation, approval, deployment) noting that the deployment job injects model_name as the full three-level namespace. Regenerate src.
…del_alias
training and batch_inference now accept either a bare model_name or an already-qualified three-level name (model_name.count('.') == 2) instead of always prepending, so passing a full name no longer double-prefixes. Also restore the model_alias widget read in batch_inference that a prior edit dropped, and correct an evaluation.py markdown line that wrongly named the injected parameter uc_model_name (it is model_name). Regenerate src.
…tive Pass ml_schema explicitly to the Evaluation task for clarity/consistency with the other job tasks (evaluation only needs it for the interactive fallback). Also give approval.py the same interactive fallback as evaluation/deployment (rebuild ml_schema, uc_model_name, and the latest model_version) so all three deployment-job notebooks can be run by hand, not just via the job. Regenerate src.
Contributor
There was a problem hiding this comment.
Pull request overview
Promotes the registered model’s bare name (fraud_detection) to a bundle variable and updates notebooks/workflows to consistently construct and use a fully-qualified Unity Catalog model name (catalog.schema.model) while keeping job-triggered deployment flows compatible.
Changes:
- Change bundle
model_namevariable to represent the bare model name (defaultfraud_detection) and update docs accordingly. - Update training and batch-inference notebooks to accept either bare or already-qualified model names and consistently use
uc_model_namefor MLflow registry operations. - Update deployment-job workflow and deployment notebooks to operate on injected full UC model names, with interactive fallbacks.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/training/notebooks/training.py | Builds uc_model_name from a bare or qualified model_name and uses it for UC registry operations. |
| src/deployment/model_deployment/notebooks/evaluation.py | Uses injected full UC model name; adds interactive fallback + version resolution. |
| src/deployment/model_deployment/notebooks/deployment.py | Uses injected full UC model name; adds interactive fallback + version resolution. |
| src/deployment/model_deployment/notebooks/approval.py | Uses injected full UC model name; adds interactive fallback + version resolution. |
| src/deployment/batch_inference/notebooks/batch_inference.py | Builds uc_model_name from bare/qualified model_name and uses it for alias/version lookups. |
| solution/training/notebooks/training.py | Mirrors training notebook updates in the solution tree. |
| solution/deployment/model_deployment/notebooks/evaluation.py | Mirrors evaluation notebook updates in the solution tree. |
| solution/deployment/model_deployment/notebooks/deployment.py | Mirrors deployment notebook updates in the solution tree. |
| solution/deployment/model_deployment/notebooks/approval.py | Mirrors approval notebook updates in the solution tree. |
| solution/deployment/batch_inference/notebooks/batch_inference.py | Mirrors batch inference notebook updates in the solution tree. |
| resources/deployment-job-workflow.yml | Adjusts deployment-job parameter default for full UC model name and passes ml_schema to Evaluation. |
| README.md | Documents that var.model_name is now the bare name and notebooks construct uc_model_name. |
| databricks.yml | Updates model_name variable semantics/description to be the bare name with default fraud_detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
+59
| model_name = dbutils.widgets.get("model_name") | ||
| # Accept either a bare name (prepend catalog + ml_schema) or an already-qualified 3-level name. | ||
| uc_model_name = ( | ||
| model_name if model_name.count(".") == 2 else f"{catalog_name}.{ml_schema}.{model_name}" | ||
| ) |
Comment on lines
+46
to
+50
| model_name = dbutils.widgets.get("model_name") | ||
| # Accept either a bare name (prepend catalog + ml_schema) or an already-qualified 3-level name. | ||
| uc_model_name = ( | ||
| model_name if model_name.count(".") == 2 else f"{catalog_name}.{ml_schema}.{model_name}" | ||
| ) |
Comment on lines
34
to
35
| uc_model_name = dbutils.widgets.get("model_name") | ||
| model_version = dbutils.widgets.get("model_version") |
Comment on lines
29
to
30
| uc_model_name = dbutils.widgets.get("model_name") | ||
| model_version = dbutils.widgets.get("model_version") |
Comment on lines
33
to
34
| uc_model_name = dbutils.widgets.get("model_name") | ||
| model_version = dbutils.widgets.get("model_version") |
Comment on lines
17
to
+21
| model_name: | ||
| description: Unity Catalog registered model name (in the per-user workspace schema). | ||
| default: ${var.catalog_name}.${var.ml_schema}.fraud_detection | ||
| description: >- | ||
| Bare (unqualified) registered model name. Notebooks prepend catalog_name + ml_schema | ||
| to form the three-level Unity Catalog name (uc_model_name). | ||
| default: fraud_detection |
Comment on lines
+24
to
+26
| # The deployment job injects the FULL three-level model name (catalog.schema.model) into | ||
| # `model_name`, plus the `model_version` that triggered it. Both are empty when this notebook | ||
| # is run interactively, so the fallback below rebuilds them. |
…is set The deployment-job notebooks derived a missing model_name or model_version from defaults, so a half-configured job (only one injected) would silently gate the wrong model or version. Strip both widget values and raise if exactly one is present: both set is a job, both empty is an interactive run (still derived), exactly one is a misconfiguration. Applied to evaluation, approval, and deployment. Regenerate src.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…l three The Copilot Autofix (d795af7) hardened the latest-version fallback against an empty search result, but it edited the generated src/approval.py directly. src is generated from solution, so the next sync would revert it. Port the same guard into solution/approval.py (so generate_src reproduces the identical src, no drift) and apply it to evaluation.py and deployment.py, which had the same max()-on-empty fallback. Regenerate src.
…ersions training.py resolves the just-registered version with max() over search_model_versions, the same pattern the Autofix hardened in the deployment notebooks. In the gapped student src the registration sits in a TODO block, so running this cell before completing it returns no versions and max() throws a cryptic empty-sequence error. Guard it with a clear message. Regenerate src.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The unqualified registered model name fraud_detection was a hardcoded literal in the model_name variable default and in the training/batch_inference build expressions. Promote it to a base_model_name bundle variable (default fraud_detection) so the three-level UC model name is composed from parameters everywhere: model_name = catalog_name.ml_schema.base_model_name. The deployment-job notebooks are unchanged; they receive the full three-level name that Databricks injects on trigger. Regenerate src.