Module 5 · step 6 of 6 · Deploying and testing

Deployment concepts

Versioned deployments, rollback, and when to predict online or in batch.

Concept7 min

In this step you will connect what you did in the app to the ideas behind safe deployments: versions, rollback, and online versus batch prediction. It matters because the first release is easy; the hard part is changing a model other people already depend on.

The idea

Deploying is not copying a file to a server. It is a promise that this address answers with the behaviour of one known model. Three ideas keep that promise.

Immutable, versioned artifacts. A deployed model is a version that never changes. A different model is a new version, so you can always say which model produced a prediction.

Rollback instead of panic. Older versions still exist, so going back is a switch, not a rebuild. No retraining is needed and the change applies to the next request.

Online or batch. Online prediction answers one request in milliseconds, for an application that is waiting. Batch prediction scores a whole file in one job, for work that is not urgent, such as a weekly list of customers at risk. Batch is simpler and cheaper; choose online only when someone or something waits for the answer.

Behind both sits access: who may call the endpoint. A key that can only predict limits the damage if it leaks.

Step by step

  1. Open your deployment and select the Versions tab. Each row shows the version number, creation date and a SHA-256 fingerprint of the file; the one being served is marked active.
  2. With more than one version, the button Rollback to v followed by a number switches the endpoint to that version and keeps its slug and access mode. With a single version the tab says: "Only one version of this pipeline exists. Promote a newer run with the same name to enable rollback." That is your situation in the demo.
  3. Select Models in the sidebar and open your model. The statuses staging, production and archived live here, and Roll back to this restores an older version to production without retraining.
  4. Back in the deployment, open Test: Test a prediction is the online mode, Batch predict is the file mode.

Rolling back a deployment restarts its drift reference, because a different model is now serving.

Common mistakes

  • Replacing the model behind a name without recording which version it is. The registry and the Versions tab exist so you never have to guess.
  • Using online prediction for a job that a nightly batch would do more cheaply.
  • Giving a service a personal login instead of a predict-only API key (see the API keys lesson).
  • Looking for the rollback control only during an incident. Find it now.

As a data scientist

Release a model like a code release: compare the candidate with the current version on the same data, deploy, watch the monitor, and keep the previous version one click away. Decide online or batch from the business need, not from habit. For the engineering view, read Deployment and Reproducibility.

Theory to read next

Read in the docs