DEV Community

Blake Price
Blake Price

Posted on

Notebook to service: the three files I add before deploying a model

Every model I've shipped started as a notebook, and every one of them needed the same three files before it could be a service.

config.py — one place for paths, model names, thresholds, and timeouts. The alternative is six constants copied into four notebooks, and then a month later nobody remembers which threshold is the real one.

serve.py — a thin FastAPI wrapper with a health endpoint and one predict endpoint. No business logic, no training code. Load the model once at startup, not per request.

test_smoke.py — two tests: the model loads, and a known input returns the expected shape. That's it. It catches 80% of the deploy failures I've caused.

The part I keep relearning: pin the versions. torch + numpy + your GPU driver are a triangle of pain, and "it worked in the notebook" means nothing when the container resolves different wheels.

What else do you add before calling a notebook production-ready?

Top comments (0)