What you will be able to do
- Explain why ML code and model artifacts move to production on different schedules
- Choose deploy code, deploy models, or the hybrid pattern from a scenario's constraints on data access, training cost, and tooling
- Promote a validated model version from a staging catalog to a prod catalog with copy_model_version
- Name the privileges required to copy a model version across Unity Catalog catalogs
Key concept
Deploy code vs deploy models — Two ways to move ML work to production. Under deploy code, the training code is promoted and the model is retrained in each environment. Under deploy models, the model artifact is trained once and then promoted.
1.Why code and models move on different schedules
A model is the output of code, but the two don't change together. Training code can sit unchanged for months while the model it produces gets rebuilt every week on fresh data. The reverse happens too: a trained model stays fixed while the code that serves and monitors it keeps changing. Because the two change at different times, a team has to decide which one it moves toward production.
Databricks illustrates this with two cases. A fraud-detection pipeline retrains weekly to pick up new transactions, so its model changes often and its code rarely does. A large deep neural network that classifies documents is expensive and slow to train, so it is retrained rarely, while its deployment, serving, and monitoring code is updated independently. The first case suggests promoting code. The second suggests promoting the trained artifact.
In both cases, promotion means crossing a boundary between environments. Each stage normally has its own catalog, as covered in Separate dev/staging/prod environments, one Unity Catalog catalog each. So promotion takes one of two forms: the code is re-run inside the next environment's catalog, or a model version is copied into it.
Checkpoint 1 of 8· Check yourself
A fraud-detection team retrains its model every week on new transactions. The training code has not changed in months. Following the reasoning in this section, which should the team promote toward production?
In this case the model changes often and the code rarely does, which points to promoting the code and retraining the model in each environment. Copying a new artifact across environments every week means promoting the part that changes most often.
“The code may not change very often, but the model might be retrained every week to incorporate new data.”Source: docs.databricks.com
Sources1
2.Deploy code: the default pattern
Under deploy code, the training pipeline is what moves. It is written in development, then promoted to staging and on to production. The model is trained again in each environment. In dev, training is part of model development. In staging, it runs on a limited subset of data as part of integration testing. In production, it runs on the full production data and produces the final model. Databricks recommends this pattern in most situations and builds its recommended MLOps workflow around it.
The strongest reason to use this pattern is data access. Training runs inside production, so only production needs read access to production training data. Dev and staging never need to see it. If a policy forbids any non-production cluster from reading that data, deploy code is the pattern that still works. Giving staging a temporary credential breaks the policy. A bundled artifact still has to be trained somewhere that can read the data.
The second reason is safe automated retraining. The training code goes through code review, tests, and approval before it reaches production. When it later retrains on a schedule, it is running logic that has already passed those checks. A registered model version carries lineage showing which run produced it, but lineage only records history. It does not put the training logic through review. A checksum on the weights proves the file hasn't changed, which is a different question. The same review and testing also apply to supporting code, such as feature and inference pipelines, which go through integration tests in staging alongside the training code.
The pattern has a cost on the people side. Data scientists have to hand their code to collaborators in a form that can be deployed, and that learning curve can be steep. Predefined project templates and workflows help. MLOps Stacks is one example: it keeps the whole development process as code in source control, so retraining is just another run of that code. Data scientists also need to be able to review training results from production, because they are the ones who can spot and fix ML-specific problems in a model trained there.
Checkpoint 2 of 8· Check yourself
Under deploy code, production retrains the model on a schedule with no one approving each new version. Why does Databricks consider this automated retraining safe?
The safety comes from the training code being reviewed, tested, and approved before it ever runs in production, so each scheduled retrain runs logic that has already been vetted. Lineage only records history, and a checksum only shows that a file has not changed. Neither one reviews the training logic.
“Automated model retraining is safer, since the training code is reviewed, tested, and approved for production.”Source: docs.databricks.com
Checkpoint 3 of 8· Exam question
A fraud detection team's compliance policy states that production customer transaction data must never leave the production Unity Catalog workspace, and no development or staging cluster may be granted read access to it. The team retrains its model weekly. Which deployment pattern satisfies this constraint?
Correct answer: A — Promote code: move the training pipeline through dev, staging, and production, and let production retrain the model against production-only data on its own schedule.
- A. This is correct because moving the training code through each environment and retraining inside production means the model is always fit on production data without that data ever being exposed to a lower environment, which is exactly what the compliance policy requires.
- B. This is incorrect because it trains on data the development workspace can access, which is not the restricted production data, so the resulting model would not reflect current production transactions and the pattern does not meet the isolation requirement.
- C. This is incorrect because bundling code and a pre-trained model together does not remove the need to train somewhere, and if that training happens outside production the data-access restriction is still violated regardless of how the artifact is packaged.
- D. This is incorrect because granting staging any access to production transaction tables, even temporary and read-only, directly violates the stated policy that production data must never leave the production workspace.
Checkpoint 4 of 8· Exam question
An ML engineer is designing environment promotion for a new project and wants automated retraining to be safe: any change to the training logic should go through code review, unit tests, and integration tests before it is allowed to touch production. Which promotion pattern most directly delivers this guarantee?
Correct answer: A — Deploying code through each environment, since the training and supporting scripts pass through the same review, testing, and approval gates as other code before running against production data.
- A. This is correct because when training code is what moves between environments, every change to that code is reviewed, tested, and approved by the same CI/CD gates as other software before it can run in production, which is what makes automated retraining safe.
- B. This is incorrect because lineage metadata records what already happened during a past training run; it does not put the training logic itself through code review or tests before that logic is allowed to execute against production data.
- C. This is incorrect because a checksum verifies the artifact was not altered in transit, but it says nothing about whether the code that produced the artifact was reviewed or tested, so it does not deliver the requested guarantee.
- D. This is incorrect because leaving the training pipeline unmanaged means the logic that actually shapes the model's behavior skips review entirely, which is the opposite of the safety the engineer is trying to achieve.
3.Deploy models: train once, promote the artifact
Under deploy models, training runs in development, and the resulting artifact is what moves. It is tested in staging and then deployed to production. Nothing is retrained along the way. The model that passed validation is the same model that serves.
Databricks suggests considering this pattern when any of the following applies:
- Model training is very expensive or hard to reproduce.
- All work happens in a single Databricks workspace.
- The team isn't working with external repos or a CI/CD process.
Take a small team that trains a model for many hours on a large GPU cluster, works in one workspace, and has no Git integration or CI/CD. That team matches all three conditions. Rebuilding the model in every environment would multiply an expensive run, and promoting code would mean first building pipeline infrastructure they don't have. Promoting the registered model version means they train once. The handoff for data scientists is also simpler: they hand over a model, not a deployable codebase.
The drawbacks follow from where training happens. Training runs in dev, so dev must be able to read the training data. If production data is blocked from development for security reasons, this pattern may not be viable. Automated retraining is also awkward. It can be scheduled in dev, but the team that deploys to production may not accept a dev-trained model as production-ready. Finally, only the model moves. Feature engineering, inference, and monitoring pipelines still have to be deployed to production separately.
| Constraint | Deploy code | Deploy models |
|---|---|---|
| Production data readable only in prod | Works: training runs in prod | May not be viable: training runs in dev |
| Training is very expensive or hard to reproduce | Model is retrained in each environment | Trained once, then promoted |
| Automated retraining | Safer: training code is reviewed and tested | Tricky: prod team may reject a dev-trained model |
| Single workspace, no external repo or CI/CD | Steep handoff without templates and workflows | Fits: simpler handoff for data scientists |
| Supporting pipelines (features, inference, monitoring) | Follow the same path through staging | Deployed to production separately |
| Where final unit and integration tests run | Staging | Development |
Checkpoint 5 of 8· Match them up
A team has chosen deploy models. Match each situation to what happens under that pattern.
Tap a term, then the definition that fits it.
Under deploy models, training happens once in development and only the artifact moves. So dev needs access to the training data, a model retrained in dev may be rejected by production, and the supporting pipelines don't come along with the model.
“Supporting code, such as pipelines used for feature engineering, inference, and monitoring, needs to be deployed to production separately.”Source: docs.databricks.com
Checkpoint 6 of 8· Exam question
A small team runs all of its machine learning work inside a single Databricks workspace, does not use an external Git repository, and has no CI/CD pipeline configured. Training a particular model takes many hours on a large GPU cluster and is expensive to repeat. Which approach best fits this team's situation?
Correct answer: A — Promote the trained model version through Unity Catalog registered models, since one training run can be reused across environments without paying the retraining cost again or building pipeline infrastructure.
- A. This is correct because deploying the model is intended for cases where training is expensive or hard to reproduce and the team operates in a single workspace without external repos or CI/CD, so copying the already-trained model version forward avoids both the retraining cost and the infrastructure the team lacks.
- B. This is incorrect because a code-promotion structure without any pipeline to run and test that code does not give the team automated retraining benefits, and it still leaves them paying the expensive GPU training cost again for no compliance gain in this scenario.
- C. This is incorrect because retraining on a schedule ignores the stated constraint that training is expensive and hard to repeat, and repeating it in every environment multiplies that cost rather than avoiding it.
- D. This is incorrect because deploying code does not strictly require an external Git repository or CI/CD, but more importantly, building that infrastructure first does not address the team's actual constraint of expensive, hard-to-repeat training.
Sources1
4.The hybrid: deploy code to staging, deploy the model to production
Some teams need the model trained on the full production dataset but don't want to pay for training again in production. The hybrid pattern covers this. Code is promoted from dev to staging as in deploy code. Staging trains the model on the full production dataset. That trained model is then promoted to production as in deploy models.
The cost moves rather than disappears. Production skips training entirely, which saves compute there. Staging, though, now runs a full training job on production-scale data, which adds operating cost in staging. Staging also needs read access to the full production dataset. So the hybrid isn't an option when policy restricts that data to production alone. In that case only pure deploy code works.
Two environments train. Dev trains during model development, and staging trains on the full production dataset. Production doesn't train at all: it receives the model version that staging produced.
Checkpoint 7 of 8· Check yourself
Compared with pure deploy code, how does the hybrid pattern change where training cost falls?
In the hybrid, staging trains on the full production dataset and production only receives the model, so training cost moves from production to staging. It does not go away. Staging gets a larger job, not a smaller subset run.
“This approach saves training costs in production but adds an extra operation cost in staging.”Source: docs.databricks.com
Sources1
5.Promoting a model version across catalogs with copy_model_version
When a team promotes a model, either through deploy models or through the second half of the hybrid, the move is a copy between registered models in different catalogs. A version registered in staging.ml_team.fraud_detection becomes a new version of prod.ml_team.fraud_detection. It is not retrained. Databricks still recommends deploying ML pipelines as code, so that production models come from automated training in production. Copying is the alternative for cases where retraining in every environment is too expensive.
import mlflow
mlflow.set_registry_uri("databricks-uc")
client = mlflow.tracking.MlflowClient()
src_model_name = "staging.ml_team.fraud_detection"
src_model_version = "1"
src_model_uri = f"models:/{src_model_name}/{src_model_version}"
dst_model_name = "prod.ml_team.fraud_detection"
copied_model_version = client.copy_model_version(src_model_uri, dst_model_name)The source model is identified by a models:/ URI that includes a version number. The destination is just the three-level name of the target registered model. copy_model_version is a method on MlflowClient and needs MLflow 2.8.0 or later. It returns the new version object, and its version field is the number assigned in the prod model.
Unity Catalog privileges control who can perform the copy. The caller needs:
USE CATALOGon both the staging and prod catalogs.USE SCHEMAonstaging.ml_teamandprod.ml_team.EXECUTEon the source modelstaging.ml_team.fraud_detection.- Ownership of
prod.ml_team.fraud_detection, or theCREATE MODEL VERSIONprivilege on it.
Those grants are the whole promotion policy. Only someone who can read the staging model and write to the prod model can promote. No separate approval rules have to be configured. The same chain can be extended to other environments, such as dev, qa, and prod, and each catalog enforces its own access control. After the copy, the version is validated in production and then marked for deployment with an alias. That step is taught in promoting a challenger to champion with aliases.
Checkpoint 8 of 8· Fill the gap
Which MlflowClient method completes this sample, which promotes version 1 of the staging model into the prod catalog's registered model without retraining it?
import mlflow
mlflow.set_registry_uri("databricks-uc")
client = mlflow.tracking.MlflowClient()
src_model_name = "staging.ml_team.fraud_detection"
src_model_version = "1"
src_model_uri = f"models:/{src_model_name}/{src_model_version}"
dst_model_name = "prod.ml_team.fraud_detection"
copied_model_version = client. ? (src_model_uri, dst_model_name)copy_model_version (MLflow 2.8.0+) takes the source models:/ URI with a version and the destination three-level model name, and registers the same artifact as a new version of the prod model. Nothing is retrained. set_registered_model_alias is the later step that marks the copied version for deployment.
Source: docs.databricks.comSources5
Sources
(5)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Models are created by code, but the resulting model artifacts and the code that created them can operate asynchronously.”
↩︎ Why code and models move on different schedules“Typically an environment (development, staging, or production) corresponds to a catalog in Unity Catalog.”
↩︎ Why code and models move on different schedules“The learning curve for data scientists to hand off code to collaborators can be steep.”
↩︎ Deploy code: the default pattern“Model training is very expensive or hard to reproduce.”
↩︎ Deploy models: train once, promote the artifact“You are not working with external repos or a CI/CD process.”
↩︎ Deploy models: train once, promote the artifact“the team responsible for deploying the model in production might not accept the resulting model as production-ready.”
↩︎ Deploy models: train once, promote the artifact“in the deploy models pattern, final unit and integration testing is performed in the development environment.”
↩︎ Deploy models: train once, promote the artifact“you can use a hybrid approach by deploying code to staging, training the model, and then deploying the model to production.”
↩︎ The hybrid: deploy code to staging, deploy the model to production“The two patterns differ in whether the model artifact or the training code that produces the model artifact is promoted towards production.”
↩︎ Key concept“Automated model retraining is safer, since the training code is reviewed, tested, and approved for production.”
↩︎ Exam trap 1“If production data is not accessible from the development environment (which may be true for security reasons), this architecture may not be viable.”
↩︎ Exam trap 2“Supporting code, such as pipelines used for feature engineering, inference, and monitoring, needs to be deployed to production separately.”
↩︎ Exam trap 3“This approach saves training costs in production but adds an extra operation cost in staging.”
↩︎ Exam trap 4“The code may not change very often, but the model might be retrained every week to incorporate new data.”
↩︎ Checkpoint“In organizations where access to production data is restricted, this pattern allows the model to be trained on production data in the production environment.”
↩︎ Prediction“Automated model retraining is safer, since the training code is reviewed, tested, and approved for production.”
↩︎ Checkpoint“Supporting code, such as pipelines used for feature engineering, inference, and monitoring, needs to be deployed to production separately.”
↩︎ Checkpoint“This approach saves training costs in production but adds an extra operation cost in staging.”
↩︎ Checkpoint - 2.
“In most situations, Databricks recommends that during the ML development process, you promote code, rather than models, from one environment to the next.”
↩︎ Deploy code: the default pattern - 3.https://docs.databricks.com/aws/en/lakehouse-architecture/operational-excellence/best-practicesOfficial docs
“It requires only the production environment to have read access to prod training data.”
↩︎ Deploy code: the default pattern - 4.
“Deploying the code automates the ability to build the model, making it much easier to retrain the model when necessary.”
↩︎ Deploy code: the default pattern - 5.
“Instead, you can copy model versions across registered models in Unity Catalog to promote them across environments.”
↩︎ Promoting a model version across catalogs with copy_model_version“The following code snippet uses the copy_model_version MLflow Client API, available in MLflow version 2.8.0 and above.”
↩︎ Promoting a model version across catalogs with copy_model_version“In addition, you need either ownership of the destination model prod.ml_team.fraud_detection or the CREATE MODEL VERSION privilege on it.”
↩︎ Promoting a model version across catalogs with copy_model_version“Access control is enforced as configured in each environment.”
↩︎ Promoting a model version across catalogs with copy_model_version