Add MLflow (Databricks) logging backend - #159
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optional MLflow (Databricks-compatible) metrics logging backend to the training metrics system, alongside the existing WandB and TensorBoard integrations, including config/doc updates and checkpoint-based run resume support.
Changes:
- Introduces
MLflowBackendwith lazy initialization, run-id writeback for resume, and flattenedJobConfigparam logging. - Adds
[metrics]configuration for MLflow +scripts/train.pycheckpoint persistence/restoration ofmlflow_run_id. - Adds
check_env --requires mlflowsupport, docs, tests, and optional dependency group (mlflow-skinny,databricks-sdk, etc.).
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
kempnerforge/metrics/tracker.py |
Adds MLflow backend, experiment resolution, and config flattening; wires backend selection into MetricsTracker. |
kempnerforge/config/metrics.py |
Adds MLflow config fields + Databricks experiment absolute-path validation for config-provided experiment. |
scripts/train.py |
Persists/restores mlflow_run_id in checkpoint metadata to support resume/requeue. |
scripts/check_env.py |
Adds mlflow preflight tag for Databricks credential presence (and optional SDK probe). |
tests/unit/test_observability.py |
Adds unit tests for MLflow backend behavior, config flattening, and Databricks experiment-path validation. |
pyproject.toml |
Adds optional mlflow dependency group. |
uv.lock |
Locks new optional dependencies (mlflow-skinny, databricks-sdk, and transitive deps) and updates protobuf. |
docs/metrics-and-profiling/mlflow.md |
New documentation page describing MLflow backend usage, config, and failure behavior. |
docs/metrics-and-profiling/metrics-tracker.md |
Updates backend construction and close semantics to include MLflow. |
docs/metrics-and-profiling/index.md |
Updates module overview/config examples to include MLflow. |
docs/configuration/config-sections.md |
Documents new [metrics] MLflow fields. |
README.md |
Mentions MLflow as a supported backend and updates diagram/module listing. |
configs/train/debug.toml |
Adds commented MLflow example config hints. |
CHANGELOG.md |
Records addition of MLflow backend and related changes. |
.gitignore |
Ignores local MLflow SQLite store + mlruns/ directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
camilobrownpinilla
left a comment
There was a problem hiding this comment.
One potential security concern, but that is already tracked as a separate issue. Bringing it up here for awareness, but the PR looks good otherwise.
|
Ready to merge. Only minor issues: |
5a5a5cb
Brings the MLflow logging backend (#159) onto the video base branch. The only conflict was in CHANGELOG.md and was purely additive - both sides prepended an entry under [Unreleased]/Added, so both are kept.
Summary
MLflowBackend, a third_LoggingBackendalongside WandB/TensorBoard, enabled viametrics.enable_mlflow. Logs the same per-step and eval metric dict (train/*,gpu/*,smoothed/*,eval/*,moe/*) to Databricks-hosted MLflow (or any MLflow server).JobConfigas params +host/slurm_job_idtags + optional system metrics. No artifacts — checkpoints stay on disk.mlflow_run_idis saved in the checkpoint and restored on resume (mirrorswandb_run_id), so a requeue reattaches to the same run — or starts a fresh run if the saved id was deleted (parity with wandbresume="allow").DATABRICKS_HOST+DATABRICKS_TOKEN/DATABRICKS_API_TOKEN); experiment resolvesmlflow_experiment→$MLFLOW_EXPERIMENT→ auto.mlflow(mlflow-skinny+databricks-sdk) keeps the base install lean and avoids a pandas downgrade; adds acheck_env --requires mlflowpreflight tag anddocs/metrics-and-profiling/mlflow.md.log_eval; the standalone eval pipeline is unchanged (no backend — same as WandB/TB).Testing
uv run ruff check kempnerforge/ tests/passesuv run ruff format --check kempnerforge/ tests/ scripts/passesuv run pyright kempnerforge/passes (0 errors)uv run pytest tests/unit/ --timeout=60passes (1658 passed, 3 skipped)scripts/train.pychange is a 3-line additive mirror of the existingwandb_run_idcheckpoint handling. Separately verified live: real logging to Databricks MLflow, plus resume / delete→new-run / system metrics via an end-to-end run against real MLflow.Closes #158