Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Versioned Flask Model Inference Service

Package a saved or reviewed pretrained model, load it safely into a Flask service, and serve attributable predictions with useful logs.

Problem statement

For this exercise, assume one team owns a Flask application that classifies bounded JSON requests using one approved model version per serving replica. A model may come from the team's training run or from a reviewed pretrained source. Both enter the same immutable package and loading path.

Design how a model is saved, serialized, stored, selected for deployment, loaded into a compatible Flask runtime, and exposed through a prediction API. Each successful response must identify the exact model version used.

Operators need readiness information and structured request outcome and latency logs without raw feature values.

A replica must not accept traffic until its complete approved artifact is verified, loaded, and warmed; it must not deserialize arbitrary bytes supplied by a caller or change models halfway through a request. Explain the critical boundaries and what happens when a new artifact cannot load.

Model training, choosing a better classifier, a multi-tenant inference platform, and implementation of Flask route code are outside scope. The business use case, traffic, artifact size, and operational constraints here are practice assumptions.

What to build

  1. A team can save or import a reviewed pretrained model as an immutable artifact with the metadata needed for compatible, verifiable loading.
  2. A client can submit a bounded JSON request and receive one prediction with the exact model version and request identifier, or an explicit failure.
  3. Operators can determine whether a replica is ready and inspect structured outcome, version, and latency telemetry without recording raw feature values.

At scale

  • Assume 1,000 peak prediction requests per second and a 200 ms p95 successful-response target.
  • Assume a model artifact can be 250 MB; loading or warming the model at process startup may take up to 60 seconds.
  • Each response must identify the model version actually used, and no replica may receive prediction traffic before its selected artifact is fully verified and ready.