|
| 1 | +# MLPlatform |
| 2 | + |
| 3 | +MLPlatform is a production-style machine learning platform simulation that covers the full model lifecycle: |
| 4 | +training orchestration, experiment tracking, model registry, automated promotion, inference serving, and observability. |
| 5 | + |
| 6 | +## Architecture |
| 7 | + |
| 8 | +```text |
| 9 | + +--------------------+ |
| 10 | + | CLI / FastAPI | |
| 11 | + +---------+----------+ |
| 12 | + | |
| 13 | + v |
| 14 | + +--------------------+ |
| 15 | + | Job Queue + Worker | |
| 16 | + | async training exec | |
| 17 | + +---------+----------+ |
| 18 | + | |
| 19 | + +------------------+-------------------+ |
| 20 | + | | | |
| 21 | + v v v |
| 22 | ++---------------+ +----------------+ +---------------------+ |
| 23 | +| Experiment DB | | Model Registry | | Observability Store | |
| 24 | +| SQLite/Postgres| | version/stage | | latency/drift/usage | |
| 25 | ++-------+-------+ +--------+-------+ +----------+----------+ |
| 26 | + | | | |
| 27 | + v v v |
| 28 | ++---------------+ +------------------+ +------------------+ |
| 29 | +| Run metadata | | Artifact store | | Monitoring APIs | |
| 30 | ++---------------+ +------------------+ +------------------+ |
| 31 | + | |
| 32 | + v |
| 33 | + +--------------------+ |
| 34 | + | FastAPI Serving | |
| 35 | + | multi-version load | |
| 36 | + +--------------------+ |
| 37 | +``` |
| 38 | + |
| 39 | +## Folder Structure |
| 40 | + |
| 41 | +```text |
| 42 | +src/mlplatform/ |
| 43 | + api/ FastAPI REST surface |
| 44 | + serving/ online inference service |
| 45 | + training/ config-driven training and queueing |
| 46 | + *.py database, registry, tracking, promotion, observability |
| 47 | +
|
| 48 | +tests/ |
| 49 | + end-to-end and component tests |
| 50 | +
|
| 51 | +.github/workflows/ |
| 52 | + CI pipeline |
| 53 | +``` |
| 54 | + |
| 55 | +## Core Capabilities |
| 56 | + |
| 57 | +- Async training submission through CLI and REST API. |
| 58 | +- YAML-driven experiments with reproducible seeding. |
| 59 | +- Persistent experiment tracking in SQLite or Postgres via SQLAlchemy. |
| 60 | +- Automatic model versioning and stage management. |
| 61 | +- Rule-based promotion checks using accuracy gain and latency thresholds. |
| 62 | +- FastAPI inference service with multiple model versions loaded simultaneously. |
| 63 | +- Basic observability for latency, request volume, and drift signals. |
| 64 | + |
| 65 | +## Local Usage |
| 66 | + |
| 67 | +```bash |
| 68 | +pip install -e .[dev] |
| 69 | +mlplatform init-db |
| 70 | +uvicorn mlplatform.api.app:create_app --factory --reload |
| 71 | +``` |
| 72 | + |
| 73 | +Run the training sanity check: |
| 74 | + |
| 75 | +```bash |
| 76 | +python -m mlplatform.scripts.training_sanity_check |
| 77 | +``` |
| 78 | + |
| 79 | +Run tests: |
| 80 | + |
| 81 | +```bash |
| 82 | +pytest |
| 83 | +``` |
| 84 | + |
| 85 | +## Design Decisions |
| 86 | + |
| 87 | +- SQLAlchemy + SQLite by default for portability; the schema is compatible with Postgres. |
| 88 | +- Queueing is simulated with a durable job table plus an in-process worker so the system behaves like an internal platform without needing Redis. |
| 89 | +- The trainer supports PyTorch when available, but the platform remains operable in minimal environments through a deterministic fallback trainer. |
| 90 | +- Model artifacts are versioned on disk with registry metadata in the database, which keeps deployment simple and rollback explicit. |
| 91 | + |
| 92 | +## Failure Handling |
| 93 | + |
| 94 | +- Training failures are persisted with stack traces and the run status is marked failed. |
| 95 | +- Promotion is blocked when safety checks fail, including missing metrics or latency regressions. |
| 96 | +- Serving returns structured errors for unknown model versions or missing artifacts. |
| 97 | +- Observability ingestion is non-blocking and never takes down the serving path. |
0 commit comments