Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Databricks · Databricks Machine Learning Associate

Deploy code or deploy models

Databricks Machine Learning Associate · Lesson 7 of 19 · 50:29

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Databricks Certified Machine Learning Associate exam. In this lesson: the deploy code and deploy models patterns, how each one moves from development to staging and production, the hybrid approach, and how to choose a pattern. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Two very different models

Juniper Rides runs two very different models: a demand model retrained every week on new rides, and a large image model that checks photos of scooter damage, which takes days of GPU time to train. The team wonders whether to move the code or the trained model from development to production, and the answer is not the same for both. This lesson covers the two deployment patterns, when each one fits, and a hybrid between them.

Two patterns

Models are created by code, but the model artifacts and the code that creates them can change at different times. The demand model may be retrained every week on new data, while its code rarely changes, and a large neural network may be trained once, while the code that serves and monitors it keeps changing. So two patterns exist, and they differ in what moves toward production: the training code, or the trained model. In both, the assets go through development, staging, and production.

Deploying code

With deploy code, which Databricks recommends in most cases, the training code is developed in development, and the same code moves to staging, and then to production. The model is trained in each environment: during development, on a limited subset of data in staging for the integration tests, and on the full production data in production. Where access to production data is restricted, the model can still train on it, without data scientists getting direct access. Automated retraining is safer, since the training code was reviewed, tested, and approved, and the supporting code, like inference and monitoring, follows the same path. The downside is a learning curve, since data scientists must hand their code to an automated pipeline, which templates help with. And they need a way to review the training results from production, to spot problems that only they can recognize.

Deploying models

With deploy models, the model artifact is trained once, by the training code in development, then tested in staging, and deployed to production. Consider it when training is very expensive or hard to reproduce, when all the work happens in a single workspace, or when the team has no external repository or CI/CD process. The handoff is simpler, and an expensive model is trained only once. But production data may not be reachable from development, where the model is trained, and the inference and monitoring code still needs its own path to production. Models in Unity Catalog support this pattern with copy_model_version, which copies a version from the staging catalog to the prod catalog.

Choosing a pattern

To choose, weigh three things. First, model size and training cost: a model that is cheap to retrain fits deploy code, while a huge model that costs days of GPU time favors deploy models. Second, data access: if production data cannot leave production, deploy code trains the model there. Third, organizational complexity: several workspaces, a Git repository, and CI/CD point to deploy code, while a single workspace with no CI/CD fits deploy models. And a hybrid exists: deploy the code to staging, train there on the full production data, then deploy the model to production, which saves training costs in production, but adds a cost in staging.

Recap

Let's recap. Two patterns move ML assets toward production: the training code, or the trained model. Deploy code, recommended in most cases, trains the model in each environment, and in production on the full production data, with reviewed code and automated retraining. Deploy models trains the artifact once, in development, which fits a very expensive model, a single workspace, or no CI/CD, and copy_model_version promotes it between catalogs. The choice weighs model size and training cost, access to production data, and organizational complexity. And the hybrid deploys code to staging, trains there on full data, and deploys the model to production.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. In the deploy code pattern, where is the model that serves production trained?

    • In development, then copied to production
    • In staging, on the full data, then copied
    • On a data scientist’s laptop
    • In production, on the full production data
    Show the answer

    In production, on the full production data

    With deploy code, the same reviewed code trains the final model in production, on the full production data. “In development, then copied to production” describes deploy models, where the artifact trained in development is promoted. “In staging, on the full data, then copied” describes the hybrid pattern, which trains in staging. And “On a data scientist’s laptop” would leave production depending on a single person's machine.

  2. The image model that checks scooter damage photos takes four days of GPU time to train, and the code that serves it changes every week. Which pattern fits best?

    • Deploy code, retraining in each environment
    • Deploy models: train once, promote the artifact
    • Retrain in production at each code change
    • Serve it straight from development
    Show the answer

    Deploy models: train once, promote the artifact

    When training is very expensive, the model is trained once and the artifact is promoted, while the serving code moves on its own. “Deploy code, retraining in each environment” would retrain the model in every environment, for four days of GPU time each. “Retrain in production at each code change” would retrain it every week, for a change that does not touch the model. And “Serve it straight from development” would serve production from development, without any staging.

  3. Data scientists cannot read production data, and the demand model must be retrained every week, with code that goes through Git and CI/CD across three workspaces. Which pattern fits?

    • Deploy models, trained in development
    • Hybrid, trained on a copy in development
    • Deploy code, trained in production
    • Deploy models, copied each month
    Show the answer

    Deploy code, trained in production

    Deploy code lets the reviewed training code retrain the model in production, on data that data scientists cannot read. “Deploy models, trained in development” would train the model in development, where the production data is not available. “Hybrid, trained on a copy in development” would also train in development, with the same problem. And “Deploy models, copied each month” would copy a model that is a month old, while it must be retrained every week.