Deploy code and deploy models are the two Databricks patterns for moving machine learning to production. In deploy code, the training code is promoted through development, staging and production, and the model is trained in each. In deploy models, a model trained in development is promoted as an artifact. Databricks recommends deploy code in most situations.
Last updated November 2026.
Both end in the same place: a registered model version in the production catalog, loaded by batch jobs or a serving endpoint through an alias. Both also need the supporting code (feature engineering, inference, monitoring) to reach production somehow. The only question is what crosses the environment boundary: the recipe, or the finished model.
Training code is developed in the development environment and the same code moves to staging and then production. The model is trained three times: in development while it is being built, in staging on a limited subset of data as part of integration tests, and in production on the full production data to produce the final model.
The costs: handing code to collaborators has a learning curve for data scientists, and they still need to review training results from production, since they are the ones who can spot an ML-specific problem.
Training runs once, in development. The resulting artifact is tested in staging and then promoted to production, for example by copying the model version from the development catalog to the production catalog in Unity Catalog.
The costs are structural. Development must be able to read production data, which security rules often forbid. Automated retraining is awkward, because a model retrained in development may not be accepted as production-ready. And the supporting pipelines still have to be deployed to production separately.
| Axis | Deploy code | Deploy models |
|---|---|---|
| What is promoted | Training code | Trained model artifact |
| Where the final model is trained | Production, on production data | Development |
| Production data access | Production only | Development needs it too |
| Automated retraining | Safe: reviewed code retrains | Tricky |
| Training cost | One run per environment | One run in total |
| Supporting code | Same path, same tests | Deployed separately |
Advantages, disadvantages and the recommendation are from the Databricks documentation page Model deployment patterns, checked November 2026.
Start from deploy code and look for a reason to leave it. The documentation lists three situations where deploy models is worth considering:
There is also a documented hybrid: deploy code to staging, train there on the full production dataset, then deploy that model to production. It saves the production training run at the price of extra operational cost in staging.
A churn model retrains weekly on customer data that only the production workspace may read, and every change needs review. Restricted data, regular retraining and mandatory review all point to deploy code: a scheduled production job retrains with approved code.
An image embedding model takes three days on a GPU cluster to fine-tune and changes twice a year. Training it again in staging and production would triple the cost for the same model. That is the deploy models case: train once, validate the version in staging, copy it to the production catalog and move its alias. Its inference code still travels the deploy-code path.
The model lifecycle opens the MLOps section, which carries 44% of the Databricks Machine Learning Professional exam, and the guide frames deploy code as the default strategy. Scenario questions tend to hide the signal in a constraint: who can read production data, how often the model retrains, how costly one training run is. Read for those three before reading the options.
In the course, Chapter 25 walks the full deploy-code pipeline (pull request, staging integration tests, release branch) and Chapter 26 covers this trade-off with quiz questions in both directions.
In deploy code, the training code is promoted from development to staging to production and the model is trained in each environment. In deploy models, the model is trained once in development and the trained artifact is promoted.
Databricks recommends deploy code in most situations, and it is the pattern built into the recommended MLOps workflow. It lets production train on production data and makes automated retraining safer because the code has been reviewed and tested.
Consider deploy models when training is very expensive or hard to reproduce, when all work happens in a single Databricks workspace, or when there are no external repos or CI/CD process. Development must be able to read production data for it to work.
Yes. The model is trained in development, again in staging on a limited subset of data during integration tests, and finally in production on the full production data. The production run produces the model that is actually used.
Unit 4 of the ML Professional course covers the lifecycle, testing and environments in ten short chapters, with a unit exam at the end. Every unit is free to open.
Open Chapter 26 →