KatInterview

Bootstrap a Reproducible Python Environment for an LLM Project

System DesignModel answer
MediumModel answerSystem Designpythondev-environmentllm

Last updated

Walk through pinning a Python interpreter, isolating dependencies with a lockfile, securing API credentials, and verifying the setup with a live smoke test.

Setting Up a Reproducible Python Dev Environment for an LLM Project

You are starting a new project that calls a hosted LLM API (in this case, Mistral). Before writing any application logic, you need a local environment that another developer — or a CI machine — can recreate exactly from the repository.

Your task: describe and demonstrate how you would set up this environment from scratch. Specifically, cover each of the following layers:

  1. Interpreter management — pin a specific Python version so the project does not silently float to whatever Python happens to be installed on the machine.
  2. Virtual environment — isolate the project's packages from the system Python and from other projects.
  3. Dependency management with a lockfile — separate the declaration of what you need from the compiled, hashed record of exactly what gets installed.
  4. Secrets handling — store API keys in environment variables, never in source control. Provide a way for new contributors to know which variables are required.
  5. Project layout — organise files so the project is easy to run and test locally.
  6. End-to-end verification — write a short smoke-test script that makes a real API call, prints the model name the API reports back, and exits non-zero on failure.

What to show:

  • The shell commands a new contributor would run after cloning the repo.
  • The key configuration files (with relevant content).
  • The smoke-test script and at least two unit tests that run without any network access.
  • Where your approach could break and how you would handle it.

You may mention modern tooling (e.g. uv) but ground your answer in the underlying concepts — the goal is to show you understand why each step exists, not just that you know a command.

Hints

Hint 1

Think in four independent layers — interpreter, isolation, packages, configuration — and explain what goes wrong if any one of them is missing.

Hint 2

A lockfile is not the same as pinned versions in requirements.txt. What extra guarantee do hashes give you, and which tool produces them?

Hint 3

Your smoke test should exit with a non-zero code on failure, and your unit tests should never touch the network. How do you enforce that split?